Skip to content

Commit

Permalink
lazy builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwilliams committed Aug 10, 2024
1 parent 3b5434c commit a4e602d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/engine/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Realm {
ForInIterator::init(self);
Math::init(self);
Json::init(self);
Array::init(self);
// Array::init(self);
ArrayIterator::init(self);
Proxy::init(self);
ArrayBuffer::init(self);
Expand Down
4 changes: 4 additions & 0 deletions core/engine/src/environments/runtime/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::rc::Rc;

use crate::{
builtins::{Array, IntrinsicObject},
environments::CompileTimeEnvironment,
object::{JsObject, PrivateName},
Context, JsResult, JsString, JsSymbol, JsValue,
Expand Down Expand Up @@ -641,6 +642,9 @@ impl Context {
match locator.environment() {
BindingLocatorEnvironment::GlobalObject => {
let key = locator.name().clone();
if key.as_str() == "Array" {
Array::init(self.realm());
}
let obj = self.global_object();
obj.try_get(key, self)
}
Expand Down
1 change: 0 additions & 1 deletion core/engine/src/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ struct Inner {
template_map: GcRefCell<FxHashMap<u64, JsObject>>,
loaded_modules: GcRefCell<FxHashMap<JsString, Module>>,
host_classes: GcRefCell<FxHashMap<TypeId, StandardConstructor>>,

host_defined: GcRefCell<HostDefined>,
}

Expand Down
1 change: 1 addition & 0 deletions core/engine/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ unsafe impl Trace for ActiveRunnable {
impl Vm {
/// Creates a new virtual machine.
pub(crate) fn new(realm: Realm) -> Self {
let _timer = Profiler::global().start_event("Vm:new", "vm");
Self {
frames: Vec::with_capacity(16),
frame: CallFrame::new(
Expand Down

0 comments on commit a4e602d

Please sign in to comment.