Jump to content

dummzeuch

Members
  • Content Count

    2977
  • Joined

  • Last visited

  • Days Won

    106

Everything posted by dummzeuch

  1. dummzeuch

    TCriticalSection and cache line size

    Unfortunately unlikely does not mean impossible. And if there is an easy fix, why not implement it? (I'm on my own time now, so I don't have to account for the time spent to my employer.) Eric Grange proposed an array of byte that increases the size of a TCriticalSection instance to 128 bytes. This probably still works for all processors currently available (on my current computer apparently it's 64 bytes), but CPUs evolve. This should do the trick: unit u_dzCriticalSection; interface uses Windows, SyncObjs; type TdzCriticalSection = class(TCriticalSection) public class function NewInstance: TObject; override; end; implementation function GetCacheLineSize: Integer; var ProcInfo, CurInfo: PSystemLogicalProcessorInformation; Len: DWORD; begin Len := 0; if (GetProcAddress(GetModuleHandle(kernel32), 'GetLogicalProcessorInformation') <> nil) and not GetLogicalProcessorInformation(nil, Len) and (GetLastError = ERROR_INSUFFICIENT_BUFFER) then begin GetMem(ProcInfo, Len); try GetLogicalProcessorInformation(ProcInfo, Len); CurInfo := ProcInfo; while Len > 0 do begin if (CurInfo.Relationship = RelationCache) and (CurInfo.Cache.Level = 1) then begin Result := CurInfo.Cache.LineSize; Exit; end; Inc(CurInfo); Dec(Len, SizeOf(CurInfo^)); end; finally FreeMem(ProcInfo); end; end; Result := 64; end; var CacheLineSize: Integer; { TdzCriticalSection } class function TdzCriticalSection.NewInstance: TObject; // see // http://delphitools.info/2011/11/30/fixing-tcriticalsection/ // for an explanation why this could speed up execution on multi core systems var InstSize: Integer; begin InstSize := InstanceSize; if InstSize < CacheLineSize then InstSize := CacheLineSize; Result := InitInstance(GetMemory(InstSize)); end; initialization CacheLineSize := GetCacheLineSize; end.
  2. dummzeuch

    Just-in-time compiling for Delphi's Regular Expressions

    Easy: Revolutionary Socialist Party 😉
  3. This code (from a 3rd party library) compiles fine in Delphi XE2 but does not in Delhi 10.2 (both compiling for Win32): type TWordArray = array of Word; function SomeFunction(segment_ptr: Pointer; segment_count: Integer ): TSmallintArray; var i: Integer; p : TWordArray; begin SetLength(Result, segment_count); p := segment_ptr; i := 0; while ((i < segment_count)) do begin Result[i] := SwapInt16(p[i]); inc(i) end; end; I get an error in the line that assigns segment_ptr to p: [dcc32 Error] test.pas(197): E2010 Incompatible types: 'TWordArray' and 'Pointer' Is there a compiler setting which allows that kind of assignment? (I didn't even know that this is possible). How else could that be resolved? My first attempt is this: function SomeFunction(segment_ptr: Pointer; segment_count: Integer): TSmallintArray; type TWordArray0 = array[0..0] of Word; PWordArray = ^TWordArray0; var i: Integer; p: PWordArray; begin SetLength(Result, segment_count); p := segment_ptr; i := 0; while ((i < segment_count)) do begin Result[i] := SwapInt16(p^[i]); inc(i) end; end; This compiles and probably should work fine (haven't tried it), but it feels so 1990ies.
  4. dummzeuch

    Centered message?

    You'd get used to it. 😉
  5. dummzeuch

    Running Tokyo 10.2.3 dcc32 from the command line

    Yes. Or you copy the code from the rsvars.bat file and append the msbuild line. Note that you need to check where the user actually installed his Delphi. E.g. I didn't install to %ProgramFiles%. You can get that information from the registry: HKEY_CURRENT_USER\Software\Embarcadero\BDS\21.0 -> RootDir
  6. dummzeuch

    Slight Refinement to Component Property Replace

    Wouldn't opening the database and tables in the data module's constructor solve this problem? I've never been a fan of leaving anything active in the designer. I must admit that I currently have no idea how this particular expert works. And I'm currently too busy with other stuff to invest much time in it. If you think it's worth the effort, please file a feature request on SourceForge for it. A few screen shots would go a long way to make a bit clearer what you mean. Or even better: An example project, which could then also be used to test the changes, if I or anybody else ever comes around doing it.
  7. dummzeuch

    Running Tokyo 10.2.3 dcc32 from the command line

    I somehow doubt that, even assuming that you skipped or at least dropped Delphi 8 like every sane person. Delphi 2005 and 2006 didn't use msbuild. [/smartass mode]
  8. dummzeuch

    Assign a pointer to a dynamic array

    Sh*t I forgot to replace the function name. I guess they have, but that code is from a release a few years old, way before Delphi 10.x. Maybe we should have updated, but given the "fun" I just had with another component update, I decided to simply try and compile the sources.
  9. dummzeuch

    Running Tokyo 10.2.3 dcc32 from the command line

    https://delphi.fandom.com/wiki/Compile_from_Commandline It doesn't explicitly mention anything newer than Delphi 2007, but since the process has not changed, why should it?
  10. dummzeuch

    Assign a pointer to a dynamic array

    Why didn't I think of that?
  11. dummzeuch

    Crash when Delphi 10.n exits... again

    This is an assertion message in synedit. It only happens if there was another exception before that which prevents that call.
  12. This is awesome! I have tried it with Delphi 10.2 so far (no optOSX64 there) and it worked as advertised. Now I need a break, my head is smoking! (had a bad day on top of that)
  13. By popular request of a single gentleman (*) there is now a button "Ignore All this Session". The exception class name is now also a regex. Empty matches any exception. (* I'm not sure this really carries the meaning of the German joke "Auf vielfachen Wunsch eines einzelnen Herrn ..." )
  14. I'm definitely a bit slow today. I can't make out what the screenshot is supposed to tell me.
  15. From the description I gather that I would have to implement IOTAProcessNotifier90 and hope that CurrentThreadChanged is called often and timely enough to provide the information on time. Might be worth a try.
  16. In that case: Did you file a feature request with Embarcadero? I'm sure I'm not the only one who would vote on it.
  17. If you have got a suggestion on how that could be implemented, I'll give it a try. So far I don't see a way to get information about the thread in which the exception has been raised.
  18. Subclass checks would be very difficult to implement because all the expert knows is the exception name and the message. I know of no way to query the class inheritance in that context. But a regex for the name would be possible.
  19. This particular problem was Delphi 2005 specific. It resulted in an error message on every start of the IDE, when the GExperts DLL was compiled with optimization on. That's why I never encountered it in my tests before, because all my test builds are compiled with optimization turned off. I don't remember why I changed that this time. Maybe I just forgot to uncheck that option. Delphi 2005 did not have separate configurations for Release and Debug builds, that came with Delphi 2007. As for older versions: Those did not support the inline keyword.
  20. You have definitely earned it. Without your help, I wouldn't have been able to add this functionality and track down all those bugs.
  21. I managed to fix the problem with Delphi 2005. It was totally unrelated: Some code when loading the code formatter configuration raised an external exception C000001D ((Illegal Instruction) for an inlined function when optimization was enabled. In the process I added the same exception handling to the editor experts that was already in place for regular experts, so now one faulty editor expert can no longer prevent all others from being loaded and initialized. Also the user gets a better error message in that case.
  22. It works now with Delphi 2006. It also kind of works with Delphi 2005, but there is a different issue that might or might not be related to this. Thanks again for your help. Care to get a free life time license of GExperts? Oh wait, it's free already. 😉 At least I would like to add you to the list of major contributors to the project shown on the about dialog. Please contact me via PM if that's OK with you and whether I should add you as @Mahdi Safsafi or if you prefer an alias.
  23. edit: Stupid me got the ifdef wrong: {$IFNDEF GX_DELPHI2007_UP} function GetParam(Obj: Pointer): Pointer; asm mov eax, [eax + $40] end; {$ELSE} function GetParam(Obj: Pointer): Pointer; asm mov eax, [eax + $3C] end; {$ENDIF} This should of course have been IFDEF rather than IFNDEF. Now it seems to work fine. I have to make some more tests. This seems to work better: Only one AV before the dialog is shown, the second one after it was shown is gone. Also, if I filter the dialog, it works like in the later versions. There is still the AV before the dialog would have been shown though: [4589E8C4]{bds.exe } + $0[20006D23]{rtl100.bpl } System.System.@HandleAnyException (Line 9963, "sys\system.pas" + 13) + $0 + $1AF[77A98E3F]{ntdll.dll } RtlInterlockedCompareExchange64 + $1AF + $21[77A842D1]{ntdll.dll } KiUserExceptionDispatcher + $21 + $5[20A89EB0]{dbkdebugide100.bpl} Debug.Debug.TDebugger.HandleDebugMessage (Line 8569, "Debug.pas" + 😎 + $5 + $1E[20C21189]{coreide100.bpl} DebuggerMgr.DebuggerMgr.TDebuggerMgr.HandleDebugMessage (Line 1942, "DebuggerMgr.pas" + 1) + $1E + $D[00415A1F]{bds.exe } AppMain.AppMain.TAppBuilder.actnDockEditWindowUpdate (Line 6345, "ui\AppMain.pas" + 6) + $D + $6[201406A7]{vcl100.bpl } Controls.Controls.TWinControl.WndProc (Line 7304, "Controls.pas" + 111) + $6 + $5[20159E7F]{vcl100.bpl } Forms.Forms.TCustomForm.WndProc (Line 3512, "Forms.pas" + 136) + $5 + $6[2013FDD0]{vcl100.bpl } Controls.Controls.TWinControl.MainWndProc (Line 7073, "Controls.pas" + 3) + $6 + $0[20040E4C]{rtl100.bpl } Classes.Classes.StdWndProc (Line 11583, "common\Classes.pas" + 😎 + $0 + $49[76F044B9]{user32.dll } AddClipboardFormatListener + $49 + $B27[76EE4FF7]{user32.dll } CallWindowProcW + $B27 + $229[76EE4149]{user32.dll } DispatchMessageW + $229 + $B[76EFE8AB]{user32.dll } DispatchMessageA + $B I'll try to find where it happens.
  24. I know it's $99, I had already found the code in the debugger before you sent me the tool. The problem seems to be something else, maybe it's really different parameters this time. I will send you the bpl via pm anyway, if you like to have a look.
  25. Thanks. Yet again. Apparently it's $99 up to XE and $A1 from XE2 up. Which is a bit odd, because the class name of the debugger changed between 2010 and XE from TWin32Debugger to TNativeDebugger so I would have expected that offset to change at the same time. But that's not the case. I could not get this to work with Delphi 2006. It kind of works but throws access violations internally. I haven't tried Delphi 2005. I guess I'll not bother with these unless somebody else wants to do the debugging work.
×