Skip to content

Commit

Permalink
Follow forwarders in many places
Browse files Browse the repository at this point in the history
  • Loading branch information
PalumboN committed Jul 28, 2022
1 parent 346d121 commit fc60ecd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
3 changes: 2 additions & 1 deletion smalltalksrc/VMMaker/CoInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,8 @@ CoInterpreter >> ceSendFromInLineCacheMiss: cogMethodOrPIC [
selector: cogMethodOrPIC selector]
ifFalse:
[(objectMemory isOopForwarded: cogMethodOrPIC selector) ifTrue:
[self handleForwardedSelectorFaultFor: cogMethodOrPIC selector.
[
cogit setSelectorOf: cogMethodOrPIC to: (self handleForwardedSelectorFaultFor: cogMethodOrPIC selector).
^self ceSendFromInLineCacheMiss: cogMethodOrPIC].
(objectMemory isForwardedClassTag: classTag) ifTrue:
[self handleForwardedSendFaultForReceiver: rcvr stackDelta: 1 "skip return pc".
Expand Down
50 changes: 36 additions & 14 deletions smalltalksrc/VMMaker/Cogit.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6859,6 +6859,11 @@ Cogit >> followForwardedMethods [
self enableCodeZoneWriteDuring: [
[ cogMethod < methodZone limitZony ] whileTrue: [
(objectMemory isOopForwarded: cogMethod selector) ifTrue: [ | followed |
followed := objectMemory followForwarded: cogMethod selector.
cogMethod selector: followed.
(objectMemory isYoung: followed) ifTrue:
[methodZone ensureInYoungReferrers: cogMethod] ].
cogMethod cmType = CMMethod ifTrue: [
(objectMemory isForwarded: cogMethod methodObject) ifTrue: [
cogMethod methodObject:
Expand Down Expand Up @@ -8642,31 +8647,48 @@ Cogit >> incrementUsageOfTargetIfLinkedSend: annotation mcpc: mcpc ignored: supe
{ #category : #'in-line cacheing' }
Cogit >> indexForSelector: selector in: cogMethod at: mcpc [
"Answer the value to put in an inline-cache that is being loaded with the selector.
Usually this is simply the selector, but in 64-bits the cache is only 32-bits wide
and so the cache is loaded with the index of the selector."
<var: #cogMethod type: #'CogMethod *'>
<inline: false>
| methodOop |
self assert: (mcpc asUnsignedInteger > cogMethod asUnsignedInteger
and: [mcpc < (cogMethod asUnsignedInteger + cogMethod blockSize)]).
self assert:
(mcpc asUnsignedInteger > cogMethod asUnsignedInteger and: [
mcpc < (cogMethod asUnsignedInteger + cogMethod blockSize) ]).
"First search the special selectors; there are only 32 of them so this shouldn't take too long.
We could short-circuit this by keeping a hint bit in the target method, or by maintaining the
maximum range of selector oops in specialSelectors since they're likely to cluster."
0 to: NumSpecialSelectors - 1 do:
[:i|
selector = (coInterpreter specialSelector: i) ifTrue:
[^-1 - i]].
0 to: NumSpecialSelectors - 1 do: [ :i |
| aSpecialSelector |
aSpecialSelector := coInterpreter specialSelector: i.
(objectMemory isOopForwarded: aSpecialSelector) ifTrue: [
aSpecialSelector := objectMemory followForwarded: aSpecialSelector ].
selector = aSpecialSelector ifTrue: [ ^ -1 - i ] ].
methodOop := cogMethod methodObject.
"Then search the method's literal frame... open code fetchPointer:ofObject: for speed..."
LiteralStart to: (objectMemory literalCountOfMethodHeader: cogMethod methodHeader) do:
[:i|
(objectMemory longAt: i * objectMemory bytesPerOop + objectMemory baseHeaderSize + methodOop) = selector ifTrue:
[self assert: selector = (coInterpreter literal: i - 1 ofMethod: methodOop).
^i - 1]].
self error: 'could not find selector in method when unlinking send site'.
^0
"Then search the method's literal frame... open code fetchPointer:ofObject: for speed..."
LiteralStart to:
(objectMemory literalCountOfMethodHeader: cogMethod methodHeader)
do: [ :i |
| methodLiteral |
methodLiteral := objectMemory longAt:
i * objectMemory bytesPerOop
+ objectMemory baseHeaderSize + methodOop.
(objectMemory isOopForwarded: methodLiteral) ifTrue: [
methodLiteral := objectMemory followForwarded: methodLiteral ].
methodLiteral = selector ifTrue: [
self assert:
selector = (coInterpreter literal: i - 1 ofMethod: methodOop).
^ i - 1 ] ].
self error:
'could not find selector in method when unlinking send site'.
^ 0
]
{ #category : #'generate machine code' }
Expand Down
2 changes: 1 addition & 1 deletion smalltalksrc/VMMaker/SpurMemoryManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8884,8 +8884,8 @@ SpurMemoryManager >> moveToPermSpace: objOop [
becomeEffectsFlags := self becomeEffectFlagsFor: objOop.
self forward: objOop to: newObj.
self followSpecialObjectsOop.
self followSpecialSelectors.
coInterpreter postBecomeAction: becomeEffectsFlags.
self followSpecialSelectors.
self postBecomeScanClassTable: becomeEffectsFlags.
coInterpreter followForwardedMethodsInMethodZone.
becomeEffectsFlags := 0.
Expand Down
2 changes: 2 additions & 0 deletions smalltalksrc/VMMaker/StackInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8040,6 +8040,8 @@ StackInterpreter >> internalFindNewMethodOrdinary [
(self lookupInMethodCacheSel: messageSelector classTag: lkupClassTag) ifTrue:
[^nil]].
lkupClass := objectMemory classForClassTag: lkupClassTag.
(objectMemory isOopForwarded: lkupClass) ifTrue:
[lkupClass := objectMemory followForwarded: lkupClass].
self lookupMethodInClass: lkupClass.
self internalizeIPandSP.
self addNewMethodToCache: lkupClass].
Expand Down

0 comments on commit fc60ecd

Please sign in to comment.