Skip to content

ADT X86_64HandlerFrame#607

Open
linxuanm wants to merge 3 commits intotitzer:masterfrom
linxuanm:adt-frames
Open

ADT X86_64HandlerFrame#607
linxuanm wants to merge 3 commits intotitzer:masterfrom
linxuanm:adt-frames

Conversation

@linxuanm
Copy link
Copy Markdown
Contributor

This PR adds an ADT X86_64HandlerFrame that wraps field accesses to both the interpreter and the SPC stack frame.

Copy link
Copy Markdown
Owner

@titzer titzer left a comment

Choose a reason for hiding this comment

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

This is a good start! I like how much this cleans up client code. See suggestions below on how to improve the ADT itself.

=104;
}

// Frame handler for interpreter and SPC stack frames; a lightweight wrapper for frame slot accesses.
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.

Let's name these "frame handles" (not handler).

}

// Frame handler for interpreter and SPC stack frames; a lightweight wrapper for frame slot accesses.
type X86_64FrameHandler {
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.

This needs to be unboxed because they should not be allocated on the heap, particularly because they could be used during GC.


// Frame handler for interpreter and SPC stack frames; a lightweight wrapper for frame slot accesses.
type X86_64FrameHandler {
case Interpreter(sfp_: Pointer) {
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.

I think this will be a lot cleaner if the constructor has a Ref<X86_64InterpreterFrame> layout. We can then define accessor methods in the type and override them for both the interpreter and the SPC frame case.

(sfp() + X86_64InterpreterFrame.accessor.offset).store<X86_64FrameAccessor>(val);
}

// Guards.
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.

I think it's better to use Virgil's cast and query operators instead of wrapping them with additional indirection. So e.g. we can just do X86_64InterpreterFrame.Interpreter.?() or do a match in client code.

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