I gave it a shot based on the generator.image that PharoVM uses to generate the VM.

But none of :

(| vm |
vm := StackInterpreterSimulator newWithOptions: #().
vm openOn: '/Users/eliot/Cog/startreader.image'.
vm openAsMorph; run)


(| vm |
vm := CogVMSimulator newWithOptions: #(ObjectMemory Spur32BitCoMemoryManager
Cogit StackToRegisterMappingCogit).
vm desiredNumStackPages: 8.
vm objectMemory setCheckForLeaks: 1.
vm openOn: '/Users/eliot/Cog/spurreader.image'.
vm openAsMorph; toggleTranscript; halt; run)

is going to work right away as newWithOptions: isn't there in that image.

So, there is a initializeWithOptions: #().

When trying out that one, I do get another error.

In fact, the initializeWithOptions: method is wrong:

initializeWithOptions: optionsDictionary
"ObjectMemory initializeWithOptions: Dictionary new"

self initBytesPerWord: (optionsDictionary at: #BytesPerWord ifAbsent: [4]).


the thing is doing #BytesPerWork ifAbsent: ... :-(

Of course, as #() is an Array an not a Dictionary.

So, I tried:

StackInterpreterSimulator initializeWithOptions: Dictionary new.
vm := StackInterpreterSimulator new.

Which got the ball rolling.

But then, of course, same story as here:


Well, based on Clement's comments, I fiddled a bit with the TranscriptStream, which I turned into a simple Transcript and let go of the local image name for the display window.

Also, did 

transcript := Transcript.
displayForm := (ImageMorph fromString: 'Display has not yet been installed') form.

in StackInterpreterSimulator initialize.

So, here is the current stance:

| vm |
StackInterpreterSimulator initializeWithOptions: Dictionary new.
vm := StackInterpreterSimulator new.
vm openOn: 'C:\MinGW\msys\1.0\home\User\pharo\pharo.image'.
vm openAsMorph.
vm run.

the morph opens.

Now, when I do run, I do get a problem in:

InterpreterStackPage>>headFP: pointer

There is an self assert: (pointer = 0 or: [pointer < baseAddress and: [realStackLimit - (LargeContextBytes / 2) <= pointer]]).

And LargeContextBytes is nil.

I looked around for initialization for that one.

It is only in the InterpreterStackPage class >> initialize

So I did;

| vm |
StackInterpreterSimulator initializeWithOptions: Dictionary new.
vm := StackInterpreterSimulator new.
InterpreterStackPage initialize.
vm openOn: 'C:\MinGW\msys\1.0\home\User\pharo\pharo.image'.
vm openAsMorph.
vm run.

Then I got a blinking square running in the top corner.

No amount of stopping processes would interrupt it.

So the simulator is running the run loop:

self fetchNextBytecode.
[true] whileTrue:
[self assertValidExecutionPointers.
 atEachStepBlock value. "N.B. may be nil"
 self dispatchOn: currentBytecode in: BytecodeTable.
 self incrementByteCount].

and relinquishing processor every once in a while and this square is shown (Display reverse below] ...

(which is where I end up when interrupting)

ioRelinquishProcessorForMicroseconds: microseconds
"In the simulator give an indication that we're idling and check for input."
Display reverse: (0@0 extent: 16@16).
Sensor peekEvent ifNotNil:
[self forceInterruptCheck].
Processor activeProcess == UIManager default uiProcess ifTrue:
[World doOneCycle].
microseconds >= 1000
ifTrue: [(Delay forMilliseconds: microseconds + 999 // 1000) wait]
ifFalse: [Processor yield]

If one could tell me how to get the display to show, it would be welcome.

The display instVar contains stuff in the debugger but isn't ok to open with something like:

In the transcript, I do see things related to initialization:

(56) Looking for primitiveSetGCBiasToGrowGCLimit in vm
Looking for module  ... not found
(3751) Looking for primitiveFileWrite in FilePlugin
Looking for module FilePlugin
(3751) Looking for secCanCreatePathOfSize in SecurityPlugin
Looking for module SecurityPlugin ... loaded
(3751) Looking for secCanDeletePathOfSize in SecurityPlugin
(3751) Looking for secCanGetFileTypeOfSize in SecurityPlugin
(3751) Looking for secCanListPathOfSize in SecurityPlugin
(3751) Looking for secCanSetFileTypeOfSize in SecurityPlugin
(3751) Looking for secDisableFileAccess in SecurityPlugin
(3751) Looking for secCanDeleteFileOfSize in SecurityPlugin
(3751) Looking for secCanOpenFileOfSizeWritable in SecurityPlugin
(3751) Looking for secCanRenameFileOfSize in SecurityPlugin
(3751) Looking for secHasFileAccess in SecurityPlugin ... loaded
(3774) Looking for primitiveFileSize in FilePlugin
(4390) Looking for primitiveCompareString in MiscPrimitivePlugin
Looking for module MiscPrimitivePlugin ... loaded
(4623) Looking for primitiveDirectoryDelimitor in FilePlugin
(7806) Looking for primitiveIndexOfAsciiInString in MiscPrimitivePlugin
(57216) Looking for primitiveStringHash in MiscPrimitivePlugin
(177977) Looking for primitiveFindFirstInString in MiscPrimitivePlugin
(179055) Looking for primitiveFileOpen in FilePlugin
(179815) Looking for primitiveFileGetPosition in FilePlugin
(179832) Looking for primitiveFileAtEnd in FilePlugin
(179873) Looking for primitiveFileRead in FilePlugin
(182837) Looking for primitiveFileSize in FilePlugin
(182868) Looking for primitiveFileSetPosition in FilePlugin
(186627) Looking for primDigitCompare in LargeIntegers
Looking for module LargeIntegers ... loaded
(186688) Looking for primDigitMultiplyNegative in LargeIntegers
(186884) Looking for primNormalizeNegative in LargeIntegers
(186985) Looking for primDigitAdd in LargeIntegers
(186986) Looking for primNormalizePositive in LargeIntegers
(187038) Looking for primDigitSubtract in LargeIntegers

Is there a way to stop the interpreter in order to debug things?

I saw: 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

How to use that?

Why do I not see the display in the sim?

I saw a "quitBlock". What is this about?

I am not far from getting this working...

Thanks for some clues!

Philippe Back
Dramatic Performance Improvements
Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027
Mail:phil@highoctane.be | Web: http://philippeback.eu
Blog: http://philippeback.be | Twitter: @philippeback
Youtube: http://www.youtube.com/user/philippeback/videos

High Octane SPRL
rue cour Boisacq 101 | 1301 Bierges | Belgium

Pharo Consortium Member - http://consortium.pharo.org/
Featured on the Software Process and Measurement Cast - http://spamcast.libsyn.com
Sparx Systems Enterprise Architect and Ability Engineering EADocX Value Added Reseller