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

commits at source.squeak.org commits at source.squeak.org
Wed May 27 16:56:16 UTC 2015


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

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

Name: VMMaker.oscog-eem.1328
Author: eem
Time: 27 May 2015, 9:54:09.994 am
UUID: c1e2ed6b-28c4-448f-88b8-4c7a3ad53b78
Ancestors: VMMaker.oscog-EstebanLorenzano.1327

Fix determination of the picInterpretAbortOffset
on ARM in cogExtendPIC:CaseNMethod:tag:isMNUCase:.

=============== Diff against VMMaker.oscog-EstebanLorenzano.1327 ===============

Item was changed:
+ SystemOrganization addCategory: #'VMMaker-Building'!
+ SystemOrganization addCategory: #'VMMaker-Interpreter'!
+ SystemOrganization addCategory: #'VMMaker-InterpreterSimulation'!
+ SystemOrganization addCategory: #'VMMaker-InterpreterSimulation-Morphic'!
+ SystemOrganization addCategory: #'VMMaker-JIT'!
+ SystemOrganization addCategory: #'VMMaker-JITSimulation'!
+ SystemOrganization addCategory: #'VMMaker-Multithreading'!
+ SystemOrganization addCategory: #'VMMaker-Plugins'!
+ SystemOrganization addCategory: #'VMMaker-Plugins-Alien'!
+ SystemOrganization addCategory: #'VMMaker-Plugins-IOS'!
+ SystemOrganization addCategory: #'VMMaker-PostProcessing'!
+ SystemOrganization addCategory: #'VMMaker-SmartSyntaxPlugins'!
+ SystemOrganization addCategory: #'VMMaker-SpurMemoryManager'!
+ SystemOrganization addCategory: #'VMMaker-SpurMemoryManagerSimulation'!
+ SystemOrganization addCategory: #'VMMaker-Support'!
+ SystemOrganization addCategory: #'VMMaker-Tests'!
+ SystemOrganization addCategory: #'VMMaker-Translation to C'!
- SystemOrganization addCategory: #VMMaker!
- SystemOrganization addCategory: 'VMMaker-Building'!
- SystemOrganization addCategory: 'VMMaker-Interpreter'!
- SystemOrganization addCategory: 'VMMaker-InterpreterSimulation'!
- SystemOrganization addCategory: 'VMMaker-InterpreterSimulation-Morphic'!
- SystemOrganization addCategory: 'VMMaker-JIT'!
- SystemOrganization addCategory: 'VMMaker-JITSimulation'!
- SystemOrganization addCategory: 'VMMaker-Multithreading'!
- SystemOrganization addCategory: 'VMMaker-Plugins'!
- SystemOrganization addCategory: 'VMMaker-Plugins-Alien'!
- SystemOrganization addCategory: 'VMMaker-Plugins-IOS'!
- SystemOrganization addCategory: 'VMMaker-PostProcessing'!
- SystemOrganization addCategory: 'VMMaker-SmartSyntaxPlugins'!
- SystemOrganization addCategory: 'VMMaker-SpurMemoryManager'!
- SystemOrganization addCategory: 'VMMaker-SpurMemoryManagerSimulation'!
- SystemOrganization addCategory: 'VMMaker-Support'!
- SystemOrganization addCategory: 'VMMaker-Tests'!
- SystemOrganization addCategory: 'VMMaker-Translation to C'!

Item was changed:
  ----- Method: CCodeGenerator>>storeAPIExportHeader:OnFile: (in category 'public') -----
  storeAPIExportHeader: headerName OnFile: fullHeaderPath
  	"Store C header code on the given file. Evaluate
  	 aBlock with the stream to generate its contents."
  
  	| header |
  	header := String streamContents:
  				[:s|
  				 s nextPutAll: (self fileHeaderVersionStampForSourceClass: nil); cr.
  				 self emitCAPIExportHeaderOn: s].
  	(self needToGenerateHeader: headerName file: fullHeaderPath contents: header) ifTrue:
  		[self storeHeaderOnFile: fullHeaderPath contents: header]!

Item was changed:
  ----- Method: CCodeGenerator>>storeHeaderOnFile:contents: (in category 'public') -----
  storeHeaderOnFile: fileName contents: contents
  	"Store C header code on the given file. Evaluate
  	 aBlock with the stream to generate its contents."
  
  	| aStream |
  	aStream := VMMaker forceNewFileNamed: fileName.
  	aStream ifNil: [Error signal: 'Could not open C header file: ', fileName].
  	[(contents beginsWith: '/* Automatic') ifFalse:
  		[aStream nextPutAll: (self fileHeaderVersionStampForSourceClass: nil); cr].
  	 aStream nextPutAll: contents]
  		ensure: [aStream close]!

Item was changed:
  ----- Method: CCodeGenerator>>structClassesForTranslationClasses: (in category 'utilities') -----
  structClassesForTranslationClasses: classes
  	"Answer in superclass order (any superclass precedes any subclass)
  	 the ancilliaryClasses that are struct classes for all the given classes."
  	| theStructClasses |
  	theStructClasses := OrderedCollection new.
  	classes do:
  		[:aTranslationClass|
  		([aTranslationClass ancilliaryClasses: self options]
  				on: MessageNotUnderstood
  				do: [:ex|
  					ex message selector == #ancilliaryClasses:
  						ifTrue: [#()]
  						ifFalse: [ex pass]]) do:
  			[:class|
  			(class isStructClass
  			 and: [(vmClass isNil or: [vmClass isAcceptableAncilliaryClass: class])
  			 and: [(theStructClasses includes: class) not]]) ifTrue:
  				[theStructClasses addLast: class]]].
  	^ChangeSet superclassOrder: theStructClasses!

Item was changed:
  ----- Method: CogARMCompiler>>sub:rn:imm:ror: (in category 'ARM convenience instructions') -----
  sub: destReg rn: srcReg imm: immediate ror: rot
  "	Remember the ROR is doubled by the cpu so use 30>>1 etc
  	SUB destReg, srcReg, #immediate ROR rot"
  
  	^self type: 1 op: SubOpcode set: 0 rn: srcReg rd: destReg shifterOperand: ((rot>>1) <<8 bitOr: immediate)!

Item was changed:
  ----- Method: CogMethodSurrogate32 class>>alignedByteSize (in category 'accessing') -----
  alignedByteSize
  	^20 + self baseHeaderSize!

Item was changed:
  ----- Method: CogMethodSurrogate64 class>>alignedByteSize (in category 'accessing') -----
  alignedByteSize
  	^32 + self baseHeaderSize!

Item was changed:
  ----- Method: Cogit>>cogExtendPIC:CaseNMethod:tag:isMNUCase: (in category 'in-line cacheing') -----
  cogExtendPIC: cPIC CaseNMethod: caseNMethod tag: caseNTag isMNUCase: isMNUCase
  	"Extend the cPIC with the supplied case.  If caseNMethod is cogged dispatch direct to
  	 its unchecked entry-point.  If caseNMethod is not cogged, jump to the fast interpreter
  	 dispatch, and if isMNUCase then dispatch to fast MNU invocation and mark the cPIC as
  	 having the MNU case for cache flushing."
   	<var: #cPIC type: #'CogMethod *'>
  	| operand target address size end |
  	"stack allocate the various collections so that they
  	 are effectively garbage collected on return."
  	coInterpreter
  		compilationBreak: cPIC selector
  		point: (objectMemory numBytesOf: cPIC selector)
  		isMNUCase: isMNUCase.
  	self allocateOpcodes: 5 bytecodes: 0.
  	methodLabel address: cPIC asUnsignedInteger; dependent: nil. "for pc-relative MoveCw: cPIC R: ClassReg"
  	self assert: (objectRepresentation inlineCacheTagIsYoung: caseNTag) not.
  	"Caller patches to open pic if caseNMethod is young."
  	self assert: (caseNMethod notNil and: [(objectMemory isYoung: caseNMethod) not]).
  	(isMNUCase not
  	 and: [coInterpreter methodHasCogMethod: caseNMethod])
  		ifTrue:
  			[operand := 0.
  			 target := (coInterpreter cogMethodOf: caseNMethod) asInteger + cmNoCheckEntryOffset]
  		ifFalse:
+ 			[operand := caseNMethod.
+ 			 isMNUCase
+ 				ifTrue:
+ 					[cPIC cpicHasMNUCase: true.
+ 					 target := cPIC asInteger + (self sizeof: CogMethod)]
+ 				ifFalse:
+ 					[target := cPIC asInteger + self picInterpretAbortOffset]].
- 			[isMNUCase ifTrue:
- 				[cPIC cpicHasMNUCase: true].
- 			 operand := caseNMethod.
- 			 target := cPIC asInteger
- 					+ (isMNUCase
- 						ifTrue: [self sizeof: CogMethod]
- 						ifFalse: [self interpretOffset - backEnd callInstructionByteSize])].
  	self CmpCw: caseNTag R: TempReg.
  	self MoveCw: operand R: SendNumArgsReg.
  	self JumpLongZero: target.
  	self MoveCw: cPIC asUnsignedInteger R: ClassReg.
  	self JumpLong: (self cPICMissTrampolineFor: cPIC cmNumArgs).
  	self computeMaximumSizes.
  	address := self addressOfEndOfCase: cPIC cPICNumCases - 1 inCPIC: cPIC.
  	size := self generateInstructionsAt: address.
  	end := self outputInstructionsAt: address.
  	processor flushICacheFrom: cPIC asInteger to: cPIC asInteger + closedPICSize.
  	cPIC cPICNumCases: cPIC cPICNumCases + 1.
  	^0!

Item was changed:
  ----- Method: Cogit>>generateClosedPICPrototype (in category 'initialization') -----
  generateClosedPICPrototype
  	"Generate the prototype ClosedPIC to determine how much space as full PIC takes.
  	 When we first allocate a closed PIC it only has one or two cases and we want to grow it.
  	 So we have to determine how big a full one is before hand."
  	numPICCases := 6.
  	"stack allocate the various collections so that they
  	 are effectively garbage collected on return."
  	self allocateOpcodes: numPICCases * 7 bytecodes: 0.
  	methodLabel address: methodZoneBase; dependent: nil. "for pc-relative MoveCw: cPIC R: ClassReg"
  	self compileClosedPICPrototype.
  	self computeMaximumSizes.
  	closedPICSize := (self sizeof: CogMethod) + (self generateInstructionsAt: methodZoneBase + (self sizeof: CogMethod)).
  	firstCPICCaseOffset := endCPICCase0 address - methodZoneBase.
  	cPICCaseSize := endCPICCase1 address - endCPICCase0 address.
  	cPICEndSize := closedPICSize - (numPICCases - 1 * cPICCaseSize + firstCPICCaseOffset).
+ 	closedPICSize := methodZone roundUpLength: closedPICSize.
+ 	self assert: picInterpretAbort address = (methodLabel address + self picInterpretAbortOffset)
- 	closedPICSize := methodZone roundUpLength: closedPICSize
  	"self cCode: ''
  		inSmalltalk:
  			[| end |
  			 end := self outputInstructionsAt: methodZoneBase + headerSize.
  			 self disassembleFrom: methodZoneBase + headerSize to: end - 1.
  			 self halt]"!

Item was added:
+ ----- Method: Cogit>>picInterpretAbortOffset (in category 'debugging') -----
+ picInterpretAbortOffset
+ 	"Answer the start of the abort sequence for invoking the interpreter in a closed PIC."
+ 	^self interpretOffset
+ 	 - (backEnd hasLinkRegister
+ 		ifTrue: [backEnd pushLinkRegisterByteSize + backEnd callInstructionByteSize]
+ 		ifFalse: [backEnd callInstructionByteSize])!

Item was changed:
  ----- Method: Integer>>asUnsignedInteger (in category '*VMMaker-interpreter simulator') -----
  asUnsignedInteger
  	self assert: self >= 0.
  	^self!

Item was changed:
  ----- Method: InterpreterPlugin class>>shouldBeTranslated (in category 'translation') -----
  shouldBeTranslated
  "is this class intended to be translated as a plugin? Most subclasses should answer true, but some such as:-
  	TestInterpreterPlugin
  	FlippArrayPlugin2
  	InflatePlugin
  	should answer false for various reasons."
  	^true!

Item was changed:
  ----- Method: InterpreterPlugin class>>shouldBeTranslatedFor: (in category 'translation') -----
  shouldBeTranslatedFor: platformName
  	"Is this class intended to be translated as a plugin, perhaps specific to a platform?
  	 Most subclasses should answer true, but some such as simulation-only versions
  	 should answer false for various reasons."
  	^self shouldBeTranslated!

Item was changed:
  ----- Method: InterpreterProxy>>isImmediate: (in category 'testing') -----
  isImmediate: anObject
  	<option: #(atLeastVMProxyMajor:minor: 1 13)>
  	^StackInterpreter objectMemoryClass isImmediate: anObject!

Item was changed:
  ----- Method: SpurGenerationScavenger>>copyAndForward: (in category 'scavenger') -----
  copyAndForward: survivor
  	"copyAndForward: survivor copies a survivor object either to
  	 futureSurvivorSpace or, if it is to be promoted, to oldSpace.
  	 It leaves a forwarding pointer behind.  If the object is weak
  	 then corpse is threaded onto the weakList for later treatment."
  	<inline: false>
  	| bytesInObj format tenure newLocation |
  	self assert: ((manager isInEden: survivor) "cog methods should be excluded."
  				or: [manager isInPastSpace: survivor]).
  	bytesInObj := manager bytesInObject: survivor.
  	format := manager formatOf: survivor.
  	tenure := self shouldBeTenured: survivor. "Allow Slang to inline."
  	newLocation := (tenure or: [futureSurvivorStart + bytesInObj > futureSpace limit])
  						ifTrue: [self copyToOldSpace: survivor bytes: bytesInObj format: format]
  						ifFalse: [self copyToFutureSpace: survivor bytes: bytesInObj].
  	manager forwardSurvivor: survivor to: newLocation.
  	"if weak or ephemeron add to the relevant list for subsequent scanning."
  	(manager isWeakFormat: format) ifTrue:
  		[self addToWeakList: survivor].
  	((manager isEphemeronFormat: format)
  	 and: [(self isScavengeSurvivor: (manager keyOfEphemeron: newLocation)) not]) ifTrue:
  		[self addToEphemeronList: survivor].
  	^newLocation!

Item was changed:
  ----- Method: SpurMemoryManager>>isForwarded: (in category 'object testing') -----
  isForwarded: objOop
  	"Answer if objOop is that if a forwarder.  Take advantage of isForwardedObjectClassIndexPun
  	 being a power of two to generate a more efficient test than the straight-forward
  		(self classIndexOf: objOop) = self isForwardedObjectClassIndexPun
  	 at the cost of this being ambiguous with free chunks.  So either never apply this to free chunks
  	 or guard with (self isFreeObject: foo) not.  So far the idiom has been to guard with isFreeObject:"
  	<api>
  	<inline: true>
  	"self assert: (self isFreeObject: objOop) not."
  	^(self longAt: objOop) noMask: self classIndexMask - self isForwardedObjectClassIndexPun!

Item was changed:
  ----- Method: StackInterpreter>>codeGeneratorToComputeAccessorDepth (in category 'primitive support') -----
  codeGeneratorToComputeAccessorDepth
  	^VMMaker new
  		buildCodeGeneratorForInterpreter: self class primitivesClass
  		includeAPIMethods: false
  		initializeClasses: false!

Item was changed:
  ----- Method: StackInterpreter>>primitiveIndexOfMethod:header: (in category 'compiled methods') -----
  primitiveIndexOfMethod: theMethod header: methodHeader
  	"Note: With the Squeak V0 format we now have 10 bits of primitive index, but they are in
  	 two places for temporary backward compatibility.  The time to unpack is negligible,
  	 since the derived primitive function pointer is stored in the method cache.  With the new
  	 format we assume a 3-byte CallPrimitive with a little-endian 16-bit primitive index."
  	<api>
  	<inline: true>
  	| firstBytecode |
  	^objectMemory hasSpurMemoryManagerAPI
  		ifTrue:
  			[(self alternateHeaderHasPrimitiveFlag: methodHeader)
  				ifTrue:
  					[firstBytecode := self firstBytecodeOfAlternateHeader: methodHeader method: theMethod.
  					 (objectMemory byteAt: firstBytecode + 1) + ((objectMemory byteAt: firstBytecode + 2) << 8)]
  				ifFalse:
  					[0]]
  		ifFalse:
  			[MULTIPLEBYTECODESETS
  				ifTrue:
  					[(self headerIndicatesAlternateBytecodeSet: methodHeader)
  						ifTrue:
  							[(self alternateHeaderHasPrimitiveFlag: methodHeader)
  								ifTrue:
  									[firstBytecode := self firstBytecodeOfAlternateHeader: methodHeader method: theMethod.
  									 (objectMemory byteAt: firstBytecode + 1) + ((objectMemory byteAt: firstBytecode + 2) << 8)]
  								ifFalse:
  									[0]]
  						ifFalse:
  							[| primBits |
  							 primBits := objectMemory integerValueOf: methodHeader.
  							 (primBits bitAnd: 16r1FF) + (primBits >> 19 bitAnd: 16r200)]]
  				ifFalse:
  					[| primBits |
  					 primBits := objectMemory integerValueOf: methodHeader.
  					 (primBits bitAnd: 16r1FF) + (primBits >> 19 bitAnd: 16r200)]]!

Item was changed:
  ----- Method: StackInterpreterSimulator>>runAtEachStep: (in category 'testing') -----
  runAtEachStep: aBlock
  	self initStackPages.
  	self loadInitialContext.
  	self internalizeIPandSP.
  	self fetchNextBytecode.
  	[true] whileTrue:
  		[self assertValidExecutionPointers.
  		 aBlock value: currentBytecode.
  		 self dispatchOn: currentBytecode in: BytecodeTable.
  		 self incrementByteCount].
  	localIP := localIP - 1.
  	"undo the pre-increment of IP before returning"
  	self externalizeIPandSP!

Item was changed:
  ----- Method: TAssignmentNode>>emitCCodeAsExpressionOn:level:generator: (in category 'C code generation') -----
  emitCCodeAsExpressionOn: aStream level: level generator: aCodeGen
  	aStream nextPut: $(.
  	self emitCCodeOn: aStream level: level generator: aCodeGen.
  	aStream nextPut: $)!

Item was changed:
  ----- Method: TParseNode>>emitCCodeAsArgumentOn:level:generator: (in category 'C code generation') -----
  emitCCodeAsArgumentOn: aStream level: level generator: aCodeGen
  	^self emitCCodeOn: aStream level: level generator: aCodeGen!

Item was changed:
  ----- Method: TParseNode>>emitCCodeAsExpressionOn:level:generator: (in category 'C code generation') -----
  emitCCodeAsExpressionOn: aStream level: level generator: aCodeGen
  	^self emitCCodeOn: aStream level: level generator: aCodeGen!

Item was changed:
  ----- Method: TSendNode>>emitCCodeAsExpressionOn:level:generator: (in category 'C code generation') -----
  emitCCodeAsExpressionOn: aStream level: level generator: aCodeGen
  	^self emitCCodeAsArgumentOn: aStream level: level generator: aCodeGen!

Item was changed:
  ----- Method: VMClass class>>initializePrimitiveErrorCodes (in category 'initialization') -----
  initializePrimitiveErrorCodes
  	"Define the VM's primitive error codes.  N.B. these are
  	 replicated in platforms/Cross/vm/sqVirtualMachine.h."
  	"VMClass initializePrimitiveErrorCodes"
  	| pet |
  	PrimErrTableIndex := 51. "Zero-relative"
  	"See SmalltalkImage>>recreateSpecialObjectsArray for the table definition.
  	 If the table exists and is large enough the corresponding entry is returned as
  	 the primitive error, otherwise the error is answered numerically."
  	pet := Smalltalk specialObjectsArray at: PrimErrTableIndex + 1 ifAbsent: [#()].
  	pet isArray ifFalse: [pet := #()].
  	PrimNoErr := 0. "for helper methods that need to answer success or an error code."
  	PrimErrGenericFailure		:= pet indexOf: nil ifAbsent: 1.
  	PrimErrBadReceiver			:= pet indexOf: #'bad receiver' ifAbsent: 2.
  	PrimErrBadArgument		:= pet indexOf: #'bad argument' ifAbsent: 3.
  	PrimErrBadIndex			:= pet indexOf: #'bad index' ifAbsent: 4.
  	PrimErrBadNumArgs		:= pet indexOf: #'bad number of arguments' ifAbsent: 5.
  	PrimErrInappropriate		:= pet indexOf: #'inappropriate operation' ifAbsent: 6.
  	PrimErrUnsupported		:= pet indexOf: #'unsupported operation' ifAbsent: 7.
  	PrimErrNoModification		:= pet indexOf: #'no modification' ifAbsent: 8.
  	PrimErrNoMemory			:= pet indexOf: #'insufficient object memory' ifAbsent: 9.
  	PrimErrNoCMemory			:= pet indexOf: #'insufficient C memory' ifAbsent: 10.
  	PrimErrNotFound			:= pet indexOf: #'not found' ifAbsent: 11.
  	PrimErrBadMethod			:= pet indexOf: #'bad method' ifAbsent: 12.
  	PrimErrNamedInternal		:= pet indexOf: #'internal error in named primitive machinery' ifAbsent: 13.
  	PrimErrObjectMayMove		:= pet indexOf: #'object may move' ifAbsent: 14.
  	PrimErrLimitExceeded		:= pet indexOf: #'resource limit exceeded' ifAbsent: 15.
  	PrimErrObjectIsPinned		:= pet indexOf: #'object is pinned' ifAbsent: 16.
  	PrimErrWritePastObject	:= pet indexOf: #'primitive write beyond end of object' ifAbsent: 17!



More information about the Vm-dev mailing list