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

commits at source.squeak.org commits at source.squeak.org
Tue Jan 7 00:10:55 UTC 2020


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

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

Name: VMMaker.oscog-eem.2650
Author: eem
Time: 6 January 2020, 4:10:39.496587 pm
UUID: ee83002f-875b-4b5f-bfe7-83c57d677666
Ancestors: VMMaker.oscog-eem.2649

Cogit:
Fix a slip in Lowcode FFI trampoline generation.
Nuke leak checking in run-time calls (getting the stack offset for on-stack pcs right is tricky and so the feature isn't useful without a lot more work, and the current bug wasn't caught by it anyway).
Add robustness to printing ARMv8 embedded 32-bit constants.
Better Halt message when stopping at an opcode breakpoint.

Plugins:
Survive double closes in the FilePluginSimulator.

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

Item was changed:
  ----- Method: Cogit>>abstractInstructionAt: (in category 'compile abstract instructions') -----
  abstractInstructionAt: index
  	<cmacro: '(index) (&abstractOpcodes[index])'>
  	<returnTypeC: #'AbstractInstruction *'>
  	((debugOpcodeIndices includes: index)
  	 and: [breakMethod isNil or: [methodObj = breakMethod]]) ifTrue:
+ 		[self halt: 'Accessing opcode index ', index printString].
- 		[self halt].
  	^abstractOpcodes at: index!

Item was changed:
  ----- Method: Cogit>>genFFICalloutTrampoline (in category 'initialization') -----
  genFFICalloutTrampoline
  	<option: #LowcodeVM>
  	| startAddress |
+ 	self zeroOpcodeIndexForNewOpcodes.
- 	opcodeIndex := 0.
  	backEnd hasLinkRegister ifTrue: [
  		self MoveR: LinkReg Aw: coInterpreter instructionPointerAddress
  	] ifFalse: [
  		self PopR: backEnd registerToSaveIP.
  		self MoveR: backEnd registerToSaveIP Aw: coInterpreter instructionPointerAddress
  	].
  
  	self CallR: TempReg.
  
  	backEnd hasLinkRegister ifTrue: [
  		self MoveAw: coInterpreter instructionPointerAddress R: LinkReg 
  	] ifFalse: [
  		self MoveAw: coInterpreter instructionPointerAddress R: backEnd registerToSaveIP.
  		self PushR: backEnd registerToSaveIP.
  	].
  
  	self RetN: 0.
  
  	startAddress := methodZoneBase.
  	self outputInstructionsForGeneratedRuntimeAt: startAddress.
  	self recordGeneratedRunTime: 'ceFFICalloutTrampoline' address: startAddress.
  	self recordRunTimeObjectReferences.
  	^ startAddress
  !

Item was changed:
  ----- Method: Cogit>>handleCallOrJumpSimulationTrap: (in category 'simulation only') -----
  handleCallOrJumpSimulationTrap: aProcessorSimulationTrap
  	<doNotGenerate>
  	| evaluable function memory result savedFramePointer savedStackPointer savedArgumentCount leaf retpc |
- 	objectMemory maybeLeakCheckForRuntimeCall.
  	evaluable := simulatedTrampolines
  					at: aProcessorSimulationTrap address
  					ifAbsent: [self errorProcessingSimulationTrap: aProcessorSimulationTrap
  								in: simulatedTrampolines].
  	function := evaluable isBlock
  					ifTrue: ['aBlock; probably some plugin primitive']
  					ifFalse:
  						[evaluable receiver == backEnd ifTrue:
  							[^self handleABICallOrJumpSimulationTrap: aProcessorSimulationTrap evaluable: evaluable].
  						 evaluable selector].
  	function ~~ #ceBaseFrameReturn: ifTrue:
  		[coInterpreter assertValidExternalStackPointers].
  	(backEnd wantsNearAddressFor: function) ifTrue:
  		[^self perform: function with: aProcessorSimulationTrap].
  	memory := coInterpreter memory.
  	aProcessorSimulationTrap type == #call
  		ifTrue:
  			[(leaf := coInterpreter mcprims includes: function)
  				ifTrue:
  					[processor
  						simulateLeafCallOf: aProcessorSimulationTrap address
  						nextpc: aProcessorSimulationTrap nextpc
  						memory: memory.
  					 retpc := processor leafRetpcIn: memory]
  				ifFalse:
  					[processor
  						simulateCallOf: aProcessorSimulationTrap address
  						nextpc: aProcessorSimulationTrap nextpc
  						memory: memory.
  					 retpc := processor retpcIn: memory].
  			 self recordInstruction: {'(simulated call of '. aProcessorSimulationTrap address. '/'. function. ')'}]
  		ifFalse:
  			[leaf := false.
  			 processor
  				simulateJumpCallOf: aProcessorSimulationTrap address
  				memory: memory.
  			 retpc := processor retpcIn: memory. "sideways call; the primitive has pushed a return address."
  			 self recordInstruction: {'(simulated jump to '. aProcessorSimulationTrap address. '/'. function. ')'}].
  	savedFramePointer := coInterpreter framePointer.
  	savedStackPointer := coInterpreter stackPointer.
  	savedArgumentCount := coInterpreter argumentCount.
  	result := ["self halt: evaluable selector."
  		   	   clickConfirm ifTrue:
  			 	[(self confirm: 'skip run-time call?') ifFalse:
  					[clickConfirm := false. self halt]].
  			   evaluable valueWithArguments: (processor
  												postCallArgumentsNumArgs: evaluable numArgs
  												in: memory)]
  				on: ReenterMachineCode
  				do: [:ex| ex return: ex returnValue].
  			
  	coInterpreter assertValidExternalStackPointers.
- 	objectMemory maybeLeakCheckForRuntimeCall.
  	"Verify the stack layout assumption compileInterpreterPrimitive: makes, provided we've
  	 not called something that has built a frame, such as closure value or evaluate method, or
  	 switched frames, such as primitiveSignal, primitiveWait, primitiveResume, primitiveSuspend et al."
  	(function beginsWith: 'primitive') ifTrue:
  		[coInterpreter checkForLastObjectOverwrite.
  		 coInterpreter primFailCode = 0
  			ifTrue: [(#(	primitiveClosureValue primitiveClosureValueWithArgs primitiveClosureValueNoContextSwitch
  						primitiveFullClosureValue primitiveFullClosureValueWithArgs primitiveFullClosureValueNoContextSwitch
  						primitiveSignal primitiveWait primitiveResume primitiveSuspend primitiveYield
  						primitiveExecuteMethodArgsArray primitiveExecuteMethod
  						primitivePerform primitivePerformWithArgs primitivePerformInSuperclass
  						primitiveTerminateTo primitiveStoreStackp primitiveDoPrimitiveWithArgs)
  							includes: function) ifFalse:
  						["This is a rare case (e.g. in Scorch where a married context's sender is set to nil on trapTrpped and hence the stack layout is altered."
  						 (function == #primitiveSlotAtPut and: [objectMemory isContext: (coInterpreter frameReceiver: coInterpreter framePointer)]) ifFalse:
  							[self assert: savedFramePointer = coInterpreter framePointer.
  							 self assert: savedStackPointer + (savedArgumentCount * objectMemory wordSize)
  									= coInterpreter stackPointer]]]
  			ifFalse:
  				[self assert: savedFramePointer = coInterpreter framePointer.
  				 self assert: savedStackPointer = coInterpreter stackPointer]].
  	result ~~ #continueNoReturn ifTrue:
  		[self recordInstruction: {'(simulated return to '. processor retpcIn: memory. ')'}.
  		 leaf
  			ifTrue: [processor simulateLeafReturnIn: memory]
  			ifFalse: [processor simulateReturnIn: memory].
  		 self assert: processor pc = retpc.
  		 processor smashCallerSavedRegistersWithValuesFrom: 16r80000000 by: objectMemory wordSize in: memory].
  	self assert: (result isInteger "an oop result"
  			or: [result == coInterpreter
  			or: [result == objectMemory
  			or: [#(nil continue continueNoReturn) includes: result]]]).
  	processor cResultRegister: (result
  							ifNil: [0]
  							ifNotNil: [result isInteger
  										ifTrue: [result]
  										ifFalse: [16rF00BA222]])
  
  	"coInterpreter cr.
  	 processor sp + 32 to: processor sp - 32 by: -4 do:
  		[:sp|
  		 sp = processor sp
  			ifTrue: [coInterpreter print: 'sp->'; tab]
  			ifFalse: [coInterpreter printHex: sp].
  		 coInterpreter tab; printHex: (coInterpreter longAt: sp); cr]"!

Item was changed:
  ----- Method: FilePluginSimulator>>close (in category 'initialize-release') -----
+ close
+ 	"close any files that ST may have opened"
+ 	openFiles do:
+ 		[:f |
+ 		 [f close]
+ 			on: Error
+ 			do: [:ex|
+ 				ex messageText ~= 'primClose: failed' ifTrue:
+ 					[ex pass]]]!
- close  "close any files that ST may have opened"
- 	openFiles do: [:f | f close]!

Item was removed:
- ----- Method: NewObjectMemory>>maybeLeakCheckForRuntimeCall (in category 'debug support') -----
- maybeLeakCheckForRuntimeCall
- 	<doNotGenerate>
- 	(checkForLeaks bitAnd: 32) ~= 0 ifTrue:
- 		[coInterpreter runLeakChecker]!

Item was changed:
  ----- Method: SpurMemoryManager>>lookup32BitWordConstant: (in category 'simulation only') -----
  lookup32BitWordConstant: word
  	"If word appears to be a class index answer the class name, otherwise answer nil.
  	 For code disassembly"
  	<doNotGenerate>
  	| class classSize classNameIndex thisClassIndex |
+ 	(hiddenRootsObj notNil
+ 	 and: [word between: 1 and: self classIndexMask]) ifFalse:
- 	(word between: 1 and: self classIndexMask) ifFalse:
  		[^nil].
  	class := self noCheckClassAtIndex: word.
  	(class isNil or: [class = nilObj]) ifTrue:
  		[^nil].	"address is either a class or a metaclass, or an instance of a class or invalid.  determine which."
  	classNameIndex := coInterpreter classNameIndex.
  	thisClassIndex := coInterpreter thisClassIndex.
  	((classSize := self numSlotsOf: class) <= (classNameIndex max: thisClassIndex)
  	 or: [classSize > 255]) ifTrue:
  		[^nil].
  	"Address could be a class or a metaclass"
  	(self lookupAddress: (self fetchPointer: classNameIndex ofObject: class)) ifNotNil:
  		[:maybeClassName| ^maybeClassName allButFirst].
  	(self lookupAddress: (self fetchPointer: thisClassIndex ofObject: class)) ifNotNil:
  		[:maybeClassName| ^maybeClassName allButFirst, ' class'].!

Item was removed:
- ----- Method: SpurMemoryManager>>maybeLeakCheckForRuntimeCall (in category 'debug support') -----
- maybeLeakCheckForRuntimeCall
- 	<doNotGenerate>
- 	(checkForLeaks bitAnd: 32) ~= 0 ifTrue:
- 		[coInterpreter runLeakChecker]!



More information about the Vm-dev mailing list