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

Frame unification #602

Open
wants to merge 54 commits into
base: pharo-12
Choose a base branch
from

Conversation

guillep
Copy link
Member

@guillep guillep commented May 13, 2023

Slight differences in the shape of frames between the pure interpreter and the VM with JIT make a lot of code duplication and make it difficult to change and debug.

This PR unifies both. The main idea that the JIT VM keeps the same frame organisation, it is the non-JIT VM (used to debug mainly nowadays) that accommodates slightly.

The core differences dealt with are:

  • the interpreter frames in the JIT'ted VM have an extra field to store its instruction pointer when calling a machine code method. Instead of duplicating the entire code, we conditionally push/iterate over that extra field in one place.
  • the base frames in the stack need to store a trampoline address in the caller saved IP to return gracefully if it is a machine code frame, and it then stores the caller context in a separate field at the base of the stack => the non-JIT VM now adopts the same organization, except that it never uses a trampoline to return

Other minor details include the refactoring in the management of instruction pointers which in the JITt'ed VM can have a mixture of machine code and interpreter instruction pointers. The code should do the same but just avoid repetition.

Also, several minor cleanups of dead code observed on the way

@guillep guillep changed the base branch from pharo-10 to pharo-12 May 13, 2023 13:07
Copy link
Contributor

@privat privat left a comment

Choose a reason for hiding this comment

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

The PR is big thus very hard to read, but the work is impressive. I tried my best to review it even if lot of things are still mysterious to me.

'jitCodeZoneWriteEnabled'
'jitCodeZoneWriteEnabled',
'cePrimReturnEnterCogCode',
'cePrimReturnEnterCogCodeProfiling'
Copy link
Contributor

Choose a reason for hiding this comment

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

why those two ivars were moved around?

Copy link
Member Author

Choose a reason for hiding this comment

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

no idea :)

smalltalksrc/VMMaker/StackInterpreter.class.st Outdated Show resolved Hide resolved

"In cog the base frames are married, in non cog they are not"
self isCog ifTrue: [
theContext := self ensureFrameIsMarried: theFP SP: (self frameReceiverLocation: theFP).
Copy link
Contributor

Choose a reason for hiding this comment

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

isCog here feels inconsistent with the rest of the PR

What about a method that returns nil in the StackInterpretor and possibly perform matrimonial work in the CoInterpretor?

moreover, the method moveFramesIn... is very similar that the one overridden in CoInterpretor, so I'm not even sure that the isCog is meaningful in neither. Could it be possible to have a single method moveFramesIn... for both?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I refactored so they look very similar (and the repetition could eventually be removed). But at some point I put my time on fixing issue and making the PR pass ^^

smalltalksrc/VMMaker/CoInterpreter.class.st Show resolved Hide resolved
smalltalksrc/VMMaker/CoInterpreter.class.st Show resolved Hide resolved
smalltalksrc/VMMaker/CoInterpreter.class.st Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants