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

commits at source.squeak.org commits at source.squeak.org
Fri May 9 18:18:28 UTC 2014


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

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

Name: VMMaker.oscog-eem.708
Author: eem
Time: 9 May 2014, 11:14:10.069 am
UUID: 6258685a-cf1e-40dc-923a-e4027e4cf169
Ancestors: VMMaker.oscog-eem.707

Rename checkValidObjectReference: et al to
checkValidOopReference: et al (since that's what they check)
and add checkValidObjectReference: to check just that.

Fix a translation-time return type clash in
doubleExtendedDoAnythingBytecode

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

Item was added:
+ ----- Method: CogObjectRepresentation>>checkValidObjectReference: (in category 'garbage collection') -----
+ checkValidObjectReference: anOop
+ 	^(objectMemory isImmediate: anOop) not
+ 	   and: [(self heapMapAtWord: (self pointerForOop: anOop)) ~= 0]!

Item was removed:
- ----- Method: CogObjectRepresentationForSpur>>checkValidObjectReference: (in category 'debug support') -----
- checkValidObjectReference: anOop
- 	^(objectMemory isImmediate: anOop)
- 	   or: [(objectMemory heapMapAtWord: (self pointerForOop: anOop)) ~= 0]!

Item was added:
+ ----- Method: CogObjectRepresentationForSpur>>checkValidOopReference: (in category 'debug support') -----
+ checkValidOopReference: anOop
+ 	^(objectMemory isImmediate: anOop)
+ 	   or: [(objectMemory heapMapAtWord: (self pointerForOop: anOop)) ~= 0]!

Item was removed:
- ----- Method: CogObjectRepresentationForSqueakV3>>checkValidObjectReference: (in category 'garbage collection') -----
- checkValidObjectReference: anOop
- 	^(objectMemory isIntegerObject: anOop)
- 	   or: [(self heapMapAtWord: (self pointerForOop: anOop)) ~= 0]!

Item was added:
+ ----- Method: CogObjectRepresentationForSqueakV3>>checkValidOopReference: (in category 'garbage collection') -----
+ checkValidOopReference: anOop
+ 	^(objectMemory isIntegerObject: anOop)
+ 	   or: [(self heapMapAtWord: (self pointerForOop: anOop)) ~= 0]!

Item was changed:
  ----- Method: Cogit>>allMachineCodeObjectReferencesValid (in category 'garbage collection') -----
  allMachineCodeObjectReferencesValid
  	"Check that all methods have valid selectors, and that all linked sends are to valid targets and have valid cache tags"
  	| ok cogMethod |
  	<var: #cogMethod type: #'CogMethod *'>
  	ok := true.
  	cogMethod := self cCoerceSimple: methodZoneBase to: #'CogMethod *'.
  	[cogMethod < methodZone limitZony] whileTrue:
  		[cogMethod cmType ~= CMFree ifTrue:
+ 			[(self asserta: (objectRepresentation checkValidOopReference: cogMethod selector)) ifFalse:
- 			[(self asserta: (objectRepresentation checkValidObjectReference: cogMethod selector)) ifFalse:
  				[ok := false].
  			 (self asserta: (self cogMethodDoesntLookKosher: cogMethod) = 0) ifFalse:
  				[ok := false]].
  		(cogMethod cmType = CMMethod
  		 or: [cogMethod cmType = CMOpenPIC]) ifTrue:
  			[(self asserta: ((self mapFor: cogMethod
+ 								 performUntil: #checkIfValidOopRefAndTarget:pc:cogMethod:
- 								 performUntil: #checkIfValidObjectRefAndTarget:pc:cogMethod:
  								 arg: cogMethod asInteger) = 0)) ifFalse:
  				[ok := false]].
  		cogMethod cmType = CMClosedPIC ifTrue:
  			[(self asserta: (self noTargetsFreeInClosedPIC: cogMethod)) ifFalse:
  				[ok := false]].
  		cogMethod := methodZone methodAfter: cogMethod].
  	^ok!

Item was removed:
- ----- Method: Cogit>>checkIfValidObjectRef:pc:cogMethod: (in category 'garbage collection') -----
- checkIfValidObjectRef: annotation pc: mcpc cogMethod: cogMethod
- 	<var: #mcpc type: #'char *'>
- 	annotation = IsObjectReference ifTrue:
- 		[| literal |
- 		 literal := backEnd literalBeforeFollowingAddress: mcpc asInteger.
- 		 (objectRepresentation checkValidObjectReference: literal) ifFalse:
- 			[coInterpreter print: 'object ref leak in CM '; printHex: cogMethod asInteger; print: ' @ '; printHex: mcpc asInteger; cr.
- 			^1]].
- 	(self isSendAnnotation: annotation) ifTrue:
- 		[| entryPoint selectorOrCacheTag offset |
- 		 entryPoint := backEnd callTargetFromReturnAddress: mcpc asInteger.
- 		 entryPoint <= methodZoneBase
- 			ifTrue:
- 				[offset := entryPoint]
- 			ifFalse:
- 				[self
- 					offsetAndSendTableFor: entryPoint
- 					annotation: annotation
- 					into: [:off :table| offset := off]].
- 		 selectorOrCacheTag := backEnd inlineCacheTagAt: mcpc asInteger.
- 		 (entryPoint > methodZoneBase
- 		  and: [offset ~= cmNoCheckEntryOffset
- 		  and: [(self cCoerceSimple: entryPoint - offset to: #'CogMethod *') cmType ~= CMOpenPIC]])
- 			ifTrue: "linked non-super send, cacheTag is a cacheTag"
- 				[(objectRepresentation checkValidInlineCacheTag: selectorOrCacheTag) ifFalse:
- 					[coInterpreter print: 'cache tag leak in CM '; printHex: cogMethod asInteger; print: ' @ '; printHex: mcpc asInteger; cr.
- 					^1]]
- 			ifFalse: "unlinked send or super send; cacheTag is a selector"
- 				[(objectRepresentation checkValidObjectReference: selectorOrCacheTag) ifFalse:
- 					[coInterpreter print: 'selector leak in CM '; printHex: cogMethod asInteger; print: ' @ '; printHex: mcpc asInteger; cr.
- 					^1]]].
- 	^0 "keep scanning"!

Item was removed:
- ----- Method: Cogit>>checkIfValidObjectRefAndTarget:pc:cogMethod: (in category 'garbage collection') -----
- checkIfValidObjectRefAndTarget: annotation pc: mcpc cogMethod: cogMethod
- 	<var: #mcpc type: #'char *'>
- 	| literal entryPoint |
- 	annotation = IsObjectReference ifTrue:
- 		[literal := backEnd literalBeforeFollowingAddress: mcpc asInteger.
- 		 (self asserta: (objectRepresentation checkValidObjectReference: literal)) ifFalse:
- 			[^1].
- 		((objectRepresentation couldBeObject: literal)
- 		 and: [objectMemory isReallyYoungObject: literal]) ifTrue:
- 			[(self asserta: (self cCoerceSimple: cogMethod to: #'CogMethod *') cmRefersToYoung) ifFalse:
- 				[^2]]].
- 	(self isSendAnnotation: annotation) ifTrue:
- 		[(self asserta: (self cCoerceSimple: cogMethod to: #'CogMethod *') cmType = CMMethod) ifFalse:
- 			[^3].
- 		 self offsetCacheTagAndCouldBeObjectAt: mcpc annotation: annotation into:
- 			[:offset :cacheTag :tagCouldBeObject|
- 			tagCouldBeObject
- 				ifTrue:
- 					[(objectRepresentation couldBeObject: cacheTag)
- 						ifTrue:
- 							[(self asserta: (objectRepresentation checkValidObjectReference: cacheTag)) ifFalse:
- 								[^4]]
- 						ifFalse:
- 							[(self asserta: (objectRepresentation checkValidInlineCacheTag: cacheTag)) ifFalse:
- 								[^5]].
- 					((objectRepresentation couldBeObject: cacheTag)
- 					 and: [objectMemory isReallyYoungObject: cacheTag]) ifTrue:
- 						[(self asserta: (self cCoerceSimple: cogMethod to: #'CogMethod *') cmRefersToYoung) ifFalse:
- 							[^6]]]
- 				ifFalse:
- 					[(self asserta: (objectRepresentation checkValidInlineCacheTag: cacheTag)) ifFalse:
- 						[^7]]].
- 		entryPoint := backEnd callTargetFromReturnAddress: mcpc asInteger.
- 		entryPoint > methodZoneBase ifTrue:
- 			["It's a linked send; find which kind."
- 			 self targetMethodAndSendTableFor: entryPoint into:
- 					[:targetMethod :sendTable|
- 					 (self asserta: (targetMethod cmType = CMMethod
- 								   or: [targetMethod cmType = CMClosedPIC
- 								   or: [targetMethod cmType = CMOpenPIC]])) ifFalse:
- 						[^8]]]].
- 	^0 "keep scanning"!

Item was added:
+ ----- Method: Cogit>>checkIfValidOopRef:pc:cogMethod: (in category 'garbage collection') -----
+ checkIfValidOopRef: annotation pc: mcpc cogMethod: cogMethod
+ 	<var: #mcpc type: #'char *'>
+ 	annotation = IsObjectReference ifTrue:
+ 		[| literal |
+ 		 literal := backEnd literalBeforeFollowingAddress: mcpc asInteger.
+ 		 (objectRepresentation checkValidOopReference: literal) ifFalse:
+ 			[coInterpreter print: 'object ref leak in CM '; printHex: cogMethod asInteger; print: ' @ '; printHex: mcpc asInteger; cr.
+ 			^1]].
+ 	(self isSendAnnotation: annotation) ifTrue:
+ 		[| entryPoint selectorOrCacheTag offset |
+ 		 entryPoint := backEnd callTargetFromReturnAddress: mcpc asInteger.
+ 		 entryPoint <= methodZoneBase
+ 			ifTrue:
+ 				[offset := entryPoint]
+ 			ifFalse:
+ 				[self
+ 					offsetAndSendTableFor: entryPoint
+ 					annotation: annotation
+ 					into: [:off :table| offset := off]].
+ 		 selectorOrCacheTag := backEnd inlineCacheTagAt: mcpc asInteger.
+ 		 (entryPoint > methodZoneBase
+ 		  and: [offset ~= cmNoCheckEntryOffset
+ 		  and: [(self cCoerceSimple: entryPoint - offset to: #'CogMethod *') cmType ~= CMOpenPIC]])
+ 			ifTrue: "linked non-super send, cacheTag is a cacheTag"
+ 				[(objectRepresentation checkValidInlineCacheTag: selectorOrCacheTag) ifFalse:
+ 					[coInterpreter print: 'cache tag leak in CM '; printHex: cogMethod asInteger; print: ' @ '; printHex: mcpc asInteger; cr.
+ 					^1]]
+ 			ifFalse: "unlinked send or super send; cacheTag is a selector"
+ 				[(objectRepresentation checkValidOopReference: selectorOrCacheTag) ifFalse:
+ 					[coInterpreter print: 'selector leak in CM '; printHex: cogMethod asInteger; print: ' @ '; printHex: mcpc asInteger; cr.
+ 					^1]]].
+ 	^0 "keep scanning"!

Item was added:
+ ----- Method: Cogit>>checkIfValidOopRefAndTarget:pc:cogMethod: (in category 'garbage collection') -----
+ checkIfValidOopRefAndTarget: annotation pc: mcpc cogMethod: cogMethod
+ 	<var: #mcpc type: #'char *'>
+ 	| literal entryPoint |
+ 	annotation = IsObjectReference ifTrue:
+ 		[literal := backEnd literalBeforeFollowingAddress: mcpc asInteger.
+ 		 (self asserta: (objectRepresentation checkValidOopReference: literal)) ifFalse:
+ 			[^1].
+ 		((objectRepresentation couldBeObject: literal)
+ 		 and: [objectMemory isReallyYoungObject: literal]) ifTrue:
+ 			[(self asserta: (self cCoerceSimple: cogMethod to: #'CogMethod *') cmRefersToYoung) ifFalse:
+ 				[^2]]].
+ 	(self isSendAnnotation: annotation) ifTrue:
+ 		[(self asserta: (self cCoerceSimple: cogMethod to: #'CogMethod *') cmType = CMMethod) ifFalse:
+ 			[^3].
+ 		 self offsetCacheTagAndCouldBeObjectAt: mcpc annotation: annotation into:
+ 			[:offset :cacheTag :tagCouldBeObject|
+ 			tagCouldBeObject
+ 				ifTrue:
+ 					[(objectRepresentation couldBeObject: cacheTag)
+ 						ifTrue:
+ 							[(self asserta: (objectRepresentation checkValidOopReference: cacheTag)) ifFalse:
+ 								[^4]]
+ 						ifFalse:
+ 							[(self asserta: (objectRepresentation checkValidInlineCacheTag: cacheTag)) ifFalse:
+ 								[^5]].
+ 					((objectRepresentation couldBeObject: cacheTag)
+ 					 and: [objectMemory isReallyYoungObject: cacheTag]) ifTrue:
+ 						[(self asserta: (self cCoerceSimple: cogMethod to: #'CogMethod *') cmRefersToYoung) ifFalse:
+ 							[^6]]]
+ 				ifFalse:
+ 					[(self asserta: (objectRepresentation checkValidInlineCacheTag: cacheTag)) ifFalse:
+ 						[^7]]].
+ 		entryPoint := backEnd callTargetFromReturnAddress: mcpc asInteger.
+ 		entryPoint > methodZoneBase ifTrue:
+ 			["It's a linked send; find which kind."
+ 			 self targetMethodAndSendTableFor: entryPoint into:
+ 					[:targetMethod :sendTable|
+ 					 (self asserta: (targetMethod cmType = CMMethod
+ 								   or: [targetMethod cmType = CMClosedPIC
+ 								   or: [targetMethod cmType = CMOpenPIC]])) ifFalse:
+ 						[^8]]]].
+ 	^0 "keep scanning"!

Item was changed:
  ----- Method: Cogit>>checkIntegrityOfObjectReferencesInCode: (in category 'debugging') -----
  checkIntegrityOfObjectReferencesInCode: fullGCFlag
  	<api>
  	"Answer if all references to objects in machine-code are valid."	
  	| cogMethod ok count |
  	<var: #cogMethod type: #'CogMethod *'>
  	cogMethod := self cCoerceSimple: methodZoneBase to: #'CogMethod *'.
  	ok := true.
  	[cogMethod < methodZone limitZony] whileTrue:
  		[cogMethod cmType ~= CMFree ifTrue:
  			[cogMethod cmRefersToYoung ifTrue:
  				[(count := methodZone occurrencesInYoungReferrers: cogMethod) ~= 1 ifTrue:
  					[coInterpreter print: 'young referrer CM '; printHex: cogMethod asInteger.
  					 count = 0
  						ifTrue: [coInterpreter print: ' is not in youngReferrers'; cr]
  						ifFalse: [coInterpreter print: ' is in youngReferrers '; printNum: count; print: ' times!!'; cr].
  					 ok := false]].
+ 			 (objectRepresentation checkValidOopReference: cogMethod selector) ifFalse:
- 			 (objectRepresentation checkValidObjectReference: cogMethod selector) ifFalse:
  				[coInterpreter print: 'object leak in CM '; printHex: cogMethod asInteger; print: ' selector'; cr.
  				 ok := false].
  			 cogMethod cmType = CMMethod
  				ifTrue:
  					[self assert: cogMethod objectHeader = objectMemory nullHeaderForMachineCodeMethod.
  					 (objectRepresentation checkValidObjectReference: cogMethod methodObject) ifFalse:
  						[coInterpreter print: 'object leak in CM '; printHex: cogMethod asInteger; print: ' methodObject'; cr.
  						 ok := false].
+ 					 (objectMemory isOopCompiledMethod: cogMethod methodObject) ifFalse:
- 					 (objectMemory isCompiledMethod: cogMethod methodObject) ifFalse:
  						[coInterpreter print: 'non-method in CM '; printHex: cogMethod asInteger; print: ' methodObject'; cr.
  						 ok := false].
  					 (self mapFor: cogMethod
+ 						 performUntil: #checkIfValidOopRef:pc:cogMethod:
- 						 performUntil: #checkIfValidObjectRef:pc:cogMethod:
  						 arg: cogMethod asInteger) ~= 0
  							ifTrue: [ok := false].
  					 fullGCFlag ifFalse:
  						[(((objectMemory isYoungObject: cogMethod methodObject)
  						    or: [objectMemory isYoung: cogMethod selector])
  						   and: [cogMethod cmRefersToYoung not]) ifTrue:
  							[coInterpreter print: 'CM '; printHex: cogMethod asInteger; print: ' refers to young but not marked as such'; cr.
  							 ok := false]]]
  				ifFalse:
  					[cogMethod cmType = CMClosedPIC
  						ifTrue:
  							[(self checkValidObjectReferencesInClosedPIC: cogMethod) ifFalse:
  								[ok := false]]
  						ifFalse:
  							[cogMethod cmType = CMOpenPIC
  								ifTrue:
  									[(self mapFor: cogMethod
+ 										performUntil: #checkIfValidOopRef:pc:cogMethod:
- 										performUntil: #checkIfValidObjectRef:pc:cogMethod:
  										arg: cogMethod asInteger) ~= 0
  											ifTrue: [ok := false]]]]].
  		cogMethod := methodZone methodAfter: cogMethod].
  	^ok!

Item was changed:
  ----- Method: StackInterpreter>>doubleExtendedDoAnythingBytecode (in category 'send bytecodes') -----
  doubleExtendedDoAnythingBytecode
  	"Replaces the Blue Book double-extended send [132], in which the first byte was wasted on 8 bits of argument count. 
  	Here we use 3 bits for the operation sub-type (opType),  and the remaining 5 bits for argument count where needed. 
  	The last byte give access to 256 instVars or literals. 
  	See also secondExtendedSendBytecode"
  	| byte2 byte3 opType top |
  	byte2 := self fetchByte.
  	byte3 := self fetchByte.
  	opType := byte2 >> 5.
  	opType = 0 ifTrue:
  		[messageSelector := self literal: byte3.
  		 argumentCount := byte2 bitAnd: 31.
  		 ^self normalSend].
  	opType = 1 ifTrue:
  		[messageSelector := self literal: byte3.
  		 argumentCount := byte2 bitAnd: 31.
  		 ^self superclassSend].
  	self fetchNextBytecode.
  	opType = 2 ifTrue: [^self pushMaybeContextReceiverVariable: byte3].
  	opType = 3 ifTrue: [^self pushLiteralConstant: byte3].
  	opType = 4 ifTrue: [^self pushLiteralVariable: byte3].
  	top := self internalStackTop.
  	opType = 7 ifTrue:
+ 		[self storeLiteralVariable: byte3 withValue: top.
+ 		 ^self].
+ 	"opType = 5 is store; opType = 6 is storePop"
- 		[^self storeLiteralVariable: byte3 withValue: top].
- 	"opType = 5 is store; opType = 6 = storePop"
  	opType = 6 ifTrue:
  		[self internalPop: 1].
  	self storeMaybeContextReceiverVariable: byte3 withValue: top!



More information about the Vm-dev mailing list