As I'm in holiday, the work is going pretty fast. The version 1.1.1 of the EDDI Compiler (eddic) is available.

This version introduces two major changes. The first is the support of dynamic memory allocation. You can allocate a struct or a standard type in help using the new operator. The memory can be released using the delete operator. Another related improved is the addition of constructors and destructors to the language. The following sample shows what can be done with the new features:

The constructor is called once the memory is allocated. The delete operator calls the destructor and then free the memory.

When a structure is allocated on the stack, the constructor is called at the declaration point and the destructor is called when the variable gets out of scope.

The memory manager is quite simple for now. Memory is allocated in blocks. Each block has a header indicating the size of the block and its availability. The size of the header is 8 bytes in 32 bits and 16 bytes in 64 bits. The free operation can be done in constant time by just setting the availability flag to false. The disadvantage of this technique is that all the blocks needs to be tested to find a free block. This can be slow in some situations. I will try to make a better version in the future.

For that, the memory model has been improved. All the offsets are now increasing and the stack addresses are set at the end of the block.

Another interesting improvement of the language is the support of switch. For now, only switch on int is supported. Here is an example of a switch in EDDI:

The performances of the optimizer have been improved, by doing live-variable analysis less often. Pointers can now be passed in registers. Some of the variables used as temporary copies are removed

The peephole optimizer has been improved to use conditional move when possible. Moreover, the peephole optimizer is now able to perform some local copy propagation.

Future work

The next version of the EDDI Compiler will be the version 1.1.2. This version will add features to read the command-line. Moreover, it will also add support for char type and string comparisons. With that, I think that the language will start to be usable for toy applications.

There will be some improvements to the code that have been left aside for a too long time.

Download

You can find the EDDI Compiler sources on the Github repository: https://github.com/wichtounet/eddic

The exact version I refer to is the v1.1.1 available in the GitHub tags or directly as the release branch.