how to add a new bytecode primitive?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

how to add a new bytecode primitive?

Mariano Martinez Peck
 
Hi. I would like to add a new shortcut bytecode to do a little experiment to see if I can improve the speed of a serializer we are doing. In the serializer we call  #basicNew for each object. I know that #new is in a bytecodePrim, and I wanted to see if doing the same with #basicNew give us some speed improvement. Just as an experiment.

Now, adding a new bytecode primitive seems complicated and I am not sure how to do it. Can someone help me?  I seems I need

1) to add the selector in
Smalltalk specialSelectors
or in
Smalltalk specialObjectsArray at: 24

2) Modify   VariableNode >>#initialize
the part of:

 encoder
        fillDict: StdSelectors
        with: SelectorNode
        mapping: ((1 to: Smalltalk specialSelectorSize) collect:
                            [:i | Smalltalk specialSelectorAt: i])
        to: (SendPlus to: SendPlus + 31).

to:

 encoder
        fillDict: StdSelectors
        with: SelectorNode
        mapping: ((1 to: Smalltalk specialSelectorSize) collect:
                            [:i | Smalltalk specialSelectorAt: i])
        to: (SendPlus to: SendPlus + 32).


3) Change  ParserNode >>#initialize

from :

Send := 208.

to:

Send := 209.

4)  Interpreter >>#

I need to change from:

.....
    (205 bytecodePrimNewWithArg)
        (206 bytecodePrimPointX)
        (207 bytecodePrimPointY)

        (208 255 sendLiteralSelectorBytecode)

to

.....
    (205 bytecodePrimNewWithArg)
        (206 bytecodePrimPointX)
        (207 bytecodePrimPointY)
        (208 bytecodePrimBasicNew)

        (209 255 sendLiteralSelectorBytecode)

What I am not sure here is if I am sure that the compiler will to still be poiting normal messages to bytecode 208 instead of starting in 209.



6) Evaluate:

 ParserNode initialize.
VariableNode initialize.


Am I missing something?

Finally, is there a bytecode primitive that it is not really used? because maybe it is easier to change for a moment an already existing one. The problem is that I want to see if we improve performance. So removing another bytecode primitive may have negatives effects too.

Thanks a lot in advance,

Mariano