Skip to content

Commit

Permalink
Fix bad merge leftover
Browse files Browse the repository at this point in the history
  • Loading branch information
guillep committed Nov 8, 2023
1 parent 3bf4274 commit 355ba5f
Showing 1 changed file with 10 additions and 66 deletions.
76 changes: 10 additions & 66 deletions smalltalksrc/VMMaker/CoInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -790,72 +790,16 @@ CoInterpreter >> attemptToSwitchToMachineCode: bcpc [
{ #category : #'return bytecodes' }
CoInterpreter >> baseFrameCannotReturnTo: contextToReturnTo [

"The stack page is effectively free now, so free it. We must free it to be
correct in determining if contextToReturnTo is still married, and in case
makeBaseFrameFor: cogs a method, which may cause a code compaction,
in which case the frame must be free to avoid the relocation machinery
tracing the dead frame. Since freeing now temporarily violates the page-list
ordering invariant, use the assert-free version."
stackPages freeStackPageNoAssert: stackPage.
retToContext := objectMemory isContext: contextToReturnTo.
(retToContext and: [ self isStillMarriedContext: contextToReturnTo ])
ifTrue: [
theFP := self frameOfMarriedContext: contextToReturnTo.
thePage := stackPages stackPageFor: theFP.
theFP = thePage headFP
ifTrue: [ theSP := thePage headSP ]
ifFalse: [ "Returning to some interior frame, presumably because of a sender assignment.
Move the frames above to another page (they may be in use, e.g. via coroutining).
Make the interior frame the top frame."
frameAbove := self findFrameAbove: theFP inPage: thePage.
"Since we've just deallocated a page we know that newStackPage won't deallocate an existing one."
newPage := stackPages newStackPage.
self assert: newPage = stackPage.
self moveFramesIn: thePage through: frameAbove toPage: newPage.
stackPages markStackPageMostRecentlyUsed: newPage.
theFP := thePage headFP.
theSP := thePage headSP ] ]
ifFalse: [
(retToContext and: [
objectMemory isIntegerObject: (objectMemory
fetchPointer: InstructionPointerIndex
ofObject: contextToReturnTo) ]) ifFalse: [
| contextToReturnFrom |
contextToReturnFrom := stackPages longAt:
stackPage baseAddress
- objectMemory wordSize.
self
tearDownAndRebuildFrameForCannotReturnBaseFrameReturnFrom:
contextToReturnFrom
to: contextToReturnTo
returnValue: localReturnValue.
^ self
externalCannotReturn: localReturnValue
from: contextToReturnFrom ].
"We must void the instructionPointer to stop it being updated if makeBaseFrameFor:
cogs a method, which may cause a code compaction."
instructionPointer := 0.
thePage := self makeBaseFrameFor: contextToReturnTo.
theFP := thePage headFP.
theSP := thePage headSP ].
self setStackPageAndLimit: thePage.
self assert: (stackPages stackPageFor: theFP) = stackPage.
stackPointer := theSP.
framePointer := theFP.
instructionPointer := self pointerForOop: self stackTop.
instructionPointer asUnsignedInteger < objectMemory startOfMemory
ifTrue: [
instructionPointer asUnsignedInteger
~= cogit ceReturnToInterpreterPC ifTrue: [ "localIP in the cog method zone indicates a return to machine code."
^ self returnToMachineCodeFrame ].
instructionPointer := self pointerForOop:
(self iframeSavedIP: framePointer) ].
self assert: (self
checkIsStillMarriedContext: contextToReturnTo
currentFP: framePointer).
self setMethod: (self iframeMethod: framePointer).
self stackTopPut: localReturnValue.
^ self fetchNextBytecode
| contextToReturnFrom |
contextToReturnFrom := stackPages longAt: stackPage baseAddress - objectMemory wordSize.
self
tearDownAndRebuildFrameForCannotReturnBaseFrameReturnFrom:
contextToReturnFrom
to: contextToReturnTo
returnValue: localReturnValue.
^ self
externalCannotReturn: localReturnValue
from: contextToReturnFrom
]

{ #category : #hooks }
Expand Down

0 comments on commit 355ba5f

Please sign in to comment.