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

Rave Bytecode #49

Closed
cpancake opened this Issue Apr 4, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@cpancake
Collaborator

cpancake commented Apr 4, 2015

The plan is (or, at least was) for Rave expressions to generate bytecode. We might be able to extend this system in the future to all Rant patterns, making them hella fast and making it easier to write ports (as only the runtime needs to be implemented, instead of the compiler and the runtime). An idea was to base the bytecode on IL bytecode, but with less cryptic opcode names. Does anyone have any other ideas?

@paavohuhtala

This comment has been minimized.

Show comment
Hide comment
@paavohuhtala

paavohuhtala Apr 4, 2015

Contributor

A solid idea. I think the best choice is a simple stack-based VM (like the CLR, but simpler). If the bytecode was similar enough to MSIL, making a Rave-To-MSIL compiler would be very easy, which could improve the performance even further.

Contributor

paavohuhtala commented Apr 4, 2015

A solid idea. I think the best choice is a simple stack-based VM (like the CLR, but simpler). If the bytecode was similar enough to MSIL, making a Rave-To-MSIL compiler would be very easy, which could improve the performance even further.

@cpancake

This comment has been minimized.

Show comment
Hide comment
@cpancake

cpancake Apr 4, 2015

Collaborator

Figured out a very simple bytecode format just for expressions. Stack-based.

Operators:

  • + - add
  • - - subtract
  • * - multiply
  • / - divide
  • % - mod
  • & - concat

Opcodes:

  • push_constant - 0x00, 1 argument, adds 1 to stack
  • push_local - 0x01, 1 argument, adds 1 to stack
  • push_string - 0x02, 1 argument, adds 1 to stack
  • assign - 0x03, 1 argument, takes one from stack
  • add - 0x04, 0 arguments, takes two from stack
  • subtract - 0x05, 0 arguments, takes two from stack
  • multiply - 0x06, 0 arguments, takes two from stack
  • divide - 0x07, 0 arguments, takes two from stack
  • mod - 0x08, 0 arguments, takes two from stack
  • concat - 0x09, 0 arguments, takes two from stack

Examples:

  • 1 + 1 - compiles to push_constant 2
  • 1 + a - compiles to push_constant 1; push_local a; add
  • a + b - compiles to push_local a; push_local b; add
  • "str" & "str2" - compiles to push_string str; push_string str2; concat
  • a = 1 - compiles to push_constant 1; assign a
Collaborator

cpancake commented Apr 4, 2015

Figured out a very simple bytecode format just for expressions. Stack-based.

Operators:

  • + - add
  • - - subtract
  • * - multiply
  • / - divide
  • % - mod
  • & - concat

Opcodes:

  • push_constant - 0x00, 1 argument, adds 1 to stack
  • push_local - 0x01, 1 argument, adds 1 to stack
  • push_string - 0x02, 1 argument, adds 1 to stack
  • assign - 0x03, 1 argument, takes one from stack
  • add - 0x04, 0 arguments, takes two from stack
  • subtract - 0x05, 0 arguments, takes two from stack
  • multiply - 0x06, 0 arguments, takes two from stack
  • divide - 0x07, 0 arguments, takes two from stack
  • mod - 0x08, 0 arguments, takes two from stack
  • concat - 0x09, 0 arguments, takes two from stack

Examples:

  • 1 + 1 - compiles to push_constant 2
  • 1 + a - compiles to push_constant 1; push_local a; add
  • a + b - compiles to push_local a; push_local b; add
  • "str" & "str2" - compiles to push_string str; push_string str2; concat
  • a = 1 - compiles to push_constant 1; assign a
@cpancake

This comment has been minimized.

Show comment
Hide comment
@cpancake

cpancake Apr 4, 2015

Collaborator

We might also just figure out the bytecode for the whole language right now. We don't know!

Collaborator

cpancake commented Apr 4, 2015

We might also just figure out the bytecode for the whole language right now. We don't know!

@TheBerkin

This comment has been minimized.

Show comment
Hide comment
@TheBerkin

TheBerkin Apr 5, 2015

Owner

Should I set up a new repo to host a markdown file for the bytecode spec? I have a feeling it will be rather large.

Owner

TheBerkin commented Apr 5, 2015

Should I set up a new repo to host a markdown file for the bytecode spec? I have a feeling it will be rather large.

@cpancake

This comment has been minimized.

Show comment
Hide comment
@cpancake

cpancake Apr 5, 2015

Collaborator

If we're going to do it for the entire language that would probably be wise.

Collaborator

cpancake commented Apr 5, 2015

If we're going to do it for the entire language that would probably be wise.

@TheBerkin TheBerkin added the NOICE! label Apr 5, 2015

@TheBerkin TheBerkin closed this Apr 27, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment