Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

add a library-embedding tool like mrbc in mruby #25

Closed
omasanori opened this issue Feb 3, 2014 · 2 comments
Closed

add a library-embedding tool like mrbc in mruby #25

omasanori opened this issue Feb 3, 2014 · 2 comments

Comments

@omasanori
Copy link
Contributor

It would be better if we have a tool to embed the built-in library in libpicrin. mruby already includes such tool, called mrbc. I saw a similar approach in V8 (but it might have changed now).

AFAIK mruby choose byte code as embedding format and V8 did JavaScript source code. Which is better for us?

@nyuichi
Copy link
Member

nyuichi commented Feb 3, 2014

@omasanori

Thank you for opening the issue. I agreed. Sooner or later, such a technique is going to be necessary.

Regarding the format, I think their approaches are slightly different in that why they do library embedding. mruby does so simply because they are aiming at increasing portability. They want to run mruby even on platforms that have no filesystems or, if any, ones which reads extremely slow or prohibit I/O. On the other hand, the only aim of V8 is to achieve the speed. They dislike even so small overhead to kick system call and read from FS in the early stage of interpreter initialization.

V8 has another special handicap in library-embedding, that is, it has no intermediate 'VM'. They directly compiles the source code into native machine code and its process will be done more than one time in an execution. This means that they cannot precompile the code before they precisely know how the runtime environment winds frames on the stack. This is just my guess but I suppose it is the reason V8 does it with raw source code string.

So, our approach. I just prefer bytecode style. However, current HEAD doesn't support external emission of bytecode. Once we managed to support pickling and unpickling of bytecode we start to go the way of mruby. Still then, we may do it with source code.

@omasanori
Copy link
Contributor Author

@wasabiz sure.

@nyuichi nyuichi closed this as completed in 48d477d Apr 5, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants