From a4e602d129f9deea3460e9bfd8a2207c1bbd2634 Mon Sep 17 00:00:00 2001 From: jasonwilliams Date: Sun, 11 Aug 2024 00:26:47 +0100 Subject: [PATCH] lazy builtins --- core/engine/src/builtins/mod.rs | 2 +- core/engine/src/environments/runtime/mod.rs | 4 ++++ core/engine/src/realm.rs | 1 - core/engine/src/vm/mod.rs | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/engine/src/builtins/mod.rs b/core/engine/src/builtins/mod.rs index b9a738f059..673f0b822b 100644 --- a/core/engine/src/builtins/mod.rs +++ b/core/engine/src/builtins/mod.rs @@ -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); diff --git a/core/engine/src/environments/runtime/mod.rs b/core/engine/src/environments/runtime/mod.rs index 8e13398cfc..e2a68ee3cb 100644 --- a/core/engine/src/environments/runtime/mod.rs +++ b/core/engine/src/environments/runtime/mod.rs @@ -1,6 +1,7 @@ use std::rc::Rc; use crate::{ + builtins::{Array, IntrinsicObject}, environments::CompileTimeEnvironment, object::{JsObject, PrivateName}, Context, JsResult, JsString, JsSymbol, JsValue, @@ -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) } diff --git a/core/engine/src/realm.rs b/core/engine/src/realm.rs index 255d713024..ed93d0f240 100644 --- a/core/engine/src/realm.rs +++ b/core/engine/src/realm.rs @@ -60,7 +60,6 @@ struct Inner { template_map: GcRefCell>, loaded_modules: GcRefCell>, host_classes: GcRefCell>, - host_defined: GcRefCell, } diff --git a/core/engine/src/vm/mod.rs b/core/engine/src/vm/mod.rs index cf32142d4a..3c26b2f05d 100644 --- a/core/engine/src/vm/mod.rs +++ b/core/engine/src/vm/mod.rs @@ -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(