First look at XE2 floating point performance

With XE2 now officially out, it’s time for a first look at Delphi XE2 compiler floating point performance (see previous episode).

For a first look I’ll reuse a Mandelbrot benchmark, based on this code Mandelbrot Set in HTML 5 Canvas. What it tests are double-precision floating-point basic operations (add, sub, mult) in a tight loop, there is relatively little in the way of memory accesses (or shouldn’t be, to be more accurate).

(more…)

Interfaces, build system, try..except..finally

There has been two major additions to Delphi Script in the SVN.

Interfaces

You can now declare, implement and use pure-interfaces in DWScript.

  • Same syntax as Delphi, minus the GUID
  • All classes from TObject can directly implement interfaces (no need to implement IUnknown or derive from TInterfacedObject)
  • interface properties are supported
  • “is” can be used to test if an interface is another interface or can be cast to a class
  • “as” can be used to cast between classes and interfaces (in all directions)
  • “implements” can be used to determine if a class implements a particular interface

The “implements” operator was introduced for OO purity, since “obj is interface” is somewhat of an heresy from an OO point of view, so you’re encouraged to lobby for “obj implements interface” 😉

Finally, you can also acquire a function pointer/delegate from an interface method (something that Delphi doesn’t support, as of XE).

Build system

The “unit” support which was previously mentioned as experimental can now be considered operational.

DWScript supports classic Pascal units, with “unit”, an “interface” and “implementation” section, and when compiling a unit it enforces the usual restrictions, so you also have “type” blocks, as disambiguating type declarations is not necessary within a unit.

To feed unit’s code to the compiler, you can either use the “virtual file system” approach, or just handle the new OnNeedUnit event. In that event you have a choice of providing either raw source code or “ready-made” unit in the form of an IdwsUnit.

Other changes

  • the combined try..except..finally statement (ala Oxygen) is now supported
  • fixes + new tests for RTTI-based exposition
  • records, classes & interface symbols have been unified as TStructuredSymbol, TRecordSymbol got its TMemberSymbol replaced by TFieldSymbol
  • a variety of minor fixes and enhancements

Sampling profiler for DWS, units, other changes

Here is the periodic news roundup for DWScript from the SVN side:

  • a new TdwsSamplingDebugger class is available, it’s a debugger for Delphi Web Script whose purpose is to offer sample profiling information for script execution.
  • experimental support for units, with classic pascal “unit”, “interface” & “implementation” sections.
  • experimental support for explicit “uses” import statements.
  • block commenting styles (* … *) and /* … */ are now supported.
  • ^ and ^= are now accepted as binary and compound-assignment operator overloading.
  • new standard functions: IntPower, DateToISO8601, DateTimeToISO8601.