Skip to content

Commit

Permalink
Fix fetch forwarders as literals
Browse files Browse the repository at this point in the history
  • Loading branch information
PalumboN committed Jul 22, 2022
1 parent 507ac33 commit 5f7907b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
23 changes: 15 additions & 8 deletions smalltalksrc/VMMaker/StackInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -5429,7 +5429,7 @@ StackInterpreter >> extPushFullClosureBytecode [
| compiledBlockLiteralIndex compiledBlock byte numArgs numCopied receiverIsOnStack ignoreContext |
compiledBlockLiteralIndex := self fetchByte + (extA << 8).
extA := 0.
compiledBlock := self literal: compiledBlockLiteralIndex.
compiledBlock := self literalMaybeForwarder: compiledBlockLiteralIndex.
self assert: (objectMemory isOopCompiledMethod: compiledBlock).
numArgs := self argumentCountOf: compiledBlock.
byte := self fetchByte.
Expand Down Expand Up @@ -8868,6 +8868,16 @@ StackInterpreter >> literalCountOfOriginalHeader: headerPointer [
^(headerPointer >> 10) bitAnd: 16rFF
]

{ #category : #'compiled methods' }
StackInterpreter >> literalMaybeForwarder: offset [

| literal |
literal := self literal: offset.
(objectMemory isForwarded: literal) ifTrue: [
literal := self unfollow: literal atIndex: offset ].
^ literal
]

{ #category : #'bitblt support' }
StackInterpreter >> loadBitBltFrom: bb [
"This entry point needs to be implemented for the interpreter proxy.
Expand Down Expand Up @@ -12616,9 +12626,7 @@ StackInterpreter >> pushLiteralVariable: literalIndex [
The fetch of the literal needs an explicit check (otherwise we would have to scan all literals in
all methods in the stack zone, and the entire method on return, and global variables are relatively
rare; in my work image 8.7% of literals are globals)."
litVar := self literal: literalIndex.
(objectMemory isForwarded: litVar) ifTrue:
[litVar := self unfollow: litVar atIndex: literalIndex].
litVar := self literalMaybeForwarder: literalIndex.
self internalPush:
(objectMemory fetchPointer: ValueIndex ofObject: litVar)]
ifFalse:
Expand Down Expand Up @@ -14678,15 +14686,14 @@ StackInterpreter >> storeInteger: fieldIndex ofObject: objectPointer withValue:

{ #category : #'stack bytecodes' }
StackInterpreter >> storeLiteralVariable: literalIndex withValue: anObject [
| litVar |
litVar := self literal: literalIndex.
"push/store/popLiteralVariable all fetch a literal, and either read or write the literal's value field.
The fetch of the literal needs an explicit check (otherwise we would have to scan all literals in
all methods in the stack zone, and the entire method on return, and global variables are relatively
rare; in my work image 8.7% of literals are globals)."

(objectMemory isForwarded: litVar) ifTrue:
[litVar := self unfollow: litVar atIndex: literalIndex].

| litVar |
litVar := self literalMaybeForwarder: literalIndex.
objectMemory storePointerImmutabilityCheck: ValueIndex ofObject: litVar withValue: anObject
]

Expand Down
4 changes: 3 additions & 1 deletion smalltalksrc/VMMaker/StackInterpreterSimulator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,9 @@ StackInterpreterSimulator >> isPrimitiveFunctionPointerAnIndex [
StackInterpreterSimulator >> literal: offset [
"trap pushes of forwarded literals to help debug following forwarded primitive args.
it is not an error to push a forwarded literal, but we'd like to step through any resulting
primtive failure code"
primtive failure code.
Use #literalMaybeForwarder: for resolve forwarders if nedeed
"
| lit |
lit := super literal: offset.
(objectMemory isOopForwarded: lit) ifTrue:
Expand Down

0 comments on commit 5f7907b

Please sign in to comment.