Why do you need to build an indirect jump table? What are
you trying
to do?
I am implementing a smalltalk. It compiles directly to machine code, with exupery. The last time I asked something to the list I was starting to use exupery. Now I am almost done with that (without many optimizations). I am doing unit testing right now. My first mail to the list asked what would be the best to implement a new st, so, in my implementation I use: 0 tagged ints. A simple (and a little fat) object memory. A very straightforward send mechanism (with C calling convention for calling methods). No contexts, but using BlockClosures (frames are the same as in C, the C compiler does not differentiate C code from ST code).
Hi Guille, I don't get something here. If you are using Exupery to generate asm code why are you talking about a C compiler?
Hi Guille, I don't get something here. If you are using Exupery to generate asm code why are you talking about a C compiler?
Ok, short answer:
The ST VM is responsible for a lot of things, one of them is to interpret bytecodes. In my ST every method is stored in x86 machine code, so, I dont need any interpreter to interpret methods (the CPU does all that)., but VMs have to deal with a lot of other things, like primitives and method lookups. That part is done in C.
Long answer: Right now building my VM is a little messy, this is more or less what I do:
File out the classes I need from Squeak.
Right now I use only ~50 basic classes, and ~40 test classes. The file out mechanism generates one file per class, called ClassName.st
Compile methods in squeak
I load every *.st file from squeak (I said load, not file in!). While I read the classes I compile the methods with SmaCC Refactory Browser - Exupery. This generates assembler as an intermediate step, but the final step produces x86 machine code. This is stored in every method.
Generate assembler files from squeak
Once everything is compiled I generate an assembler file for every class, for example ClassName.s. This could be a little confusing. I already compiled everything, why would I need to generate assembler files? Because assembler files are very handy to represent the image, take a look into a real method:
/* Test>>test Method bytecodes */ .global Test_Class_test_bytecodes Test_Class_test_bytecodes: .int ByteArray + 1 .int 154 /* Number: 77 */ .int 17888 /* Number: 8944 */ .global _Test_Class_test_bytecodes _Test_Class_test_bytecodes: .byte 85, 137, 229, 139, 69, 8, 80, 184 .int Test_Class_test_literals + 1 .byte 139, 64, 11, 232 .int getMethodIP - 4 - . .byte 255, 208, 129, 196, 4, 0, 0, 0, 139, 69, 8, 80, 184 .int Test_Class_test_literals + 1 .byte 139, 64, 15, 232 .int getMethodIP - 4 - . .byte 255, 208, 129, 196, 4, 0, 0, 0, 80, 184 .int Test_Class_test_literals + 1 .byte 139, 64, 19, 232 .int getMethodIP - 4 - . .byte 255, 208, 129, 196, 4, 0, 0, 0, 201, 195 .align 2
As you can see, that is not assembler, but those bytes, are generated with Exupery. Notice the references to other Objects. It is very easy to represent the image with this method. For example, look how an array would be represented in this way:
/* Array */ .global Test_Class_test_literals Test_Class_test_literals: .int Array + 1 .int 24 /* Number: 12 */ .int 9784 /* Number: 4892 */ .global _Test_Class_test_literals _Test_Class_test_literals: .int symbol_initialize + 1 .int symbol_selfTest + 1 .int symbol_printString + 1
Those + 1 , are there because of the 0 tagged integers.
Generate a library with the code
With all the .s files I generate a library
Compile everything into a static executable
I compile the library and the other C files into a static executable. I do that because right now, I havent implemented the st compiler. And thats why I still need squeak. When I implement the compiler (SmaCC-RB-Exupery), I will have to generate some kind of dynamic loading of the st part.
Cheers Guille
I compile the ST code from .st files to .s (assembler) using SmaCC, RefactoryBrowser, and then exupery, I still need squeak in order to run all that. I only use the bottom layer of exupery, (does not use IntermediateXXXXXX classes) I implemented the cmovxx instruction in exupery, because it is very useful. But I need jump tables to implement for example, faster versions of ifTrue:ifFalse:, and a lot of other things. This could lead to faster results. Right Now I am getting (with the same machine), tinyBenchmarks: Squeak: 172043010 bytecodes/sec; 5468700 sends/sec Squeak/Exupery: 775757575 bytecodes/sec; 13569800 sends/sec. myST/Exupery: 1072251308 bytecodes/sec; 36056442 sends/sec
That are numbers!
Cheers,
Sebastian
Bryce _______________________________________________ Exupery mailing list Exupery@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/exupery
Cheers Guille
Exupery mailing list Exupery@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/exupery
Exupery mailing list Exupery@lists.squeakfoundation.org http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/exupery