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

commits at source.squeak.org commits at source.squeak.org
Thu Mar 26 06:46:34 UTC 2015


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1123.mcz

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

Name: VMMaker.oscog-eem.1123
Author: eem
Time: 25 March 2015, 11:44:08.131 pm
UUID: 3ecc162f-6d41-4c60-a718-b96e7de481f7
Ancestors: VMMaker.oscog-tpr.1122

Have genPrimReturnEnterCogCodeEnilopmart:
directly pop the result off the stack into
ReceiverResultReg and directly write the retpc
from instructionPointer into pc for ARM.

Given Cog-eem.251 and the above the simulator
is correct on ARM through most of
cePrimReturnEnterCogCode, but the plugin appears
to fail to jump when the pc is written to:

000023ec: orr	sl, sl, #16711680	; 0xff0000
000023f0: orr	sl, sl, #65024	; 0xfe00
000023f4: orr	sl, sl, #60	; 0x3c = 16r7FFFFE3C = &instructionPointer
000023f8: ldr	pc, [sl] = 16rFFFE3C00
000023fc: mov	sl, #2130706432	; 0x7f000000
00002400: orr	sl, sl, #16711680	; 0xff0000
00002404: orr	sl, sl, #65024	; 0xfe00
00002408: orr	sl, sl, #24 = 16r7FFFFE18 = &newMethod
0000240c: ldr	r6, [sl] = 16rFFFE1800

instead of jumping to the contents of the
instructionPointer (16rB6D4 in this case).

=============== Diff against VMMaker.oscog-tpr.1122 ===============

Item was changed:
  ----- Method: SimpleStackBasedCogit>>genPrimReturnEnterCogCodeEnilopmart: (in category 'initialization') -----
  genPrimReturnEnterCogCodeEnilopmart: profiling
  	"Generate the substitute return code for an external or FFI primitive call.
  	 On success simply return, extracting numArgs from newMethod.
  	 On primitive failure call ceActivateFailingPrimitiveMethod: newMethod."
  	| jmpSample continuePostSample jmpFail |
  	<var: #jmpSample type: #'AbstractInstruction *'>
  	<var: #continuePostSample type: #'AbstractInstruction *'>
  	<var: #jmpFail type: #'AbstractInstruction *'>
  	opcodeIndex := 0.
  
  	profiling ifTrue:
  		["Test nextProfileTick for being non-zero and call checkProfileTick: if so.
  		  N.B. nextProfileTick is 64-bits so 32-bit systems need to test both halves."
  		objectMemory wordSize = 4
  			ifTrue:
  				[self MoveAw: coInterpreter nextProfileTickAddress R: TempReg.
  				 self MoveAw: coInterpreter nextProfileTickAddress + objectMemory wordSize R: ClassReg.
  				 self OrR: TempReg R: ClassReg]
  			ifFalse:
  				[self MoveAw: coInterpreter nextProfileTickAddress R: TempReg.
  				 self CmpCq: 0 R: TempReg].
  		"If set, jump to record sample call."
  		jmpSample := self JumpNonZero: 0.
  		continuePostSample := self Label].
  
  	self maybeCompileAllocFillerCheck.
  
  	"Test primitive failure"
  	self MoveAw: coInterpreter primFailCodeAddress R: TempReg.
  	self flag: 'ask concrete code gen if move sets condition codes?'.
  	self CmpCq: 0 R: TempReg.
  	jmpFail := self JumpNonZero: 0.
  
  	"Switch back to the Smalltalk stack.  Stack better be in either of these two states:
  		success:	stackPointer	->	result (was receiver)
  										arg1
  										...
  										argN
  										return pc
  		failure:							receiver
  										arg1
  										...
  					stackPointer	->	argN
  										return pc
  	We push the instructionPointer to reestablish the return pc in the success case,
  	but leave it to ceActivateFailingPrimitiveMethod: to do so in the failure case."
  
  	backEnd hasLinkRegister
  		ifTrue:
+ 			[backEnd genLoadStackPointers.											"Switch back to Smalltalk stack."
+ 			 backEnd hasPCRegister
+ 				ifTrue:
+ 					[self PopR: ReceiverResultReg.										"Pop result from stack"
+ 					 self MoveAw: coInterpreter instructionPointerAddress R: PCReg]	"Return"
+ 				ifFalse:
+ 					[self MoveMw: 0 r: SPReg R: ReceiverResultReg.						"Fetch result from stack"
+ 					 self MoveAw: coInterpreter instructionPointerAddress R: LinkReg.	"Get ret pc"
+ 					 self RetN: objectMemory wordSize]]								"Return, popping result from stack"
- 			[backEnd genLoadStackPointers.									"Switch back to Smalltalk stack."
- 			 self MoveMw: 0 r: SPReg R: ReceiverResultReg.						"Fetch result from stack"
- 			 self MoveAw: coInterpreter instructionPointerAddress R: LinkReg.	"Get and restore ret pc"
- 			 self RetN: objectMemory wordSize]											"Return, popping result from stack"
  		ifFalse:
  			[self MoveAw: coInterpreter instructionPointerAddress R: ClassReg.	"Get return pc"
  			 backEnd genLoadStackPointers.									"Switch back to Smalltalk stack."
  			 self MoveMw: 0 r: SPReg R: ReceiverResultReg.						"Fetch result from stack"
  			 self MoveR: ClassReg Mw: 0 r: SPReg.								"Restore return pc"
  			 self RetN: 0].														"Return, popping result from stack"
  
  	"Primitive failed.  Invoke C code to build the frame and continue."
  	jmpFail jmpTarget: (self MoveAw: coInterpreter newMethodAddress R: SendNumArgsReg).
  	"Reload sp with CStackPointer; easier than popping args of checkProfileTick."
  	self MoveAw: self cStackPointerAddress R: SPReg.
  	self 
  		compileCallFor: #ceActivateFailingPrimitiveMethod:
  		numArgs: 1
  		arg: SendNumArgsReg
  		arg: nil
  		arg: nil
  		arg: nil
  		resultReg: nil
  		saveRegs: false.
  
  	"On Spur ceActivateFailingPrimitiveMethod: may retry the primitive and return if successful.
  	 So continue by returning to the caller.
  	 Switch back to the Smalltalk stack.  Stack should be in this state:
  				success:	stackPointer ->	result (was receiver)
  											arg1
  											...
  											argN
  											return pc
  	 We can push the instructionPointer or load it into the LinkRegister to reestablish the return pc"
  	self MoveAw: coInterpreter instructionPointerAddress
  		R: (backEnd hasLinkRegister ifTrue: [LinkReg] ifFalse: [ClassReg]).
  	backEnd genLoadStackPointers.
  	backEnd hasLinkRegister
  		ifTrue:
  			[self MoveMw: 0 r: SPReg R: ReceiverResultReg]	"Fetch result from stack"
  		ifFalse:
  			[self MoveMw: objectMemory wordSize r: SPReg R: ReceiverResultReg.	"Fetch result from stack"
  			 self PushR: ClassReg].											"Restore return pc on CISCs"
  	self flag: 'currently caller pushes result'.
  	self RetN: objectMemory wordSize.	"return to caller, popping receiver"
  
  	profiling ifTrue:
  		["Call ceCheckProfileTick: to record sample and then continue.  newMethod
  		 should be up-to-date.  Need to save and restore the link reg around this call."
  		 jmpSample jmpTarget: self Label.
  		 backEnd hasLinkRegister ifTrue: [self PushR: LinkReg].
  		 self CallRT: (self cCode: '(unsigned long)ceCheckProfileTick'
  						inSmalltalk: [self simulatedTrampolineFor: #ceCheckProfileTick]).
  		 backEnd hasLinkRegister ifTrue: [self PopR: LinkReg].
  		 self Jump: continuePostSample]!



More information about the Vm-dev mailing list