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

Interpreter improvements #71

Closed
dmlloyd opened this issue Sep 30, 2020 · 3 comments
Closed

Interpreter improvements #71

dmlloyd opened this issue Sep 30, 2020 · 3 comments
Labels
area: virtual JVM The virtual JVM implementation kind: enhancement ✨ A new feature or use case

Comments

@dmlloyd
Copy link
Collaborator

dmlloyd commented Sep 30, 2020

The initial interpreter is basically a graph iterator which keeps stack frames as hash maps mapping Value to boxed Objects. This might end up being good enough, but I doubt it. We will likely want to come up with a better interpreter that JIT-compiles code blocks into bytecode to run on the host JVM.

@headius and @enebo have taken some initial looks at what this might entail.

Since it is expected that the initial interpreter will suffice for the purposes of the initial implementation, there is no milestone on this issue.

@dmlloyd dmlloyd added kind: enhancement ✨ A new feature or use case area: virtual JVM The virtual JVM implementation labels Sep 30, 2020
@dmlloyd
Copy link
Collaborator Author

dmlloyd commented Oct 7, 2020

A basic design could look like this:

  • Generate a class for each method body which represents the stack frame; stack frame instances would implement a common interface or superclass, and would form a linked list representing the call stack, with a field for each value slot (i.e. an unlimited-register machine).
  • Generate a class for each object, perhaps with a degree of mapping between the virtual type hierarchy and the generated concrete type hierarchy; the generated class would include fields that mirror the virtual type's fields, and methods that correspond to the virtual type's methods with added parameters for the caller's frame and possibly the current thread.

This design would avoid the need to employ a register allocator or other potentially complex/time-consuming analysis steps, at the expense of build-time memory footprint (but note that this is still much better than the map-based approach being used right now). Since the majority of build time code is expected to execute few times (often just once), this seems like a fair tradeoff.

@dmlloyd
Copy link
Collaborator Author

dmlloyd commented Oct 7, 2020

Another option would be to eschew the stack frame class in favor of using local variables directly, but some solution for stack walking would still be necessary (for building exception stack traces if nothing else). Walking the real stack using the host's StackWalker and mapping each frame to a virtual frame is one possible solution.

@quintesse quintesse modified the milestone: 0.1.0 Jan 19, 2021
@dmlloyd
Copy link
Collaborator Author

dmlloyd commented Oct 7, 2021

Done.

@dmlloyd dmlloyd closed this as completed Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: virtual JVM The virtual JVM implementation kind: enhancement ✨ A new feature or use case
Projects
None yet
Development

No branches or pull requests

2 participants