[Vm-dev] VM Maker: VMMaker-dtl.389.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Dec 21 23:37:57 UTC 2016

David T. Lewis uploaded a new version of VMMaker to project VM Maker:

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

Name: VMMaker-dtl.389
Author: dtl
Time: 21 December 2016, 6:31:30.057 pm
UUID: 3cce2df0-2d06-46f6-bed2-8946fb48c878
Ancestors: VMMaker-dtl.388

VMMaker 4.15.11

Fix the interpreter for running images of the Squeak 3.6 and 3.8 era. Several obsolete primitives were removed in VMMaker-dtl.387, but these are still required for older images.

For this update, the primitive table initialiation is unchanged, but a run time update is done for the ContextInterpreter to restore the old primitive assignments. It is not clear if this will be a good strategy but for now add InterpreterPrimitives>>installPrimitive:at: and use it to update the table on first entry to the interpret() loop.

Possible future updates could support run time fixup to the primitive table for Squeak 3.2 and earlier images.

=============== Diff against VMMaker-dtl.388 ===============

Item was changed:
  ----- Method: ContextInterpreter>>interpret (in category 'interpreter shell') -----
  	"This is the main interpreter loop. It normally loops forever, fetching and executing bytecodes. When running in the context of a browser plugin VM, however, it must return control to the browser periodically. This should done only when the state of the currently running Squeak thread is safely stored in the object heap. Since this is the case at the moment that a check for interrupts is performed, that is when we return to the browser if it is time to do so. Interrupt checks happen quite frequently."
  	<inline: false> "should not be inlined into any senders"
+ 	"Update the primitive table as required for the current running image."
+ 	self updatePrimitiveTable..
  	"record entry time when running as a browser plug-in"
  	self browserPluginInitialiseIfNeeded.
  	self initializeImageFormatVersionIfNeeded.
  	self internalizeIPandSP.
  	self fetchNextBytecode.
  	[true] whileTrue: [self dispatchOn: currentBytecode in: BytecodeTable].
  	localIP := localIP - 1.  "undo the pre-increment of IP before returning"
  	self externalizeIPandSP.

Item was removed:
- ----- Method: ContextInterpreter>>primIndex (in category 'primitive support') -----
- primIndex
- 	^ primitiveIndex!

Item was added:
+ ----- Method: ContextInterpreter>>primitiveValueUninterruptably (in category 'control primitives') -----
+ primitiveValueUninterruptably
+ 	"The only purpose of this primitive is to indicate that the new EH mechanisms are supported."
+ 	<inline: false>
+ 	^self primitiveValue!

Item was added:
+ ----- Method: ContextInterpreter>>primitiveValueWithArgs (in category 'control primitives') -----
+ primitiveValueWithArgs
+ 	| argumentArray blockContext blockArgumentCount arrayArgumentCount initialIP |
+ 	argumentArray := self popStack.
+ 	blockContext := self popStack.
+ 	blockArgumentCount := self argumentCountOfBlock: blockContext.
+ 	"If the argArray isnt actually an Array we ahve to unpop the above two"
+ 	(objectMemory isArray: argumentArray) ifFalse: [self unPop:2. ^self primitiveFail].
+ 	self successful ifTrue: [arrayArgumentCount := objectMemory fetchWordLengthOf: argumentArray.
+ 			self success: (arrayArgumentCount = blockArgumentCount
+ 						and: [(objectMemory fetchPointer: CallerIndex ofObject: blockContext) = objectMemory getNilObj])].
+ 	self successful
+ 		ifTrue: [self
+ 				transfer: arrayArgumentCount
+ 				fromIndex: 0
+ 				ofObject: argumentArray
+ 				toIndex: TempFrameStart
+ 				ofObject: blockContext.
+ 			"Assume: The call to transfer:... makes blockContext a root if necessary, 
+ 			allowing use to use unchecked stored in the following code. "
+ 			initialIP := objectMemory fetchPointer: InitialIPIndex ofObject: blockContext.
+ 			objectMemory
+ 				storePointerUnchecked: InstructionPointerIndex
+ 				ofObject: blockContext
+ 				withValue: initialIP.
+ 			self storeStackPointerValue: arrayArgumentCount inContext: blockContext.
+ 			objectMemory
+ 				storePointerUnchecked: CallerIndex
+ 				ofObject: blockContext
+ 				withValue: activeContext.
+ 			self newActiveContext: blockContext]
+ 		ifFalse: [self unPop: 2]!

Item was changed:
  ----- Method: Interpreter class>>initializePrimitiveTable (in category 'initialization') -----
(excessive size, no diff calculated)

Item was changed:
  VMClass subclass: #InterpreterPrimitives
+ 	instanceVariableNames: 'objectMemory primitiveTable primitiveTableUpdated primFailCode argumentCount interruptKeycode newMethod preemptionYields'
- 	instanceVariableNames: 'objectMemory primitiveTable primFailCode argumentCount interruptKeycode newMethod preemptionYields'
  	classVariableNames: 'CrossedX EndOfRun InterpreterSourceVersion MillisecondClockMask PrimitiveExternalCallIndex PrimitiveTable'
  	poolDictionaries: 'VMObjectIndices VMSqueakV3ObjectRepresentationConstants'
  	category: 'VMMaker-Interpreter'!
  !InterpreterPrimitives commentStamp: 'dtl 4/14/2013 23:16' prior: 0!
  InterpreterPrimitives implements most of the VM's core primitives.  It is the root of the interpreter hierarchy so as to share the core primitives amongst the various interpreters.
  Instance Variables
  	argumentCount:	<Integer>
  	messageSelector:	<Integer>
  	newMethod:		<Integer>
  	nextProfileTick:		<Integer>
  	objectMemory:		<ObjectMemory> (simulation only)
  	preemptionYields:	<Boolean>
  	primFailCode:		<Integer>
  	profileMethod:		<Integer>
  	profileProcess:		<Integer>
  	profileSemaphore:	<Integer>
  	- the number of arguments of the current message
  	- the oop of the selector of the current message
  	- the oop of the result of looking up the current message
  	- the millisecond clock value of the next profile tick (if profiling is in effect)
  	- the memory manager and garbage collector that manages the heap
  	- a boolean controlling the process primitives.  If true (old, incorrect, blue-book semantics) a preempted process is sent to the back of its run-queue.  If false, a process preempted by a higher-priority process is put back at the head of its run queue, hence preserving cooperative scheduling within priorities.
  	- primtiive success/failure flag, 0 for success, otherwise the reason code for failure
  	- the oop of the method at the time nextProfileTick was reached
  	- the oop of the activeProcess at the time nextProfileTick was reached
  	- the oop of the semaphore to signal when nextProfileTick is reached

Item was added:
+ ----- Method: InterpreterPrimitives>>installPrimitive:at: (in category 'primitive table') -----
+ installPrimitive: selector at: anInteger
+ 	"The primitive table is normally initialized at compile time. This allows an entry
+ 	in the table to be istalled at runtime."
+ 	<inline: false> "for readability"
+ 	primitiveTable at: anInteger put: selector.
+ !

Item was added:
+ ----- Method: InterpreterPrimitives>>updatePrimitiveTable (in category 'primitive table') -----
+ updatePrimitiveTable
+ 	"Make any run time updates to the primitive table that may be required for supporting
+ 	the current running image. May be called by an interpreter that determines at run time
+ 	that it neeces to provide support for an older image."
+ 	"As of VMMaker-dtl.387 8 November 2016 (VMMaker 4.15.9), these primitives were
+ 	removed from the primitive table for consistency with recent Cog/Spur. They are still
+ 	required for running many older Squeak images. Install them here to support those
+ 	images."
+ 	"TODO Need a general way to set up the table at runtime for a range of images"
+ 	<inline: false>
+ 	primitiveTableUpdated = true ifFalse: [
+ 		primitiveTableUpdated := true.
+ 		self installPrimitive: #primitiveBlockCopy at: 80.
+ 		self installPrimitive: #primitiveValue at: 81.
+ 		self installPrimitive: #primitiveValueWithArgs at: 82.
+ 		self installPrimitive: #primitiveValueUninterruptably at: 123.
+ 	]
+ !

Item was changed:
  ----- Method: VMMaker class>>versionString (in category 'version testing') -----
  	"VMMaker versionString"
+ 	^'4.15.11'!
- 	^'4.15.10'!

More information about the Vm-dev mailing list