2016-02-25 12:07:07 +00:00
|
|
|
#
|
|
|
|
# Autogenerated by generate-bytecode-expectations.
|
|
|
|
#
|
|
|
|
|
|
|
|
---
|
|
|
|
wrap: yes
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
for (var p of [0, 1, 2]) {}
|
|
|
|
"
|
2020-05-07 19:34:44 +00:00
|
|
|
frame size: 12
|
2016-02-25 12:07:07 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 127
|
2016-02-25 12:07:07 +00:00
|
|
|
bytecodes: [
|
2017-07-27 12:45:00 +00:00
|
|
|
/* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(GetIterator), R(4), U8(1), U8(3),
|
2019-12-20 14:06:40 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
|
|
|
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(3), U8(1), U8(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(context), R(7),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-01-14 14:15:52 +00:00
|
|
|
/* 43 S> */ B(CallProperty0), R(2), R(3), U8(7),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1),
|
|
|
|
B(LdaNamedProperty), R(8), U8(2), U8(9),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(20),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(LdaNamedProperty), R(8), U8(3), U8(11),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(8), R(1),
|
2019-01-21 09:47:58 +00:00
|
|
|
/* 43 S> */ B(Mov), R(1), R(0),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(8),
|
2021-02-17 14:36:58 +00:00
|
|
|
/* 34 E> */ B(JumpLoop), U8(35), I8(0),
|
2017-01-25 17:39:24 +00:00
|
|
|
B(LdaSmi), I8(-1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
|
|
|
B(Star5),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star6),
|
Revert "[esnext] load `iterator.next` only once at beginning of iteration"
This reverts commit bf4cc9ee154f15942594016777f77d3208230f5f.
Reason for revert: Breaks windows with msvc and linux with gcc
https://build.chromium.org/p/client.v8/builders/V8%20Win64%20-%20msvc/builds/841
https://build.chromium.org/p/client.v8/builders/V8%20Linux%20gcc%204.8/builds/17265
Original change's description:
> [esnext] load `iterator.next` only once at beginning of iteration
>
> https://github.com/tc39/ecma262/pull/988 gained concensus during the
> september 2017 TC39 meetings. This moves the load of the "next" method
> to the very beginning of the iteration protocol, rather than during
> each iteration step.
>
> This impacts:
>
> - yield*
> - for-of loops
> - spread arguments
> - array spreads
>
> In the v8 implementation, this also affects async iteration versions of
> these things (the sole exception being the Async-From-Sync iterator,
> which requires a few more changes to work with this, likely done in a
> followup patch).
>
> This change introduces a new AST node, ResolvedProperty, which can be used
> as a callee by Call nodes to produce the same bytecode as Property calls,
> without observably re-loading the property. This is used in several
> AST-desugarings involving the iteration protocol.
>
> BUG=v8:6861, v8:5699
> R=rmcilroy@chromium.org, neis@chromium.org, adamk@chromium.org
>
> Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
> Change-Id: Ib81106a0182687fc5efea0bc32302ad06376773b
> Reviewed-on: https://chromium-review.googlesource.com/687997
> Commit-Queue: Caitlin Potter <caitp@igalia.com>
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Reviewed-by: Georg Neis <neis@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#50452}
TBR=rmcilroy@chromium.org,adamk@chromium.org,neis@chromium.org,caitp@igalia.com,caitp@chromium.org
Change-Id: I1797c0d596dfd6850d6f0f505f591a7a990dd1f1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6861, v8:5699
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/857616
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50454}
2018-01-09 16:50:16 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2016-11-16 10:46:23 +00:00
|
|
|
B(LdaTheHole),
|
2020-03-11 15:07:16 +00:00
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(4),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(35),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Mov), R(context), R(9),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(3), U8(4), U8(13),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(26),
|
|
|
|
B(Star10),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(CallProperty0), R(10), R(3), U8(15),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfJSReceiver), U8(19),
|
|
|
|
B(Star11),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(11),
|
|
|
|
B(Star9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(5),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Ldar), R(9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(ReThrow),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(7),
|
2016-11-16 10:46:23 +00:00
|
|
|
B(SetPendingMessage),
|
2017-05-16 16:38:52 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(5),
|
2017-05-16 16:38:52 +00:00
|
|
|
B(JumpIfFalse), U8(5),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(6),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(ReThrow),
|
|
|
|
B(LdaUndefined),
|
|
|
|
/* 62 S> */ B(Return),
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
constant pool: [
|
2018-07-05 18:34:09 +00:00
|
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
2016-09-06 16:10:19 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[27, 65, 71],
|
|
|
|
[84, 103, 105],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
var x = 'potatoes';
|
|
|
|
for (var p of x) { return p; }
|
|
|
|
"
|
2020-05-07 19:34:44 +00:00
|
|
|
frame size: 13
|
2016-02-25 12:07:07 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 134
|
2016-02-25 12:07:07 +00:00
|
|
|
bytecodes: [
|
2016-05-11 12:21:56 +00:00
|
|
|
/* 42 S> */ B(LdaConstant), U8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star0),
|
2019-09-06 12:41:00 +00:00
|
|
|
/* 68 S> */ B(GetIterator), R(0), U8(0), U8(2),
|
2019-12-20 14:06:40 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
|
|
|
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(4), U8(1), U8(4),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(context), R(8),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2019-01-14 14:15:52 +00:00
|
|
|
/* 63 S> */ B(CallProperty0), R(3), R(4), U8(6),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(9), U8(1),
|
|
|
|
B(LdaNamedProperty), R(9), U8(2), U8(8),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(23),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(LdaNamedProperty), R(9), U8(3), U8(10),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(9), R(2),
|
2019-01-21 09:47:58 +00:00
|
|
|
/* 63 S> */ B(Mov), R(2), R(1),
|
2019-01-02 16:12:54 +00:00
|
|
|
/* 73 S> */ B(LdaSmi), I8(1),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(9), R(7),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
|
|
|
B(Jump), U8(11),
|
2017-01-25 17:39:24 +00:00
|
|
|
B(LdaSmi), I8(-1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
|
|
|
B(Star6),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star7),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2016-11-16 10:46:23 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(35),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Mov), R(context), R(10),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(4), U8(4), U8(12),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(26),
|
|
|
|
B(Star11),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(CallProperty0), R(11), R(4), U8(14),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfJSReceiver), U8(19),
|
|
|
|
B(Star12),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(12), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(11),
|
|
|
|
B(Star10),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(6),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Ldar), R(10),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(ReThrow),
|
|
|
|
B(Ldar), R(8),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(SetPendingMessage),
|
|
|
|
B(Ldar), R(6),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(5), U8(2), I8(0),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(Jump), U8(8),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(7),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(ReThrow),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(7),
|
[debug] Don't put a source position on internal `Return`s.
Be explicit about source positions for `Return`s in the
BytecodeGenerator, and only do self-healing explicitly in the
`ReturnStatement` translation, where an end position of
`kNoSourcePosition` is turned into the return position of the
function literal.
This allows us to reason more easily about which `Return`s actually
receive a meaningful source position, and in particular it allows us
to construct the internal `Return`s for `yield` and `yield*` with no
source position attached to them. Previously they'd get the source
position for the implicit (final) return attached to it, which confused
the debugger and led to breakpoints being set in the completely wrong
spot.
Considering the simplified example
```
function* foo(){
var a = 1;
}
```
this would previously generate the following bytecode
```
0 : SwitchOnGeneratorState r0, [0], [1] { 0: @20 }
4 : Mov <closure>, r2
7 : Mov <this>, r3
13 E> 10 : InvokeIntrinsic [_CreateJSGeneratorObject], r2-r3
14 : Star0
13 E> 15 : SuspendGenerator r0, r0-r1, [0]
20 : ResumeGenerator r0, r0-r1
24 : Star2
25 : InvokeIntrinsic [_GeneratorGetResumeMode], r0-r0
29 : SwitchOnSmiNoFeedback [1], [2], [0] { 0: @39, 1: @36 }
33 : Ldar r2
13 E> 35 : Throw
36 : Ldar r2
30 S> 38 : Return <=========================== internal Return
27 S> 39 : LdaSmi [1]
41 : Star1
42 : LdaUndefined
30 S> 43 : Return
```
where everything between offset 4 and 42 corresponds to the implicit
yield at the beginning of every generator function, in particular the
code between 20 and 42 corresponds to that initial yields resumption
logic. Notice how the internal Return at offset 38 gets assigned the
source position of the function literal (the same as the implicit
return at the end). This confuses the debugger quite a bit when trying
to set a breakpoint on the closing brace, since it's going in bytecode
order and will thus discover the `Return` at offset 38 first (matching
the source position 30 it's currently looking for) and setting the
breakpoint there. This `Return` bytecode however is only executed when
the generator is resumed via `GeneratorPrototype.return()`, and it'll
not hit when the developer uses the generator normally, which is not
the desired behavior and extremely confusing (especially since stepping
on the other hand works as expected).
With this patch, we no longer slap a source position (and in particular
not the function literal's return position) onto these internal
`Return`s as you can see from the generated bytecode below:
```
0 : SwitchOnGeneratorState r0, [0], [1] { 0: @20 }
4 : Mov <closure>, r2
7 : Mov <this>, r3
13 E> 10 : InvokeIntrinsic [_CreateJSGeneratorObject], r2-r3
14 : Star0
13 E> 15 : SuspendGenerator r0, r0-r1, [0]
20 : ResumeGenerator r0, r0-r1
24 : Star2
25 : InvokeIntrinsic [_GeneratorGetResumeMode], r0-r0
29 : SwitchOnSmiNoFeedback [1], [2], [0] { 0: @39, 1: @36 }
33 : Ldar r2
13 E> 35 : Throw
36 : Ldar r2
38 : Return
27 S> 39 : LdaSmi [1]
41 : Star1
42 : LdaUndefined
30 S> 43 : Return
```
This also allows us to remove the break position finding hack that was
kept in BreakIterator::BreakIndexFromPosition() for generators and
modules.
Fixed: chromium:901819
Change-Id: If19a6b26e2622d49b6b5e54bf7a162747543f970
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2727820
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73119}
2021-03-01 19:04:43 +00:00
|
|
|
B(Return),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(LdaUndefined),
|
|
|
|
/* 85 S> */ B(Return),
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
constant pool: [
|
2016-09-06 16:10:19 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["potatoes"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
|
2017-05-16 11:36:04 +00:00
|
|
|
Smi [6],
|
|
|
|
Smi [9],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[25, 66, 72],
|
|
|
|
[85, 104, 106],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
for (var x of [10, 20, 30]) {
|
|
|
|
if (x == 10) continue;
|
|
|
|
if (x == 20) break;
|
|
|
|
}
|
|
|
|
"
|
2020-05-07 19:34:44 +00:00
|
|
|
frame size: 12
|
2016-02-25 12:07:07 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 143
|
2016-02-25 12:07:07 +00:00
|
|
|
bytecodes: [
|
2017-07-27 12:45:00 +00:00
|
|
|
/* 48 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(GetIterator), R(4), U8(1), U8(3),
|
2019-12-20 14:06:40 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
|
|
|
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(3), U8(1), U8(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(context), R(7),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-01-14 14:15:52 +00:00
|
|
|
/* 43 S> */ B(CallProperty0), R(2), R(3), U8(7),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(8), U8(1),
|
|
|
|
B(LdaNamedProperty), R(8), U8(2), U8(9),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(36),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(LdaNamedProperty), R(8), U8(3), U8(11),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(8), R(1),
|
2019-01-21 09:47:58 +00:00
|
|
|
/* 43 S> */ B(Mov), R(1), R(0),
|
2017-01-25 17:39:24 +00:00
|
|
|
/* 66 S> */ B(LdaSmi), I8(10),
|
2019-01-21 09:47:58 +00:00
|
|
|
/* 72 E> */ B(TestEqual), R(0), U8(13),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(JumpIfFalse), U8(4),
|
2019-01-14 14:15:52 +00:00
|
|
|
/* 79 S> */ B(Jump), U8(11),
|
2017-01-25 17:39:24 +00:00
|
|
|
/* 91 S> */ B(LdaSmi), I8(20),
|
2019-01-21 09:47:58 +00:00
|
|
|
/* 97 E> */ B(TestEqual), R(0), U8(14),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(JumpIfFalse), U8(4),
|
2020-03-20 11:13:04 +00:00
|
|
|
/* 104 S> */ B(Jump), U8(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
/* 34 E> */ B(JumpLoop), U8(51), I8(0),
|
2017-01-25 17:39:24 +00:00
|
|
|
B(LdaSmi), I8(-1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
|
|
|
B(Star5),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star6),
|
Revert "[esnext] load `iterator.next` only once at beginning of iteration"
This reverts commit bf4cc9ee154f15942594016777f77d3208230f5f.
Reason for revert: Breaks windows with msvc and linux with gcc
https://build.chromium.org/p/client.v8/builders/V8%20Win64%20-%20msvc/builds/841
https://build.chromium.org/p/client.v8/builders/V8%20Linux%20gcc%204.8/builds/17265
Original change's description:
> [esnext] load `iterator.next` only once at beginning of iteration
>
> https://github.com/tc39/ecma262/pull/988 gained concensus during the
> september 2017 TC39 meetings. This moves the load of the "next" method
> to the very beginning of the iteration protocol, rather than during
> each iteration step.
>
> This impacts:
>
> - yield*
> - for-of loops
> - spread arguments
> - array spreads
>
> In the v8 implementation, this also affects async iteration versions of
> these things (the sole exception being the Async-From-Sync iterator,
> which requires a few more changes to work with this, likely done in a
> followup patch).
>
> This change introduces a new AST node, ResolvedProperty, which can be used
> as a callee by Call nodes to produce the same bytecode as Property calls,
> without observably re-loading the property. This is used in several
> AST-desugarings involving the iteration protocol.
>
> BUG=v8:6861, v8:5699
> R=rmcilroy@chromium.org, neis@chromium.org, adamk@chromium.org
>
> Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
> Change-Id: Ib81106a0182687fc5efea0bc32302ad06376773b
> Reviewed-on: https://chromium-review.googlesource.com/687997
> Commit-Queue: Caitlin Potter <caitp@igalia.com>
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Reviewed-by: Adam Klein <adamk@chromium.org>
> Reviewed-by: Georg Neis <neis@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#50452}
TBR=rmcilroy@chromium.org,adamk@chromium.org,neis@chromium.org,caitp@igalia.com,caitp@chromium.org
Change-Id: I1797c0d596dfd6850d6f0f505f591a7a990dd1f1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:6861, v8:5699
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/857616
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#50454}
2018-01-09 16:50:16 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2016-11-16 10:46:23 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(4),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(35),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Mov), R(context), R(9),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(3), U8(4), U8(15),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(26),
|
|
|
|
B(Star10),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(CallProperty0), R(10), R(3), U8(17),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfJSReceiver), U8(19),
|
|
|
|
B(Star11),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(11),
|
|
|
|
B(Star9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(5),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Ldar), R(9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(ReThrow),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(7),
|
2016-11-16 10:46:23 +00:00
|
|
|
B(SetPendingMessage),
|
2017-05-16 16:38:52 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(5),
|
2017-05-16 16:38:52 +00:00
|
|
|
B(JumpIfFalse), U8(5),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(6),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(ReThrow),
|
|
|
|
B(LdaUndefined),
|
|
|
|
/* 113 S> */ B(Return),
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
constant pool: [
|
2018-07-05 18:34:09 +00:00
|
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
2016-09-06 16:10:19 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[27, 81, 87],
|
|
|
|
[100, 119, 121],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
var x = { 'a': 1, 'b': 2 };
|
|
|
|
for (x['a'] of [1,2,3]) { return x['a']; }
|
|
|
|
"
|
2020-05-07 19:34:44 +00:00
|
|
|
frame size: 12
|
2016-02-25 12:07:07 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 146
|
2016-02-25 12:07:07 +00:00
|
|
|
bytecodes: [
|
2018-11-08 08:55:43 +00:00
|
|
|
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star0),
|
2017-07-27 12:45:00 +00:00
|
|
|
/* 77 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(GetIterator), R(3), U8(2), U8(4),
|
2019-12-20 14:06:40 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
|
|
|
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(2), U8(2), U8(6),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(context), R(6),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2019-01-14 14:15:52 +00:00
|
|
|
/* 68 S> */ B(CallProperty0), R(1), R(2), U8(8),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(7), U8(1),
|
|
|
|
B(LdaNamedProperty), R(7), U8(3), U8(10),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(28),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(LdaNamedProperty), R(7), U8(4), U8(12),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(7),
|
2019-08-08 20:43:41 +00:00
|
|
|
/* 67 E> */ B(StaNamedProperty), R(0), U8(5), U8(14),
|
|
|
|
/* 96 S> */ B(LdaNamedProperty), R(0), U8(5), U8(16),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2017-01-25 17:39:24 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(0), R(8),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(11),
|
2017-01-25 17:39:24 +00:00
|
|
|
B(LdaSmi), I8(-1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
|
|
|
B(Star4),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star5),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2016-11-16 10:46:23 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(3),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(35),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Mov), R(context), R(9),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(2), U8(6), U8(18),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(26),
|
|
|
|
B(Star10),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(CallProperty0), R(10), R(2), U8(20),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfJSReceiver), U8(19),
|
|
|
|
B(Star11),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(11), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(11),
|
|
|
|
B(Star9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(4),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Ldar), R(9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(ReThrow),
|
|
|
|
B(Ldar), R(6),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(SetPendingMessage),
|
|
|
|
B(Ldar), R(4),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(7), U8(2), I8(0),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(Jump), U8(8),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(5),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(ReThrow),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(5),
|
[debug] Don't put a source position on internal `Return`s.
Be explicit about source positions for `Return`s in the
BytecodeGenerator, and only do self-healing explicitly in the
`ReturnStatement` translation, where an end position of
`kNoSourcePosition` is turned into the return position of the
function literal.
This allows us to reason more easily about which `Return`s actually
receive a meaningful source position, and in particular it allows us
to construct the internal `Return`s for `yield` and `yield*` with no
source position attached to them. Previously they'd get the source
position for the implicit (final) return attached to it, which confused
the debugger and led to breakpoints being set in the completely wrong
spot.
Considering the simplified example
```
function* foo(){
var a = 1;
}
```
this would previously generate the following bytecode
```
0 : SwitchOnGeneratorState r0, [0], [1] { 0: @20 }
4 : Mov <closure>, r2
7 : Mov <this>, r3
13 E> 10 : InvokeIntrinsic [_CreateJSGeneratorObject], r2-r3
14 : Star0
13 E> 15 : SuspendGenerator r0, r0-r1, [0]
20 : ResumeGenerator r0, r0-r1
24 : Star2
25 : InvokeIntrinsic [_GeneratorGetResumeMode], r0-r0
29 : SwitchOnSmiNoFeedback [1], [2], [0] { 0: @39, 1: @36 }
33 : Ldar r2
13 E> 35 : Throw
36 : Ldar r2
30 S> 38 : Return <=========================== internal Return
27 S> 39 : LdaSmi [1]
41 : Star1
42 : LdaUndefined
30 S> 43 : Return
```
where everything between offset 4 and 42 corresponds to the implicit
yield at the beginning of every generator function, in particular the
code between 20 and 42 corresponds to that initial yields resumption
logic. Notice how the internal Return at offset 38 gets assigned the
source position of the function literal (the same as the implicit
return at the end). This confuses the debugger quite a bit when trying
to set a breakpoint on the closing brace, since it's going in bytecode
order and will thus discover the `Return` at offset 38 first (matching
the source position 30 it's currently looking for) and setting the
breakpoint there. This `Return` bytecode however is only executed when
the generator is resumed via `GeneratorPrototype.return()`, and it'll
not hit when the developer uses the generator normally, which is not
the desired behavior and extremely confusing (especially since stepping
on the other hand works as expected).
With this patch, we no longer slap a source position (and in particular
not the function literal's return position) onto these internal
`Return`s as you can see from the generated bytecode below:
```
0 : SwitchOnGeneratorState r0, [0], [1] { 0: @20 }
4 : Mov <closure>, r2
7 : Mov <this>, r3
13 E> 10 : InvokeIntrinsic [_CreateJSGeneratorObject], r2-r3
14 : Star0
13 E> 15 : SuspendGenerator r0, r0-r1, [0]
20 : ResumeGenerator r0, r0-r1
24 : Star2
25 : InvokeIntrinsic [_GeneratorGetResumeMode], r0-r0
29 : SwitchOnSmiNoFeedback [1], [2], [0] { 0: @39, 1: @36 }
33 : Ldar r2
13 E> 35 : Throw
36 : Ldar r2
38 : Return
27 S> 39 : LdaSmi [1]
41 : Star1
42 : LdaUndefined
30 S> 43 : Return
```
This also allows us to remove the break position finding hack that was
kept in BreakIterator::BreakIndexFromPosition() for generators and
modules.
Fixed: chromium:901819
Change-Id: If19a6b26e2622d49b6b5e54bf7a162747543f970
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2727820
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73119}
2021-03-01 19:04:43 +00:00
|
|
|
B(Return),
|
2016-05-11 12:21:56 +00:00
|
|
|
B(LdaUndefined),
|
|
|
|
/* 105 S> */ B(Return),
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
constant pool: [
|
2018-07-05 18:34:09 +00:00
|
|
|
OBJECT_BOILERPLATE_DESCRIPTION_TYPE,
|
|
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
2016-09-06 16:10:19 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
|
2017-05-16 11:36:04 +00:00
|
|
|
Smi [6],
|
|
|
|
Smi [9],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[32, 78, 84],
|
|
|
|
[97, 116, 118],
|
2016-02-25 12:07:07 +00:00
|
|
|
]
|
|
|
|
|