[Vm-dev] VM Maker: VMMaker.oscog-cb.1789.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Apr 8 22:54:54 UTC 2016
ClementBera uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-cb.1789.mcz
==================== Summary ====================
Name: VMMaker.oscog-cb.1789
Author: cb
Time: 8 April 2016, 3:52:22.016614 pm
UUID: c7c64db3-8654-41d0-abbe-3002a7213130
Ancestors: VMMaker.oscog-cb.1788
full block closure
=============== Diff against VMMaker.oscog-cb.1788 ===============
Item was added:
+ ----- Method: CogObjectRepresentation>>genCreateFullClosure:numArgs:numCopied:ignoreContext:contextNumArgs:large:inBlock: (in category 'bytecode generator support') -----
+ genCreateFullClosure: compiledBlock numArgs: numArgs numCopied: numCopied ignoreContext: ignoreContext contextNumArgs: contextNumArgs large: contextIsLarge inBlock: contextIsBlock
+ "Create a full closure"
+ self subclassResponsibility!
Item was added:
+ ----- Method: CogObjectRepresentationForSpur>>genCreateFullClosure:numArgs:numCopied:ignoreContext:contextNumArgs:large:inBlock: (in category 'bytecode generator support') -----
+ genCreateFullClosure: compiledBlock numArgs: numArgs numCopied: numCopied ignoreContext: ignoreContext contextNumArgs: contextNumArgs large: contextIsLarge inBlock: contextIsBlock
+ "Create a full closure with the given values."
+ | numSlots byteSize header skip |
+ <var: #skip type: #'AbstractInstruction *'>
+
+ "First get thisContext into ReceiverResultReg and thence in ClassReg."
+ ignoreContext
+ ifTrue: [ cogit genMoveNilR: ClassReg ]
+ ifFalse:
+ [self genGetActiveContextNumArgs: contextNumArgs large: contextIsLarge inBlock: contextIsBlock.
+ cogit MoveR: ReceiverResultReg R: ClassReg ].
+
+ numSlots := FullClosureFirstCopiedValueIndex + numCopied.
+ byteSize := objectMemory smallObjectBytesForSlots: numSlots.
+ self assert: ClassFullBlockClosureCompactIndex ~= 0.
+ header := objectMemory
+ headerForSlots: numSlots
+ format: objectMemory indexablePointersFormat
+ classIndex: ClassFullBlockClosureCompactIndex.
+ cogit MoveAw: objectMemory freeStartAddress R: ReceiverResultReg.
+ self genStoreHeader: header intoNewInstance: ReceiverResultReg using: TempReg.
+ cogit
+ LoadEffectiveAddressMw: byteSize r: ReceiverResultReg R: TempReg;
+ MoveR: TempReg Aw: objectMemory freeStartAddress;
+ CmpCq: objectMemory getScavengeThreshold R: TempReg.
+ skip := cogit JumpBelow: 0.
+ cogit CallRT: ceScheduleScavengeTrampoline.
+ skip jmpTarget: cogit Label.
+
+ cogit
+ MoveR: ClassReg Mw: ClosureOuterContextIndex * objectMemory bytesPerOop + objectMemory baseHeaderSize r: ReceiverResultReg;
+ genMoveConstant: compiledBlock R: TempReg;
+ MoveR: TempReg Mw: ClosureStartPCIndex * objectMemory bytesPerOop + objectMemory baseHeaderSize r: ReceiverResultReg;
+ MoveCq: (objectMemory integerObjectOf: numArgs) R: TempReg;
+ MoveR: TempReg Mw: ClosureNumArgsIndex * objectMemory bytesPerOop + objectMemory baseHeaderSize r: ReceiverResultReg.
+ ^0!
Item was changed:
----- Method: SimpleStackBasedCogit class>>initializeBytecodeTableForSistaV1 (in category 'class initialization') -----
initializeBytecodeTableForSistaV1
"SimpleStackBasedCogit initializeBytecodeTableForSistaV1"
BytecodeSetHasDirectedSuperSend := true.
FirstSpecialSelector := 96.
NumSpecialSelectors := 32.
self flag:
'Special selector send class must be inlined to agree with the interpreter, which
inlines class. If class is sent to e.g. a general instance of ProtoObject then unless
class is inlined there will be an MNU. It must be that the Cointerpreter and Cogit
have identical semantics. We get away with not hardwiring the other special
selectors either because in the Cointerpreter they are not inlined or because they
are inlined only to instances of classes for which there will always be a method.'.
self generatorTableFrom: #(
"1 byte bytecodes"
"pushes"
(1 0 15 genPushReceiverVariableBytecode isInstVarRef)
(1 16 31 genPushLiteralVariable16CasesBytecode needsFrameNever: 1)
(1 32 63 genPushLiteralConstantBytecode needsFrameNever: 1)
(1 64 75 genPushTemporaryVariableBytecode)
(1 76 76 genPushReceiverBytecode)
(1 77 77 genPushConstantTrueBytecode needsFrameNever: 1)
(1 78 78 genPushConstantFalseBytecode needsFrameNever: 1)
(1 79 79 genPushConstantNilBytecode needsFrameNever: 1)
(1 80 80 genPushConstantZeroBytecode needsFrameNever: 1)
(1 81 81 genPushConstantOneBytecode needsFrameNever: 1)
(1 82 82 genExtPushPseudoVariable)
(1 83 83 duplicateTopBytecode needsFrameNever: 1)
(1 84 87 unknownBytecode)
"returns"
(1 88 88 genReturnReceiver return needsFrameIfInBlock: isMappedInBlock 0)
(1 89 89 genReturnTrue return needsFrameIfInBlock: isMappedInBlock 0)
(1 90 90 genReturnFalse return needsFrameIfInBlock: isMappedInBlock 0)
(1 91 91 genReturnNil return needsFrameIfInBlock: isMappedInBlock 0)
(1 92 92 genReturnTopFromMethod return needsFrameIfInBlock: isMappedInBlock -1)
(1 93 93 genReturnNilFromBlock return needsFrameNever: -1)
(1 94 94 genReturnTopFromBlock return needsFrameNever: -1)
(1 95 95 genExtNopBytecode needsFrameNever: 0)
"sends"
(1 96 117 genSpecialSelectorSend isMapped) "#+ #- #< #> #<= #>= #= #~= #* #/ #\\ #@ #bitShift: #// #bitAnd: #bitOr: #at: #at:put: #size #next #nextPut: #atEnd"
(1 118 118 genSpecialSelectorEqualsEquals needsFrameNever: notMapped -1) "not mapped because it is directly inlined (for now)"
(1 119 119 genSpecialSelectorClass needsFrameNever: notMapped 0) "not mapped because it is directly inlined (for now)"
(1 120 127 genSpecialSelectorSend isMapped) "#blockCopy: #value #value: #do: #new #new: #x #y"
(1 128 143 genSendLiteralSelector0ArgsBytecode isMapped)
(1 144 159 genSendLiteralSelector1ArgBytecode isMapped)
(1 160 175 genSendLiteralSelector2ArgsBytecode isMapped)
"jumps"
(1 176 183 genShortUnconditionalJump branch v3:ShortForward:Branch:Distance:)
(1 184 191 genShortJumpIfTrue branch isBranchTrue isMapped "because of mustBeBoolean"
v3:ShortForward:Branch:Distance:)
(1 192 199 genShortJumpIfFalse branch isBranchFalse isMapped "because of mustBeBoolean"
v3:ShortForward:Branch:Distance:)
"stores"
(1 200 207 genStoreAndPopReceiverVariableBytecode isInstVarRef isMappedIfImmutability needsFrameIfImmutability: -1)
(1 208 215 genStoreAndPopTemporaryVariableBytecode)
(1 216 216 genPopStackBytecode needsFrameNever: -1)
(1 217 217 genUnconditionalTrapBytecode isMapped)
(1 218 223 unknownBytecode)
"2 byte bytecodes"
(2 224 224 extABytecode extension)
(2 225 225 extBBytecode extension)
"pushes"
(2 226 226 genExtPushReceiverVariableBytecode isInstVarRef) "Needs a frame for context inst var access"
(2 227 227 genExtPushLiteralVariableBytecode needsFrameNever: 1)
(2 228 228 genExtPushLiteralBytecode needsFrameNever: 1)
(2 229 229 genLongPushTemporaryVariableBytecode)
(2 230 230 genPushClosureTempsBytecode)
(2 231 231 genPushNewArrayBytecode)
(2 232 232 genExtPushIntegerBytecode needsFrameNever: 1)
(2 233 233 genExtPushCharacterBytecode needsFrameNever: 1)
"returns"
"sends"
(2 234 234 genExtSendBytecode isMapped)
(2 235 235 genExtSendSuperBytecode isMapped)
"sista bytecodes"
(2 236 236 unknownBytecode)
"jumps"
(2 237 237 genExtUnconditionalJump branch isMapped "because of interrupt check" v4:Long:Branch:Distance:)
(2 238 238 genExtJumpIfTrue branch isBranchTrue isMapped "because of mustBeBoolean" v4:Long:Branch:Distance:)
(2 239 239 genExtJumpIfFalse branch isBranchFalse isMapped "because of mustBeBoolean" v4:Long:Branch:Distance:)
"stores"
(2 240 240 genSistaExtStoreAndPopReceiverVariableBytecode isInstVarRef isMappedIfImmutability)
(2 241 241 genSistaExtStoreAndPopLiteralVariableBytecode isMappedIfImmutability)
(2 242 242 genLongStoreAndPopTemporaryVariableBytecode)
(2 243 243 genSistaExtStoreReceiverVariableBytecode isInstVarRef isMappedIfImmutability)
(2 244 244 genSistaExtStoreLiteralVariableBytecode isMappedIfImmutability)
(2 245 245 genLongStoreTemporaryVariableBytecode)
(2 246 247 unknownBytecode)
"3 byte bytecodes"
(3 248 248 genCallPrimitiveBytecode)
(3 249 249 unknownBytecode) "reserved for Push Float"
(3 250 250 genExtPushClosureBytecode block v4:Block:Code:Size:)
(3 251 251 genExtPushRemoteTempOrInstVarLongBytecode)
(3 252 252 genExtStoreRemoteTempOrInstVarLongBytecode isMappedIfImmutability)
(3 253 253 genExtStoreAndPopRemoteTempOrInstVarLongBytecode isMappedIfImmutability)
(3 254 254 genExtJumpIfNotInstanceOfBehaviorsOrPopBytecode)
+ (3 255 255 genExtPushFullClosureBytecode))!
- (3 255 255 unknownBytecode))!
Item was added:
+ ----- Method: SimpleStackBasedCogit>>genExtPushFullClosureBytecode (in category 'bytecode generators') -----
+ genExtPushFullClosureBytecode
+ "Full Block creation compilation. The block's actual code will be compiled separatedly."
+ "* 255 11111111 xxxxxxxx siyyyyyy push Closure Compiled block literal index xxxxxxxx (+ Extend A * 256) numCopied yyyyyy receiverOnStack: s = 1 ignoreOuterContext: i = 1"
+ | numCopied ignoreContext receiverIsOnStack compiledBlock |
+ self assert: needsFrame.
+ compiledBlock := self getLiteral: byte1 + (extA << 8).
+ extA := 0.
+ numCopied := byte2 bitAnd: 1<< 6 - 1.
+ receiverIsOnStack := byte2 anyMask: 1 << 7.
+ ignoreContext := byte2 anyMask: 1 << 6.
+ objectRepresentation
+ genCreateFullClosure: compiledBlock
+ numArgs: (coInterpreter argumentCountOf: compiledBlock)
+ numCopied: numCopied
+ ignoreContext: ignoreContext
+ contextNumArgs: methodOrBlockNumArgs
+ large: (coInterpreter methodNeedsLargeContext: methodObj)
+ inBlock: inBlock.
+ "Closure in ReceiverResultReg"
+ 1 to: numCopied do:
+ [:i|
+ self
+ PopR: TempReg;
+ MoveR: TempReg
+ Mw: numCopied - i + FullClosureFirstCopiedValueIndex * objectMemory bytesPerOop + objectMemory baseHeaderSize
+ r: ReceiverResultReg].
+ receiverIsOnStack
+ ifTrue: [self PopR: TempReg]
+ ifFalse: [ self MoveMw: FoxMFReceiver r: FPReg R: TempReg].
+ self
+ MoveR: TempReg
+ Mw: FullClosureReceiverIndex * objectMemory bytesPerOop + objectMemory baseHeaderSize
+ r: ReceiverResultReg.
+ self PushR: ReceiverResultReg.
+ ^0!
Item was changed:
----- Method: StackToRegisterMappingCogit class>>initializeBytecodeTableForSistaV1 (in category 'class initialization') -----
initializeBytecodeTableForSistaV1
"StackToRegisterMappingCogit initializeBytecodeTableForSistaV1"
numPushNilsFunction := #sistaV1:Num:Push:Nils:.
pushNilSizeFunction := #sistaV1PushNilSize:numInitialNils:.
BytecodeSetHasDirectedSuperSend := true.
FirstSpecialSelector := 96.
NumSpecialSelectors := 32.
self flag:
'Special selector send class must be inlined to agree with the interpreter, which
inlines class. If class is sent to e.g. a general instance of ProtoObject then unless
class is inlined there will be an MNU. It must be that the Cointerpreter and Cogit
have identical semantics. We get away with not hardwiring the other special
selectors either because in the Cointerpreter they are not inlined or because they
are inlined only to instances of classes for which there will always be a method.'.
self generatorTableFrom: #(
"1 byte bytecodes"
"pushes"
(1 0 15 genPushReceiverVariableBytecode isInstVarRef needsFrameNever: 1)
(1 16 31 genPushLitVarDirSup16CasesBytecode needsFrameNever: 1)
(1 32 63 genPushLiteralConstantBytecode needsFrameNever: 1)
(1 64 75 genPushTemporaryVariableBytecode needsFrameIfMod16GENumArgs: 1)
(1 76 76 genPushReceiverBytecode needsFrameNever: 1)
(1 77 77 genPushConstantTrueBytecode needsFrameNever: 1)
(1 78 78 genPushConstantFalseBytecode needsFrameNever: 1)
(1 79 79 genPushConstantNilBytecode needsFrameNever: 1)
(1 80 80 genPushConstantZeroBytecode needsFrameNever: 1)
(1 81 81 genPushConstantOneBytecode needsFrameNever: 1)
(1 82 82 genExtPushPseudoVariable)
(1 83 83 duplicateTopBytecode needsFrameNever: 1)
(1 84 87 unknownBytecode)
"returns"
(1 88 88 genReturnReceiver return needsFrameIfInBlock: isMappedInBlock 0)
(1 89 89 genReturnTrue return needsFrameIfInBlock: isMappedInBlock 0)
(1 90 90 genReturnFalse return needsFrameIfInBlock: isMappedInBlock 0)
(1 91 91 genReturnNil return needsFrameIfInBlock: isMappedInBlock 0)
(1 92 92 genReturnTopFromMethod return needsFrameIfInBlock: isMappedInBlock -1)
(1 93 93 genReturnNilFromBlock return needsFrameNever: -1)
(1 94 94 genReturnTopFromBlock return needsFrameNever: -1)
(1 95 95 genExtNopBytecode needsFrameNever: 0)
"sends"
(1 96 96 genSpecialSelectorArithmetic isMapped AddRR)
(1 97 97 genSpecialSelectorArithmetic isMapped SubRR)
(1 98 98 genSpecialSelectorComparison isMapped JumpLess)
(1 99 99 genSpecialSelectorComparison isMapped JumpGreater)
(1 100 100 genSpecialSelectorComparison isMapped JumpLessOrEqual)
(1 101 101 genSpecialSelectorComparison isMapped JumpGreaterOrEqual)
(1 102 102 genSpecialSelectorComparison isMapped JumpZero)
(1 103 103 genSpecialSelectorComparison isMapped JumpNonZero)
(1 104 109 genSpecialSelectorSend isMapped) " #* #/ #\\ #@ #bitShift: //"
(1 110 110 genSpecialSelectorArithmetic isMapped AndRR)
(1 111 111 genSpecialSelectorArithmetic isMapped OrRR)
(1 112 117 genSpecialSelectorSend isMapped) "#at: #at:put: #size #next #nextPut: #atEnd"
(1 118 118 genSpecialSelectorEqualsEquals needsFrameNever: notMapped -1) "not mapped because it is directly inlined (for now)"
(1 119 119 genSpecialSelectorClass needsFrameIfStackGreaterThanOne: notMapped 0) "not mapped because it is directly inlined (for now)"
(1 120 127 genSpecialSelectorSend isMapped) "#blockCopy: #value #value: #do: #new #new: #x #y"
(1 128 143 genSendLiteralSelector0ArgsBytecode isMapped)
(1 144 159 genSendLiteralSelector1ArgBytecode isMapped)
(1 160 175 genSendLiteralSelector2ArgsBytecode isMapped)
"jumps"
(1 176 183 genShortUnconditionalJump branch v3:ShortForward:Branch:Distance:)
(1 184 191 genShortJumpIfTrue branch isBranchTrue isMapped "because of mustBeBoolean"
v3:ShortForward:Branch:Distance:)
(1 192 199 genShortJumpIfFalse branch isBranchFalse isMapped "because of mustBeBoolean"
v3:ShortForward:Branch:Distance:)
(1 200 207 genStoreAndPopReceiverVariableBytecode isInstVarRef isMappedIfImmutability needsFrameIfImmutability: -1)
(1 208 215 genStoreAndPopTemporaryVariableBytecode)
(1 216 216 genPopStackBytecode needsFrameNever: -1)
(1 217 217 genUnconditionalTrapBytecode isMapped)
(1 218 223 unknownBytecode)
"2 byte bytecodes"
(2 224 224 extABytecode extension)
(2 225 225 extBBytecode extension)
"pushes"
(2 226 226 genExtPushReceiverVariableBytecode isInstVarRef) "Needs a frame for context inst var access"
(2 227 227 genExtPushLitVarDirSupBytecode needsFrameNever: 1)
(2 228 228 genExtPushLiteralBytecode needsFrameNever: 1)
(2 229 229 genLongPushTemporaryVariableBytecode)
(2 230 230 genPushClosureTempsBytecode)
(2 231 231 genPushNewArrayBytecode)
(2 232 232 genExtPushIntegerBytecode needsFrameNever: 1)
(2 233 233 genExtPushCharacterBytecode needsFrameNever: 1)
"returns"
"sends"
(2 234 234 genExtSendBytecode isMapped)
(2 235 235 genExtSendSuperBytecode isMapped)
"sista bytecodes"
(2 236 236 unknownBytecode)
"jumps"
(2 237 237 genExtUnconditionalJump branch isMapped "because of interrupt check" v4:Long:Branch:Distance:)
(2 238 238 genExtJumpIfTrue branch isBranchTrue isMapped "because of mustBeBoolean" v4:Long:Branch:Distance:)
(2 239 239 genExtJumpIfFalse branch isBranchFalse isMapped "because of mustBeBoolean" v4:Long:Branch:Distance:)
"stores"
(2 240 240 genSistaExtStoreAndPopReceiverVariableBytecode isInstVarRef isMappedIfImmutability)
(2 241 241 genSistaExtStoreAndPopLiteralVariableBytecode isMappedIfImmutability)
(2 242 242 genLongStoreAndPopTemporaryVariableBytecode)
(2 243 243 genSistaExtStoreReceiverVariableBytecode isInstVarRef isMappedIfImmutability)
(2 244 244 genSistaExtStoreLiteralVariableBytecode isMappedIfImmutability)
(2 245 245 genLongStoreTemporaryVariableBytecode)
(2 246 247 unknownBytecode)
"3 byte bytecodes"
(3 248 248 genCallPrimitiveBytecode)
(3 249 249 unknownBytecode) "reserved for Push Float"
(3 250 250 genExtPushClosureBytecode block v4:Block:Code:Size:)
(3 251 251 genExtPushRemoteTempOrInstVarLongBytecode)
(3 252 252 genExtStoreRemoteTempOrInstVarLongBytecode isMappedIfImmutability)
(3 253 253 genExtStoreAndPopRemoteTempOrInstVarLongBytecode isMappedIfImmutability)
(3 254 254 genExtJumpIfNotInstanceOfBehaviorsOrPopBytecode branch v4:Long:BranchIfNotInstanceOf:Distance:)
+ (3 255 255 genExtPushFullClosureBytecode))!
- (3 255 255 unknownBytecode))!
Item was added:
+ ----- Method: StackToRegisterMappingCogit>>genExtPushFullClosureBytecode (in category 'bytecode generators') -----
+ genExtPushFullClosureBytecode
+ "Full Block creation compilation. The block's actual code will be compiled separatedly."
+ "* 255 11111111 xxxxxxxx siyyyyyy push Closure Compiled block literal index xxxxxxxx (+ Extend A * 256) numCopied yyyyyy receiverOnStack: s = 1 ignoreOuterContext: i = 1"
+ | numCopied ignoreContext receiverIsOnStack compiledBlock reg |
+ self assert: needsFrame.
+ compiledBlock := self getLiteral: byte1 + (extA << 8).
+ extA := 0.
+ numCopied := byte2 bitAnd: 1<< 6 - 1.
+ receiverIsOnStack := byte2 anyMask: 1 << 7.
+ ignoreContext := byte2 anyMask: 1 << 6.
+ optStatus isReceiverResultRegLive: false.
+ self ssAllocateCallReg: ReceiverResultReg
+ and: SendNumArgsReg
+ and: ClassReg.
+ objectRepresentation
+ genCreateFullClosure: compiledBlock
+ numArgs: (coInterpreter argumentCountOf: compiledBlock)
+ numCopied: numCopied
+ ignoreContext: ignoreContext
+ contextNumArgs: methodOrBlockNumArgs
+ large: (coInterpreter methodNeedsLargeContext: methodObj)
+ inBlock: inBlock.
+ "Closure in ReceiverResultReg"
+ 1 to: numCopied do:
+ [:i|
+ reg := self ssStorePop: true toPreferredReg: TempReg.
+ objectRepresentation
+ genStoreSourceReg: reg
+ slotIndex: ClosureFirstCopiedValueIndex + numCopied - i
+ intoNewObjectInDestReg: ReceiverResultReg].
+ receiverIsOnStack
+ ifTrue: [reg := self ssStorePop: true toPreferredReg: TempReg]
+ ifFalse: [(self addressOf: simSelf) storeToReg: (reg := TempReg)].
+ objectRepresentation
+ genStoreSourceReg: reg
+ slotIndex: FullClosureReceiverIndex
+ intoNewObjectInDestReg: ReceiverResultReg.
+ self ssPushRegister: ReceiverResultReg.
+ ^0!
More information about the Vm-dev
mailing list