Skip to content

Instantly share code, notes, and snippets.

@guillep
Last active February 29, 2016 12:25
Show Gist options
  • Save guillep/9bc9543404b34d49408d to your computer and use it in GitHub Desktop.
Save guillep/9bc9543404b34d49408d to your computer and use it in GitHub Desktop.
VM Simulator Scripts
| sim |
InterpreterStackPages initialize.
StackInterpreterSimulator initializeWithOptions: Dictionary new.
sim := StackInterpreterSimulator new.
sim openOn: 'pharo4/Pharo.image'.
sim openAsMorph.
sim initStackPages.
sim loadInitialContext.
sim internalizeIPandSP.
sim fetchNextBytecode.
10000000 timesRepeat: [ sim singleStep ].
[sim run] fork.
vm := StackInterpreterSimulator newWithOptions: #(#ObjectMemory #Spur32BitMemoryManager ).
om := vm objectMemory.
vm desiredNumStackPages: 8. "Makes simulation faster by creating fewer stack pages."
vm openOn: Smalltalk imagePath.
vm instVarNamed: 'assertVEPAES' put: false. "This makes the simulation faster by turning off some expensive asserts"
vm openAsMorph
[[vm runForNBytes: 1500000]
on: Halt , ProvideAnswerNotification "This exception handler ignores some halts and confirmers occurring during simulation"
do: [:ex |
ex messageText == #primitiveExecuteMethodArgsArray
ifTrue: [ex resume].
ex messageText = 'clear transcript?'
ifTrue: [ex resume: false].
ex pass]] ensure: [Display restore].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment