starlight
starlight copied to clipboard
Add codegen support for builtin calls in self-hosted builtins.
We could make all calls to all functions prefixed with __
transform into bytecode sequences rather than real calls to builtins. This should be done only when compiling self-hosted builtins.
Some calls are implemented now. I think now it is necessary to add support for method calls i.e foo.___call(x,y,z)
will call foo
with arguments y
and z
while x
will be this
variable.
Hi, I'd like to work on this and also #51 too. Could you give me a more detailed guide or some example?. Thank you very much!
@jameslahm hello! Right now only non-member calls to builtins are supported but under crates/starlight/builtins we still rely on some functions that might get overwritten at runtime i.e Function.prototype.call
and what is needed is to add more calls that can be compiled to bytecode. To reach this handle_builtin_call
and is_builtin_call
in bytecompiler.rs should be modified and support for Expr::Member should be added.
For #51 hashmap should exist that will contains these codegen plugins. Maybe something like this: HashMap<String,Box<dyn Fn(&mut ByteCompiler) -> Result<(),JsValue>>>
. There are a few problems with this and first of all, I do not think passing just expressions to these plugins is a good idea second is that the current byte compiler API is terrible and hard to use, a lot of work is required to make it nicer, I recently added error handling to byte compiler and this got a number of panics from 12.000 to 1.200.