Commit 23dace88 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

Suppress GetMethod errors in IteratorClose

Normative change in ecma262 [1].

Errors thrown by GetMethod(iterator, "return") are suppressed in favor
of the original exception.

[1] https://github.com/tc39/ecma262/pull/1408

Bug: v8:10397
Change-Id: I0dea8bd677c557cced7103c846416bd81f06f482
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2183400
Commit-Queue: Shu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67662}
parent 12ac48d2
......@@ -109,7 +109,8 @@ namespace array {
mappedValue = Call(
context, UnsafeCast<Callable>(mapfn), thisArg, nextValue, k);
} catch (e) {
iterator::IteratorCloseOnException(iteratorRecord, e);
iterator::IteratorCloseOnException(iteratorRecord);
ReThrow(context, e);
}
} else {
mappedValue = nextValue;
......@@ -121,7 +122,8 @@ namespace array {
try {
FastCreateDataProperty(a, k, mappedValue);
} catch (e) deferred {
iterator::IteratorCloseOnException(iteratorRecord, e);
iterator::IteratorCloseOnException(iteratorRecord);
ReThrow(context, e);
}
// x. Set k to k + 1.
k += 1;
......
......@@ -334,8 +334,9 @@ void BaseCollectionsAssembler::AddConstructorEntriesFromIterable(
}
BIND(&if_exception);
{
iterator_assembler.IteratorCloseOnException(context, iterator,
var_exception.value());
IteratorCloseOnException(context, iterator);
CallRuntime(Runtime::kReThrow, context, var_exception.value());
Unreachable();
}
BIND(&exit);
}
......
......@@ -133,49 +133,6 @@ TNode<Object> IteratorBuiltinsAssembler::IteratorValue(
return var_value.value();
}
void IteratorBuiltinsAssembler::IteratorCloseOnException(
TNode<Context> context, const IteratorRecord& iterator, Label* if_exception,
TVariable<Object>* exception) {
// Perform ES #sec-iteratorclose when an exception occurs. This simpler
// algorithm does not include redundant steps which are never reachable from
// the spec IteratorClose algorithm.
DCHECK((if_exception != nullptr && exception != nullptr));
CSA_ASSERT(this, IsNotTheHole(exception->value()));
CSA_ASSERT(this, IsJSReceiver(iterator.object));
// Let return be ? GetMethod(iterator, "return").
TNode<Object> method;
{
compiler::ScopedExceptionHandler handler(this, if_exception, exception);
method = GetProperty(context, iterator.object, factory()->return_string());
}
// If return is undefined, return Completion(completion).
GotoIf(Word32Or(IsUndefined(method), IsNull(method)), if_exception);
{
// Let innerResult be Call(return, iterator, « »).
// If an exception occurs, the original exception remains bound.
compiler::ScopedExceptionHandler handler(this, if_exception, nullptr);
Call(context, method, iterator.object);
}
// (If completion.[[Type]] is throw) return Completion(completion).
Goto(if_exception);
}
void IteratorBuiltinsAssembler::IteratorCloseOnException(
TNode<Context> context, const IteratorRecord& iterator,
TNode<Object> exception) {
Label rethrow(this, Label::kDeferred);
TVARIABLE(Object, exception_variable, exception);
IteratorCloseOnException(context, iterator, &rethrow, &exception_variable);
BIND(&rethrow);
CallRuntime(Runtime::kReThrow, context, exception_variable.value());
Unreachable();
}
TNode<JSArray> IteratorBuiltinsAssembler::IterableToList(
TNode<Context> context, TNode<Object> iterable, TNode<Object> iterator_fn) {
GrowableFixedArray values(state());
......@@ -311,7 +268,9 @@ TNode<JSArray> IteratorBuiltinsAssembler::StringListFromIterable(
// 2. Return ? IteratorClose(iteratorRecord, error).
BIND(&if_exception);
IteratorCloseOnException(context, iterator_record, var_exception.value());
IteratorCloseOnException(context, iterator_record);
CallRuntime(Runtime::kReThrow, context, var_exception.value());
Unreachable();
}
}
......
......@@ -52,15 +52,6 @@ class IteratorBuiltinsAssembler : public CodeStubAssembler {
TNode<Context> context, TNode<JSReceiver> result,
base::Optional<TNode<Map>> fast_iterator_result_map = base::nullopt);
// https://tc39.github.io/ecma262/#sec-iteratorclose
void IteratorCloseOnException(TNode<Context> context,
const IteratorRecord& iterator,
Label* if_exception,
TVariable<Object>* exception);
void IteratorCloseOnException(TNode<Context> context,
const IteratorRecord& iterator,
TNode<Object> exception);
// #sec-iterabletolist
// Build a JSArray by iterating over {iterable} using {iterator_fn},
// following the ECMAscript operation with the same name.
......
......@@ -37,9 +37,6 @@ namespace iterator {
extern macro IteratorBuiltinsAssembler::IteratorValue(
implicit context: Context)(JSReceiver, Map): JSAny;
extern macro IteratorBuiltinsAssembler::IteratorCloseOnException(
implicit context: Context)(IteratorRecord, JSAny): never;
extern macro IteratorBuiltinsAssembler::IterableToList(
implicit context: Context)(JSAny, JSAny): JSArray;
......@@ -80,30 +77,26 @@ namespace iterator {
return Call(context, iteratorCallable, receiver);
}
transitioning
macro IteratorCloseOnException(implicit context: Context)(
iterator: IteratorRecord, exception: Object): never labels
IfException(Object) {
// Let return be ? GetMethod(iterator, "return").
let method: JSAny;
// https://tc39.es/ecma262/#sec-iteratorclose
@export
transitioning macro IteratorCloseOnException(implicit context: Context)(
iterator: IteratorRecord) {
try {
method = GetProperty(iterator.object, kReturnString);
} catch (e) {
goto IfException(e);
}
// 4. Let innerResult be GetMethod(iterator, "return").
const method = GetProperty(iterator.object, kReturnString);
// If return is undefined, return Completion(completion).
if (method == Undefined || method == Null) goto IfException(exception);
// 5. If innerResult.[[Type]] is normal, then
// a. Let return be innerResult.[[Value]].
// b. If return is undefined, return Completion(completion).
if (method == Undefined || method == Null) return;
// Let innerResult be Call(return, iterator, « »).
// If an exception occurs, the original exception remains bound
try {
// c. Set innerResult to Call(return, iterator).
// If an exception occurs, the original exception remains bound
Call(context, method, iterator.object);
} catch (_e) {
goto IfException(exception);
// Swallow the exception.
}
// (If completion.[[Type]] is throw) return Completion(completion).
goto IfException(exception);
}
}
......@@ -57,7 +57,8 @@ namespace object {
}
return result;
} catch (e) deferred {
iterator::IteratorCloseOnException(i, e);
iterator::IteratorCloseOnException(i);
ReThrow(context, e);
}
} label Throw deferred {
ThrowTypeError(MessageTemplate::kNotIterable);
......
......@@ -270,7 +270,8 @@ namespace promise {
index += 1;
}
} catch (e) deferred {
iterator::IteratorCloseOnException(iter, e) otherwise Reject;
iterator::IteratorCloseOnException(iter);
goto Reject(e);
}
} label Done {}
......
......@@ -279,8 +279,8 @@ namespace promise {
}
}
} catch (e) deferred {
iterator::IteratorCloseOnException(iteratorRecord, e)
otherwise Reject;
iterator::IteratorCloseOnException(iteratorRecord);
goto Reject(e);
} label Done {}
// (8.d)
......
......@@ -117,7 +117,8 @@ namespace promise {
}
}
} catch (e) deferred {
iterator::IteratorCloseOnException(i, e) otherwise Reject;
iterator::IteratorCloseOnException(i);
goto Reject(e);
}
} label Reject(exception: Object) deferred {
Call(
......
......@@ -3538,16 +3538,15 @@ BytecodeGenerator::AssignmentLhsData BytecodeGenerator::PrepareAssignmentLhs(
// In pseudo-code, this builds:
//
// if (!done) {
// let method = iterator.return
// if (method !== null && method !== undefined) {
// try {
// if (typeof(method) !== "function") throw TypeError
// try {
// let method = iterator.return
// if (method !== null && method !== undefined) {
// let return_val = method.call(iterator)
// if (!%IsObject(return_val)) throw TypeError
// } catch (e) {
// if (iteration_continuation != RETHROW)
// rethrow e
// }
// } catch (e) {
// if (iteration_continuation != RETHROW)
// rethrow e
// }
// }
//
......@@ -3562,44 +3561,24 @@ void BytecodeGenerator::BuildFinalizeIteration(
builder()->LoadAccumulatorWithRegister(done).JumpIfTrue(
ToBooleanMode::kConvertToBoolean, iterator_is_done.New());
// method = iterator.return
// if (method !== null && method !== undefined) {
Register method = register_allocator()->NewRegister();
builder()
->LoadNamedProperty(iterator.object(),
ast_string_constants()->return_string(),
feedback_index(feedback_spec()->AddLoadICSlot()))
.StoreAccumulatorInRegister(method)
.JumpIfUndefinedOrNull(iterator_is_done.New());
{
RegisterAllocationScope register_scope(this);
BuildTryCatch(
// try {
// if (typeof(method) !== "function") throw TypeError
// let return_val = method.call(iterator)
// if (!%IsObject(return_val)) throw TypeError
// let method = iterator.return
// if (method !== null && method !== undefined) {
// let return_val = method.call(iterator)
// if (!%IsObject(return_val)) throw TypeError
// }
// }
[&]() {
BytecodeLabel if_callable;
Register method = register_allocator()->NewRegister();
builder()
->CompareTypeOf(TestTypeOfFlags::LiteralFlag::kFunction)
.JumpIfTrue(ToBooleanMode::kAlreadyBoolean, &if_callable);
{
// throw %NewTypeError(kReturnMethodNotCallable)
RegisterAllocationScope register_scope(this);
RegisterList new_type_error_args =
register_allocator()->NewRegisterList(2);
builder()
->LoadLiteral(
Smi::FromEnum(MessageTemplate::kReturnMethodNotCallable))
.StoreAccumulatorInRegister(new_type_error_args[0])
.LoadLiteral(ast_string_constants()->empty_string())
.StoreAccumulatorInRegister(new_type_error_args[1])
.CallRuntime(Runtime::kNewTypeError, new_type_error_args)
.Throw();
}
builder()->Bind(&if_callable);
->LoadNamedProperty(
iterator.object(), ast_string_constants()->return_string(),
feedback_index(feedback_spec()->AddLoadICSlot()))
.JumpIfUndefinedOrNull(iterator_is_done.New())
.StoreAccumulatorInRegister(method);
RegisterList args(iterator.object());
builder()->CallProperty(
......
......@@ -208,9 +208,9 @@ snippet: "
async function* f() { for (let x of [42]) yield x }
f();
"
frame size: 19
frame size: 18
parameter count: 1
bytecode array length: 361
bytecode array length: 341
bytecodes: [
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
B(Mov), R(closure), R(4),
......@@ -230,7 +230,7 @@ bytecodes: [
B(LdaSmi), I8(1),
B(Star), R(4),
B(Mov), R(8), R(5),
B(JumpConstant), U8(15),
B(Jump), U8(247),
/* 36 S> */ B(CreateArrayLiteral), U8(4), U8(0), U8(37),
B(Star), R(10),
B(GetIterator), R(10), U8(1), U8(3),
......@@ -285,34 +285,26 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(13),
B(Ldar), R(10),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(15),
B(LdaNamedProperty), R(9), U8(10), U8(13),
B(Star), R(15),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(16),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(17),
B(LdaConstant), U8(11),
B(Star), R(18),
B(CallRuntime), U16(Runtime::kNewTypeError), R(17), U8(2),
B(Throw),
B(CallProperty0), R(15), R(9), U8(15),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(16),
B(CallProperty0), R(16), R(9), U8(15),
B(JumpIfJSReceiver), U8(21),
B(Star), R(17),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(17), U8(1),
B(Jump), U8(12),
B(Star), R(16),
B(Star), R(15),
B(LdaZero),
B(TestReferenceEqual), R(11),
B(JumpIfTrue), U8(5),
B(Ldar), R(16),
B(Ldar), R(15),
B(ReThrow),
B(Ldar), R(13),
B(SetPendingMessage),
B(Ldar), R(11),
B(SwitchOnSmiNoFeedback), U8(12), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(0),
B(Jump), U8(14),
B(Ldar), R(12),
B(ReThrow),
......@@ -326,7 +318,7 @@ bytecodes: [
B(Star), R(4),
B(Jump), U8(41),
B(Star), R(8),
B(CreateCatchContext), R(8), U8(14),
B(CreateCatchContext), R(8), U8(13),
B(Star), R(7),
B(LdaTheHole),
B(SetPendingMessage),
......@@ -351,7 +343,7 @@ bytecodes: [
B(Ldar), R(6),
B(SetPendingMessage),
B(Ldar), R(4),
B(SwitchOnSmiNoFeedback), U8(16), U8(3), I8(0),
B(SwitchOnSmiNoFeedback), U8(14), U8(3), I8(0),
B(Jump), U8(22),
B(Ldar), R(5),
B(ReThrow),
......@@ -378,20 +370,18 @@ constant pool: [
Smi [16],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
Smi [6],
Smi [9],
SCOPE_INFO_TYPE,
Smi [267],
Smi [6],
Smi [9],
Smi [23],
]
handlers: [
[19, 315, 315],
[22, 281, 281],
[19, 295, 295],
[22, 261, 261],
[86, 172, 180],
[204, 237, 239],
[196, 217, 219],
]
---
......
......@@ -10,9 +10,9 @@ snippet: "
var x, a = [0,1,2,3];
[x] = a;
"
frame size: 14
frame size: 13
parameter count: 1
bytecode array length: 166
bytecode array length: 146
bytecodes: [
/* 45 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
B(Star), R(1),
......@@ -55,29 +55,21 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(8),
B(Ldar), R(5),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(10),
B(LdaNamedProperty), R(4), U8(4), U8(13),
B(Star), R(10),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(11),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(12),
B(LdaConstant), U8(5),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2),
B(Throw),
B(CallProperty0), R(10), R(4), U8(15),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(11),
B(CallProperty0), R(11), R(4), U8(15),
B(JumpIfJSReceiver), U8(21),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1),
B(Jump), U8(12),
B(Star), R(11),
B(Star), R(10),
B(LdaZero),
B(TestReferenceEqual), R(6),
B(JumpIfTrue), U8(5),
B(Ldar), R(11),
B(Ldar), R(10),
B(ReThrow),
B(Ldar), R(8),
B(SetPendingMessage),
......@@ -95,11 +87,10 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
]
handlers: [
[34, 76, 84],
[108, 141, 143],
[100, 121, 123],
]
---
......@@ -107,9 +98,9 @@ snippet: "
var x, y, a = [0,1,2,3];
[,x,...y] = a;
"
frame size: 15
frame size: 14
parameter count: 1
bytecode array length: 252
bytecode array length: 232
bytecodes: [
/* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
B(Star), R(2),
......@@ -186,29 +177,21 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(9),
B(Ldar), R(6),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(11),
B(LdaNamedProperty), R(5), U8(4), U8(23),
B(Star), R(11),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(12),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(13),
B(LdaConstant), U8(5),
B(Star), R(14),
B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2),
B(Throw),
B(CallProperty0), R(11), R(5), U8(25),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(12),
B(CallProperty0), R(12), R(5), U8(25),
B(JumpIfJSReceiver), U8(21),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1),
B(Jump), U8(12),
B(Star), R(12),
B(Star), R(11),
B(LdaZero),
B(TestReferenceEqual), R(7),
B(JumpIfTrue), U8(5),
B(Ldar), R(12),
B(Ldar), R(11),
B(ReThrow),
B(Ldar), R(9),
B(SetPendingMessage),
......@@ -226,11 +209,10 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
]
handlers: [
[34, 162, 170],
[194, 227, 229],
[186, 207, 209],
]
---
......@@ -238,9 +220,9 @@ snippet: "
var x={}, y, a = [0];
[x.foo,y=4] = a;
"
frame size: 16
frame size: 15
parameter count: 1
bytecode array length: 217
bytecode array length: 197
bytecodes: [
/* 40 S> */ B(CreateEmptyObjectLiteral),
B(Star), R(0),
......@@ -304,29 +286,21 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(9),
B(Ldar), R(6),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(12),
B(LdaNamedProperty), R(5), U8(5), U8(17),
B(Star), R(12),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(13),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(14),
B(LdaConstant), U8(6),
B(Star), R(15),
B(CallRuntime), U16(Runtime::kNewTypeError), R(14), U8(2),
B(Throw),
B(CallProperty0), R(12), R(5), U8(19),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(13),
B(CallProperty0), R(13), R(5), U8(19),
B(JumpIfJSReceiver), U8(21),
B(Star), R(14),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1),
B(Jump), U8(12),
B(Star), R(13),
B(Star), R(12),
B(LdaZero),
B(TestReferenceEqual), R(7),
B(JumpIfTrue), U8(5),
B(Ldar), R(13),
B(Ldar), R(12),
B(ReThrow),
B(Ldar), R(9),
B(SetPendingMessage),
......@@ -345,11 +319,10 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["foo"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
]
handlers: [
[37, 127, 135],
[159, 192, 194],
[151, 172, 174],
]
---
......
......@@ -9,9 +9,9 @@ wrap: yes
snippet: "
for (var p of [0, 1, 2]) {}
"
frame size: 13
frame size: 12
parameter count: 1
bytecode array length: 163
bytecode array length: 143
bytecodes: [
/* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
B(Star), R(4),
......@@ -51,29 +51,21 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(7),
B(Ldar), R(4),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(9),
B(LdaNamedProperty), R(3), U8(4), U8(13),
B(Star), R(9),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(10),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(11),
B(LdaConstant), U8(5),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2),
B(Throw),
B(CallProperty0), R(9), R(3), U8(15),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(10),
B(CallProperty0), R(10), R(3), U8(15),
B(JumpIfJSReceiver), U8(21),
B(Star), R(11),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1),
B(Jump), U8(12),
B(Star), R(10),
B(Star), R(9),
B(LdaZero),
B(TestReferenceEqual), R(5),
B(JumpIfTrue), U8(5),
B(Ldar), R(10),
B(Ldar), R(9),
B(ReThrow),
B(Ldar), R(7),
B(SetPendingMessage),
......@@ -91,11 +83,10 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
]
handlers: [
[31, 73, 81],
[105, 138, 140],
[97, 118, 120],
]
---
......@@ -103,9 +94,9 @@ snippet: "
var x = 'potatoes';
for (var p of x) { return p; }
"
frame size: 14
frame size: 13
parameter count: 1
bytecode array length: 171
bytecode array length: 151
bytecodes: [
/* 42 S> */ B(LdaConstant), U8(0),
B(Star), R(0),
......@@ -147,34 +138,26 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(8),
B(Ldar), R(5),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(10),
B(LdaNamedProperty), R(4), U8(4), U8(12),
B(Star), R(10),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(11),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(12),
B(LdaConstant), U8(5),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kNewTypeError), R(12), U8(2),
B(Throw),
B(CallProperty0), R(10), R(4), U8(14),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(11),
B(CallProperty0), R(11), R(4), U8(14),
B(JumpIfJSReceiver), U8(21),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1),
B(Jump), U8(12),
B(Star), R(11),
B(Star), R(10),
B(LdaZero),
B(TestReferenceEqual), R(6),
B(JumpIfTrue), U8(5),
B(Ldar), R(11),
B(Ldar), R(10),
B(ReThrow),
B(Ldar), R(8),
B(SetPendingMessage),
B(Ldar), R(6),
B(SwitchOnSmiNoFeedback), U8(6), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(5), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(7),
B(ReThrow),
......@@ -189,13 +172,12 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
Smi [6],
Smi [9],
]
handlers: [
[29, 75, 83],
[107, 140, 142],
[99, 120, 122],
]
---
......@@ -205,9 +187,9 @@ snippet: "
if (x == 20) break;
}
"
frame size: 13
frame size: 12
parameter count: 1
bytecode array length: 179
bytecode array length: 159
bytecodes: [
/* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
B(Star), R(4),
......@@ -254,29 +236,21 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(7),
B(Ldar), R(4),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(9),
B(LdaNamedProperty), R(3), U8(4), U8(15),
B(Star), R(9),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(10),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(11),
B(LdaConstant), U8(5),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2),
B(Throw),
B(CallProperty0), R(9), R(3), U8(17),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(10),
B(CallProperty0), R(10), R(3), U8(17),
B(JumpIfJSReceiver), U8(21),
B(Star), R(11),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1),
B(Jump), U8(12),
B(Star), R(10),
B(Star), R(9),
B(LdaZero),
B(TestReferenceEqual), R(5),
B(JumpIfTrue), U8(5),
B(Ldar), R(10),
B(Ldar), R(9),
B(ReThrow),
B(Ldar), R(7),
B(SetPendingMessage),
......@@ -294,11 +268,10 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
]
handlers: [
[31, 89, 97],
[121, 154, 156],
[113, 134, 136],
]
---
......@@ -306,9 +279,9 @@ snippet: "
var x = { 'a': 1, 'b': 2 };
for (x['a'] of [1,2,3]) { return x['a']; }
"
frame size: 13
frame size: 12
parameter count: 1
bytecode array length: 185
bytecode array length: 165
bytecodes: [
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41),
B(Star), R(0),
......@@ -354,34 +327,26 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(6),
B(Ldar), R(3),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(9),
B(LdaNamedProperty), R(2), U8(6), U8(18),
B(Star), R(9),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(10),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(11),
B(LdaConstant), U8(7),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kNewTypeError), R(11), U8(2),
B(Throw),
B(CallProperty0), R(9), R(2), U8(20),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(10),
B(CallProperty0), R(10), R(2), U8(20),
B(JumpIfJSReceiver), U8(21),
B(Star), R(11),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1),
B(Jump), U8(12),
B(Star), R(10),
B(Star), R(9),
B(LdaZero),
B(TestReferenceEqual), R(4),
B(JumpIfTrue), U8(5),
B(Ldar), R(10),
B(Ldar), R(9),
B(ReThrow),
B(Ldar), R(6),
B(SetPendingMessage),
B(Ldar), R(4),
B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(5),
B(ReThrow),
......@@ -398,12 +363,11 @@ constant pool: [
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
Smi [6],
Smi [9],
]
handlers: [
[37, 89, 97],
[121, 154, 156],
[113, 134, 136],
]
......@@ -96,9 +96,9 @@ snippet: "
function* f() { for (let x of [42]) yield x }
f();
"
frame size: 15
frame size: 14
parameter count: 1
bytecode array length: 251
bytecode array length: 231
bytecodes: [
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
B(Mov), R(closure), R(4),
......@@ -167,34 +167,26 @@ bytecodes: [
B(SetPendingMessage),
B(Star), R(9),
B(Ldar), R(6),
B(JumpIfToBooleanTrue), U8(58),
B(JumpIfToBooleanTrue), U8(38),
B(Mov), R(context), R(11),
B(LdaNamedProperty), R(5), U8(10), U8(13),
B(Star), R(11),
B(JumpIfUndefinedOrNull), U8(50),
B(Mov), R(context), R(12),
B(TestTypeOf), U8(6),
B(JumpIfTrue), U8(18),
B(Wide), B(LdaSmi), I16(159),
B(Star), R(13),
B(LdaConstant), U8(11),
B(Star), R(14),
B(CallRuntime), U16(Runtime::kNewTypeError), R(13), U8(2),
B(Throw),
B(CallProperty0), R(11), R(5), U8(15),
B(JumpIfUndefinedOrNull), U8(29),
B(Star), R(12),
B(CallProperty0), R(12), R(5), U8(15),
B(JumpIfJSReceiver), U8(21),
B(Star), R(13),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(13), U8(1),
B(Jump), U8(12),
B(Star), R(12),
B(Star), R(11),
B(LdaZero),
B(TestReferenceEqual), R(7),
B(JumpIfTrue), U8(5),
B(Ldar), R(12),
B(Ldar), R(11),
B(ReThrow),
B(Ldar), R(9),
B(SetPendingMessage),
B(Ldar), R(7),
B(SwitchOnSmiNoFeedback), U8(12), U8(2), I8(0),
B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(8),
B(ReThrow),
......@@ -215,13 +207,12 @@ constant pool: [
Smi [16],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
Smi [6],
Smi [9],
]
handlers: [
[72, 155, 163],
[187, 220, 222],
[179, 200, 202],
]
---
......
......@@ -548,10 +548,6 @@
'built-ins/AsyncFromSyncIteratorPrototype/next/absent-value-not-passed': [FAIL],
'built-ins/AsyncFromSyncIteratorPrototype/return/absent-value-not-passed': [FAIL],
# https://bugs.chromium.org/p/v8/issues/detail?id=10397
'language/statements/for-await-of/iterator-close-throw-get-method-abrupt': [FAIL],
'language/statements/for-of/iterator-close-throw-get-method-abrupt': [FAIL],
# http://crbug/v8/10449
'built-ins/Atomics/waitAsync/bad-range': [FAIL],
'built-ins/Atomics/waitAsync/descriptor': [FAIL],
......
......@@ -682,7 +682,8 @@ namespace test {
// IteratorBuiltinsAssembler match the signatures provided in
// iterator.tq.
@export
macro TestIterator(implicit context: Context)(o: JSReceiver, map: Map) {
transitioning macro TestIterator(implicit context:
Context)(o: JSReceiver, map: Map) {
try {
const t1: JSAny = iterator::GetIteratorMethod(o);
const t2: iterator::IteratorRecord = iterator::GetIterator(o);
......@@ -690,12 +691,12 @@ namespace test {
const _t3: JSAny = iterator::IteratorStep(t2) otherwise Fail;
const _t4: JSAny = iterator::IteratorStep(t2, map) otherwise Fail;
const t5: JSAny = iterator::IteratorValue(o);
const _t5: JSAny = iterator::IteratorValue(o);
const _t6: JSAny = iterator::IteratorValue(o, map);
const _t7: JSArray = iterator::IterableToList(t1, t1);
iterator::IteratorCloseOnException(t2, t5);
iterator::IteratorCloseOnException(t2);
} label Fail {}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment