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

commits at source.squeak.org commits at source.squeak.org
Fri Mar 14 00:42:36 UTC 2014


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

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

Name: VMMaker.oscog-eem.641
Author: eem
Time: 13 March 2014, 5:40:09.228 pm
UUID: c0305b66-db2d-45aa-8d25-267732aa1784
Ancestors: VMMaker.oscog-eem.640

Spur: Revise interface between GC and machine-code for Spur's
ephemerons.  We can't mark and free in a single pass with
ephemerons because a machine-code method reachable only from
the stack could refer to something referred to from an ephemeron.
So all machine code must be marked before freeing.

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

Item was added:
+ ----- Method: CoInterpreter>>freeUnmarkedMachineCode (in category 'object memory support') -----
+ freeUnmarkedMachineCode
+ 	"Free machine-code methods whose compiled methods are unmarked
+ 	 (or open PICs whose selectors are not marked).
+ 	 The stack pages have already been traced so any methods
+ 	 of live stack activations have already been marked and traced."
+ 	<doNotGenerate>
+ 	cogit freeUnmarkedMachineCode!

Item was added:
+ ----- Method: CoInterpreter>>markAndTraceMachineCodeOfMarkedMethods (in category 'object memory support') -----
+ markAndTraceMachineCodeOfMarkedMethods
+ 	"Deal with a fulGC's effects on machine code.  Mark and
+ 	 trace oops in marked machine code methods.  The stack
+ 	 pages have already been traced so any methods of live
+ 	 stack activations have already been marked and traced."
+ 	<doNotGenerate>
+ 	cogit markAndTraceMachineCodeOfMarkedMethods!

Item was changed:
  ----- Method: CoInterpreter>>markAndTraceOrFreeMachineCode: (in category 'object memory support') -----
  markAndTraceOrFreeMachineCode: fullGCFlag
  	"Deal with a fulGC's effects on machine code.  Either mark and trace
+ 	 oops in machine code or free machine-code methods that refer to freed
- 	 oops in machine code or free machine-code methds that refer to freed
  	 oops.  The stack pages have already been traced so any methods
  	 of live stack activations have already been marked and traced."
  	cogit markAndTraceObjectsOrFreeMachineCode: fullGCFlag!

Item was added:
+ ----- Method: Cogit>>freeUnmarkedMachineCode (in category 'jit - api') -----
+ freeUnmarkedMachineCode
+ 	"Free machine-code methods whose compiled methods are unmarked
+ 	 and open PICs whose selectors are not marked."
+ 	<api>
+ 	<option: #SpurMemoryManager>
+ 	| cogMethod |
+ 	<var: #cogMethod type: #'CogMethod *'>
+ 	cogMethod := self cCoerceSimple: methodZoneBase to: #'CogMethod *'.
+ 	[cogMethod < methodZone limitZony] whileTrue:
+ 		[(cogMethod cmType = CMMethod
+ 		  and: [(objectMemory isMarked: cogMethod methodObject) not]) ifTrue:
+ 			[self freeMethod: cogMethod].
+ 		 (cogMethod cmType = CMOpenPIC
+ 		  and: [(objectMemory isImmediate: cogMethod selector) not
+ 		  and: [(objectMemory isMarked: cogMethod selector) not]]) ifTrue:
+ 			[self freeMethod: cogMethod].
+ 		 cogMethod := methodZone methodAfter: cogMethod].
+ 	self unlinkSendsToFree!

Item was added:
+ ----- Method: Cogit>>markAndTraceLiteralsIn: (in category 'garbage collection') -----
+ markAndTraceLiteralsIn: cogMethod
+ 	<option: #SpurMemoryManager>
+ 	"Unlink sends that have unmarked classes in inline caches or freed/freeable targets.
+ 	 Nil-out inline caches linked to open PICs.
+ 	 Assert that any selectors are marked.  We can do this since
+ 	 this is only run on marked methods and thus any selectors they
+ 	 reference should already be marked."
+ 	<var: #cogMethod type: #'CogMethod *'>
+ 	<inline: true>
+ 	self assert: ((cogMethod cmType = CMMethod
+ 				 and: [objectMemory isMarked: cogMethod methodObject])
+ 				 or: [cogMethod cmType = CMOpenPIC
+ 				 and: [(objectMemory isImmediate: cogMethod selector)
+ 					or: [objectMemory isMarked: cogMethod selector]]]).
+ 	objectRepresentation markAndTraceLiteral: cogMethod selector.
+ 	self mapFor: cogMethod
+ 		 performUntil: #markLiterals:pc:method:
+ 		 arg: cogMethod asInteger!

Item was added:
+ ----- Method: Cogit>>markAndTraceMachineCodeOfMarkedMethods (in category 'jit - api') -----
+ markAndTraceMachineCodeOfMarkedMethods
+ 	"Mark objects in machine-code of marked methods (or open PICs with marked selectors)."
+ 	<api>
+ 	<option: #SpurMemoryManager>
+ 	| cogMethod |
+ 	<var: #cogMethod type: #'CogMethod *'>
+ 	objectMemory leakCheckFullGC ifTrue:
+ 		[self assert: self allMachineCodeObjectReferencesValid].
+ 	codeModified := false.
+ 	self markAndTraceObjectReferencesInGeneratedRuntime.
+ 	cogMethod := self cCoerceSimple: methodZoneBase to: #'CogMethod *'.
+ 	[cogMethod < methodZone limitZony] whileTrue:
+ 		[(cogMethod cmType = CMMethod
+ 		  and: [objectMemory isMarked: cogMethod methodObject]) ifTrue:
+ 			[self markAndTraceLiteralsIn: cogMethod].
+ 		 (cogMethod cmType = CMOpenPIC
+ 		  and: [(objectMemory isImmediate: cogMethod selector)
+ 				or: [objectMemory isMarked: cogMethod selector]]) ifTrue:
+ 			[self markAndTraceLiteralsIn: cogMethod].
+ 		 cogMethod := methodZone methodAfter: cogMethod].
+ 	objectMemory leakCheckFullGC ifTrue:
+ 		[self assert: self allMachineCodeObjectReferencesValid].
+ 	codeModified ifTrue: "After updating oops in inline caches we need to flush the icache."
+ 		[processor flushICacheFrom: methodZoneBase to: methodZone limitZony asInteger]!

Item was changed:
  ----- Method: Cogit>>markAndTraceObjectsOrFreeMachineCode: (in category 'jit - api') -----
  markAndTraceObjectsOrFreeMachineCode: inFullGC
  	<api>
+ 	<option: #SqueakV3ObjectMemory>
  	inFullGC
  		ifTrue: [self markAndTraceOrFreeMachineCodeForFullGC]
  		ifFalse: [self markAndTraceMachineCodeForNewSpaceGC]!

Item was added:
+ ----- Method: Cogit>>markLiterals:pc:method: (in category 'garbage collection') -----
+ markLiterals: annotation pc: mcpc method: cogMethod
+ 	"Mark and trace literals.
+ 	 Additionally in Newspeak, void push implicits that have unmarked classes."
+ 	<var: #mcpc type: #'char *'>
+ 	| literal |
+ 	annotation = IsObjectReference ifTrue:
+ 		[literal := backEnd literalBeforeFollowingAddress: mcpc asInteger.
+ 		 objectRepresentation markAndTraceLiteral: literal].
+ 	(self isSendAnnotation: annotation) ifTrue:
+ 		[self offsetCacheTagAndCouldBeObjectAt: mcpc annotation: annotation into:
+ 			[:entryPoint :cacheTag :tagCouldBeObj |
+ 			 tagCouldBeObj ifTrue:
+ 				[objectRepresentation markAndTraceLiteral: cacheTag].  "cacheTag is selector"
+ 			  self cppIf: NewspeakVM ifTrue:
+ 				[entryPoint = ceImplicitReceiverTrampoline ifTrue:
+ 					[| classpc mixinpc class mixin |
+ 					 classpc := mcpc asInteger + backEnd jumpShortByteSize.
+ 					 mixinpc := mcpc asInteger + backEnd jumpShortByteSize + BytesPerOop.
+ 					 class := backEnd unalignedLongAt: classpc.
+ 					 class ~= 0
+ 						ifTrue:
+ 							[self assert: (objectMemory addressCouldBeObj: class).
+ 							 (objectRepresentation cacheTagIsMarked: class)
+ 								ifTrue:
+ 									[(mixin := backEnd unalignedLongAt: mixinpc) ~= 0 ifTrue:
+ 										[objectRepresentation markAndTraceLiteral: mixin]]
+ 								ifFalse:
+ 									[backEnd
+ 										unalignedLongAt: classpc put: 0;
+ 										unalignedLongAt: mixinpc put: 0.
+ 									 codeModified := true]]
+ 						ifFalse:
+ 							[self assert: (backEnd unalignedLongAt: mixinpc) = 0]]]]].
+ 	^0 "keep scanning"!

Item was changed:
  ----- Method: SpurMemoryManager>>markAccessibleObjects (in category 'gc - global') -----
  markAccessibleObjects
  	self assert: self validClassTableRootPages.
  	self assert: segmentManager allBridgesMarked.
  	self cCode: [] "for debugging markAndTrace: set (MarkStackRecord := OrderedCollection new)"
  		inSmalltalk: [MarkStackRecord ifNotNil: [MarkStackRecord resetTo: 1]].
  
  	marking := true.
  	"This must come first to enable stack page reclamation.  It clears
  	  the trace flags on stack pages and so must preceed any marking.
  	  Otherwise it will clear the trace flags of reached pages."
  	coInterpreter initStackPageGC.
  	self markAndTraceHiddenRoots.
  	self markAndTraceExtraRoots.
  	self assert: self validClassTableRootPages.
  	coInterpreter markAndTraceInterpreterOops: true.
- 	coInterpreter markAndTraceOrFreeMachineCode: true.
  	self assert: self validObjStacks.
  	self markWeaklingsAndMarkAndFireEphemerons.
  	self assert: self validObjStacks.
  	marking := false!

Item was changed:
  ----- Method: SpurMemoryManager>>markWeaklingsAndMarkAndFireEphemerons (in category 'gc - global') -----
  markWeaklingsAndMarkAndFireEphemerons
  	"After the initial scan-mark is complete ephemerons can be processed.
  	 Weaklings have accumulated on the weaklingStack, but more may be
  	 uncovered during ephemeron processing.  So trace the strong slots
  	 of the weaklings, and as ephemerons are processed ensure any newly
  	 reached weaklings are also traced."
  	| numTracedWeaklings |
  	<inline: false>
  	numTracedWeaklings := 0.
  	[coInterpreter markAndTraceUntracedReachableStackPages.
+ 	 coInterpreter markAndTraceMachineCodeOfMarkedMethods.
  	 numTracedWeaklings := self markAndTraceWeaklingsFrom: numTracedWeaklings.
  	 self noUnscannedEphemerons ifTrue:
  		[coInterpreter
  			markAndTraceUntracedReachableStackPages;
+ 	 		markAndTraceMachineCodeOfMarkedMethods;
+ 			freeUntracedStackPages;
+ 			freeUnmarkedMachineCode.
- 			freeUntracedStackPages.
  		 ^self].
  	 self markInactiveEphemerons ifFalse:
  		[self fireAllUnscannedEphemerons].
  	 self markAllUnscannedEphemerons]
  		repeat!

Item was added:
+ ----- Method: StackInterpreter>>freeUnmarkedMachineCode (in category 'object memory support') -----
+ freeUnmarkedMachineCode
+ 	"This is a no-op in the StackInterpreter"!

Item was added:
+ ----- Method: StackInterpreter>>markAndTraceMachineCodeOfMarkedMethods (in category 'object memory support') -----
+ markAndTraceMachineCodeOfMarkedMethods
+ 	"This is a no-op in the StackVM"!



More information about the Vm-dev mailing list