2017-07-02 20:59:29 +00:00
|
|
|
#
|
|
|
|
# Autogenerated by generate-bytecode-expectations.
|
|
|
|
#
|
|
|
|
|
|
|
|
---
|
|
|
|
wrap: no
|
|
|
|
test function name: f
|
|
|
|
async iteration: yes
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
async function* f() { }
|
|
|
|
f();
|
|
|
|
"
|
2018-01-23 13:51:38 +00:00
|
|
|
frame size: 8
|
2017-07-02 20:59:29 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 130
|
2017-07-02 20:59:29 +00:00
|
|
|
bytecodes: [
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(closure), R(1),
|
|
|
|
B(Mov), R(this), R(2),
|
2020-02-10 16:09:27 +00:00
|
|
|
/* 17 E> */ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(1), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star0),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(context), R(3),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(Mov), R(context), R(4),
|
2017-07-25 18:37:36 +00:00
|
|
|
B(Ldar), R(0),
|
2018-01-23 13:51:38 +00:00
|
|
|
/* 17 E> */ B(SuspendGenerator), R(0), R(0), U8(5), U8(0),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(1), U8(2), I8(0),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(5),
|
2017-07-02 20:59:29 +00:00
|
|
|
/* 17 E> */ B(Throw),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(5), R(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(41),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaUndefined),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
|
|
|
B(Jump), U8(34),
|
|
|
|
B(Star5),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(CreateCatchContext), R(5), U8(3),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(4),
|
|
|
|
B(PushContext), R(5),
|
Reland x3 "[runtime] Remove extension slots from context objects"
Original change's description:
> [runtime] Remove extension slots from context objects
>
> Context objects have an extension slot, which contains further
> additional data that depends on the type of the context.
>
> This CL removes the extension slot from contexts that don't need
> them, hence reducing memory.
>
> The following contexts will still have an extension slot: native,
> module, await, block and with contexts. See objects/contexts.h for
> what the slot is used for.
> The following contexts will not have an extension slot anymore (they
> were not used before): script, catch and builtin contexts.
> Eval and function contexts only have the extension slot if they
> contain a sloppy eval.
>
> Bug: v8:9744
> Change-Id: I8ca56c22fa02437bbac392ea72174ebfca80e030
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1863191
> Commit-Queue: Victor Gomes <victorgomes@google.com>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Auto-Submit: Victor Gomes <victorgomes@google.com>
> Cr-Commit-Position: refs/heads/master@{#64372}
TBR=verwaest@chromium.org,jgruber@chromium.org,ulan@chromium.org,leszeks@chromium.org,petermarshall@chromium.org
Bug: v8:9744
Change-Id: I8700ed2fa62c89e86c39bb16ac3167f38ea8d63f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873695
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64477}
2019-10-22 12:59:24 +00:00
|
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(0), R(6),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorReject), R(6), U8(2),
|
|
|
|
B(PopContext), R(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star2),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(0), U8(1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(3),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(SetPendingMessage),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(1),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(4), U8(3), I8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(21),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(Ldar), R(2),
|
|
|
|
B(ReThrow),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(0), R(4),
|
|
|
|
B(Mov), R(2), R(5),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(4), U8(3),
|
[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),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(2),
|
[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),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaUndefined),
|
|
|
|
/* 22 S> */ B(Return),
|
|
|
|
]
|
|
|
|
constant pool: [
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [28],
|
|
|
|
Smi [15],
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [7],
|
2018-02-16 12:36:47 +00:00
|
|
|
SCOPE_INFO_TYPE,
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [6],
|
2019-01-02 16:12:54 +00:00
|
|
|
Smi [9],
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [22],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[18, 88, 88],
|
|
|
|
[21, 59, 59],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
async function* f() { yield 42 }
|
|
|
|
f();
|
|
|
|
"
|
2018-01-23 13:51:38 +00:00
|
|
|
frame size: 8
|
2017-07-02 20:59:29 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 171
|
2017-07-02 20:59:29 +00:00
|
|
|
bytecodes: [
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(closure), R(1),
|
|
|
|
B(Mov), R(this), R(2),
|
2020-02-10 16:09:27 +00:00
|
|
|
/* 17 E> */ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(1), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star0),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(context), R(3),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(Mov), R(context), R(4),
|
2017-07-25 18:37:36 +00:00
|
|
|
B(Ldar), R(0),
|
2018-01-23 13:51:38 +00:00
|
|
|
/* 17 E> */ B(SuspendGenerator), R(0), R(0), U8(5), U8(0),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(5),
|
2017-07-02 20:59:29 +00:00
|
|
|
/* 17 E> */ B(Throw),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(5), R(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(82),
|
2017-07-02 20:59:29 +00:00
|
|
|
/* 22 S> */ B(LdaSmi), I8(42),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(0), R(5),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(5), U8(3),
|
|
|
|
/* 22 E> */ B(SuspendGenerator), R(0), R(0), U8(5), U8(1),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(4), U8(2), I8(0),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(5),
|
2017-07-02 20:59:29 +00:00
|
|
|
/* 22 E> */ B(Throw),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(5), R(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(41),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaUndefined),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
|
|
|
B(Jump), U8(34),
|
|
|
|
B(Star5),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(CreateCatchContext), R(5), U8(6),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(4),
|
|
|
|
B(PushContext), R(5),
|
Reland x3 "[runtime] Remove extension slots from context objects"
Original change's description:
> [runtime] Remove extension slots from context objects
>
> Context objects have an extension slot, which contains further
> additional data that depends on the type of the context.
>
> This CL removes the extension slot from contexts that don't need
> them, hence reducing memory.
>
> The following contexts will still have an extension slot: native,
> module, await, block and with contexts. See objects/contexts.h for
> what the slot is used for.
> The following contexts will not have an extension slot anymore (they
> were not used before): script, catch and builtin contexts.
> Eval and function contexts only have the extension slot if they
> contain a sloppy eval.
>
> Bug: v8:9744
> Change-Id: I8ca56c22fa02437bbac392ea72174ebfca80e030
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1863191
> Commit-Queue: Victor Gomes <victorgomes@google.com>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Auto-Submit: Victor Gomes <victorgomes@google.com>
> Cr-Commit-Position: refs/heads/master@{#64372}
TBR=verwaest@chromium.org,jgruber@chromium.org,ulan@chromium.org,leszeks@chromium.org,petermarshall@chromium.org
Bug: v8:9744
Change-Id: I8700ed2fa62c89e86c39bb16ac3167f38ea8d63f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873695
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64477}
2019-10-22 12:59:24 +00:00
|
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(0), R(6),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorReject), R(6), U8(2),
|
|
|
|
B(PopContext), R(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star2),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(0), U8(1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(3),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(SetPendingMessage),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(1),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(7), U8(3), I8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(21),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(Ldar), R(2),
|
|
|
|
B(ReThrow),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(0), R(4),
|
|
|
|
B(Mov), R(2), R(5),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(4), U8(3),
|
[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),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(2),
|
[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),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaUndefined),
|
|
|
|
/* 31 S> */ B(Return),
|
|
|
|
]
|
|
|
|
constant pool: [
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [28],
|
|
|
|
Smi [69],
|
|
|
|
Smi [15],
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [7],
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [15],
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [7],
|
2018-02-16 12:36:47 +00:00
|
|
|
SCOPE_INFO_TYPE,
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [6],
|
2019-01-02 16:12:54 +00:00
|
|
|
Smi [9],
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [22],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[18, 129, 129],
|
|
|
|
[21, 100, 100],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
async function* f() { for (let x of [42]) yield x }
|
|
|
|
f();
|
|
|
|
"
|
2020-05-07 19:34:44 +00:00
|
|
|
frame size: 18
|
2017-07-02 20:59:29 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 310
|
2017-07-02 20:59:29 +00:00
|
|
|
bytecodes: [
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(2),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Mov), R(closure), R(4),
|
|
|
|
B(Mov), R(this), R(5),
|
2020-02-10 16:09:27 +00:00
|
|
|
/* 17 E> */ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(4), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star0),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Mov), R(context), R(6),
|
|
|
|
B(Mov), R(context), R(7),
|
2019-01-31 15:36:58 +00:00
|
|
|
B(Ldar), R(0),
|
|
|
|
/* 17 E> */ B(SuspendGenerator), R(0), R(0), U8(8), U8(0),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(8),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2019-01-31 15:36:58 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(2), U8(2), I8(0),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Ldar), R(8),
|
2017-07-02 20:59:29 +00:00
|
|
|
/* 17 E> */ B(Throw),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Mov), R(8), R(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(221),
|
2019-05-15 19:41:48 +00:00
|
|
|
/* 36 S> */ B(CreateArrayLiteral), U8(4), U8(0), U8(37),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star10),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(GetIterator), R(10), 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(Star9),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(9), U8(5), U8(5),
|
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(Star10),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(context), R(13),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star10),
|
2019-01-14 14:15:52 +00:00
|
|
|
/* 31 S> */ B(CallProperty0), R(8), R(9), U8(7),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star14),
|
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(14), U8(1),
|
|
|
|
B(LdaNamedProperty), R(14), U8(6), U8(9),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(62),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(LdaNamedProperty), R(14), U8(7), U8(11),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star14),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaFalse),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star10),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(14), R(1),
|
2019-01-31 15:36:58 +00:00
|
|
|
/* 31 S> */ B(Mov), R(1), R(3),
|
2017-08-07 14:13:18 +00:00
|
|
|
/* 42 S> */ B(LdaFalse),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Star), R(17),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(0), R(15),
|
|
|
|
B(Mov), R(3), R(16),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(15), U8(3),
|
|
|
|
/* 42 E> */ B(SuspendGenerator), R(0), R(0), U8(15), U8(1),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(15),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star15),
|
2019-01-31 15:36:58 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(8), U8(2), I8(0),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(15),
|
2017-07-02 20:59:29 +00:00
|
|
|
/* 42 E> */ B(Throw),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star11),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(15), R(12),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(16),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(15),
|
2021-02-17 14:36:58 +00:00
|
|
|
/* 22 E> */ B(JumpLoop), U8(77), I8(0),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaSmi), I8(-1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star12),
|
|
|
|
B(Star11),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star12),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star11),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star13),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(10),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(37),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Mov), R(context), R(15),
|
2019-08-08 20:43:41 +00:00
|
|
|
B(LdaNamedProperty), R(9), U8(10), U8(13),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(28),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Star), R(16),
|
|
|
|
B(CallProperty0), R(16), R(9), U8(15),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfJSReceiver), U8(20),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Star), R(17),
|
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(17), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(11),
|
|
|
|
B(Star15),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(11),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(Ldar), R(15),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(ReThrow),
|
|
|
|
B(Ldar), R(13),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(SetPendingMessage),
|
|
|
|
B(Ldar), R(11),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(13),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(12),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(ReThrow),
|
2019-01-02 16:12:54 +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(12), R(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(41),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaUndefined),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
|
|
|
B(Jump), U8(34),
|
|
|
|
B(Star8),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(CreateCatchContext), R(8), U8(13),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Ldar), R(7),
|
|
|
|
B(PushContext), R(8),
|
Reland x3 "[runtime] Remove extension slots from context objects"
Original change's description:
> [runtime] Remove extension slots from context objects
>
> Context objects have an extension slot, which contains further
> additional data that depends on the type of the context.
>
> This CL removes the extension slot from contexts that don't need
> them, hence reducing memory.
>
> The following contexts will still have an extension slot: native,
> module, await, block and with contexts. See objects/contexts.h for
> what the slot is used for.
> The following contexts will not have an extension slot anymore (they
> were not used before): script, catch and builtin contexts.
> Eval and function contexts only have the extension slot if they
> contain a sloppy eval.
>
> Bug: v8:9744
> Change-Id: I8ca56c22fa02437bbac392ea72174ebfca80e030
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1863191
> Commit-Queue: Victor Gomes <victorgomes@google.com>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Auto-Submit: Victor Gomes <victorgomes@google.com>
> Cr-Commit-Position: refs/heads/master@{#64372}
TBR=verwaest@chromium.org,jgruber@chromium.org,ulan@chromium.org,leszeks@chromium.org,petermarshall@chromium.org
Bug: v8:9744
Change-Id: I8700ed2fa62c89e86c39bb16ac3167f38ea8d63f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873695
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64477}
2019-10-22 12:59:24 +00:00
|
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star10),
|
2019-01-31 15:36:58 +00:00
|
|
|
B(Mov), R(0), R(9),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorReject), R(9), U8(2),
|
|
|
|
B(PopContext), R(8),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
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),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2019-01-31 15:36:58 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(0), U8(1),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Ldar), R(6),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(SetPendingMessage),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Ldar), R(4),
|
2020-05-07 19:34:44 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(14), U8(3), I8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(21),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Ldar), R(5),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(ReThrow),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star9),
|
2019-01-31 15:36:58 +00:00
|
|
|
B(Mov), R(0), R(7),
|
2019-01-14 14:15:52 +00:00
|
|
|
B(Mov), R(5), R(8),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(7), U8(3),
|
[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),
|
2019-01-14 14:15: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),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaUndefined),
|
|
|
|
/* 50 S> */ B(Return),
|
|
|
|
]
|
|
|
|
constant pool: [
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [28],
|
|
|
|
Smi [130],
|
|
|
|
Smi [15],
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [7],
|
2018-07-05 18:34:09 +00:00
|
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
2017-07-02 20:59:29 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [15],
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [7],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
|
|
|
|
Smi [6],
|
2019-01-02 16:12:54 +00:00
|
|
|
Smi [9],
|
2018-02-16 12:36:47 +00:00
|
|
|
SCOPE_INFO_TYPE,
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [6],
|
2019-01-02 16:12:54 +00:00
|
|
|
Smi [9],
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [22],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[18, 268, 268],
|
|
|
|
[21, 239, 239],
|
|
|
|
[79, 159, 165],
|
|
|
|
[178, 199, 201],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
---
|
|
|
|
snippet: "
|
|
|
|
function* g() { yield 42 }
|
|
|
|
async function* f() { yield* g() }
|
|
|
|
f();
|
|
|
|
"
|
2019-08-23 14:23:52 +00:00
|
|
|
frame size: 17
|
2017-07-02 20:59:29 +00:00
|
|
|
parameter count: 1
|
2021-02-17 14:36:58 +00:00
|
|
|
bytecode array length: 422
|
2017-07-02 20:59:29 +00:00
|
|
|
bytecodes: [
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnGeneratorState), R(0), U8(0), U8(5),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(closure), R(1),
|
|
|
|
B(Mov), R(this), R(2),
|
2020-02-10 16:09:27 +00:00
|
|
|
/* 44 E> */ B(InvokeIntrinsic), U8(Runtime::k_CreateJSGeneratorObject), R(1), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star0),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(context), R(3),
|
2017-08-16 16:43:28 +00:00
|
|
|
B(Mov), R(context), R(4),
|
2017-07-25 18:37:36 +00:00
|
|
|
B(Ldar), R(0),
|
2018-01-23 13:51:38 +00:00
|
|
|
/* 44 E> */ B(SuspendGenerator), R(0), R(0), U8(5), U8(0),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star5),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(5), U8(2), I8(0),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(5),
|
2017-07-02 20:59:29 +00:00
|
|
|
/* 44 E> */ B(Throw),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(5), R(2),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(JumpConstant), U8(18),
|
2019-05-15 19:41:48 +00:00
|
|
|
/* 49 S> */ B(LdaGlobal), U8(7), U8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star9),
|
2019-01-02 16:12:54 +00:00
|
|
|
/* 56 E> */ B(CallUndefinedReceiver0), R(9), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star10),
|
2019-05-15 19:41:48 +00:00
|
|
|
B(LdaNamedProperty), R(10), U8(8), U8(4),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(14),
|
|
|
|
B(Star11),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(CallProperty0), R(11), R(10), U8(6),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfJSReceiver), U8(21),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowSymbolAsyncIteratorInvalid), R(0), U8(0),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(10), U8(9), U8(8),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star11),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(CallProperty0), R(11), R(10), U8(10),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star11),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_CreateAsyncFromSyncIterator), R(11), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(7), U8(10), U8(12),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star9),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(LdaUndefined),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2017-07-13 13:53:13 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(6),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(11), U8(2), I8(1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(CallProperty1), R(9), R(7), R(8), U8(14),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(130),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(7), U8(13), U8(16),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(10),
|
|
|
|
B(Star10),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallProperty1), R(10), R(7), R(8), U8(18),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(116),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(0), R(10),
|
|
|
|
B(Mov), R(8), R(11),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(10), U8(2),
|
|
|
|
/* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(10), U8(1),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(10),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star10),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star11),
|
2017-07-13 13:53:13 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(11),
|
2017-07-13 13:53:13 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(10),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(ReThrow),
|
2019-05-09 17:25:21 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(10), R(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(215),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(7), U8(14), U8(20),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(10),
|
|
|
|
B(Star12),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallProperty1), R(12), R(7), R(8), U8(22),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(61),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(7), U8(13), U8(24),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfUndefinedOrNull), U8(50),
|
|
|
|
B(Star12),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallProperty0), R(12), R(7), U8(26),
|
2019-05-09 17:25:21 +00:00
|
|
|
B(Jump), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star13),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(0), R(12),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(12), U8(2),
|
|
|
|
/* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(12), U8(2),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(12),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star12),
|
2019-05-09 17:25:21 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star13),
|
2019-05-09 17:25:21 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(13),
|
2019-05-09 17:25:21 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(12),
|
2019-05-09 17:25:21 +00:00
|
|
|
B(ReThrow),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(12),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfJSReceiver), U8(8),
|
|
|
|
B(Star14),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(14), U8(1),
|
|
|
|
B(CallRuntime), U16(Runtime::kThrowThrowMethodMissing), R(0), U8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star13),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Mov), R(0), R(12),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorAwaitUncaught), R(12), U8(2),
|
|
|
|
/* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(12), U8(3),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(12),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star12),
|
2018-01-11 17:24:11 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star13),
|
2017-07-13 13:53:13 +00:00
|
|
|
B(LdaZero),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(TestReferenceEqual), R(13),
|
2017-07-13 13:53:13 +00:00
|
|
|
B(JumpIfTrue), U8(5),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(12),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(ReThrow),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Ldar), R(12),
|
|
|
|
B(Mov), R(12), R(5),
|
2017-08-16 16:43:28 +00:00
|
|
|
B(JumpIfJSReceiver), U8(7),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(5), U8(15), U8(28),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfToBooleanTrue), U8(35),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(5), U8(16), U8(30),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star15),
|
2018-01-11 17:24:11 +00:00
|
|
|
B(LdaFalse),
|
2019-08-23 14:23:52 +00:00
|
|
|
B(Star), R(16),
|
|
|
|
B(Mov), R(0), R(14),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorYield), R(14), U8(3),
|
|
|
|
/* 49 E> */ B(SuspendGenerator), R(0), R(0), U8(14), U8(4),
|
|
|
|
B(ResumeGenerator), R(0), R(0), U8(14),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star8),
|
2017-08-11 15:16:31 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorGetResumeMode), R(0), U8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
|
|
|
B(JumpLoop), U8(220), I8(0),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(LdaNamedProperty), R(5), U8(16), U8(32),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2017-08-16 16:43:28 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2018-04-18 00:04:34 +00:00
|
|
|
B(TestReferenceEqual), R(6),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(JumpIfFalse), U8(10),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(7), R(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(41),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaUndefined),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2020-02-20 22:12:12 +00:00
|
|
|
B(LdaSmi), I8(1),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
|
|
|
B(Jump), U8(34),
|
|
|
|
B(Star5),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(CreateCatchContext), R(5), U8(17),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star4),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(4),
|
|
|
|
B(PushContext), R(5),
|
Reland x3 "[runtime] Remove extension slots from context objects"
Original change's description:
> [runtime] Remove extension slots from context objects
>
> Context objects have an extension slot, which contains further
> additional data that depends on the type of the context.
>
> This CL removes the extension slot from contexts that don't need
> them, hence reducing memory.
>
> The following contexts will still have an extension slot: native,
> module, await, block and with contexts. See objects/contexts.h for
> what the slot is used for.
> The following contexts will not have an extension slot anymore (they
> were not used before): script, catch and builtin contexts.
> Eval and function contexts only have the extension slot if they
> contain a sloppy eval.
>
> Bug: v8:9744
> Change-Id: I8ca56c22fa02437bbac392ea72174ebfca80e030
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1863191
> Commit-Queue: Victor Gomes <victorgomes@google.com>
> Reviewed-by: Toon Verwaest <verwaest@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Leszek Swirski <leszeks@chromium.org>
> Reviewed-by: Peter Marshall <petermarshall@chromium.org>
> Auto-Submit: Victor Gomes <victorgomes@google.com>
> Cr-Commit-Position: refs/heads/master@{#64372}
TBR=verwaest@chromium.org,jgruber@chromium.org,ulan@chromium.org,leszeks@chromium.org,petermarshall@chromium.org
Bug: v8:9744
Change-Id: I8700ed2fa62c89e86c39bb16ac3167f38ea8d63f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1873695
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64477}
2019-10-22 12:59:24 +00:00
|
|
|
B(LdaImmutableCurrentContextSlot), U8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star7),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(0), R(6),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorReject), R(6), U8(2),
|
|
|
|
B(PopContext), R(5),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star2),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaSmi), I8(2),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
|
|
|
B(Jump), U8(5),
|
|
|
|
B(Star2),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(LdaZero),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star1),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTheHole),
|
|
|
|
B(SetPendingMessage),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star3),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_GeneratorClose), R(0), U8(1),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(3),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(SetPendingMessage),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(1),
|
2019-09-06 12:41:00 +00:00
|
|
|
B(SwitchOnSmiNoFeedback), U8(19), U8(3), I8(0),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Jump), U8(21),
|
2019-01-02 16:12:54 +00:00
|
|
|
B(Ldar), R(2),
|
|
|
|
B(ReThrow),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaTrue),
|
2021-02-17 14:36:58 +00:00
|
|
|
B(Star6),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Mov), R(0), R(4),
|
|
|
|
B(Mov), R(2), R(5),
|
|
|
|
B(InvokeIntrinsic), U8(Runtime::k_AsyncGeneratorResolve), R(4), U8(3),
|
[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),
|
2018-01-23 13:51:38 +00:00
|
|
|
B(Ldar), R(2),
|
[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),
|
2017-07-02 20:59:29 +00:00
|
|
|
B(LdaUndefined),
|
|
|
|
/* 60 S> */ B(Return),
|
|
|
|
]
|
|
|
|
constant pool: [
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [28],
|
|
|
|
Smi [144],
|
|
|
|
Smi [210],
|
|
|
|
Smi [256],
|
|
|
|
Smi [312],
|
|
|
|
Smi [15],
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [7],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["g"],
|
|
|
|
SYMBOL_TYPE,
|
2019-09-06 12:41:00 +00:00
|
|
|
SYMBOL_TYPE,
|
2017-07-02 20:59:29 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
2018-01-11 17:24:11 +00:00
|
|
|
Smi [11],
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [66],
|
2017-07-02 20:59:29 +00:00
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["return"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["throw"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
|
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
2018-02-16 12:36:47 +00:00
|
|
|
SCOPE_INFO_TYPE,
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [333],
|
2017-07-02 20:59:29 +00:00
|
|
|
Smi [6],
|
2019-01-02 16:12:54 +00:00
|
|
|
Smi [9],
|
2021-02-17 14:36:58 +00:00
|
|
|
Smi [22],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
handlers: [
|
2021-02-17 14:36:58 +00:00
|
|
|
[18, 380, 380],
|
|
|
|
[21, 351, 351],
|
2017-07-02 20:59:29 +00:00
|
|
|
]
|
|
|
|
|