Add bytecode generation tests for array spreads.
Bug: v8:7973 Change-Id: I44ad457c3a103c36bd7b928cc64a056c1a1afc46 Reviewed-on: https://chromium-review.googlesource.com/1183102 Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Hai Dang <dhai@google.com> Cr-Commit-Position: refs/heads/master@{#55257}
This commit is contained in:
parent
8b2cee550c
commit
f30b43ed95
@ -117,3 +117,164 @@ constant pool: [
|
||||
handlers: [
|
||||
]
|
||||
|
||||
---
|
||||
snippet: "
|
||||
var a = [ 1, 2 ]; return [ ...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(1),
|
||||
B(LdaConstant), U8(2),
|
||||
/* 64 S> */ B(Star), R(2),
|
||||
B(LdaNamedProperty), R(0), U8(3), U8(7),
|
||||
B(Star), R(7),
|
||||
B(CallProperty0), R(7), R(0), U8(9),
|
||||
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(11),
|
||||
B(Star), R(4),
|
||||
B(CallProperty0), R(4), R(5), U8(13),
|
||||
B(Star), R(3),
|
||||
B(JumpIfJSReceiver), U8(7),
|
||||
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
|
||||
B(LdaNamedProperty), R(3), U8(5), U8(15),
|
||||
B(JumpIfToBooleanTrue), U8(21),
|
||||
B(LdaNamedProperty), R(3), U8(6), U8(17),
|
||||
B(Star), R(3),
|
||||
B(StaInArrayLiteral), R(1), R(2), U8(2),
|
||||
B(Ldar), R(2),
|
||||
B(Inc), U8(4),
|
||||
B(Star), R(2),
|
||||
B(JumpLoop), U8(35), I8(0),
|
||||
B(Ldar), R(1),
|
||||
/* 68 S> */ B(Return),
|
||||
]
|
||||
constant pool: [
|
||||
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
||||
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
||||
Smi [0],
|
||||
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 [ 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(1),
|
||||
B(LdaConstant), U8(2),
|
||||
/* 67 S> */ B(Star), R(2),
|
||||
B(LdaNamedProperty), R(0), U8(3), U8(7),
|
||||
B(Star), R(7),
|
||||
B(CallProperty0), R(7), R(0), U8(9),
|
||||
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(11),
|
||||
B(Star), R(4),
|
||||
B(CallProperty0), R(4), R(5), U8(13),
|
||||
B(Star), R(3),
|
||||
B(JumpIfJSReceiver), U8(7),
|
||||
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
|
||||
B(LdaNamedProperty), R(3), U8(5), U8(15),
|
||||
B(JumpIfToBooleanTrue), U8(21),
|
||||
B(LdaNamedProperty), R(3), U8(6), U8(17),
|
||||
B(Star), R(3),
|
||||
B(StaInArrayLiteral), R(1), R(2), U8(2),
|
||||
B(Ldar), R(2),
|
||||
B(Inc), U8(4),
|
||||
B(Star), R(2),
|
||||
B(JumpLoop), U8(35), I8(0),
|
||||
B(Ldar), R(1),
|
||||
/* 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: 8
|
||||
parameter count: 1
|
||||
bytecode array length: 98
|
||||
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(1),
|
||||
B(LdaConstant), U8(2),
|
||||
/* 64 S> */ B(Star), R(2),
|
||||
B(LdaNamedProperty), R(0), U8(3), U8(7),
|
||||
B(Star), R(7),
|
||||
B(CallProperty0), R(7), R(0), U8(9),
|
||||
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(11),
|
||||
B(Star), R(4),
|
||||
B(CallProperty0), R(4), R(5), U8(13),
|
||||
B(Star), R(3),
|
||||
B(JumpIfJSReceiver), U8(7),
|
||||
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1),
|
||||
B(LdaNamedProperty), R(3), U8(5), U8(15),
|
||||
B(JumpIfToBooleanTrue), U8(21),
|
||||
B(LdaNamedProperty), R(3), U8(6), U8(17),
|
||||
B(Star), R(3),
|
||||
B(StaInArrayLiteral), R(1), R(2), U8(2),
|
||||
B(Ldar), R(2),
|
||||
B(Inc), U8(4),
|
||||
B(Star), R(2),
|
||||
B(JumpLoop), U8(35), I8(0),
|
||||
B(LdaSmi), I8(3),
|
||||
B(StaInArrayLiteral), R(1), R(2), U8(2),
|
||||
B(Ldar), R(2),
|
||||
B(Inc), U8(4),
|
||||
B(Star), R(2),
|
||||
B(Ldar), R(1),
|
||||
/* 71 S> */ B(Return),
|
||||
]
|
||||
constant pool: [
|
||||
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
||||
ARRAY_BOILERPLATE_DESCRIPTION_TYPE,
|
||||
Smi [0],
|
||||
SYMBOL_TYPE,
|
||||
ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"],
|
||||
ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"],
|
||||
ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"],
|
||||
]
|
||||
handlers: [
|
||||
]
|
||||
|
||||
|
@ -1437,6 +1437,12 @@ TEST(ArrayLiterals) {
|
||||
"return [ [ 1, 2 ], [ 3 ] ];\n",
|
||||
|
||||
"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];\n",
|
||||
|
||||
"var a = [ 1, 2 ]; return [ ...a ];\n",
|
||||
|
||||
"var a = [ 1, 2 ]; return [ 0, ...a ];\n",
|
||||
|
||||
"var a = [ 1, 2 ]; return [ ...a, 3 ];\n",
|
||||
};
|
||||
|
||||
CHECK(CompareTexts(BuildActual(printer, snippets),
|
||||
|
Loading…
Reference in New Issue
Block a user