User:Kmcguire/JavaClassLoadAndExecute: Difference between revisions
Content deleted Content added
m added C code example of beginning VM |
m Bot: Replace deprecated source tag with syntaxhighlight |
||
(One intermediate revision by one other user not shown) | |||
Line 1:
This page is about reading and interpreting Java bytecode. The code examples below are old and are by no means complete. However, they may serve some purpose as guidance. I have been working on a VM and have come a long ways from the code below, but also my code has become more complex and for someone who is interested in writting a VM for their OS the code below may prove to be much more useful than my full project.
You can find the project here. It is still simple by my effort but it is much larger. I hope to finish it to a point where it can be useful as a base for usage in my own toy OS. Or, useful in yours. I have made effort so far as to not reply on but the bare minimal of the standard library. Also, one day I will change out my ''malloc'' usage for a more in house solution.
https://code.google.com/p/rhino-java-virtual-machine/
Here are some resources which will allow you to implement a full virtual machine:
Line 30 ⟶ 24:
''Below is an example of loading multiple class files and interpreting some basic instructions. Also demonstrated is maintaining type information on the stack and in local variables. No garbage collection is needed for the Python code. In the C example code the infrastructure for garbage collection is there, but no code written to actually perform the collection.
== C Example ==
<
#include <stdio.h>
#include <malloc.h>
Line 799 ⟶ 793:
return 1;
}
</syntaxhighlight>
== Python Example ==
<
#!/usr/bin/python3.1
import os
Line 1,484 ⟶ 1,478:
print('------ return -------')
pprint.pprint(ret)
</syntaxhighlight>
|