-
-
Notifications
You must be signed in to change notification settings - Fork 400
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
lazy builtins #3973
base: main
Are you sure you want to change the base?
lazy builtins #3973
Conversation
1c4cc00
to
c52c687
Compare
let function = object | ||
.downcast_mut::<NativeFunctionObject>() | ||
.expect("Builtin must be a function object"); | ||
function.f = NativeFunction::from_fn_ptr(self.function); | ||
function.constructor = Some(ConstructorKind::Base); | ||
function.realm = Some(self.realm.clone()); |
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.
Oops, I suggested to remove this, but I think this is still needed.
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've made some updates to this, take a look
|
||
#[derive(Debug, Clone, Trace, Finalize)] | ||
pub(crate) enum BuiltinKind { | ||
Function(JsFunction), |
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.
Hmm, thinking a bit more about this, I think Function
should store a NativeFunctionObject
instead, and the builder methods should be adjusted to consider this. Else, the builder won't set the builtin to the correct value while initializing.
Handle toString for lazyBuiltIn objects
cf4a379
to
d697af1
Compare
if builtin.borrow().data.init_and_realm.is_some() { | ||
let mut builtin_borrow = builtin.borrow_mut(); | ||
let (init, realm_inner) = builtin_borrow | ||
.data | ||
.init_and_realm | ||
.take() | ||
.expect("init_and_realm not set"); |
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.
With the new changes this can be improved. Instead of calling init_and_realm.is_some()
, then init_and_realm.take()
, we can do if let Some(data) = builtin.borrow_mut().data.init_and_realm.take()
Lazy Builtins