-
Notifications
You must be signed in to change notification settings - Fork 22
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
Basic Bytecode Impl with oxc's parser #21
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not be too familiar with bytecode, but it seems odd to me that every instruction operates on an arbitrary address passed in the bytecode itself. Usually bytecode or machine code architectures are either stack-based or register-based, but you usually don't have instructions directly operating on memory addresses. This looks like an odd design to me, and it seems like it'd be much cleaner if it was a stack machine.
nova_vm/src/lib.rs
Outdated
let mut memory = Vec::<Value>::with_capacity(self.pc as usize); | ||
|
||
for _ in 0..self.pc { | ||
memory.push(Value::Undefined); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed, since each instruction can specify the memory address it operates on?
It also seems like the bytecode building and the interpreting could be split apart, rather than having to share the Also, what is |
Yeah...I haven't built a bytecode interpreter before this so that makes more sense. Do you mean something like this? (Still not really sure how these things are designed)
And Add would pop |
That's right. Building such a bytecode might be tricker, though, since the values on top of the stack might not be the ones you need, and building the most optimal bytecode might mean moving instructions around. But you could have instructions to copy a value from elsewhere in the stack to the top, and a noop instruction to discard values from the top. |
Maybe rather than using noop for discarding a value a noop and drop might be better? (same as for wasm) |
|
Stale, might be able to use later. |
No description provided.