Skip to content

Commit

Permalink
Recovering the behaviour of internalExecuteMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
tesonep committed Oct 19, 2023
1 parent f6bf6f3 commit dc71f76
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
15 changes: 12 additions & 3 deletions smalltalksrc/VMMaker/CoInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -554,21 +554,30 @@ CoInterpreter >> activateNewFullClosure: blockClosure method: theMethod numArgs:
]

{ #category : #'message sending' }
CoInterpreter >> activateNewMethod [
CoInterpreter >> activateNewMethod: shouldCompileToMachineCode [

| methodHeader inInterpreter switched |

"Eagerly compile it if appropriate so that doits are fast."
methodHeader := self rawHeaderOf: newMethod.
(self isCogMethodReference: methodHeader) ifFalse: [
(self methodWithHeaderShouldBeCogged: methodHeader)
(shouldCompileToMachineCode and: [(self methodWithHeaderShouldBeCogged: methodHeader)])
ifTrue: [
cogit cog: newMethod selector: objectMemory nilObject.
methodHeader := self rawHeaderOf: newMethod ]
ifFalse: [ self maybeFlagMethodAsInterpreted: newMethod ] ].

inInterpreter := self isInstructionPointerInInterpreter:
instructionPointer.

(self isCogMethodReference: methodHeader)
ifTrue:
[inInterpreter ifTrue:
[self iframeSavedIP: framePointer put: instructionPointer asInteger.
instructionPointer := cogit ceReturnToInterpreterPC].
^ self activateCoggedNewMethod: inInterpreter].

"We are in the interpreter"
methodHeader := self justActivateNewMethod: true.

"Now check for stack overflow or an event (interrupt, must scavenge, etc)."
Expand Down Expand Up @@ -3444,7 +3453,7 @@ CoInterpreter >> interpretMethodFromMachineCode [
self
executePrimitiveFromInterpreter: false
ifFail: [ "if not primitive, or primitive failed, activate the method and reenter the interpreter"
self activateNewMethod.
self activateNewMethod: false.
self siglong: reenterInterpreter jmp: ReturnToInterpreter.
"NOTREACHED"
^ nil ]
Expand Down
22 changes: 19 additions & 3 deletions smalltalksrc/VMMaker/StackInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,14 @@ StackInterpreter >> activateNewFullClosure: blockClosure method: theMethod numAr
{ #category : #'message sending' }
StackInterpreter >> activateNewMethod [

<inline: #always>

self activateNewMethod: true
]

{ #category : #'message sending' }
StackInterpreter >> activateNewMethod: shouldCompileToMachineCode [

| methodHeader switched |
methodHeader := self justActivateNewMethod: false. "either interpreted or machine code"

Expand Down Expand Up @@ -4634,7 +4642,7 @@ StackInterpreter >> commonSendOrdinary [
self sendBreakpoint: messageSelector receiver: (self stackValue: argumentCount).
self doRecordSendTrace.
self findNewMethodOrdinary.
self executeNewMethod.
self executeNewMethod: false.
self fetchNextBytecode
]

Expand Down Expand Up @@ -5424,6 +5432,14 @@ StackInterpreter >> establishFrameForContextToReturnTo: contextToReturnTo [

{ #category : #'message sending' }
StackInterpreter >> executeNewMethod [

<inline: #always>

self executeNewMethod: true
]

{ #category : #'message sending' }
StackInterpreter >> executeNewMethod: shouldCompileToMachineCode [
"if not primitive, or primitive failed, activate the method"

| inInterpreter |
Expand All @@ -5432,7 +5448,7 @@ StackInterpreter >> executeNewMethod [
self
executePrimitiveFromInterpreter: inInterpreter
ifFail: [ "if not primitive, or primitive failed, activate the method"
self activateNewMethod ]
self activateNewMethod: shouldCompileToMachineCode ]
]

{ #category : #'message sending' }
Expand Down Expand Up @@ -9384,7 +9400,7 @@ StackInterpreter >> mappedDirectCall [
argumentCount := self argumentCountOfMethodHeader: methodHeader.
"The primitive function pointer is not cached in the interpreter, but it's called quickly in the JIT"
primitiveFunctionPointer := self functionPointerFor: localPrimIndex inClass: objectMemory nilObject..
self activateNewMethod
self activateNewMethod: false
]

{ #category : #'sista bytecodes' }
Expand Down

0 comments on commit dc71f76

Please sign in to comment.