[Vm-dev] VM Maker: VMMaker.oscog-cb.1906.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Jul 21 08:55:46 UTC 2016
ClementBera uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-cb.1906.mcz
==================== Summary ====================
Name: VMMaker.oscog-cb.1906
Author: cb
Time: 21 July 2016, 10:54:27.397258 am
UUID: 0fb76baf-8640-46ea-a1b0-0612ef56d02d
Ancestors: VMMaker.oscog-nice.1905
- Fixed inlined multiply primitive.
- added accessor in the facade for in-image compilation
- disabled jitting of full block temporarily (to have the VM stable).
=============== Diff against VMMaker.oscog-nice.1905 ===============
Item was changed:
----- Method: Cogit>>compileEntireFullBlockMethod: (in category 'compile abstract instructions') -----
compileEntireFullBlockMethod: numCopied
"Compile the abstract instructions for the entire full block method."
<option: #SistaV1BytecodeSet>
| result |
self preenMethodLabel.
self compileFullBlockEntry.
"Frame build"
self compileFullBlockMethodFrameBuild: numCopied.
"Method body"
(result := self compileMethodBody) < 0 ifTrue:
[^result].
self assert: blockCount = 0.
+ ^-1!
- ^0!
Item was added:
+ ----- Method: CurrentImageCoInterpreterFacadeForSpurObjectRepresentation>>remoteIsInstVarAccess (in category 'accessing') -----
+ remoteIsInstVarAccess
+ ^ 128!
Item was changed:
----- Method: StackToRegisterMappingCogit>>genBinaryConstOpVarInlinePrimitive: (in category 'inline primitive generators') -----
genBinaryConstOpVarInlinePrimitive: prim
"Const op var version of binary inline primitives."
"SistaV1: 248 11111000 iiiiiiii mjjjjjjj Call Primitive #iiiiiiii + (jjjjjjj * 256) m=1 means inlined primitive, no hard return after execution.
See EncoderForSistaV1's class comment and StackInterpreter>>#binaryInlinePrimitive:"
<option: #SistaVM>
| ra val untaggedVal adjust |
ra := self allocateRegForStackEntryAt: 0.
self ssTop popToReg: ra.
self ssPop: 1.
val := self ssTop constant.
self ssPop: 1.
untaggedVal := val - objectMemory smallIntegerTag.
prim caseOf: {
"0 through 6, +, -, *, /, //, \\, quo:, SmallInteger op SmallInteger => SmallInteger, no overflow"
[0] -> [self AddCq: untaggedVal R: ra].
[1] -> [self MoveCq: val R: TempReg.
self SubR: ra R: TempReg.
objectRepresentation genAddSmallIntegerTagsTo: TempReg.
self MoveR: TempReg R: ra].
+ [2] -> [objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: ra.
+ self MoveCq: untaggedVal R: TempReg.
- [2] -> [objectRepresentation genRemoveSmallIntegerTagsInScratchReg: ra.
- self MoveCq: (objectMemory integerValueOf: val) R: TempReg.
self MulR: TempReg R: ra.
+ objectRepresentation genSetSmallIntegerTagsIn: ra].
- objectRepresentation genAddSmallIntegerTagsTo: ra].
"2016 through 2019, bitAnd:, bitOr:, bitXor, bitShift:, SmallInteger op SmallInteger => SmallInteger, no overflow"
[16] -> [ self AndCq: val R: ra ].
[17] -> [ self OrCq: val R: ra ].
[18] -> [ self XorCw: untaggedVal R: ra. ].
"2032 through 2037, >, <, >=, <=. =, ~=, SmallInteger op SmallInteger => Boolean (flags?? then in jump bytecodes if ssTop is a flags value, just generate the instruction!!!!)"
"CmpCqR is SubRCq so everything is reversed, but because no CmpRCq things are reversed again and we invert the sense of the jumps."
[32] -> [ self CmpCq: val R: ra.
self genBinaryInlineComparison: JumpLess opFalse: JumpGreaterOrEqual destReg: ra ].
[33] -> [ self CmpCq: val R: ra.
self genBinaryInlineComparison: JumpGreater opFalse: JumpLessOrEqual destReg: ra ].
[34] -> [ self CmpCq: val R: ra.
self genBinaryInlineComparison: JumpLessOrEqual opFalse: JumpGreater destReg: ra ].
[35] -> [ self CmpCq: val R: ra.
self genBinaryInlineComparison: JumpGreaterOrEqual opFalse: JumpLess destReg: ra ].
[36] -> [ self CmpCq: val R: ra.
self genBinaryInlineComparison: JumpZero opFalse: JumpNonZero destReg: ra ].
[37] -> [ self CmpCq: val R: ra.
self genBinaryInlineComparison: JumpNonZero opFalse: JumpZero destReg: ra ].
"2064 through 2068, Pointer Object>>at:, Byte Object>>at:, Short16 Word Object>>at: LongWord32 Object>>at: Quad64Word Object>>at:. obj op 0-rel SmallInteger => oop"
[64] -> [objectRepresentation genConvertSmallIntegerToIntegerInReg: ra.
adjust := (objectMemory baseHeaderSize >> objectMemory shiftForWord) - 1. "shift by baseHeaderSize and then move from 1 relative to zero relative"
adjust ~= 0 ifTrue: [ self AddCq: adjust R: ra. ].
self genMoveConstant: val R: TempReg.
self MoveXwr: ra R: TempReg R: ra].
[65] -> [objectRepresentation genConvertSmallIntegerToIntegerInReg: ra.
adjust := objectMemory baseHeaderSize - 1. "shift by baseHeaderSize and then move from 1 relative to zero relative"
self AddCq: adjust R: ra.
self genMoveConstant: val R: TempReg.
self MoveXbr: ra R: TempReg R: ra.
objectRepresentation genConvertIntegerToSmallIntegerInReg: ra]
}
otherwise: [^EncounteredUnknownBytecode].
self ssPushRegister: ra.
^0!
Item was changed:
----- Method: StackToRegisterMappingCogit>>genBinaryVarOpConstInlinePrimitive: (in category 'inline primitive generators') -----
genBinaryVarOpConstInlinePrimitive: prim
"Var op const version of inline binary inline primitives."
"SistaV1: 248 11111000 iiiiiiii mjjjjjjj Call Primitive #iiiiiiii + (jjjjjjj * 256) m=1 means inlined primitive, no hard return after execution.
See EncoderForSistaV1's class comment and StackInterpreter>>#binaryInlinePrimitive:"
<option: #SistaVM>
| rr val untaggedVal |
val := self ssTop constant.
self ssPop: 1.
rr := self allocateRegForStackEntryAt: 0.
self ssTop popToReg: rr.
self ssPop: 1.
untaggedVal := val - objectMemory smallIntegerTag.
prim caseOf: {
"0 through 6, +, -, *, /, //, \\, quo:, SmallInteger op SmallInteger => SmallInteger, no overflow"
[0] -> [self AddCq: untaggedVal R: rr].
[1] -> [self SubCq: untaggedVal R: rr ].
[2] -> [self flag: 'could use MulCq:R'.
objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: rr.
+ self MoveCq: untaggedVal R: TempReg.
- self MoveCq: (objectMemory integerValueOf: val) R: TempReg.
self MulR: TempReg R: rr.
+ objectRepresentation genSetSmallIntegerTagsIn: rr].
- objectRepresentation genAddSmallIntegerTagsTo: rr].
"2016 through 2019, bitAnd:, bitOr:, bitXor, bitShift:, SmallInteger op SmallInteger => SmallInteger, no overflow"
[16] -> [ self AndCq: val R: rr ].
[17] -> [ self OrCq: val R: rr ].
[18] -> [ self flag: 'could use XorCq:'.
self XorCw: untaggedVal R: rr. ].
"2032 through 2037, >, <, >=, <=. =, ~=, SmallInteger op SmallInteger => Boolean (flags?? then in jump bytecodes if ssTop is a flags value, just generate the instruction!!!!)"
"CmpCqR is SubRCq so everything is reversed."
[32] -> [ self CmpCq: val R: rr.
self genBinaryInlineComparison: JumpGreater opFalse: JumpLessOrEqual destReg: rr ].
[33] -> [ self CmpCq: val R: rr.
self genBinaryInlineComparison: JumpLess opFalse: JumpGreaterOrEqual destReg: rr ].
[34] -> [ self CmpCq: val R: rr.
self genBinaryInlineComparison: JumpGreaterOrEqual opFalse: JumpLess destReg: rr ].
[35] -> [ self CmpCq: val R: rr.
self genBinaryInlineComparison: JumpLessOrEqual opFalse: JumpGreater destReg: rr ].
[36] -> [ self CmpCq: val R: rr.
self genBinaryInlineComparison: JumpZero opFalse: JumpNonZero destReg: rr ].
[37] -> [ self CmpCq: val R: rr.
self genBinaryInlineComparison: JumpNonZero opFalse: JumpZero destReg: rr ].
"2064 through 2068, Pointer Object>>at:, Byte Object>>at:, Short16 Word Object>>at: LongWord32 Object>>at: Quad64Word Object>>at:. obj op 0-rel SmallInteger => oop"
[64] -> [objectRepresentation genLoadSlot: (objectMemory integerValueOf: val) - 1 sourceReg: rr destReg: rr].
[65] -> [self MoveCq: (objectMemory integerValueOf: val) + objectMemory baseHeaderSize - 1 R: TempReg.
self MoveXbr: TempReg R: rr R: rr.
objectRepresentation genConvertIntegerToSmallIntegerInReg: rr]
}
otherwise: [^EncounteredUnknownBytecode].
self ssPushRegister: rr.
^0!
Item was changed:
----- Method: StackToRegisterMappingCogit>>genBinaryVarOpVarInlinePrimitive: (in category 'inline primitive generators') -----
genBinaryVarOpVarInlinePrimitive: prim
"Var op var version of binary inline primitives."
"SistaV1: 248 11111000 iiiiiiii mjjjjjjj Call Primitive #iiiiiiii + (jjjjjjj * 256) m=1 means inlined primitive, no hard return after execution.
See EncoderForSistaV1's class comment and StackInterpreter>>#binaryInlinePrimitive:"
<option: #SistaVM>
| ra rr adjust |
self allocateRegForStackTopTwoEntriesInto: [:rTop :rNext | ra := rTop. rr := rNext ].
self ssTop popToReg: ra.
self ssPop: 1.
self ssTop popToReg: rr.
self ssPop: 1.
prim caseOf: {
"0 through 6, +, -, *, /, //, \\, quo:, SmallInteger op SmallInteger => SmallInteger, no overflow"
[0] -> [objectRepresentation genRemoveSmallIntegerTagsInScratchReg: ra.
self AddR: ra R: rr].
[1] -> [self SubR: ra R: rr.
objectRepresentation genAddSmallIntegerTagsTo: rr].
+ [2] -> [self genShiftAwaySmallIntegerTagsInScratchReg: rr.
+ self genRemoveSmallIntegerTagsInScratchReg: ra.
- [2] -> [objectRepresentation genRemoveSmallIntegerTagsInScratchReg: rr.
- objectRepresentation genShiftAwaySmallIntegerTagsInScratchReg: ra.
self MulR: ra R: rr.
+ self genSetSmallIntegerTagsIn: rr].
- objectRepresentation genAddSmallIntegerTagsTo: rr].
"2016 through 2019, bitAnd:, bitOr:, bitXor, bitShift:, SmallInteger op SmallInteger => SmallInteger, no overflow"
[16] -> [ self AndR: ra R: rr ].
[17] -> [ self OrR: ra R: rr ].
[18] -> [objectRepresentation genRemoveSmallIntegerTagsInScratchReg: ra.
self XorR: ra R: rr. ].
"2032 through 2037, >, <, >=, <=. =, ~=, SmallInteger op SmallInteger => Boolean (flags?? then in jump bytecodes if ssTop is a flags value, just generate the instruction!!!!)"
"CmpCqR is SubRCq so everything is reversed."
[32] -> [ self CmpR: ra R: rr.
self genBinaryInlineComparison: JumpGreater opFalse: JumpLessOrEqual destReg: rr ].
[33] -> [ self CmpR: ra R: rr.
self genBinaryInlineComparison: JumpLess opFalse: JumpGreaterOrEqual destReg: rr ].
[34] -> [ self CmpR: ra R: rr.
self genBinaryInlineComparison: JumpGreaterOrEqual opFalse: JumpLess destReg: rr ].
[35] -> [ self CmpR: ra R: rr.
self genBinaryInlineComparison: JumpLessOrEqual opFalse: JumpGreater destReg: rr ].
[36] -> [ self CmpR: ra R: rr.
self genBinaryInlineComparison: JumpZero opFalse: JumpNonZero destReg: rr ].
[37] -> [ self CmpR: ra R: rr.
self genBinaryInlineComparison: JumpNonZero opFalse: JumpZero destReg: rr ].
"2064 through 2068, Pointer Object>>at:, Byte Object>>at:, Short16 Word Object>>at: LongWord32 Object>>at: Quad64Word Object>>at:. obj op 0-rel SmallInteger => oop"
[64] -> [objectRepresentation genConvertSmallIntegerToIntegerInReg: ra.
adjust := (objectMemory baseHeaderSize >> objectMemory shiftForWord) - 1. "shift by baseHeaderSize and then move from 1 relative to zero relative"
adjust ~= 0 ifTrue: [ self AddCq: adjust R: ra. ].
self MoveXwr: ra R: rr R: rr ].
[65] -> [objectRepresentation genConvertSmallIntegerToIntegerInReg: ra.
adjust := objectMemory baseHeaderSize - 1. "shift by baseHeaderSize and then move from 1 relative to zero relative"
self AddCq: adjust R: ra.
self MoveXbr: ra R: rr R: rr.
objectRepresentation genConvertIntegerToSmallIntegerInReg: rr]
}
otherwise: [^EncounteredUnknownBytecode].
self ssPushRegister: rr.
^0!
Item was changed:
----- Method: StackToRegisterMappingCogit>>genTrinaryInlinePrimitive: (in category 'inline primitive generators') -----
genTrinaryInlinePrimitive: prim
"Unary inline primitives."
"SistaV1: 248 11111000 iiiiiiii mjjjjjjj Call Primitive #iiiiiiii + (jjjjjjj * 256) m=1 means inlined primitive, no hard return after execution.
See EncoderForSistaV1's class comment and StackInterpreter>>#trinaryInlinePrimitive:"
<option: #SistaVM>
| ra1 ra2 rr adjust needsStoreCheck |
"The store check requires rr to be ReceiverResultReg"
needsStoreCheck := (objectRepresentation isUnannotatableConstant: self ssTop) not.
self
allocateRegForStackTopThreeEntriesInto: [:rTop :rNext :rThird | ra2 := rTop. ra1 := rNext. rr := rThird ]
thirdIsReceiver: (prim = 0 and: [ needsStoreCheck ]).
self assert: (rr ~= ra1 and: [rr ~= ra2 and: [ra1 ~= ra2]]).
self ssTop popToReg: ra2.
self ssPop: 1.
self ssTop popToReg: ra1.
self ssPop: 1.
self ssTop popToReg: rr.
self ssPop: 1.
objectRepresentation genConvertSmallIntegerToIntegerInReg: ra1.
"Now: ra is the variable object, rr is long, TempReg holds the value to store."
+ self flag: #TODO. "This is not really working as the immutability and store check needs to be present. "
prim caseOf: {
"0 - 1 pointerAt:put: and byteAt:Put:"
[0] -> [ adjust := (objectMemory baseHeaderSize >> objectMemory shiftForWord) - 1. "shift by baseHeaderSize and then move from 1 relative to zero relative"
adjust ~= 0 ifTrue: [ self AddCq: adjust R: ra1. ].
self MoveR: ra2 Xwr: ra1 R: rr.
"I added needsStoreCheck so if you initialize an array with a Smi such as 0 or a boolean you don't need the store check"
needsStoreCheck ifTrue:
[ self assert: needsFrame.
objectRepresentation genStoreCheckReceiverReg: rr valueReg: ra2 scratchReg: TempReg inFrame: true] ].
[1] -> [ objectRepresentation genConvertSmallIntegerToIntegerInReg: ra2.
adjust := objectMemory baseHeaderSize - 1. "shift by baseHeaderSize and then move from 1 relative to zero relative"
self AddCq: adjust R: ra1.
self MoveR: ra2 Xbr: ra1 R: rr.
objectRepresentation genConvertIntegerToSmallIntegerInReg: ra2. ]
}
otherwise: [^EncounteredUnknownBytecode].
self ssPushRegister: ra2.
^0!
More information about the Vm-dev
mailing list