Skip to content

Commit 65f416e

Browse files
authored
refactor(ecmascript): [[Get]], [[Set]], [[GetOwnProperty]], [[DefineOwnProperty]] caching (#823)
1 parent 9bc4452 commit 65f416e

File tree

72 files changed

+4150
-4022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+4150
-4022
lines changed

nova_vm/src/ecmascript/abstract_operations/operations_on_iterator_objects.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ use crate::{
1616
builtins::ArgumentsList,
1717
execution::{
1818
Agent, JsResult,
19-
agent::{ExceptionType, JsError},
19+
agent::{ExceptionType, JsError, try_result_into_js, try_result_into_option_js},
2020
},
2121
types::{
2222
BUILTIN_STRING_MEMORY, Function, IntoObject, IntoValue, Object, OrdinaryObject,
2323
PropertyKey, Value,
2424
},
2525
},
2626
engine::{
27-
ScopableCollection, ScopedCollection, TryResult, VmIteratorRecord,
27+
ScopableCollection, ScopedCollection, VmIteratorRecord,
2828
context::{Bindable, GcScope, NoGcScope},
2929
rootable::Scopable,
3030
},
@@ -495,12 +495,12 @@ pub(crate) fn iterator_close_with_value<'a>(
495495
// 1. Assert: iteratorRecord.[[Iterator]] is an Object.
496496
// 2. Let iterator be iteratorRecord.[[Iterator]].
497497
// 3. Let innerResult be Completion(GetMethod(iterator, "return")).
498-
let inner_result = if let TryResult::Continue(inner_result) = try_get_object_method(
498+
let inner_result = if let Some(inner_result) = try_result_into_option_js(try_get_object_method(
499499
agent,
500500
iterator,
501501
BUILTIN_STRING_MEMORY.r#return.into(),
502502
gc.nogc(),
503-
) {
503+
)) {
504504
inner_result
505505
} else {
506506
let scoped_iterator = iterator.scope(agent, gc.nogc());
@@ -574,12 +574,12 @@ pub(crate) fn iterator_close_with_error<'a>(
574574
// 1. Assert: iteratorRecord.[[Iterator]] is an Object.
575575
// 2. Let iterator be iteratorRecord.[[Iterator]].
576576
// 3. Let innerResult be Completion(GetMethod(iterator, "return")).
577-
let inner_result = if let TryResult::Continue(inner_result) = try_get_object_method(
577+
let inner_result = if let Some(inner_result) = try_result_into_option_js(try_get_object_method(
578578
agent,
579579
iterator,
580580
BUILTIN_STRING_MEMORY.r#return.into(),
581581
gc.nogc(),
582-
) {
582+
)) {
583583
inner_result
584584
} else {
585585
let scoped_iterator = iterator.scope(agent, gc.nogc());
@@ -659,20 +659,23 @@ pub(crate) fn async_iterator_close_with_value<'a>(
659659
// 2. Let iterator be iteratorRecord.[[Iterator]].
660660
let mut iterator = iterator.bind(gc.nogc());
661661
// 3. Let innerResult be Completion(GetMethod(iterator, "return")).
662-
let inner_result = if let TryResult::Continue(inner_result) = try_get_object_method(
662+
let inner_result = if let Some(inner_result) = try_result_into_js(try_get_object_method(
663663
agent,
664664
iterator,
665665
BUILTIN_STRING_MEMORY.r#return.into(),
666666
gc.nogc(),
667-
) {
667+
))
668+
.unbind()?
669+
.bind(gc.nogc())
670+
{
668671
// Note: completion.[[Type]] is known to not be throw, so if
669672
// innerResult.[[Type]] is throw then the following steps mean that
670673
// "rethrow innerResult immediately". Hence we can use the ? operator
671674
// below.
672675
// 4. If innerResult.[[Type]] is normal, then
673676
// 5. If completion.[[Type]] is throw, return ? completion.
674677
// 6. If innerResult.[[Type]] is throw, return ? innerResult.
675-
inner_result.unbind()?.bind(gc.nogc())
678+
inner_result
676679
} else {
677680
let scoped_iterator = iterator.scope(agent, gc.nogc());
678681
let inner_result = get_object_method(

0 commit comments

Comments
 (0)