Jump to content

Anders Melander

Members
  • Content Count

    2265
  • Joined

  • Last visited

  • Days Won

    117

Posts posted by Anders Melander


  1. 56 minutes ago, Vandrovnik said:

    Almost all my problems with JCL and JVCL installs were because of I had somewhere on the disk (on the path) another instance of JCL/JVCL, which was (partially) used instead of the new version.

    That's funny. Almost all my problems with JCL and JVCL was caused by the fact that I installed them in the first place. Easily solvable though 🙂

    • Haha 1

  2. Hmm. It seems to be doing odd/even rounding:

    FastTrunc(0.5) = 0
    FastTrunc(1.5) = 2
    FastTrunc(2.5) = 2
    FastTrunc(3.5) = 4

    Ah, it's the fluff. I got the logic mixed up:

            // Do we need to change anything?
            TEST    EAX, MXCSR_ROUND_DOWN
            JNZ     @SetMXCSR
            TEST    EAX, MXCSR_ROUND_UP
            JZ      @SkipSetMXCSR // Skip expensive LDMXCSR
    @SetMXCSR:
            [...]

     

    Yet again, the duck provides the answer.


  3. So I have the following function which is supposed to truncate a Single using the SSE CVTTSS2SI instruction. Pretty simple except for all the MXCSR fluff.
    Yes, I know I could just use the SSE4.1 ROUNDSS instruction, which does all of the below in a single instruction, but that's not relevant to this.

     

    Anyway, the problem is that my function doesn't always agree with System.Trunc (which is implemented with the x87 instruction FISTP). I guess that is to expected in some case due to the difference in precision (80 vs 32 bits) but as far as I can tell that is not the problem I'm encountering here - and I would also only expect it to manifest as a problem in rounding and not truncation.

     

    Specifically I have the value -2343.5

    System.Trunc(-2343.5) = -2343

    FastTrunc(-2343.5)=-2344

     

    Given that truncation is supposed to round towards zero, I believe that System.Trunc is correct. But then why is CVTTTSS2SI not doing that?

     

    function FastTrunc_SSE2(Value: Single): Integer;
    var
      SaveMXCSR: Cardinal;
      NewMXCSR: Cardinal;
    const
      // SSE MXCSR rounding modes
      MXCSR_ROUND_MASK    = $FFFF9FFF;
      MXCSR_ROUND_NEAREST = $00000000;
      MXCSR_ROUND_DOWN    = $00002000;
      MXCSR_ROUND_UP      = $00004000;
      MXCSR_ROUND_TRUNC   = $00006000;
    asm
            XOR     ECX, ECX
    
            // Save current rounding mode
            STMXCSR SaveMXCSR
            // Load rounding mode
            MOV     EAX, SaveMXCSR
            // Do we need to change anything?
            TEST    EAX, MXCSR_ROUND_DOWN
            JNZ     @SetMXCSR
            TEST    EAX, MXCSR_ROUND_UP
            JZ      @SkipSetMXCSR // Skip expensive LDMXCSR
    @SetMXCSR:
            // Save current rounding mode in ECX and flag that we need to restore it
            MOV     ECX, EAX
            // Set rounding mode to truncation
            AND     EAX, MXCSR_ROUND_MASK
            OR      EAX, MXCSR_ROUND_TRUNC
            // Set new rounding mode
            MOV     NewMXCSR, EAX
            LDMXCSR NewMXCSR
    @SkipSetMXCSR:
    
    {$if defined(TARGET_x86)}
            MOVSS   XMM0, Value
    {$ifend}
            // Round/Trunc
            CVTSS2SI EAX, XMM0
    
            // Restore rounding mode
            // Did we modify it?
            TEST    ECX, ECX
            JZ      @SkipRestoreMXCSR // Skip expensive LDMXCSR
            // Restore old rounding mode
            LDMXCSR SaveMXCSR
    @SkipRestoreMXCSR:
    end;

     


  4. 8 hours ago, PeterPanettone said:

    In practice, the lack of professional layout capabilities results in many bumbling-looking applications, with controls that sometimes overlap when run on a device with display settings different from those of the original application developer. This shortcoming has given Delphi the unjustified reputation of being an unprofessional amateur developer tool.

    Nonsense. Windows developers have been able to create professionally looking applications that for decades without the aid of layout controls. The main reason for amateurish looking applications is amateurish developers.

     

    9 hours ago, PeterPanettone said:

    Or even better, Embarcadero should buy the TdxLayoutControl component from DevExpress and integrate it into the Professional version. This would give Delphi the professionalism it deserves due to its other capabilities.

    The DevExpress layout control is tightly coupled to the rest of their library but even if it had been possible to separate it from the rest then it would be a terrible idea. Embarcadero does not have the resources or expertise to maintain and evolve something as complex as TdxLayoutControl. Just look at the state of the 3rd party libraries they already have incorporated into Delphi.

    I wouldn't mind a rudimentary layout control as a part of the VCL but if they can't even get something as simple as TGridPanel to work properly then I think it's better they not even try.

    • Like 10

  5. 4 minutes ago, Pat Heuvel said:

    Am I doing something wrong?

    Probably not but I have never tested with a map file produced by C++ Builder and it looks like the format differs slightly from that of Delphi.

    The segment/module list of a Delphi map file looks like this:

    Detailed map of segments
    
     0001:00000000 0000FED4 C=CODE     S=.text    G=(none)   M=System   ACBP=A9
     0001:0000FED4 00000C9C C=CODE     S=.text    G=(none)   M=SysInit  ACBP=A9
     0001:00010B70 0000373C C=CODE     S=.text    G=(none)   M=System.Types ACBP=A9
     0001:000142AC 000007E8 C=CODE     S=.text    G=(none)   M=System.UITypes ACBP=A9
     0001:00014A94 00001E04 C=CODE     S=.text    G=(none)   M=Winapi.Windows ACBP=A9
     0001:00016898 000003A8 C=CODE     S=.text    G=(none)   M=System.SysConst ACBP=A9
    [...]

    As you can see there's no path in the module names.

     

    If you create a bug report at the map2pdb issue tracker and attach the map file (zipped) I will take a look at it.


  6. 1 minute ago, Wagner Landgraf said:

    where the heck to I find old VTune versions to install

    There used to be a link to download previous versions (which is how I managed to use it with Windows 7 at that time), but apparently they've removed that ability:

    https://community.intel.com/t5/Analyzers/where-can-I-download-an-older-version-vtune/m-p/1561574#M24281

     

    Quote

    Only Customer with access to priority support can download the older version of tools. Otherwise Intel provides the latest and greatest version for the public use.

    😞


  7. 1 hour ago, Wagner Landgraf said:

    Has anybody tried to use VTune inside a VM with M1 (ARM MAC)?

    I recall I was able to use it, but I rebuilt my VM and now I can't make it work.

    VTune only supports Intel hardware as it relies on certain CPU features that are only available on Intel CPUs. At least that what they claim:

    https://www.intel.com/content/www/us/en/developer/articles/system-requirements/vtune-profiler-system-requirements.html

     

    Maybe you can get an older version of VTune to work. For example the current version of VTune doesn't support hardware assisted profiling on my (admittedly pretty old) processor.


  8. 16 hours ago, Vincent Parrett said:

    I was told this by an embarcadero (actuallly, it was probably borland at the time) employee when I queried what happened to the comments in some code I donated. 

    I've heard this too, but it was many, many years ago.

     

    16 hours ago, Vincent Parrett said:

    In the DUnitX source they distribute, TODO comments are all stripped but not regular comments.

    Well that explains the complete lack of comments. All their comments are like:

    // TODO : Document this, FFS!

    and

    // TODO : WFT is this shit?

     


  9. I'm not sure I understand you. Where would your users specify the hint texts? In BTM?

     

    If so you can configure BTM to synthesize properties in case the property "default" mechanism caused them not to be stored.
    This is already done for the TField.DisplayLabel property which isn't stored in the DFM if its value equals the FieldName property:
    image.thumb.png.a3f4c64145f0643ae28cbb0a17f6d965.png

     

    So you need to specify:

    1. The control type as a regular expression.
    2. The name of the property to synthesize. Hint in your case.
    3. The synthesized value of the property. Probably just an empty string in your case.

    The problem here is that you probably want this done for lots of different controls so I'm not if this is feasible for you.

     

    It would of course best if you could just set the default hint texts in your base language so there's something to translate. Surely, if a control needs a hint text in one language, it needs it in all languages.


  10. 2 minutes ago, Kas Ob. said:

    Hours and hours digging into Windows kernel, also the name of that first in the stack function is very specific and very familiar RtlUserThreadStart, as example, CreateRemoteThread doesn't invoke this one.

    Hmm. Okay, I'll defer to your expertise then 🙂 - but I can't tell, from looking at the call stack, if the thread was created from Delphi code or from something injected into the process from the outside. I was hoping there was some obvious clue that I had missed.

     

    5 minutes ago, Kas Ob. said:

    Lastly from old readings, i can't find many resources but have a look here http://www.nynaeve.net/?p=200

    Quote

    RtlUserThreadStart is used on Windows Vista and Windows Server 2008 (and later OS’s) to form the initial entrypoint context for a thread started with NtCreateThreadEx (this is a marked departure from the approach taken by NtCreateThread, wherein the user mode caller supplies the initial thread context).

    More hmmm. Doesn't really tell me much with regard to the source of the thread.


  11. 1 hour ago, Kas Ob. said:

    without any doubt it is started from CreateThread there is high chance to be from TThread somewhere, but this is an encapsulation after all.

    There are other ways for a thread to get started, but ignoring that and assuming it was created with CreateThread, one could simply place a breakpoint on the CreateThread import in Winapi.Windows and investigate the call stack as the threads gets crated.

    • Like 1

  12. 11 hours ago, Dmitry Arefiev said:

    The performance issue may be resolved by replacing: 

    If so then it would probably be better if they implemented a proper rate-limiting mechanism.

     

    Looking at the Threading unit, it's rare to see professional code with this few comments. Is there some sort of rule within Embarcadero against commenting the code?

    • Like 2
×