Comments (3)
At least as an intermediate solution, the bytecode interpreter, needs a slightly adapted design to store the stack.
It is pretty much the same as the design for the AST-based interpreter, but we reserve space for the stack at the end of the Frame
. The design of Inner
remains unchanged.
Frame for Bytecode Interpreter
+-----------+
| Inner | (Optional: for args/vars accessed from inner scopes, and non-local returns)
+-----------+
| Receiver |
+-----------+
| Arg 1 |
| ... |
| Arg n |
+-----------+
| Local 1 |
| ... |
| Local n | <-- initial StackPtr
+-----------+
| Stack |
| ... |
+-----------+
| StackPtr |
+-----------+
To not have to pass around where to find the stack pointer, it's encoded in the last slot. The main reason here is not to have to change the common parts between AST and BC frames. Though, performance-wise it might not be optimal, because it's not a constant offset. The semantics of the stack pointer is that it points to the current element. For an empty stack, i.e., the initial StackPtr
this means it points to the element before the first stack element.
In the long term, I hope the stack won't need to be part of the frame anymore. In TruffleSOM, it already works nicely to keep the stack simply in the interpreter loop and never escape it from there. The hope is that a compiler has an easier time to simply eliminate the array for the stack. For PySOM's bytecode interpreter, I'll have to see whether this works out and is worth it.
from pysom.
RPython Implementation Note
To make the RPython type system happy, everything stored in the Frame
needs to be type erased (see rlib.rerased
).
This is needed to be able to store a list
together with the AbstractObject
SOM objects, and the int
for the StackPtr
in the same list.
Since the Inner
only stores AbstractObject
instances, it doesn't need erasure.
For simplicity, the OnStack
marker is simply a trueObject
or falseObject
, which should boil down to simply pointer comparisons.
from pysom.
Performance results for the AST interpreter changes:
from pysom.
Related Issues (9)
- Interpreter Adaptation for New Frame Design HOT 1
- Avoid class guard and object-layout guard HOT 1
- Investigate drop in AST JIT performance because of #18
- Running hello world fails HOT 2
- Implement common bytecode sequences
- Design Considerations for Loop Inlining HOT 1
- Make AST and BC interpreter use the same frame format HOT 1
- AST vs Bytecode Interpreter Inline Caching Strategy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysom.