D For A Web Developer

Etienne via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 30 07:51:45 PDT 2014


> A JIT for D? That would be many, many man-years of work.

Wrong!

It would be quite easy. I've figured it out myself.

I've thought of using Pegged with PEG/BNF ParseTrees, made faster using 
ParseTree serialization matched to the source's CRC32-encoding for 
memoization, with a multi-threaded model of tree-generation when 
branching in Or! steps.

Then, the interpretation stage can re-create the D environment with hash 
maps of a "Entity" Variant of D types, functions, values and 
instantiations added with their respective identifiers, each as a single 
Entity struct containing their instructions as a simple array.

e.g. struct Entity { Entity[] scope; Entity[] instructions }

Once that's done, you should have all your types and objects in 
HashMaps, ready to execute with an entry point. You move through the 
instructions with a foreach loop by looking up function calls and 
expecting the appropriate return type.

Call me crazy, but I think typed variants would be easier and faster to 
handle than the regular casting methods that interpreted languages use 
currently.

Anyway, the hardest part again would be to write a good garbage collector.


More information about the Digitalmars-d mailing list