Forgive my lack of documentation. This will be remidied shortly. Also, some instructions remain unimplemented, as I haven't found a use for them yet.
Also, note the absolute lack of references (int &a = b). Haskell has created the idea in my head they are not needed, but I can see them being useful and I will almost undoubtedly implement them at some point.
I look forward to sorting through your abuse to see if anyone says anything constructive.
>>41
Don't they have to compare the subject with every case? I would call that O(n), especially when deciding what an opcode is requires upwards of 60 comparisons (depending on the opcode).
Name:
Anonymous2012-03-09 21:57
>>42
you can make optimizations so the result of the comparison after treatment is the new program counter address
something like:
switch(a){
case 1:
case 2:
case 3:
where
res = a // simple example
label1:
addr_base + res
// code
// padding
label2:
addr_base + res << 1
// code
// padding
label3:
addr_base + res << 2
//code
also depending on the level of virtualization everything can be done with just masking and shifting
>>47
granted, implementing a switch statement necessarily trivial. But an easy and memory expensive way is to create an array of code pointers with enough slots to contain the range of case values. This is a bit psuedo codey, but:
switch(n) {
case 1:
printf("meep");
case 5:
printf("mop");
break;
case 13:
printf("mope");
break;
default:
printf("nope");
}
You could also just do binary search on a statically allocated array with keys and instruction offsets. I'm not sure which would be faster. Using a simple tight implementation of binary search might be more friendly on the instruction cache than this traversal of an inlined data structure.
You can also combine both approaches, where you can do binary search up until you get to a cluster of values, at which point, you can directly index into a prepared array. In this case, you would have a binary tree of arrays of instruction offsets. This can be good when the switch values cluster up in certain places, but have large gaps in between the clusters.
Another approach could be to use a statically allocated hash table. You could calculate a hashing function that perfectly hashes the used keys onto a small array. And then you only need to do a single comparison to see if the matched key matches the input. If it does not match, then the input cannot be any of the other keys, and you can go to the default case.
Name:
Anonymous2012-03-10 3:19
>>51
SBCL doesn't appear to be doing that. That is why it TWO times slower than C/C++. Lisp is shit.
although one could write a macro in lisp to translate the switch statements to a balanced if else chains. If you wanted to involve something akin to a statically allocated look up table, you'd probably need to have the macro define a global array and reference it in the generated code.
>>70 What is the point of this project? Experimenting with fibs. What will it do better than jre? Running fibs.
Name:
Anonymous2012-03-15 8:40
google
I stopped reading there.
Name:
Anonymous2012-03-16 23:35
>>70 What is the point of this project?
Try reading the docs What will it do better than jre?
Not be bloated, overly complex or spam stderr.
Is anyone up for helping testing? I currently only know this will compile on my computer. If anyone's willing to type a few lines into their terminal I'll be grateful
Also, What will it do better than jre?
Not target a single paradigm, therefore crippling any other paradigm despite how much a compiler writer would want to use it because of it's support, speed and maturity.
Name:
jerome2012-03-17 0:35
>>74
did you write this in couple all-nighters?
and now you are aiming for a quick bugfix?
``absolute lack of references'' no 3-operand instructions no exceptions unsafe push/call mechanism with no protection for the return address or way to determine the argument count only two data types (4-byte integer and float)
This VM is shit. Try posting it on esolangs.org, in the category ``Joke Languages''. ``Not target a single paradigm'' IHBT
Name:
Anonymous2012-03-17 1:43
>>77 ``absolute lack of references''
For now. no 3-operand instructions
I'm implementing one right now, which calls object file functions. unsafe push/call mechanism with no protection for the return address or way to determine the argument count
The return address is on a different stack from normal stack data. It's impossible to harm it. only two data types (4-byte integer and float)
Actually, it's typeless. THe only indication of how the VM should tread data is it's size and the instruction beign executed. (ADDF as opposed to ADD). This VM is shit. Try posting it on esolangs.org, in the category ``Joke Languages''.
I don't agree. Also, I'd rather not. Especially considering this isn't a language. And I do enjoy the esolags website. ``Not target a single paradigm''
That's the point.
Name:
Anonymous2012-03-17 3:06
So wait...
how do i actually use this with some language? like limbo?