v8/test/cctest/interpreter/bytecode_expectations/Generators.golden
Sathya Gunasekaran c805d5e317 [parser] Provide better error when destructuring callable
The patch changes CallPrinter's AST traversal to continue even after
the first positive match for an AST node. This helps us check for the
subsequent GetIterator AST node in case of destructuring.

We can not differentiate between the function call failing and the
GetIterator failing based on source position info. This would involve
runtime checks costing performance.

Instead of providing an incorrect error, we provide both the
possiblities to user and allow them to disambiguate.

Previously,
  d8> function f() { return 5; }
  undefined
  d8> var [a] = f();
  (d8):1: TypeError: f is not a function
  var [a] = f();
            ^
  TypeError: f is not a function
      at (d8):1:11


Now,
  d8> function f() { return 5; }
  undefined
  d8> var [a] = f();
  (d8):1: TypeError: f is not a function or its return value is not iterable
  var [a] = f();
            ^
  TypeError: f is not a function or its return value is not iterable
      at (d8):1:11

Bug: v8:6616, v8:6513
Change-Id: I3d6427f10cae54951b0ad0e5ddcbe802bb7191c1
Reviewed-on: https://chromium-review.googlesource.com/594894
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Reviewed-by: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47025}
2017-08-01 01:19:08 +00:00

480 lines
18 KiB
Plaintext

#
# Autogenerated by generate-bytecode-expectations.
#
---
wrap: no
test function name: f
---
snippet: "
function* f() { }
f();
"
frame size: 5
parameter count: 1
bytecode array length: 85
bytecodes: [
B(Mov), R(new_target), R(1),
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(1),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(1), I8(0),
B(LdaSmi), I8(81),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(Mov), R(closure), R(3),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(Star), R(0),
/* 11 E> */ B(StackCheck),
B(Star), R(1),
/* 11 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 16 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(1), U8(2), I8(0),
B(Ldar), R(3),
/* 11 E> */ B(Throw),
B(Ldar), R(3),
/* 16 S> */ B(Return),
B(LdaUndefined),
/* 16 S> */ B(Return),
]
constant pool: [
Smi [38],
Smi [10],
Smi [7],
]
handlers: [
]
---
snippet: "
function* f() { yield 42 }
f();
"
frame size: 5
parameter count: 1
bytecode array length: 130
bytecodes: [
B(Mov), R(new_target), R(1),
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(1),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0),
B(LdaSmi), I8(81),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(Mov), R(closure), R(3),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(Star), R(0),
/* 11 E> */ B(StackCheck),
B(Star), R(1),
/* 11 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 25 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
/* 11 E> */ B(Throw),
B(Ldar), R(3),
/* 25 S> */ B(Return),
/* 16 S> */ B(LdaSmi), I8(42),
B(Star), R(3),
B(LdaFalse),
B(Star), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(3), U8(2),
B(SuspendGenerator), R(1), R(0), U8(3), U8(1),
/* 25 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(4), U8(2), I8(0),
B(Ldar), R(3),
/* 16 E> */ B(Throw),
B(Ldar), R(3),
/* 25 S> */ B(Return),
B(LdaUndefined),
/* 25 S> */ B(Return),
]
constant pool: [
Smi [38],
Smi [83],
Smi [10],
Smi [7],
Smi [10],
Smi [7],
]
handlers: [
]
---
snippet: "
function* f() { for (let x of [42]) yield x }
f();
"
frame size: 18
parameter count: 1
bytecode array length: 422
bytecodes: [
B(Mov), R(new_target), R(10),
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(10), U8(1),
B(PushContext), R(12),
B(RestoreGeneratorState), R(10),
B(Star), R(11),
B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0),
B(LdaSmi), I8(81),
B(Star), R(12),
B(CallRuntime), U16(Runtime::kAbort), R(12), U8(1),
B(LdaSmi), I8(-2),
B(Star), R(11),
B(Mov), R(closure), R(12),
B(Mov), R(this), R(13),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(12), U8(2),
B(Star), R(2),
/* 11 E> */ B(StackCheck),
B(Star), R(10),
/* 11 E> */ B(SuspendGenerator), R(10), R(0), U8(12), U8(0),
/* 44 S> */ B(Return),
B(RestoreGeneratorRegisters), R(10), R(0), U8(12),
B(LdaSmi), I8(-2),
B(Star), R(11),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(10), U8(1),
B(Star), R(12),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(10), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(12),
/* 11 E> */ B(Throw),
B(Ldar), R(12),
/* 44 S> */ B(Return),
B(LdaTheHole),
B(Star), R(1),
B(LdaZero),
B(Star), R(6),
B(Mov), R(context), R(14),
B(Mov), R(context), R(15),
/* 30 S> */ B(CreateArrayLiteral), U8(4), U8(0), U8(37),
B(Star), R(16),
B(LdaNamedProperty), R(16), U8(5), U8(1),
B(Star), R(17),
B(CallProperty0), R(17), R(16), U8(3),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(4),
B(Ldar), R(11),
B(SwitchOnSmiNoFeedback), U8(6), U8(1), I8(1),
B(LdaSmi), I8(-2),
/* 30 E> */ B(TestEqualStrictNoFeedback), R(11),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(81),
B(Star), R(16),
B(CallRuntime), U16(Runtime::kAbort), R(16), U8(1),
/* 25 S> */ B(LdaNamedProperty), R(4), U8(7), U8(7),
B(Star), R(16),
B(CallProperty0), R(16), R(4), U8(5),
B(Star), R(5),
/* 25 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(5), U8(1),
B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1),
B(LdaNamedProperty), R(5), U8(8), U8(9),
B(JumpIfToBooleanTrue), U8(74),
B(LdaNamedProperty), R(5), U8(9), U8(11),
B(Star), R(7),
B(LdaSmi), I8(2),
B(Star), R(6),
B(Mov), R(7), R(3),
/* 16 E> */ B(StackCheck),
B(Mov), R(3), R(0),
/* 36 S> */ B(LdaFalse),
B(Star), R(17),
B(Mov), R(0), R(16),
B(InvokeIntrinsic), U8(Runtime::k_CreateIterResultObject), R(16), U8(2),
B(SuspendGenerator), R(10), R(0), U8(16), U8(1),
/* 44 S> */ B(Return),
B(RestoreGeneratorRegisters), R(10), R(0), U8(16),
B(LdaSmi), I8(-2),
B(Star), R(11),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(10), U8(1),
B(Star), R(16),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(10), U8(1),
B(SwitchOnSmiNoFeedback), U8(10), U8(2), I8(0),
B(Ldar), R(16),
/* 36 E> */ B(Throw),
B(LdaZero),
B(Star), R(12),
B(Mov), R(16), R(13),
B(Jump), U8(56),
B(LdaZero),
B(Star), R(6),
B(JumpLoop), U8(120), I8(0),
B(Jump), U8(36),
B(Star), R(16),
B(Ldar), R(closure),
B(CreateCatchContext), R(16), U8(12), U8(13),
B(PushContext), R(16),
B(Star), R(15),
B(LdaSmi), I8(2),
B(TestEqualStrict), R(6), U8(13),
B(JumpIfFalse), U8(6),
B(LdaSmi), I8(1),
B(Star), R(6),
B(LdaImmutableCurrentContextSlot), U8(4),
B(Star), R(17),
B(CallRuntime), U16(Runtime::kReThrow), R(17), U8(1),
B(PopContext), R(16),
B(LdaSmi), I8(-1),
B(Star), R(12),
B(Jump), U8(8),
B(Star), R(13),
B(LdaSmi), I8(1),
B(Star), R(12),
B(LdaTheHole),
B(SetPendingMessage),
B(Star), R(14),
B(LdaZero),
B(TestEqualStrict), R(6), U8(14),
B(JumpIfTrue), U8(104),
B(LdaNamedProperty), R(4), U8(14), U8(15),
B(Star), R(8),
B(TestUndetectable),
B(JumpIfFalse), U8(4),
B(Jump), U8(93),
B(LdaSmi), I8(1),
B(TestEqualStrict), R(6), U8(18),
B(JumpIfFalse), U8(61),
B(Ldar), R(8),
B(TestTypeOf), U8(5),
B(JumpIfFalse), U8(4),
B(Jump), U8(18),
B(Wide), B(LdaSmi), I16(134),
B(Star), R(15),
B(LdaConstant), U8(15),
B(Star), R(16),
B(CallRuntime), U16(Runtime::kNewTypeError), R(15), U8(2),
B(Throw),
B(Mov), R(context), R(15),
B(Mov), R(8), R(16),
B(Mov), R(4), R(17),
B(InvokeIntrinsic), U8(Runtime::k_Call), R(16), U8(2),
B(Jump), U8(20),
B(Star), R(16),
B(Ldar), R(closure),
B(CreateCatchContext), R(16), U8(12), U8(16),
B(Star), R(15),
B(LdaTheHole),
B(SetPendingMessage),
B(Ldar), R(15),
B(PushContext), R(16),
B(PopContext), R(16),
B(Jump), U8(27),
B(Mov), R(8), R(15),
B(Mov), R(4), R(16),
B(InvokeIntrinsic), U8(Runtime::k_Call), R(15), U8(2),
B(Star), R(9),
B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(9), U8(1),
B(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1),
B(Ldar), R(14),
B(SetPendingMessage),
B(Ldar), R(12),
B(SwitchOnSmiNoFeedback), U8(17), U8(2), I8(0),
B(Jump), U8(8),
B(Ldar), R(13),
/* 44 S> */ B(Return),
B(Ldar), R(13),
B(ReThrow),
B(LdaUndefined),
/* 44 S> */ B(Return),
]
constant pool: [
Smi [38],
Smi [103],
Smi [10],
Smi [7],
TUPLE2_TYPE,
SYMBOL_TYPE,
Smi [82],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
Smi [15],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE [".catch"],
FIXED_ARRAY_TYPE,
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE [""],
FIXED_ARRAY_TYPE,
Smi [6],
Smi [9],
]
handlers: [
[92, 279, 285],
[95, 243, 245],
[346, 356, 358],
]
---
snippet: "
function* g() { yield 42 }
function* f() { yield* g() }
f();
"
frame size: 10
parameter count: 1
bytecode array length: 284
bytecodes: [
B(Mov), R(new_target), R(1),
B(Ldar), R(new_target),
B(JumpIfUndefined), U8(25),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetContext), R(1), U8(1),
B(PushContext), R(3),
B(RestoreGeneratorState), R(1),
B(Star), R(2),
B(SwitchOnSmiNoFeedback), U8(0), U8(2), I8(0),
B(LdaSmi), I8(81),
B(Star), R(3),
B(CallRuntime), U16(Runtime::kAbort), R(3), U8(1),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(Mov), R(closure), R(3),
B(Mov), R(this), R(4),
B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(3), U8(2),
B(Star), R(0),
/* 38 E> */ B(StackCheck),
B(Star), R(1),
/* 38 E> */ B(SuspendGenerator), R(1), R(0), U8(3), U8(0),
/* 54 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(3),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(3),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
B(Ldar), R(3),
/* 38 E> */ B(Throw),
B(Ldar), R(3),
/* 54 S> */ B(Return),
/* 43 S> */ B(LdaGlobal), U8(4), U8(2),
B(Star), R(9),
/* 50 E> */ B(CallUndefinedReceiver0), R(9), U8(0),
B(Star), R(7),
B(LdaNamedProperty), R(7), U8(5), U8(4),
B(Star), R(8),
B(CallProperty0), R(8), R(7), U8(16),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
B(Star), R(5),
B(LdaUndefined),
B(Star), R(6),
B(LdaZero),
B(Star), R(4),
B(Ldar), R(2),
B(SwitchOnSmiNoFeedback), U8(6), U8(1), I8(1),
B(LdaSmi), I8(-2),
B(TestEqualStrictNoFeedback), R(2),
B(JumpIfTrue), U8(11),
B(LdaSmi), I8(81),
B(Star), R(9),
B(CallRuntime), U16(Runtime::kAbort), R(9), U8(1),
B(Ldar), R(4),
B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(1),
B(LdaNamedProperty), R(5), U8(9), U8(8),
B(Star), R(9),
B(CallProperty1), R(9), R(5), R(6), U8(22),
B(Jump), U8(65),
B(LdaNamedProperty), R(5), U8(10), U8(6),
B(JumpIfUndefined), U8(13),
B(JumpIfNull), U8(11),
B(Star), R(9),
B(CallProperty1), R(9), R(5), R(6), U8(18),
B(Jump), U8(48),
B(Ldar), R(6),
/* 54 S> */ B(Return),
B(LdaNamedProperty), R(5), U8(11), U8(10),
B(JumpIfUndefined), U8(13),
B(JumpIfNull), U8(11),
B(Star), R(9),
B(CallProperty1), R(9), R(5), R(6), U8(24),
B(Jump), U8(28),
B(LdaNamedProperty), R(5), U8(10), U8(6),
B(Star), R(9),
B(JumpIfUndefined), U8(15),
B(JumpIfNull), U8(13),
B(CallProperty0), R(9), R(5), U8(20),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
B(CallRuntime), U16(Runtime::kThrowThrowMethodMissing), R(0), U8(0),
B(Star), R(3),
B(JumpIfJSReceiver), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
B(LdaNamedProperty), R(3), U8(12), U8(12),
B(JumpIfToBooleanTrue), U8(33),
B(Ldar), R(3),
B(SuspendGenerator), R(1), R(0), U8(9), U8(1),
/* 54 S> */ B(Return),
B(RestoreGeneratorRegisters), R(1), R(0), U8(9),
B(LdaSmi), I8(-2),
B(Star), R(2),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetInputOrDebugPos), R(1), U8(1),
B(Star), R(6),
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(1), U8(1),
B(Star), R(4),
B(JumpLoop), U8(146), I8(0),
B(LdaNamedProperty), R(3), U8(13), U8(14),
B(Star), R(5),
B(LdaSmi), I8(1),
B(TestEqualStrictNoFeedback), R(4),
B(JumpIfFalse), U8(5),
B(Ldar), R(5),
/* 54 S> */ B(Return),
B(LdaUndefined),
/* 54 S> */ B(Return),
]
constant pool: [
Smi [38],
Smi [101],
Smi [10],
Smi [7],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["g"],
SYMBOL_TYPE,
Smi [124],
Smi [17],
Smi [37],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["throw"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
]
handlers: [
]