ClementBera uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-cb.2088.mcz ==================== Summary ==================== Name: VMMaker.oscog-cb.2088 Author: cb Time: 13 January 2017, 11:59:36.056166 am UUID: d4675fc2-e1e7-4f0c-a254-b2d37124af20 Ancestors: VMMaker.oscog-eem.2087 Added support for BitShiftRight: and bitShiftLeft: unsafe operations =============== Diff against VMMaker.oscog-eem.2087 =============== Item was changed: ----- Method: SistaCogit>>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. self MulR: TempReg R: ra. objectRepresentation genSetSmallIntegerTagsIn: ra]. + "2016 through 2020, bitAnd:, bitOr:, bitXor, bitShiftLeft:, bitShiftRight:, SmallInteger op SmallInteger => SmallInteger, no overflow" - "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. ]. + [19] -> [ objectRepresentation genConvertSmallIntegerToIntegerInReg: ra. + self MoveCq: untaggedVal R: TempReg. + self LogicalShiftLeftR: ra R: TempReg. + objectRepresentation genAddSmallIntegerTagsTo: TempReg. + self MoveR: TempReg R: ra]. + [20] -> [objectRepresentation genConvertSmallIntegerToIntegerInReg: ra. + self MoveCq: untaggedVal R: TempReg. + self ArithmeticShiftRightR: ra R: TempReg. + objectRepresentation genClearAndSetSmallIntegerTagsIn: TempReg. + self MoveR: TempReg 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: SistaCogit>>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 MulR: TempReg R: rr. objectRepresentation genSetSmallIntegerTagsIn: rr]. + "2016 through 2020, bitAnd:, bitOr:, bitXor, bitShiftLeft:, bitShiftRight:, SmallInteger op SmallInteger => SmallInteger, no overflow" - "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. ]. + [19] -> [ objectRepresentation genRemoveSmallIntegerTagsInScratchReg: rr. + self LogicalShiftLeftCq: (objectMemory integerValueOf: val) R: rr. + objectRepresentation genAddSmallIntegerTagsTo: rr ]. + [20] -> [self ArithmeticShiftRightCq: (objectMemory integerValueOf: val) R: rr. + objectRepresentation genClearAndSetSmallIntegerTagsIn: 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: SistaCogit>>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. self MulR: ra R: rr. self genSetSmallIntegerTagsIn: rr]. + "2016 through 2020, bitAnd:, bitOr:, bitXor, bitShiftLeft:, bitShiftRight:, SmallInteger op SmallInteger => SmallInteger, no overflow" - "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. ]. + [19] -> [ objectRepresentation genConvertSmallIntegerToIntegerInReg: ra. + objectRepresentation genRemoveSmallIntegerTagsInScratchReg: rr. + self LogicalShiftLeftR: ra R: rr. + objectRepresentation genAddSmallIntegerTagsTo: rr]. + [20] -> [objectRepresentation genConvertSmallIntegerToIntegerInReg: ra. + self ArithmeticShiftRightR: ra R: rr. + objectRepresentation genClearAndSetSmallIntegerTagsIn: 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: StackInterpreter>>binaryInlinePrimitive: (in category 'miscellaneous bytecodes') ----- binaryInlinePrimitive: primIndex "SistaV1: 248 11111000 iiiiiiii mjjjjjjj Call Primitive #iiiiiiii + (jjjjjjj * 256) m=1 means inlined primitive, no hard return after execution." <option: #SistaVM> | result result64 | primIndex caseOf: { "2000 unchecked SmallInteger #+. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [0] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) + (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2001 unchecked SmallInteger #-. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [1] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) - (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2002 unchecked SmallInteger #*. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [2] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) * (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2003 unchecked SmallInteger #/. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [3] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) / (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2004 unchecked SmallInteger #//. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [4] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) // (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2005 unchecked SmallInteger #\\. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [5] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) \\ (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2006 unchecked SmallInteger #quo:. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [6] -> [| rcvr arg | rcvr := objectMemory integerValueOf: (self internalStackValue: 1). arg := objectMemory integerValueOf: self internalStackTop. result := self quot: rcvr ient: arg. self internalPop: 1; internalStackTopPut: (objectMemory integerObjectOf: result)]. "2016 unchecked SmallInteger #bitAnd:. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [16] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) bitAnd: (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2017 unchecked SmallInteger #bitOr:. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [17] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) bitOr: (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. "2018 unchecked SmallInteger #bitXor:. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" [18] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) bitXor: (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. + "2019 unchecked SmallInteger #bitShiftLeft:. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" + [19] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) + << (objectMemory integerValueOf: self internalStackTop)). - "2019 unchecked SmallInteger #bitShift:. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" - [19] -> [result := objectMemory integerObjectOf: ((objectMemory integerValueOf: (self internalStackValue: 1)) - bitShift: (objectMemory integerValueOf: self internalStackTop)). self internalPop: 1; internalStackTopPut: result]. + "2019 unchecked SmallInteger #bitShiftRight:. Both arguments are SmallIntegers and the result fits in a SmallInteger (* depends on word size)" + [20] -> [result := objectMemory integerObjectOf: (objectMemory wordSize = 4 + ifTrue: [ (objectMemory integerValueOf: (self internalStackValue: 1)) >> (objectMemory integerValueOf: self internalStackTop)] + ifFalse: [ (objectMemory integerValueOf: (self internalStackValue: 1)) >>> (objectMemory integerValueOf: self internalStackTop)]). + self internalPop: 1; internalStackTopPut: result]. "2032 unchecked SmallInteger #>. Both arguments are SmallIntegers" [32] -> [result := objectMemory booleanObjectOf: ((self internalStackValue: 1) > self internalStackTop). self internalPop: 1; internalStackTopPut: result]. "2033 unchecked SmallInteger #<. Both arguments are SmallIntegers" [33] -> [result := objectMemory booleanObjectOf: ((self internalStackValue: 1) < self internalStackTop). self internalPop: 1; internalStackTopPut: result]. "2034 unchecked SmallInteger #>=. Both arguments are SmallIntegers" [34] -> [result := objectMemory booleanObjectOf: ((self internalStackValue: 1) >= self internalStackTop). self internalPop: 1; internalStackTopPut: result]. "2035 unchecked SmallInteger #<=. Both arguments are SmallIntegers" [35] -> [result := objectMemory booleanObjectOf: ((self internalStackValue: 1) <= self internalStackTop). self internalPop: 1; internalStackTopPut: result]. "2036 unchecked SmallInteger #=. Both arguments are SmallIntegers" [36] -> [result := objectMemory booleanObjectOf: ((self internalStackValue: 1) = self internalStackTop). self internalPop: 1; internalStackTopPut: result]. "2037 unchecked SmallInteger #~=. Both arguments are SmallIntegers" [37] -> [result := objectMemory booleanObjectOf: ((self internalStackValue: 1) ~= self internalStackTop). self internalPop: 1; internalStackTopPut: result]. "2064 unchecked Pointer Object>>at:. The receiver is guaranteed to be a pointer object. The 0-relative (1-relative?) index is an in-range SmallInteger" [64] -> [result := objectMemory fetchPointer: (objectMemory integerValueOf: self internalStackTop) - 1 ofObject: (self internalStackValue: 1). self internalPop: 1; internalStackTopPut: result]. "2065 unchecked Byte Object>>at:. The receiver is guaranteed to be a non-pointer object. The 0-relative (1-relative?) index is an in-range SmallInteger. The result is a SmallInteger." [65] -> [result := objectMemory fetchByte: (objectMemory integerValueOf: self internalStackTop) - 1 ofObject: (self internalStackValue: 1). self internalPop: 1; internalStackTopPut: (objectMemory integerObjectOf: result)]. "2066 unchecked 16-bit Word Object>>at:. The receiver is guaranteed to be a non-pointer object. The 0-relative (1-relative?) index is an in-range SmallInteger. The result is a SmallInteger." [66] -> [result := objectMemory fetchShort16: (objectMemory integerValueOf: self internalStackTop) - 1 ofObject: (self internalStackValue: 1). self internalPop: 1; internalStackTopPut: (objectMemory integerObjectOf: result)]. "2067 unchecked 32 bit Word Object>>at:. The receiver is guaranteed to be a non-pointer object. The 0-relative (1-relative?) index is an in-range SmallInteger. The result is a SmallInteger or a LargePositiveInteger." [67] -> [result := objectMemory fetchLong32: (objectMemory integerValueOf: self internalStackTop) - 1 ofObject: (self internalStackValue: 1). self internalPop: 1; internalStackTopPut: (self signed64BitValueOf: result)]. "2068 unchecked 64 bit Word Object>>at:. The receiver is guaranteed to be a non-pointer object. The 0-relative (1-relative?) index is an in-range SmallInteger. The result is a SmallInteger or a LargePositiveInteger." [68] -> [result64 := objectMemory fetchLong64: (objectMemory integerValueOf: self internalStackTop) - 1 ofObject: (self internalStackValue: 1). self internalPop: 1; internalStackTopPut: (self signed64BitValueOf: result)] } otherwise: [localIP := localIP - 3. self respondToUnknownBytecode]! |
Free forum by Nabble | Edit this page |