Skip to content

Commit 5d5f51d

Browse files
committed
only lazify array, fix the double borrow issue
1 parent c1b85a8 commit 5d5f51d

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

core/engine/src/builtins/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,15 @@ impl Realm {
206206
AsyncIterator::init(self);
207207
AsyncFromSyncIterator::init(self);
208208
ForInIterator::init(self);
209+
Math::init(self);
210+
Json::init(self);
209211
ArrayIterator::init(self);
210212
Proxy::init(self);
211213
ArrayBuffer::init(self);
212214
SharedArrayBuffer::init(self);
213215
BigInt::init(self);
214216
Boolean::init(self);
217+
Date::init(self);
215218
DataView::init(self);
216219
Map::init(self);
217220
MapIterator::init(self);
@@ -223,7 +226,9 @@ impl Realm {
223226
Eval::init(self);
224227
Set::init(self);
225228
SetIterator::init(self);
229+
String::init(self);
226230
StringIterator::init(self);
231+
RegExp::init(self);
227232
RegExpStringIterator::init(self);
228233
BuiltinTypedArray::init(self);
229234
Int8Array::init(self);

core/engine/src/context/intrinsics.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl StandardConstructors {
257257
)),
258258
async_generator_function: StandardConstructor::default(),
259259
proxy: StandardConstructor::default(),
260-
date: StandardConstructor::lazy(Date::init, realm_inner),
260+
date: StandardConstructor::default(),
261261
function: StandardConstructor {
262262
constructor: JsFunction::empty_intrinsic_function(true),
263263
prototype: JsFunction::empty_intrinsic_function(false).into(),
@@ -270,8 +270,11 @@ impl StandardConstructors {
270270
boolean: StandardConstructor::with_prototype(JsObject::from_proto_and_data(
271271
None, false,
272272
)),
273-
string: StandardConstructor::lazy(String::init, realm_inner),
274-
regexp: StandardConstructor::lazy(RegExp::init, realm_inner),
273+
string: StandardConstructor::with_prototype(JsObject::from_proto_and_data(
274+
None,
275+
js_string!(),
276+
)),
277+
regexp: StandardConstructor::default(),
275278
symbol: StandardConstructor::default(),
276279
error: StandardConstructor::default(),
277280
type_error: StandardConstructor::default(),
@@ -1165,8 +1168,8 @@ impl IntrinsicObjects {
11651168
pub(crate) fn uninit(realm_inner: &WeakGc<RealmInner>) -> Option<Self> {
11661169
Some(Self {
11671170
reflect: JsObject::default(),
1168-
math: JsObject::lazy(Math::init, realm_inner),
1169-
json: JsObject::lazy(Json::init, realm_inner),
1171+
math: JsObject::default(),
1172+
json: JsObject::default(),
11701173
throw_type_error: JsFunction::empty_intrinsic_function(false),
11711174
array_prototype_values: JsFunction::empty_intrinsic_function(false),
11721175
array_prototype_to_string: JsFunction::empty_intrinsic_function(false),

core/engine/src/native_function.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,14 @@ pub(crate) fn native_function_call(
343343
argument_count: usize,
344344
context: &mut Context,
345345
) -> JsResult<CallValue> {
346-
native_function_call_inner(
347-
obj,
348-
&obj.downcast_ref::<NativeFunctionObject>()
349-
.expect("the object should be a native function object")
350-
.clone(),
351-
argument_count,
352-
context,
353-
)
346+
let native_function = &obj
347+
.clone()
348+
.downcast::<NativeFunctionObject>()
349+
.expect("the object should be a native function object")
350+
.borrow_mut()
351+
.data
352+
.clone();
353+
native_function_call_inner(obj, native_function, argument_count, context)
354354
}
355355

356356
/// Call this object.

0 commit comments

Comments
 (0)