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

commits at source.squeak.org commits at source.squeak.org
Mon Feb 6 00:27:16 UTC 2023


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

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

Name: VMMaker.oscog-eem.3303
Author: eem
Time: 5 February 2023, 4:26:59.944077 pm
UUID: 1177e91d-0578-45c3-9ca8-78ccdfce6c30
Ancestors: VMMaker.oscog-eem.3302

Do a more precise implementation of VMMaker.oscog-eem.3302.  In the StackIntackInterpreter instrucftionPointer is never relative to newMethod; this only occurs in the Cogit with machine code primitives invoking C primitive implementations.  Further, the basic fix to mapVMRegisters to avoid the hazard of updating instructionPointer twice also needs to be applied to followMethodNewMethodAndInstructionPointer.

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

Item was added:
+ ----- Method: CoInterpreter>>followMethodNewMethodAndInstructionPointer (in category 'object memory support') -----
+ followMethodNewMethodAndInstructionPointer
+ 	"c.f. mapVMRegisters"
+ 	<inline: #always>
+ 	| ipdelta |
+ 	(objectMemory isForwarded: method) ifTrue:
+ 		[ipdelta := (self method: method includesAddress: instructionPointer) ifTrue:
+ 						[instructionPointer - method].
+ 		 method := objectMemory followForwarded: method.
+ 		 ipdelta ifNotNil:
+ 			[instructionPointer := method + ipdelta]].
+ 	(objectMemory isOopForwarded: newMethod) ifTrue: "maybe oop due to object-as-method"
+ 		[ipdelta := (ipdelta isNil "don't relocate twice!!!!"
+ 					  and: [self method: newMethod includesAddress: instructionPointer]) ifTrue:
+ 						[instructionPointer - newMethod].
+ 		 newMethod := objectMemory followForwarded: newMethod].
+ 		 ipdelta ifNotNil:
+ 			[instructionPointer := newMethod + ipdelta]!

Item was added:
+ ----- Method: CoInterpreter>>mapVMRegisters (in category 'object memory support') -----
+ mapVMRegisters
+ 	"Map the oops in the interpreter's vm ``registers'' to their new values 
+ 	during garbage collection or a become: operation."
+ 	"Assume: All traced variables contain valid oops.
+ 	 N.B. Don't trace messageSelector and lkupClass; these are ephemeral, live
+ 	 only during message lookup and because createActualMessageTo will not
+ 	 cause a GC these cannot change during message lookup.
+ 	 c.f. followMethodNewMethodAndInstructionPointer.
+ 	 Override to relocate the instructionPointer relative to newMethod, if required.
+ 	 In the Cogit the VM may be in a machine code primitive when the GC is invoked.
+ 	 However, because compaction moves several objects, it is possible for the
+ 	 compacted method to overlap the pre-compacted newMethod and hence
+ 	 there's a danger of updating instructionPointer twice."
+ 	| ipdelta |
+ 	(objectMemory shouldRemapObj: method) ifTrue:
+ 		[ipdelta := (self method: method includesAddress: instructionPointer) ifTrue:
+ 						[instructionPointer - method].
+ 		 method := objectMemory remapObj: method.
+ 		 ipdelta ifNotNil:
+ 			[instructionPointer := method + ipdelta]].
+ 	(objectMemory shouldRemapOop: newMethod) ifTrue: "maybe oop due to object-as-method"
+ 		[ipdelta := (ipdelta isNil "don't relocate twice!!!!"
+ 					  and: [self method: newMethod includesAddress: instructionPointer]) ifTrue:
+ 						[instructionPointer - newMethod].
+ 		 newMethod := objectMemory remapObj: newMethod.
+ 		 ipdelta ifNotNil:
+ 			[instructionPointer := newMethod + ipdelta]]!

Item was changed:
  ----- Method: StackInterpreter>>followMethodNewMethodAndInstructionPointer (in category 'object memory support') -----
  followMethodNewMethodAndInstructionPointer
  	"c.f. mapVMRegisters"
  	<inline: #always>
  	| ipdelta |
  	(objectMemory isForwarded: method) ifTrue:
  		[ipdelta := (self method: method includesAddress: instructionPointer) ifTrue:
  						[instructionPointer - method].
  		 method := objectMemory followForwarded: method.
  		 ipdelta ifNotNil:
  			[instructionPointer := method + ipdelta]].
  	(objectMemory isOopForwarded: newMethod) ifTrue:
+ 		[newMethod := objectMemory followForwarded: newMethod]!
- 		[ipdelta := (self method: newMethod includesAddress: instructionPointer) ifTrue:
- 						[instructionPointer - newMethod].
- 		 newMethod := objectMemory followForwarded: newMethod].
- 		 ipdelta ifNotNil:
- 			[instructionPointer := newMethod + ipdelta]!

Item was changed:
  ----- Method: StackInterpreter>>mapVMRegisters (in category 'object memory support') -----
  mapVMRegisters
  	"Map the oops in the interpreter's vm ``registers'' to their new values 
  	during garbage collection or a become: operation."
  	"Assume: All traced variables contain valid oops.
  	 N.B. Don't trace messageSelector and lkupClass; these are ephemeral, live
  	 only during message lookup and because createActualMessageTo will not
  	 cause a GC these cannot change during message lookup.
+ 	 c.f. followMethodNewMethodAndInstructionPointer."
- 	 c.f. followMethodNewMethodAndInstructionPointer"
- 	| ipdelta |
  	(objectMemory shouldRemapObj: method) ifTrue:
+ 		[instructionPointer := instructionPointer - method. "*rel to method"
- 		[ipdelta := (self method: method includesAddress: instructionPointer) ifTrue:
- 						[instructionPointer - method].
  		 method := objectMemory remapObj: method.
+ 		 instructionPointer := instructionPointer + method]. "*rel to method"
- 		 ipdelta ifNotNil:
- 			[instructionPointer := method + ipdelta]].
  	(objectMemory shouldRemapOop: newMethod) ifTrue: "maybe oop due to object-as-method"
+ 		[newMethod := objectMemory remapObj: newMethod]!
- 		[ipdelta := (ipdelta isNil "don't relocate twice!!!!"
- 					  and: [self method: newMethod includesAddress: instructionPointer]) ifTrue:
- 						[instructionPointer - newMethod].
- 		 newMethod := objectMemory remapObj: newMethod.
- 		 ipdelta ifNotNil:
- 			[instructionPointer := newMethod + ipdelta]]!



More information about the Vm-dev mailing list