Skip to content

Support frame variables in the SPC without deopt - #728

Draft
matthew-mojira wants to merge 1 commit into
titzer:masterfrom
matthew-mojira:spc_frame_var_slots
Draft

matthew-mojira wants to merge 1 commit into
titzer:masterfrom
matthew-mojira:spc_frame_var_slots

Conversation

@matthew-mojira

Copy link
Copy Markdown
Contributor

So that the path profiling monitor can be compiled and use frame variables (without having to deopt) I have added support for the SPC to hold frame variables. The layout is the same as the interpreter, so that if there is actually a deopt or tierup/OSR the frame variables don't require any special handling.

One thing I noticed is that there isn't really a formal way to add/remove/change frame variables. The fast interpreter reads the frame_var_tags field from the function before executing the function which is robust against changes to frame_var_tags. But in the SPC it is compiled once against the frame_var_tags seen at compile time. So if anything ever changes the frame_var_tags at runtime (or after it is compiled) then the SPC code will not notice.

Currently, only legacy exception handling uses frame variables and that is done at validation time before the SPC runs. For my path profiling monitor I had to add a function to add frame variables to hold the path number register, but these variables are added in the onParse method of the monitor which should be before the SPC compiles the function.

@matthew-mojira
matthew-mojira marked this pull request as ready for review October 15, 2026 23:30
@matthew-mojira
matthew-mojira marked this pull request as draft October 15, 2026 23:36
@matthew-mojira

Copy link
Copy Markdown
Contributor Author

there is still a bug for probes that are deopting to the wrong place that still warrant another PR

// XXX does not support dynamically changing frame_var_tags in a function
def pushFrameVars(func: FuncDecl) {
if (FeatureDisable.frameVariables || func.frame_var_tags == null) return;
for (t in func.frame_var_tags) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The original code just added them to the state and records them as constant 0, without writing their frame tags. The new code eagerly initializes them, and I think that is not necessary.

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.

2 participants