[Vm-dev] VM Maker: VMMaker.oscog-cb.1774.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Apr 6 17:31:20 UTC 2016


ClementBera uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-cb.1774.mcz

==================== Summary ====================

Name: VMMaker.oscog-cb.1774
Author: cb
Time: 6 April 2016, 10:28:43.581 am
UUID: f4e5d06c-ff8a-4732-b3e4-724e85e421ae
Ancestors: VMMaker.oscog-eem.1773

more full closure support.

=============== Diff against VMMaker.oscog-eem.1773 ===============

Item was changed:
  ----- Method: InterpreterPrimitives>>primitiveClosureValue (in category 'control primitives') -----
  primitiveClosureValue
  	| blockClosure numArgs closureMethod outerContext |
  	blockClosure := self stackValue: argumentCount.
  	numArgs := self argumentCountOfClosure: blockClosure.
  	argumentCount = numArgs ifFalse:
  		[^self primitiveFail].
  
+ 	(self is: blockClosure instanceOf: (objectMemory splObj: ClassBlockClosure) compactClassIndex: ClassBlockClosureCompactIndex)
+ 		ifTrue: 
+ 			[ "Somewhat paranoiac checks we need while debugging that we may be able to discard
+ 			 in a robust system."
+ 			outerContext := objectMemory fetchPointer: ClosureOuterContextIndex ofObject: blockClosure.
+ 			(objectMemory isContext: outerContext) ifFalse:
+ 				[^self primitiveFail].
+ 			closureMethod := objectMemory fetchPointer: MethodIndex ofObject: outerContext.
+ 			"Check if the closure's method is actually a CompiledMethod."
+ 			(objectMemory isOopCompiledMethod: closureMethod) ifFalse:
+ 				[^self primitiveFail].
- 	"Somewhat paranoiac checks we need while debugging that we may be able to discard
- 	 in a robust system."
- 	outerContext := objectMemory fetchPointer: ClosureOuterContextIndex ofObject: blockClosure.
- 	(objectMemory isContext: outerContext) ifFalse:
- 		[^self primitiveFail].
- 	closureMethod := objectMemory fetchPointer: MethodIndex ofObject: outerContext.
- 	"Check if the closure's method is actually a CompiledMethod."
- 	(objectMemory isOopCompiledMethod: closureMethod) ifFalse:
- 		[^self primitiveFail].
  
+ 			"Note we use activateNewMethod, not executeNewMethod, to avoid
+ 			 quickCheckForInterrupts.  Don't check until we have a full activation."
+ 			self activateNewClosureMethod: blockClosure numArgs: numArgs mayContextSwitch: true ]
+ 		ifFalse: 
+ 			[ closureMethod := objectMemory fetchPointer: FullClosureCompiledBlockIndex ofObject: blockClosure.
+ 			(objectMemory isOopCompiledMethod: closureMethod)
+ 				ifFalse: [ ^ self primitiveFail ].
+ 			"Note we use activateNewMethod, not executeNewMethod, to avoid
+ 			 quickCheckForInterrupts.  Don't check until we have a full activation."
+ 			self activateNewFullClosureMethod: blockClosure numArgs: numArgs mayContextSwitch: true ]!
- 	"Note we use activateNewMethod, not executeNewMethod, to avoid
- 	 quickCheckForInterrupts.  Don't check until we have a full activation."
- 	self activateNewClosureMethod: blockClosure numArgs: numArgs mayContextSwitch: true!

Item was added:
+ ----- Method: StackInterpreter>>activateNewFullClosureMethod:numArgs:mayContextSwitch: (in category 'control primitives') -----
+ activateNewFullClosureMethod: blockClosure numArgs: numArgs mayContextSwitch: mayContextSwitch
+ 	"Similar to activateNewMethod but for Closure and newMethod."
+ 	| numCopied outerContext theMethod methodHeader numTemps |
+ 	<inline: true>
+ 	outerContext := objectMemory fetchPointer: ClosureOuterContextIndex ofObject: blockClosure.
+ 	numCopied := self copiedValueCountOfFullClosure: blockClosure.
+ 
+ 	theMethod := objectMemory followField: FullClosureCompiledBlockIndex ofObject: blockClosure.
+ 	self push: instructionPointer.
+ 	self push: framePointer.
+ 	framePointer := stackPointer.
+ 	self push: theMethod.
+ 	self push: (self encodeFrameFieldHasContext: false isBlock: true numArgs: numArgs).
+ 	self push: objectMemory nilObject. "FxThisContext field"
+ 	self push: (objectMemory followField: FullClosureReceiverIndex ofObject: blockClosure).
+ 
+ 	"Copy the copied values..."
+ 	0 to: numCopied - 1 do:
+ 		[:i|
+ 		self push: (objectMemory
+ 					fetchPointer: i + FullClosureFirstCopiedValueIndex
+ 					ofObject: blockClosure)].
+ 
+ 	self assert: (self frameIsBlockActivation: framePointer).
+ 	self assert: (self frameHasContext: framePointer) not.
+ 
+ 	methodHeader := objectMemory methodHeaderOf: newMethod.
+ 	numTemps := self temporaryCountOfMethodHeader: methodHeader.
+ 	
+ 	numArgs + numCopied + 1 to: numTemps do: [ :i | self push: objectMemory nilObject].
+ 
+ 	instructionPointer := (self initialPCForHeader: methodHeader method: newMethod) - 1.
+ 	
+ 	self setMethod: theMethod.
+ 
+ 	"Now check for stack overflow or an event (interrupt, must scavenge, etc)"
+ 	stackPointer < stackLimit ifTrue:
+ 		[self handleStackOverflowOrEventAllowContextSwitch: mayContextSwitch]!

Item was added:
+ ----- Method: StackInterpreter>>copiedValueCountOfFullClosure: (in category 'internal interpreter access') -----
+ copiedValueCountOfFullClosure: closurePointer
+ 	<api> "for Cogit"
+ 	^(objectMemory numSlotsOf: closurePointer) - FullClosureFirstCopiedValueIndex!



More information about the Vm-dev mailing list