Browse Source

lazy builtins

pull/3945/head
jasonwilliams 3 months ago
parent
commit
a4e602d129
  1. 2
      core/engine/src/builtins/mod.rs
  2. 4
      core/engine/src/environments/runtime/mod.rs
  3. 1
      core/engine/src/realm.rs
  4. 1
      core/engine/src/vm/mod.rs

2
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);

4
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)
}

1
core/engine/src/realm.rs

@ -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>,
}

1
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(

Loading…
Cancel
Save