-
Notifications
You must be signed in to change notification settings - Fork 78
Fix meta try primitive #968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: pharo-12
Are you sure you want to change the base?
Conversation
savedTempOop2 := tempOop2. | ||
tempOop2 := self stackValue: 3. "actual receiver" | ||
rcvr := self stackValue: 2. "receiver for primitive" | ||
(objectMemory isOopForwarded: rcvr) ifTrue: [ | ||
rcvr := objectMemory followForwarded: rcvr ]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a nice side effect, fixing the indexes here (0 based) "fixes" the following test in Pharo:
MirrorPrimitivesTest >> testExecutingPrimitive
| actual |
<expectedFailure> "it will be supported by VM at some point"
actual := MirrorPrimitives withReceiver: 100 tryPrimitive: 1 withArguments: #(2).
self assert: actual equals: 102
self pop: 4; push: rcvr] "use first arg as receiver" | ||
ifFalse: | ||
[self pop: 2]. | ||
ifTrue: [ "use first arg as receiver""...and receiver if the three arg form" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This first comment got moved by the reformatting, I'll put it back
Bug
Debugging the follign code (Cmd+Shift+D)
And stepping into
tryPrimitive:withArgs:
crashes the VM.Cause
This happens because the primitive stores intermediate data in special vm variables (tempOop and tempOop2) that are remapped in case a GC passes and later restored if the called primitive fails.
In this case, the call to primitive 118 is reentrant: primitive 118 calls primitive 118.
And this causes the lose of the tempOop and tempOop2 values of the first call.
TODOs after this PR
basicNew
et al