-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|242|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Blogs Home -> Blogs


 
JL235
Created : 09 April 2008
Edited : 09 April 2008

Language Update



Another update now on the how the language is proceding. Unfortinately I have exams in one month so I cannot currently work on this fulltime. However I have been busy making some improvements over the last few weeks and so here is some info on the inner workings of my VM.

Instructions

The way my interpreter works is to parse the given source code, turn this into a syntax tree which represents the entire program, and then generate instructions for the virtual machine to run. Note that this is for my interpreter written in Java running on top of the Java VM.

The major addition that I have made is that the instruction set now uses objects! Each one is an instance of the Instruction class which has just one method, run(VM vm). This means the instructions are just a list of objects which it one by one calls in turn.

This has both pros and cons. On the one hand it is more expensive then using integers to represent the instructions. However the cost will never increase. With integers the more instructions I add then the more if or switch statements I need and so this limits the number of instructions I can have because less will be faster. I'd expect with the if statements formed into a nice tree structure they can still be faster, but it adds complexity and maintenance problems and the overhead still increases. With Instruction objects I can have 10 or 10,000 and the speed will be equal.

On the flip side this will make it very easy for people to extend the language. All you need to do is write your own instance of Instruction and it'll be added to the VM's instruction set! An instruction is also fully atomic and since it's written in Java it'll run directly on Java and so gets no speed penalty. This means that for those time critical sections you can easily drop down to Java (maybe then drop down again to C) in order to add some extra speed.

What's even better is that it will make adding extra functionality very easy. Anything Java can do you can do, and potentially you could even put a whole program inside the Instruction and it'll be fully equal to any currently existing Instruction in the VM.

Garbage Collection

As a part of a recent optimisation spree, I've redesigned the memory in the VM (the stack, local and global memory locations) to all use integers instead of objects. In some cases just switching over increased performance by 4 times! However this has lead to me needing to build my first simple Garbage Collector in order to find Strings that I was keeping a hold of, but was no longer using. A mark-and-sweep tracing garbage collector. I might even add it as a part of the instruction set, so that it is called at optimistic points in the program, such as when the stack is very small. When it's small there is a good chance of freeing lots of resources!

Release..?

No release time has been set, but I plan to get the extensions finished next and then port some of the internal VM code for doing graphics over to be external. Then I need to disable a few partially implemented features and maybe tweak the syntax some more. I haven't quite decided yet.

Anywho, things are definitely still on track. Watch this space!

 

Comments