5f8a42727d
This is a reland of 1c48d52bb1
.
It turned out that IterableToList doesn't always behave according to
the ES operation with the same name. Specifically, it allows holey arrays
to take its fast path, which produces an output array with holes where
actually "undefined" elements should appear.
This CL changes the version of IterableToList that is used for spreads
(IterableToListWithSymbolLookup) such that holey arrays take the slow path.
It also includes tests for such situations.
Original change's description:
> [interpreter] Add bytecode for leading array spreads.
>
> This CL improves the performance of creating [...a, b] or [...a].
> If the array literal has a leading spread, this CL emits the bytecode
> [CreateArrayFromIterable] to create the literal. CreateArrayFromIterable
> is implemented by [IterableToListDefault] builtin to create the initial
> array for the leading spread. IterableToListDefault has a fast path to
> clone efficiently if the spread is an actual array.
>
> The bytecode generated is now shorter. Bytecode generation is refactored
> into to BuildCreateArrayLiteral, which allows VisitCallSuper to benefit
> from this optimization also.
> For now, turbofan also lowers the bytecode to the builtin.
>
> The idiomatic use of [...a] to clone the array a now performs better
> than a simple for-loop, but still does not match the performance of slice.
>
> Bug: v8:7980
>
> Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
> Change-Id: Ibde659c82d3c7aa1b1777a3d2f6426ac8cc15e35
> Reviewed-on: https://chromium-review.googlesource.com/1181024
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
> Reviewed-by: Jakob Gruber <jgruber@chromium.org>
> Reviewed-by: Georg Neis <neis@chromium.org>
> Commit-Queue: Georg Neis <neis@chromium.org>
> Commit-Queue: Hai Dang <dhai@google.com>
> Cr-Commit-Position: refs/heads/master@{#55520}
Bug: v8:7980
Change-Id: I0b5603a12d2b588327658bf0a9b214bd0f22e237
Cq-Include-Trybots: luci.v8.try:v8_linux_noi18n_rel_ng
Reviewed-on: https://chromium-review.googlesource.com/1201882
Commit-Queue: Hai Dang <dhai@google.com>
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55639}
219 lines
5.5 KiB
Plaintext
219 lines
5.5 KiB
Plaintext
#
|
|
# Autogenerated by generate-bytecode-expectations.
|
|
#
|
|
|
|
---
|
|
wrap: yes
|
|
|
|
---
|
|
snippet: "
|
|
return [ 1, 2 ];
|
|
"
|
|
frame size: 0
|
|
parameter count: 1
|
|
bytecode array length: 6
|
|
bytecodes: [
|
|
/* 30 E> */ B(StackCheck),
|
|
/* 34 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
|
/* 50 S> */ B(Return),
|
|
]
|
|
constant pool: [
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
]
|
|
handlers: [
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
var a = 1; return [ a, a + 1 ];
|
|
"
|
|
frame size: 3
|
|
parameter count: 1
|
|
bytecode array length: 36
|
|
bytecodes: [
|
|
/* 30 E> */ B(StackCheck),
|
|
/* 42 S> */ B(LdaSmi), I8(1),
|
|
B(Star), R(0),
|
|
/* 45 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
|
B(Star), R(2),
|
|
B(LdaZero),
|
|
B(Star), R(1),
|
|
B(Ldar), R(0),
|
|
/* 54 E> */ B(StaInArrayLiteral), R(2), R(1), U8(1),
|
|
B(LdaSmi), I8(1),
|
|
B(Star), R(1),
|
|
B(Ldar), R(0),
|
|
/* 59 E> */ B(AddSmi), I8(1), U8(3),
|
|
B(StaInArrayLiteral), R(2), R(1), U8(1),
|
|
B(Ldar), R(2),
|
|
/* 65 S> */ B(Return),
|
|
]
|
|
constant pool: [
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
]
|
|
handlers: [
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
return [ [ 1, 2 ], [ 3 ] ];
|
|
"
|
|
frame size: 0
|
|
parameter count: 1
|
|
bytecode array length: 6
|
|
bytecodes: [
|
|
/* 30 E> */ B(StackCheck),
|
|
/* 34 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(4),
|
|
/* 61 S> */ B(Return),
|
|
]
|
|
constant pool: [
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
]
|
|
handlers: [
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
var a = 1; return [ [ a, 2 ], [ a + 2 ] ];
|
|
"
|
|
frame size: 5
|
|
parameter count: 1
|
|
bytecode array length: 66
|
|
bytecodes: [
|
|
/* 30 E> */ B(StackCheck),
|
|
/* 42 S> */ B(LdaSmi), I8(1),
|
|
B(Star), R(0),
|
|
/* 45 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(4),
|
|
B(Star), R(2),
|
|
B(LdaZero),
|
|
B(Star), R(1),
|
|
B(CreateArrayLiteral), U8(1), U8(1), U8(37),
|
|
B(Star), R(4),
|
|
B(LdaZero),
|
|
B(Star), R(3),
|
|
B(Ldar), R(0),
|
|
/* 56 E> */ B(StaInArrayLiteral), R(4), R(3), U8(2),
|
|
B(Ldar), R(4),
|
|
B(StaInArrayLiteral), R(2), R(1), U8(4),
|
|
B(LdaSmi), I8(1),
|
|
B(Star), R(1),
|
|
B(CreateArrayLiteral), U8(2), U8(6), U8(37),
|
|
B(Star), R(4),
|
|
B(LdaZero),
|
|
B(Star), R(3),
|
|
B(Ldar), R(0),
|
|
/* 68 E> */ B(AddSmi), I8(2), U8(7),
|
|
B(StaInArrayLiteral), R(4), R(3), U8(8),
|
|
B(Ldar), R(4),
|
|
B(StaInArrayLiteral), R(2), R(1), U8(4),
|
|
B(Ldar), R(2),
|
|
/* 76 S> */ B(Return),
|
|
]
|
|
constant pool: [
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
]
|
|
handlers: [
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
var a = [ 1, 2 ]; return [ ...a ];
|
|
"
|
|
frame size: 1
|
|
parameter count: 1
|
|
bytecode array length: 9
|
|
bytecodes: [
|
|
/* 30 E> */ B(StackCheck),
|
|
/* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
|
B(Star), R(0),
|
|
/* 52 S> */ B(CreateArrayFromIterable),
|
|
/* 68 S> */ B(Return),
|
|
]
|
|
constant pool: [
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
]
|
|
handlers: [
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
var a = [ 1, 2 ]; return [ 0, ...a ];
|
|
"
|
|
frame size: 8
|
|
parameter count: 1
|
|
bytecode array length: 86
|
|
bytecodes: [
|
|
/* 30 E> */ B(StackCheck),
|
|
/* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
|
B(Star), R(0),
|
|
/* 52 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37),
|
|
B(Star), R(2),
|
|
B(LdaConstant), U8(2),
|
|
/* 67 S> */ B(Star), R(1),
|
|
B(LdaNamedProperty), R(0), U8(3), U8(5),
|
|
B(Star), R(7),
|
|
B(CallProperty0), R(7), R(0), U8(7),
|
|
B(Mov), R(0), R(6),
|
|
B(JumpIfJSReceiver), U8(7),
|
|
B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0),
|
|
B(Star), R(5),
|
|
B(LdaNamedProperty), R(5), U8(4), U8(9),
|
|
B(Star), R(4),
|
|
B(CallProperty0), R(4), R(5), U8(11),
|
|
B(Star), R(3),
|
|
B(JumpIfJSReceiver), U8(7),
|
|
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
|
|
B(LdaNamedProperty), R(3), U8(5), U8(13),
|
|
B(JumpIfToBooleanTrue), U8(21),
|
|
B(LdaNamedProperty), R(3), U8(6), U8(15),
|
|
B(Star), R(3),
|
|
B(StaInArrayLiteral), R(2), R(1), U8(3),
|
|
B(Ldar), R(1),
|
|
B(Inc), U8(2),
|
|
B(Star), R(1),
|
|
B(JumpLoop), U8(35), I8(0),
|
|
B(Ldar), R(2),
|
|
/* 71 S> */ B(Return),
|
|
]
|
|
constant pool: [
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
Smi [1],
|
|
SYMBOL_TYPE,
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
|
]
|
|
handlers: [
|
|
]
|
|
|
|
---
|
|
snippet: "
|
|
var a = [ 1, 2 ]; return [ ...a, 3 ];
|
|
"
|
|
frame size: 3
|
|
parameter count: 1
|
|
bytecode array length: 25
|
|
bytecodes: [
|
|
/* 30 E> */ B(StackCheck),
|
|
/* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37),
|
|
B(Star), R(0),
|
|
/* 52 S> */ B(CreateArrayFromIterable),
|
|
B(Star), R(2),
|
|
B(LdaNamedProperty), R(2), U8(1), U8(1),
|
|
B(Star), R(1),
|
|
B(LdaSmi), I8(3),
|
|
B(StaInArrayLiteral), R(2), R(1), U8(3),
|
|
B(Ldar), R(2),
|
|
/* 71 S> */ B(Return),
|
|
]
|
|
constant pool: [
|
|
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
|
ONE_BYTE_INTERNALIZED_STRING_TYPE ["length"],
|
|
]
|
|
handlers: [
|
|
]
|
|
|