[Vm-dev] VM Maker: BytecodeSets.spur-eem.19.mcz
commits at source.squeak.org
commits at source.squeak.org
Tue Mar 31 23:59:51 UTC 2015
Eliot Miranda uploaded a new version of BytecodeSets to project VM Maker:
http://source.squeak.org/VMMaker/BytecodeSets.spur-eem.19.mcz
==================== Summary ====================
Name: BytecodeSets.spur-eem.19
Author: eem
Time: 31 March 2015, 4:59:45.812 pm
UUID: 03b6e370-a91c-4eb6-a80c-8b2fab6a4f4e
Ancestors: BytecodeSets.spur-eem.18
Fix SistaV1 decode for the extended push and dup
bytecodes.
Add the new absent self and absent outer bytecodes to Newspeak V4 decode.
=============== Diff against BytecodeSets.spur-eem.18 ===============
Item was changed:
----- Method: InstructionStream>>interpretNext2ByteNSV4Instruction:for:extA:extB:startPC: (in category '*BytecodeSets-NewsqueakV4-decoding') -----
interpretNext2ByteNSV4Instruction: bytecode for: client extA: extA extB: extB startPC: startPC
"Send to the argument, client, a message that specifies the next instruction.
This method handles the two-byte codes.
For a table of the bytecode set, see EncoderForNewsqueakV4's class comment."
| byte method |
method := self method.
byte := self method at: pc.
pc := pc + 1.
"We do an inline quasi-binary search on bytecode"
bytecode < 235 ifTrue:
[bytecode < 231 ifTrue:
[bytecode < 229 ifTrue:
[| literal |
bytecode = 226 ifTrue:
[^client pushReceiverVariable: (extA bitShift: 8) + byte].
literal := method literalAt: (extA bitShift: 8) + byte + 1.
bytecode = 227 ifTrue:
[^client pushLiteralVariable: literal].
^client pushConstant: literal].
bytecode = 229 ifTrue:
[^client pushConstant: (extB bitShift: 8) + byte].
^client pushTemporaryVariable: byte].
bytecode = 231 ifTrue:
[^byte < 128
ifTrue: [client pushNewArrayOfSize: byte]
ifFalse: [client pushConsArrayWithElements: byte - 128]].
bytecode = 232 ifTrue:
[^client storeIntoReceiverVariable: (extA bitShift: 8) + byte].
bytecode = 233 ifTrue:
[^client storeIntoLiteralVariable: (method literalAt: (extA bitShift: 8) + byte + 1)].
^client storeIntoTemporaryVariable: byte].
bytecode < 238 ifTrue:
[bytecode = 235 ifTrue:
[^client popIntoReceiverVariable: (extA bitShift: 8) + byte].
bytecode = 236 ifTrue:
[^client popIntoLiteralVariable: (method literalAt: (extA bitShift: 8) + byte + 1)].
^client popIntoTemporaryVariable: byte].
bytecode < 242 ifTrue:
[| selector numArgs |
selector := method literalAt: (extA bitShift: 5) + (byte // 8) + 1.
numArgs := (extB bitShift: 3) + (byte \\ 8).
bytecode = 238 ifTrue:
[^client send: selector super: false numArgs: numArgs].
bytecode = 239 ifTrue:
[^client send: selector super: true numArgs: numArgs].
bytecode = 240 ifTrue:
[^client sendToAbsentImplicitReceiver: selector numArgs: numArgs].
^client sendToAbsentDynamicSuperclass: selector numArgs: numArgs].
bytecode < 245 ifTrue:
[bytecode = 242 ifTrue:
[^client jump: (extB bitShift: 8) + byte].
^client jump: (extB bitShift: 8) + byte if: bytecode = 243].
+ bytecode = 245 ifTrue:
+ [| selector numArgs |
+ selector := method literalAt: (extA bitShift: 5) + (byte // 8) + 1.
+ numArgs := (extB bitShift: 3) + (byte \\ 8).
+ ^client sendToAbsentSelf: selector numArgs: numArgs].
- "245 11110101 xxxxxxxx UNASSIGNED"
"246-247 1111011 i xxxxxxxx UNASSIGNED
248-249 1111100 i xxxxxxxx UNASSIGNED"
^self unusedBytecode: client at: startPC!
Item was changed:
----- Method: InstructionStream>>interpretNext3ByteNSV4Instruction:for:extA:extB:startPC: (in category '*BytecodeSets-NewsqueakV4-decoding') -----
interpretNext3ByteNSV4Instruction: bytecode for: client extA: extA extB: extB startPC: startPC
"Send to the argument, client, a message that specifies the next instruction.
This method handles the three-byte codes.
For a table of the bytecode set, see EncoderForNewsqueakV4's class comment."
| method byte2 byte3 |
method := self method.
byte2 := method at: pc.
byte3 := method at: pc + 1.
pc := pc + 2.
"we search the bytecodes by static frequency"
bytecode = 253 ifTrue:
["253 11111101 eeiiikkk jjjjjjjj Push Closure Num Copied iii (+ Ext A // 16 * 8) Num Args kkk (+ Ext A \\ 16 * 8) BlockSize jjjjjjjj (+ Ext B * 256). ee = num extensions"
^client
pushClosureCopyNumCopiedValues: ((byte2 bitShift: -3) bitAnd: 7) + (extA // 16 bitShift: 3)
numArgs: (byte2 bitAnd: 7) + (extA \\ 16 bitShift: 3)
blockSize: byte3 + (extB bitShift: 8)].
bytecode = 250 ifTrue:
[^client pushRemoteTemp: byte2 inVectorAt: byte3].
bytecode = 252 ifTrue:
[^client popIntoRemoteTemp: byte2 inVectorAt: byte3].
bytecode = 251 ifTrue:
[^client storeIntoRemoteTemp: byte2 inVectorAt: byte3].
bytecode = 249 ifTrue:
+ [^client callPrimitive: byte2 + (byte3 bitShift: 8)].
+ bytecode = 254 ifTrue:
+ [| selector numArgs depth |
+ selector := method literalAt: (extA bitShift: 5) + (byte2 // 8) + 1.
+ numArgs := (extB bitShift: 3) + (byte2 \\ 8).
+ depth := byte3.
+ ^client sendToAbsentOuter: selector numArgs: numArgs depth: depth].
+ "255-255 11111111 xxxxxxxx yyyyyyyy UNASSIGNED"
- [^client callPrimitive: byte2 + (byte3 bitShift: 8)].
- "254-255 1111111 i xxxxxxxx yyyyyyyy UNASSIGNED"
^self unusedBytecode: client at: startPC!
Item was changed:
----- Method: InstructionStream>>interpretNextSistaV1InstructionFor: (in category '*BytecodeSets-SistaV1-decoding') -----
interpretNextSistaV1InstructionFor: client
"Send to the argument, client, a message that specifies the next instruction."
| byte div16 offset method extA extB savedPC |
method := self method.
"For a table of the bytecode set, see EncoderForSistaV1's class comment."
"consume and compute any extensions first."
extA := extB := 0.
savedPC := pc.
[byte := self method at: pc.
pc := pc + 1.
byte >= 16rE0 and: [byte <= 16rE1]] whileTrue:
[| extByte |
extByte := self method at: pc.
pc := pc + 1.
byte = 16rE0
ifTrue:
[extA := (extA bitShift: 8) + extByte]
ifFalse:
[extB := (extB = 0 and: [extByte > 127])
ifTrue: [extByte - 256]
ifFalse: [(extB bitShift: 8) + extByte]]].
div16 := byte // 16.
offset := byte \\ 16.
"We do an inline quasi-binary search on each of the possible 16 values of div16"
div16 < 11 ifTrue:
[div16 < 6 ifTrue:
[div16 < 4 ifTrue:
[div16 < 2 ifTrue:
[div16 = 0 ifTrue:
[^client pushReceiverVariable: offset].
^client pushLiteralVariable: (method literalAt: offset + 1)]. "div16 = 1"
^client pushConstant: (method literalAt: byte \\ 32 + 1)].
div16 = 4 ifTrue:
[offset < 12 ifTrue:
[^client pushTemporaryVariable: offset].
offset = 12 ifTrue:
[^client pushReceiver].
offset = 13 ifTrue:
[^client pushConstant: true].
offset = 14 ifTrue:
[^client pushConstant: false].
offset = 15 ifTrue:
[^client pushConstant: nil]].
"div16 = 5"
offset < 2 ifTrue:
[^client pushConstant: offset].
+ offset = 2 ifTrue:
- offset = 3 ifTrue:
[^self interpretSistaV1ExtendedPush: extB for: client].
+ offset = 3 ifTrue:
- offset = 4 ifTrue:
[^client doDup].
+
offset = 8 ifTrue:
[^client methodReturnReceiver].
offset = 9 ifTrue:
[^client methodReturnConstant: true].
offset = 10 ifTrue:
[^client methodReturnConstant: false].
offset = 11 ifTrue:
[^client methodReturnConstant: nil].
offset = 12 ifTrue:
[^client methodReturnTop].
offset = 13 ifTrue:
[^client blockReturnConstant: nil].
offset = 14 ifTrue:
[^client blockReturnTop].
offset = 15 ifTrue:
[^client doNop].
^self unusedBytecode: client at: savedPC].
"short sends"
div16 = 6 ifTrue:
[^client
send: (Smalltalk specialSelectorAt: offset + 1)
super: false
numArgs: (Smalltalk specialNargsAt: offset + 1)].
div16 = 7 ifTrue:
[^client
send: (Smalltalk specialSelectorAt: offset + 17)
super: false
numArgs: (Smalltalk specialNargsAt: offset + 17)].
^client
send: (method literalAt: offset + 1)
super: false
numArgs: div16 - 8].
"div16 >= 11; bytecode >= 176"
div16 < 14 ifTrue:
[div16 = 11 ifTrue:
[offset < 8 ifTrue:
[^client jump: offset + 1].
^client jump: offset - 7 if: true].
div16 = 12 ifTrue:
[offset < 8 ifTrue:
[^client jump: offset + 1 if: false].
^client popIntoReceiverVariable: offset - 8].
"div16 = 13"
offset < 8 ifTrue:
[^client popIntoTemporaryVariable: offset].
offset = 9 ifTrue:
[^client doDup].
^self unusedBytecode: client at: savedPC].
"2 byte and 3 byte codes"
byte < 248 ifTrue:
[^self interpretNext2ByteSistaV1Instruction: byte for: client extA: extA extB: extB startPC: savedPC].
^self interpretNext3ByteSistaV1Instruction: byte for: client extA: extA extB: extB startPC: savedPC!
More information about the Vm-dev
mailing list