-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add qjsc -r
flag to output raw bytecode
#460
Conversation
How will you handle handle bytecode incompatibility? Edit, hit enter too fast. Bytecode generated by a given version of QJSC need not be compatible with previous or further versions of the engine. There is a BC version we bump when we make changes to the way bytecode is (de)serialized. I support the approach, but I worry people are going to run into problems because this incompatibility is not obvious... |
QuickJS already throws a syntax error, so on the technical level I'm not sure what else would need to be done: https://github.com/quickjs-ng/quickjs/blob/07fa1cbc4a8938085a716051c0f14a3453a885fb/quickjs.c#L35116-L35120 Socially, I plan on shipping an emscripten-compiled version of |
Sounds reasonable. We can also look into the syntax error message and make it more helpful if need be as well. |
qjsc.c
Outdated
@@ -450,25 +462,29 @@ int main(int argc, char **argv) | |||
ctx = JS_NewContext(rt); | |||
|
|||
/* loader for ES6 modules */ | |||
JS_SetModuleLoaderFunc(rt, NULL, jsc_module_loader, NULL); | |||
OutputTypeEnum *output_type_ptr = (OutputTypeEnum *)js_malloc(ctx, sizeof(OutputTypeEnum)); |
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 don't you make the output type a static variable at the top of the file and simplify this? There is already precedent with things like outfile
and strip
and then you don't need to shove it in there
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.
There is a problem: the output file must be open in binary mode to output the raw bytecode:
This is necessary for legacy architectures with end-of-line translation and other obscure text mode conversion schemes. |
I want to allow users to ship a raw
.jsc
bytecode file for faster bootup times.