[Vm-dev] VM Maker: VMMaker.oscog-eem.1044.mcz

commits at source.squeak.org commits at source.squeak.org
Thu Feb 5 00:46:44 UTC 2015

Eliot Miranda uploaded a new version of VMMaker to project VM Maker:

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

Name: VMMaker.oscog-eem.1044
Author: eem
Time: 4 February 2015, 4:45:23.297 pm
UUID: e04ad0a1-2b15-4561-a3ed-1a4d4d6d58c8
Ancestors: VMMaker.oscog-eem.1043

Nope.  The fix is to make ensureBehaviorHash:

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

Item was changed:
  ----- Method: SpurMemoryManager>>ensureBehaviorHash: (in category 'class table') -----
  ensureBehaviorHash: aBehavior
+ 	| hash err |
- 	| newHash err |
  	<inline: true>
  	self assert: (coInterpreter addressCouldBeClassObj: aBehavior).
+ 	^(hash := self rawHashBitsOf: aBehavior) ~= 0
+ 		ifTrue:
+ 			[hash]
+ 		ifFalse:
+ 			[(coInterpreter objCouldBeClassObj: aBehavior)
+ 				ifFalse: [PrimErrBadReceiver negated]
+ 				ifTrue:
+ 					[(err := self enterIntoClassTable: aBehavior) ~= 0
+ 						ifTrue: [err negated]
+ 						ifFalse: [self rawHashBitsOf: aBehavior]]]!
- 	(newHash := self rawHashBitsOf: aBehavior) = 0 ifTrue:
- 		[(coInterpreter objCouldBeClassObj: aBehavior) ifFalse:
- 			[^PrimErrBadReceiver negated].
- 		 (err := self enterIntoClassTable: aBehavior) ~= 0 ifTrue:
- 			[^err negated].
- 		 newHash := self rawHashBitsOf: aBehavior.
- 		 self assert: (self classAtIndex: newHash) = aBehavior].
- 	^newHash!

Item was changed:
  ----- Method: StackInterpreter>>primitiveObject:perform:withArguments:lookedUpIn: (in category 'control primitives') -----
  primitiveObject: actualReceiver perform: selector withArguments: argumentArray lookedUpIn: lookupClassOrNil
  	"Common routine used by perform:withArgs:, perform:withArgs:inSuperclass:,
  	 object:perform:withArgs:inClass: et al.  Answer nil on success.
  	 NOTE:  The case of doesNotUnderstand: is not a failure to perform.
  	 The only failures are arg types and consistency of argumentCount.
  	 Since we're in the stack VM we can assume there is space to push the arguments
  	 provided they are within limits (max argument count is 15).  We can therefore deal
  	 with the arbitrary amount of state to remove from the stack (lookup class, selector,
  	 mirror receiver) and arbitrary argument orders by deferring popping anything until
  	 we know whether the send has succeeded.  So on failure we merely have to remove
  	 the actual receiver and arguments pushed, and on success we have to slide the actual
  	 receiver and arguments down to replace the original ones."
  	<inline: true>
+ 	| arraySize performArgCount delta |
- 	| arraySize performArgCount classTag delta |
  	(objectMemory isArray: argumentArray) ifFalse:
  		[^self primitiveFailFor: PrimErrBadArgument].
  	"Check if number of arguments is reasonable; MaxNumArgs isn't available
  	 so just use LargeContextSize"
  	arraySize := objectMemory numSlotsOf: argumentArray.
  	arraySize > LargeContextSlots ifTrue:
  		[^self primitiveFailFor: PrimErrBadNumArgs].
  	performArgCount := argumentCount.
  	"Push newMethod to save it in case of failure,
  	 then push the actual receiver and args out of the array."
  	self push: newMethod.
  	self push: actualReceiver.
  	"Copy the arguments to the stack, and execute"
  	1 to: arraySize do:
  		[:index| self push: (objectMemory fetchPointer: index - 1 ofObject: argumentArray)].
  	argumentCount := arraySize.
  	messageSelector := selector.
  	self sendBreakpoint: messageSelector receiver: actualReceiver.
  	self printSends ifTrue:
  		[self printActivationNameForSelector: messageSelector
  				startClass: (lookupClassOrNil isNil
  								ifTrue: [objectMemory fetchClassOf: actualReceiver]
  								ifFalse: [lookupClassOrNil]);
+ 	self findNewMethodInClassTag: (lookupClassOrNil isNil
- 	classTag := lookupClassOrNil isNil
  										ifTrue: [objectMemory fetchClassTagOf: actualReceiver]
+ 										ifFalse: [objectMemory classTagForClass: lookupClassOrNil]).
- 										ifFalse: [objectMemory classTagForClass: lookupClassOrNil].
- 	self findNewMethodInClassTag: classTag.
  	"Only test CompiledMethods for argument count - any other objects playacting as CMs will have to take their chances"
  	((objectMemory isOopCompiledMethod: newMethod)
  	  and: [(self argumentCountOf: newMethod) ~= argumentCount]) ifTrue:
  		["Restore the state by popping all those array entries and pushing back the selector and array, and fail"
  		 self pop: arraySize + 1.
  		 newMethod := self popStack.
  		 ^self primitiveFailFor: PrimErrBadNumArgs].
  	"Cannot fail this primitive from here-on.  Slide the actual receiver and arguments down
  	 to replace the perform arguments and saved newMethod and then execute the new
  	 method. Use argumentCount not arraySize because an MNU may have changed it."
  	delta := objectMemory wordSize * (performArgCount + 2). "+2 = receiver + saved newMethod"
  	argumentCount * objectMemory wordSize to: 0 by: objectMemory wordSize negated do:
  			longAt: stackPointer + offset + delta
  			put: (stackPages longAt: stackPointer + offset)].
  	self pop: performArgCount + 2.
  	self executeNewMethod.
  	self initPrimCall.  "Recursive xeq affects primErrorCode"

More information about the Vm-dev mailing list