Skip to content
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

Fix/speed regression #705

Merged
merged 8 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions smalltalksrc/VMMaker/CoInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,17 @@ CoInterpreter >> activateNewMethod [

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, do not compile on method activation

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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, activate compiled method if already compiled

methodHeader := self justActivateNewMethod: true.

"Now check for stack overflow or an event (interrupt, must scavenge, etc)."
Expand Down Expand Up @@ -2604,6 +2606,28 @@ CoInterpreter >> executeFullCogBlock: cogMethod closure: closure mayContextSwitc
"NOTREACHED"
]

{ #category : #'message sending' }
CoInterpreter >> executeNewMethod: eagerlyCompile [
"if not primitive, or primitive failed, activate the method"
<inline: true>
| inInterpreter |
inInterpreter := self isInstructionPointerInInterpreter:
instructionPointer.
self executePrimitiveFromInterpreter: inInterpreter ifFail: [
| methodHeader |
eagerlyCompile ifTrue: [
"Eagerly compile it if appropriate so that doits are fast."
methodHeader := self rawHeaderOf: newMethod.
(self isCogMethodReference: methodHeader) ifFalse: [
(self methodWithHeaderShouldBeCogged: methodHeader)
ifTrue: [
cogit cog: newMethod selector: objectMemory nilObject.
methodHeader := self rawHeaderOf: newMethod ]
ifFalse: [ self maybeFlagMethodAsInterpreted: newMethod ] ]].
"if not primitive, or primitive failed, activate the method"
self activateNewMethod ]
]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the major change in here, now this method can be parametrised to eagerly compile methods (or not). By default the interpreter will not do it.

{ #category : #'return bytecodes' }
CoInterpreter >> externalAboutToReturn: resultOop through: aContext [
| ourContext |
Expand Down
9 changes: 8 additions & 1 deletion smalltalksrc/VMMaker/StackInterpreter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4634,7 +4634,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 +5424,13 @@ StackInterpreter >> establishFrameForContextToReturnTo: contextToReturnTo [

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

"Eagerly compile method"
self executeNewMethod: true
]

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

| inInterpreter |
Expand Down