Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

Unified Diff: test/cctest/interpreter/test-bytecode-generator.cc

Issue 1392933002: [Interpreter] Reduce temporary register usage in generated bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate comments from mstarzinger. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/interpreter/test-bytecode-generator.cc
diff --git a/test/cctest/interpreter/test-bytecode-generator.cc b/test/cctest/interpreter/test-bytecode-generator.cc
index d9ca8f8606960017aeeafaea12a52081064c1bc3..500d30bc2ccd3692f6f52a457415c2233f4c7175 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -75,6 +75,8 @@ class BytecodeGeneratorHelper {
#define B(x) static_cast<uint8_t>(Bytecode::k##x)
#define U8(x) static_cast<uint8_t>((x) & 0xff)
#define R(x) static_cast<uint8_t>(-(x) & 0xff)
+#define A(x, n) R(helper.kLastParamIndex - (n) + 1 + (x))
+#define THIS(n) A(0, n)
#define _ static_cast<uint8_t>(0x5a)
#if defined(V8_TARGET_LITTLE_ENDIAN)
#define U16(x) static_cast<uint8_t>((x) & 0xff), \
@@ -128,7 +130,7 @@ static void CheckConstant(InstanceType expected, Object* actual) {
template <typename T>
-static void CheckBytecodeArrayEqual(struct ExpectedSnippet<T> expected,
+static void CheckBytecodeArrayEqual(const ExpectedSnippet<T>& expected,
Handle<BytecodeArray> actual,
bool has_unknown = false) {
CHECK_EQ(actual->frame_size(), expected.frame_size);
@@ -240,144 +242,121 @@ TEST(PrimitiveExpressions) {
B(Return)},
0},
{"var x = 0; return x + 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 12,
+ 8,
{B(LdaZero), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(Add), R(1), //
+ B(Add), R(0), //
B(Return)},
0},
{"var x = 0; return x - 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 12,
+ 8,
{B(LdaZero), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(Sub), R(1), //
+ B(Sub), R(0), //
B(Return)},
0},
{"var x = 4; return x * 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(4), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(Mul), R(1), //
+ B(Mul), R(0), //
B(Return)},
0},
{"var x = 4; return x / 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(4), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(Div), R(1), //
+ B(Div), R(0), //
B(Return)},
0},
{"var x = 4; return x % 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(4), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(Mod), R(1), //
+ B(Mod), R(0), //
B(Return)},
0},
{"var x = 1; return x | 2;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(1), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(2), //
- B(BitwiseOr), R(1), //
+ B(BitwiseOr), R(0), //
B(Return)},
0},
{"var x = 1; return x ^ 2;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(1), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(2), //
- B(BitwiseXor), R(1), //
+ B(BitwiseXor), R(0), //
B(Return)},
0},
{"var x = 1; return x & 2;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(1), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(2), //
- B(BitwiseAnd), R(1), //
+ B(BitwiseAnd), R(0), //
B(Return)},
0},
{"var x = 10; return x << 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(10), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(ShiftLeft), R(1), //
+ B(ShiftLeft), R(0), //
B(Return)},
0},
{"var x = 10; return x >> 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(10), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(ShiftRight), R(1), //
+ B(ShiftRight), R(0), //
B(Return)},
0},
{"var x = 10; return x >>> 3;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 13,
+ 9,
{B(LdaSmi8), U8(10), //
B(Star), R(0), //
- B(Ldar), R(0), // Easy to spot r1 not really needed here.
- B(Star), R(1), // Dead store.
B(LdaSmi8), U8(3), //
- B(ShiftRightLogical), R(1), //
+ B(ShiftRightLogical), R(0), //
B(Return)},
0},
{"var x = 0; return (x, 3);",
- 1 * kPointerSize,
+ kPointerSize,
1,
- 8,
+ 6,
{B(LdaZero), //
B(Star), R(0), //
- B(Ldar), R(0), //
B(LdaSmi8), U8(3), //
B(Return)},
0}};
@@ -418,8 +397,36 @@ TEST(LogicalExpressions) {
B(LdaSmi8), U8(3), //
B(Return)},
0},
+ {"var x = 0; return x || (1, 2, 3);",
+ 1 * kPointerSize,
+ 1,
+ 10,
+ {B(LdaZero), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(JumpIfToBooleanTrue), U8(4), //
+ B(LdaSmi8), U8(3), //
+ B(Return)},
+ 0},
+ {"var a = 2, b = 3, c = 4; return a || (a, b, a, b, c = 5, 3);",
+ 3 * kPointerSize,
+ 1,
+ 23,
+ {B(LdaSmi8), U8(2), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(4), //
+ B(Star), R(2), //
+ B(Ldar), R(0), //
+ B(JumpIfToBooleanTrue), U8(8), //
+ B(LdaSmi8), U8(5), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(3), //
+ B(Return)},
+ 0},
{"var x = 1; var a = 2, b = 3; return x || ("
-#define X "a, b, a, b, "
+#define X "a = 1, b = 2, "
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
#undef X
"3);",
@@ -434,7 +441,7 @@ TEST(LogicalExpressions) {
B(Star), R(2), //
B(Ldar), R(0), //
B(JumpIfToBooleanTrueConstant), U8(0), //
-#define X B(Ldar), R(1), B(Ldar), R(2), B(Ldar), R(1), B(Ldar), R(2),
+#define X B(LdaSmi8), U8(1), B(Star), R(1), B(LdaSmi8), U8(2), B(Star), R(2),
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
#undef X
B(LdaSmi8), U8(3), //
@@ -442,7 +449,7 @@ TEST(LogicalExpressions) {
1,
{268, 0, 0, 0}},
{"var x = 0; var a = 2, b = 3; return x && ("
-#define X "a, b, a, b, "
+#define X "a = 1, b = 2, "
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
#undef X
"3);",
@@ -457,10 +464,10 @@ TEST(LogicalExpressions) {
B(Star), R(2), //
B(Ldar), R(0), //
B(JumpIfToBooleanFalseConstant), U8(0), //
-#define X B(Ldar), R(1), B(Ldar), R(2), B(Ldar), R(1), B(Ldar), R(2),
+#define X B(LdaSmi8), U8(1), B(Star), R(1), B(LdaSmi8), U8(2), B(Star), R(2),
X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X
#undef X
- B(LdaSmi8), U8(3), //
+ B(LdaSmi8), U8(3), //
B(Return)},
1,
{268, 0, 0, 0}},
@@ -468,14 +475,14 @@ TEST(LogicalExpressions) {
0 * kPointerSize,
1,
2,
- {B(LdaZero), //
+ {B(LdaZero), //
B(Return)},
0},
{"return 1 || 3;",
0 * kPointerSize,
1,
3,
- {B(LdaSmi8), U8(1), //
+ {B(LdaSmi8), U8(1), //
B(Return)},
0},
{"var x = 1; return x && 3 || 0, 1;",
@@ -507,27 +514,51 @@ TEST(Parameters) {
ExpectedSnippet<int> snippets[] = {
{"function f() { return this; }",
- 0, 1, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0},
+ 0,
+ 1,
+ 3,
+ {B(Ldar), THIS(1), B(Return)},
+ 0},
{"function f(arg1) { return arg1; }",
- 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex), B(Return)}, 0},
+ 0,
+ 2,
+ 3,
+ {B(Ldar), A(1, 2), B(Return)},
+ 0},
{"function f(arg1) { return this; }",
- 0, 2, 3, {B(Ldar), R(helper.kLastParamIndex - 1), B(Return)}, 0},
+ 0,
+ 2,
+ 3,
+ {B(Ldar), THIS(2), B(Return)},
+ 0},
{"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return arg4; }",
- 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 3), B(Return)}, 0},
+ 0,
+ 8,
+ 3,
+ {B(Ldar), A(4, 8), B(Return)},
+ 0},
{"function f(arg1, arg2, arg3, arg4, arg5, arg6, arg7) { return this; }",
- 0, 8, 3, {B(Ldar), R(helper.kLastParamIndex - 7), B(Return)}, 0},
+ 0,
+ 8,
+ 3,
+ {B(Ldar), THIS(8), B(Return)},
+ 0},
{"function f(arg1) { arg1 = 1; }",
- 0, 2, 6,
- {B(LdaSmi8), U8(1), //
- B(Star), R(helper.kLastParamIndex), //
- B(LdaUndefined), //
+ 0,
+ 2,
+ 6,
+ {B(LdaSmi8), U8(1), //
+ B(Star), A(1, 2), //
+ B(LdaUndefined), //
B(Return)},
0},
{"function f(arg1, arg2, arg3, arg4) { arg2 = 1; }",
- 0, 5, 6,
- {B(LdaSmi8), U8(1), //
- B(Star), R(helper.kLastParamIndex - 2), //
- B(LdaUndefined), //
+ 0,
+ 5,
+ 6,
+ {B(LdaSmi8), U8(1), //
+ B(Star), A(2, 5), //
+ B(LdaUndefined), //
B(Return)},
0},
};
@@ -697,107 +728,85 @@ TEST(PropertyLoads) {
ExpectedSnippet<const char*> snippets[] = {
{"function f(a) { return a.name; }\nf({name : \"test\"})",
- 1 * kPointerSize,
+ 0,
2,
- 10,
+ 6,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
+ B(Return), //
},
1,
{"name"}},
{"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})",
- 1 * kPointerSize,
+ 0,
2,
- 10,
+ 6,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
+ B(Return) //
},
1,
{"key"}},
{"function f(a) { return a[100]; }\nf({100 : \"test\"})",
- 1 * kPointerSize,
+ 0,
2,
- 10,
+ 6,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaSmi8), U8(100), //
- B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
- B(Return) //
+ B(LdaSmi8), U8(100), //
+ B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
+ B(Return) //
},
0},
{"function f(a, b) { return a[b]; }\nf({arg : \"test\"}, \"arg\")",
- 1 * kPointerSize,
+ 0,
3,
- 10,
+ 6,
{
- B(Ldar), R(helper.kLastParamIndex - 1), //
- B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(KeyedLoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
- B(Return) //
+ B(Ldar), A(1, 2), //
+ B(KeyedLoadICSloppy), A(1, 3), U8(vector->GetIndex(slot1)), //
+ B(Return) //
},
0},
{"function f(a) { var b = a.name; return a[-124]; }\n"
"f({\"-124\" : \"test\", name : 123 })",
- 2 * kPointerSize,
+ kPointerSize,
2,
- 21,
+ 13,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(1), U8(vector->GetIndex(slot1)), //
- B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(1), //
- B(LdaSmi8), U8(-124), //
- B(KeyedLoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(-124), //
+ B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot2)), //
+ B(Return), //
},
1,
{"name"}},
{"function f(a) { \"use strict\"; return a.name; }\nf({name : \"test\"})",
- 1 * kPointerSize,
+ 0,
2,
- 12,
+ 6,
{
- // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
- // expression, or any other unused literal expression.
- B(LdaConstant), U8(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(LoadICStrict), R(0), U8(vector->GetIndex(slot1)), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(LoadICStrict), A(1, 2), U8(vector->GetIndex(slot1)), //
+ B(Return), //
},
- 2,
- {"use strict", "name"}},
+ 1,
+ {"name"}},
{"function f(a, b) { \"use strict\"; return a[b]; }\n"
"f({arg : \"test\"}, \"arg\")",
- 1 * kPointerSize,
+ 0,
3,
- 12,
+ 6,
{
- // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
- // expression, or any other unused literal expression.
- B(LdaConstant), U8(0), //
- B(Ldar), R(helper.kLastParamIndex - 1), //
- B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(KeyedLoadICStrict), R(0), U8(vector->GetIndex(slot1)), //
- B(Return) //
+ B(Ldar), A(2, 3), //
+ B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), //
+ B(Return), //
},
- 1,
- {"use strict"}}};
+ 0,
+ }};
for (size_t i = 0; i < arraysize(snippets); i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
@@ -820,129 +829,106 @@ TEST(PropertyStores) {
ExpectedSnippet<const char*> snippets[] = {
{"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})",
- 2 * kPointerSize,
+ kPointerSize,
2,
- 16,
+ 12,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaConstant), U8(0), //
- B(Star), R(1), //
- B(LdaConstant), U8(1), //
- B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
2,
{"name", "val"}},
{"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})",
- 2 * kPointerSize,
+ kPointerSize,
2,
- 16,
+ 12,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaConstant), U8(0), //
- B(Star), R(1), //
- B(LdaConstant), U8(1), //
- B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
2,
{"key", "val"}},
{"function f(a) { a[100] = \"val\"; }\nf({100 : \"test\"})",
- 2 * kPointerSize,
+ kPointerSize,
2,
- 16,
+ 12,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaSmi8), U8(100), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaSmi8), U8(100), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(0), //
+ B(KeyedStoreICSloppy), //
+ A(1, 2), R(0), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
1,
{"val"}},
{"function f(a, b) { a[b] = \"val\"; }\nf({arg : \"test\"}, \"arg\")",
- 2 * kPointerSize,
+ 0,
3,
- 16,
+ 8,
{
- B(Ldar), R(helper.kLastParamIndex - 1), //
- B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(KeyedStoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(KeyedStoreICSloppy), //
+ A(1, 3), A(2, 3), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
1,
{"val"}},
{"function f(a) { a.name = a[-124]; }\n"
"f({\"-124\" : \"test\", name : 123 })",
- 3 * kPointerSize,
+ kPointerSize,
2,
- 23,
+ 15,
{
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaConstant), U8(0), //
- B(Star), R(1), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(2), //
- B(LdaSmi8), U8(-124), //
- B(KeyedLoadICSloppy), R(2), U8(vector->GetIndex(slot1)), //
- B(StoreICSloppy), R(0), R(1), U8(vector->GetIndex(slot2)), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(-124), //
+ B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
+ B(StoreICSloppy), A(1, 2), R(0), U8(vector->GetIndex(slot2)), //
+ B(LdaUndefined), //
+ B(Return), //
},
1,
{"name"}},
{"function f(a) { \"use strict\"; a.name = \"val\"; }\n"
"f({name : \"test\"})",
- 2 * kPointerSize,
+ kPointerSize,
2,
- 18,
+ 12,
{
- // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
- // expression, or any other unused literal expression.
- B(LdaConstant), U8(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaConstant), U8(2), //
- B(StoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(StoreICStrict), A(1, 2), R(0), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
- 3,
- {"use strict", "name", "val"}},
+ 2,
+ {"name", "val"}},
{"function f(a, b) { \"use strict\"; a[b] = \"val\"; }\n"
"f({arg : \"test\"}, \"arg\")",
- 2 * kPointerSize,
+ 0,
3,
- 18,
+ 8,
{
- // TODO(rmcilroy) Avoid unnecessary LdaConstant for "use strict"
- // expression, or any other unused literal expression.
- B(LdaConstant), U8(0), //
- B(Ldar), R(helper.kLastParamIndex - 1), //
- B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(1), //
- B(LdaConstant), U8(1), //
- B(KeyedStoreICStrict), R(0), R(1), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(KeyedStoreICStrict), A(1, 3), A(2, 3), //
+ U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
- 2,
- {"use strict", "val"}}};
+ 1,
+ {"val"}}};
for (size_t i = 0; i < arraysize(snippets); i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
@@ -973,13 +959,13 @@ TEST(PropertyCall) {
2,
16,
{
- B(Ldar), R(helper.kLastParamIndex), //
+ B(Ldar), A(1, 2), //
B(Star), R(1), //
B(LdaConstant), U8(0), //
B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
B(Star), R(0), //
B(Call), R(0), R(1), U8(0), //
- B(Return) //
+ B(Return), //
},
1,
{"func"}},
@@ -988,14 +974,14 @@ TEST(PropertyCall) {
4,
24,
{
- B(Ldar), R(helper.kLastParamIndex - 2), //
+ B(Ldar), A(1, 4), //
B(Star), R(1), //
B(LdaConstant), U8(0), //
B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex - 1), //
+ B(Ldar), A(2, 4), //
B(Star), R(2), //
- B(Ldar), R(helper.kLastParamIndex), //
+ B(Ldar), A(3, 4), //
B(Star), R(3), //
B(Call), R(0), R(1), U8(2), //
B(Return) //
@@ -1005,19 +991,17 @@ TEST(PropertyCall) {
{"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)",
4 * kPointerSize,
3,
- 30,
+ 26,
{
- B(Ldar), R(helper.kLastParamIndex - 1), //
+ B(Ldar), A(1, 3), //
B(Star), R(1), //
B(LdaConstant), U8(0), //
B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(3), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(Add), R(3), //
+ B(Ldar), A(2, 3), //
+ B(Add), A(2, 3), //
B(Star), R(2), //
- B(Ldar), R(helper.kLastParamIndex), //
+ B(Ldar), A(2, 3), //
B(Star), R(3), //
B(Call), R(0), R(1), U8(2), //
B(Return), //
@@ -1294,7 +1278,7 @@ TEST(CallRuntime) {
2,
10,
{
- B(Ldar), R(helper.kLastParamIndex), //
+ B(Ldar), A(1, 2), //
B(Star), R(0), //
B(CallRuntime), U16(Runtime::kIsArray), R(0), U8(1), //
B(Return) //
@@ -1381,39 +1365,35 @@ TEST(IfConditions) {
{unused, unused, unused, unused, unused, unused}},
{"function f(a) { if (a <= 0) { return 200; } else { return -200; } }"
"f(99);",
- kPointerSize,
+ 0,
2,
- 19,
- {B(Ldar), R(helper.kLastParamIndex), //
- B(Star), R(0), //
- B(LdaZero), //
- B(TestLessThanOrEqual), R(0), //
- B(JumpIfFalse), U8(7), //
- B(LdaConstant), U8(0), //
- B(Return), //
- B(Jump), U8(5), //
- B(LdaConstant), U8(1), //
- B(Return), //
- B(LdaUndefined), //
- B(Return)}, //
+ 15,
+ {B(LdaZero), //
+ B(TestLessThanOrEqual), A(1, 2), //
+ B(JumpIfFalse), U8(7), //
+ B(LdaConstant), U8(0), //
+ B(Return), //
+ B(Jump), U8(5), //
+ B(LdaConstant), U8(1), //
+ B(Return), //
+ B(LdaUndefined), //
+ B(Return)}, //
2,
{helper.factory()->NewNumberFromInt(200),
helper.factory()->NewNumberFromInt(-200), unused, unused, unused,
unused}},
{"function f(a, b) { if (a in b) { return 200; } }"
"f('prop', { prop: 'yes'});",
- kPointerSize,
+ 0,
3,
- 15,
- {B(Ldar), R(helper.kLastParamIndex - 1), //
- B(Star), R(0), //
- B(Ldar), R(helper.kLastParamIndex), //
- B(TestIn), R(0), //
- B(JumpIfFalse), U8(5), //
- B(LdaConstant), U8(0), //
- B(Return), //
- B(LdaUndefined), //
- B(Return)}, //
+ 11,
+ {B(Ldar), A(2, 3), //
+ B(TestIn), A(1, 3), //
+ B(JumpIfFalse), U8(5), //
+ B(LdaConstant), U8(0), //
+ B(Return), //
+ B(LdaUndefined), //
+ B(Return)}, //
1,
{helper.factory()->NewNumberFromInt(200), unused, unused, unused, unused,
unused}},
@@ -1422,34 +1402,34 @@ TEST(IfConditions) {
X X X X X X X X X X X X X X X X X X X X X X X X
#undef X
" return 200; } else { return -200; } } f(0.001)",
- 3 * kPointerSize,
+ 2 * kPointerSize,
2,
- 218,
- {B(LdaZero), //
- B(Star), R(0), //
- B(LdaZero), //
- B(Star), R(1), //
- B(Ldar), R(0), //
- B(Star), R(2), //
- B(LdaConstant), U8(0), //
- B(TestEqualStrict), R(2), //
- B(JumpIfFalseConstant), U8(2), //
-#define X B(Ldar), R(0), B(Star), R(1), B(Ldar), R(1), B(Star), R(0),
- X X X X X X X X X X X X X X X X X X X X X X X X
+ 214,
+ {
+#define X B(Ldar), R(0), B(Star), R(1), B(Ldar), R(1), B(Star), R(0)
+ B(LdaZero), //
+ B(Star), R(0), //
+ B(LdaZero), //
+ B(Star), R(1), //
+ B(LdaConstant), U8(0), //
+ B(TestEqualStrict), R(0), //
+ B(JumpIfFalseConstant), U8(2), //
+ X, X, X, X, X, X, X, X, X, X, //
+ X, X, X, X, X, X, X, X, X, X, //
+ X, X, X, X, //
+ B(LdaConstant), U8(1), //
+ B(Return), //
+ B(Jump), U8(5), //
+ B(LdaConstant), U8(3), //
+ B(Return), //
+ B(LdaUndefined), //
+ B(Return)}, //
#undef X
- B(LdaConstant), U8(1), //
- B(Return), //
- B(Jump), U8(5), //
- B(LdaConstant), U8(3), //
- B(Return), //
- B(LdaUndefined), //
- B(Return)}, //
4,
{helper.factory()->NewHeapNumber(0.01),
helper.factory()->NewNumberFromInt(200),
helper.factory()->NewNumberFromInt(199),
- helper.factory()->NewNumberFromInt(-200),
- unused, unused}},
+ helper.factory()->NewNumberFromInt(-200), unused, unused}},
{"function f(a, b) {\n"
" if (a == b) { return 1; }\n"
" if (a === b) { return 1; }\n"
@@ -1459,22 +1439,18 @@ TEST(IfConditions) {
" if (a >= b) { return 1; }\n"
" if (a in b) { return 1; }\n"
" if (a instanceof b) { return 1; }\n"
- " /* if (a != b) { return 1; } */" // TODO(oth) Ast visitor yields
- " /* if (a !== b) { return 1; } */" // UNARY NOT, rather than !=/!==.
" return 0;\n"
"} f(1, 1);",
- kPointerSize,
+ 0,
3,
- 106,
+ 74,
{
#define IF_CONDITION_RETURN(condition) \
- B(Ldar), R(helper.kLastParamIndex - 1), \
- B(Star), R(0), \
- B(Ldar), R(helper.kLastParamIndex), \
- B(condition), R(0), \
- B(JumpIfFalse), U8(5), \
- B(LdaSmi8), U8(1), \
- B(Return),
+ B(Ldar), A(2, 3), \
+ B(condition), A(1, 3), \
+ B(JumpIfFalse), U8(5), \
+ B(LdaSmi8), U8(1), \
+ B(Return),
IF_CONDITION_RETURN(TestEqual) //
IF_CONDITION_RETURN(TestEqualStrict) //
IF_CONDITION_RETURN(TestLessThan) //
@@ -1483,9 +1459,9 @@ TEST(IfConditions) {
IF_CONDITION_RETURN(TestGreaterThanOrEqual) //
IF_CONDITION_RETURN(TestIn) //
IF_CONDITION_RETURN(TestInstanceOf) //
+ B(LdaZero), //
+ B(Return)}, //
#undef IF_CONDITION_RETURN
- B(LdaZero), //
- B(Return)}, //
0,
{unused, unused, unused, unused, unused, unused}},
};
@@ -1508,31 +1484,29 @@ TEST(DeclareGlobals) {
1,
45,
{
- B(Ldar), R(Register::function_closure().index()), //
- B(Star), R(2), //
- B(LdaConstant), U8(0), //
- B(Star), R(3), //
- B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
- B(PushContext), R(1), //
- B(LdaConstant), U8(1), //
- B(Star), R(2), //
- B(LdaZero), //
- B(Star), R(3), //
- B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
- B(LdaConstant), U8(2), //
- B(Star), R(2), //
- B(LdaZero), //
- B(Star), R(3), //
- B(LdaSmi8), U8(1), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), //
- U8(3), //
- B(LdaUndefined), //
- B(Return) //
+ B(Ldar), R(Register::function_closure().index()), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(3), //
+ B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
+ B(PushContext), R(1), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(2), //
+ B(LdaZero), //
+ B(Star), R(3), //
+ B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
+ B(LdaConstant), U8(2), //
+ B(Star), R(2), //
+ B(LdaZero), //
+ B(Star), R(3), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), //
+ B(LdaUndefined), //
+ B(Return), //
},
3,
- {InstanceType::FIXED_ARRAY_TYPE,
- InstanceType::FIXED_ARRAY_TYPE,
+ {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
{"function f() {}",
3 * kPointerSize,
@@ -1586,8 +1560,7 @@ TEST(DeclareGlobals) {
B(Return) //
},
3,
- {InstanceType::FIXED_ARRAY_TYPE,
- InstanceType::FIXED_ARRAY_TYPE,
+ {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
{"function f() {}\nf();",
4 * kPointerSize,
@@ -1634,34 +1607,28 @@ TEST(BasicLoops) {
{"var x = 0;"
"var y = 1;"
"while (x < 10) {"
- " y = y * 10;"
+ " y = y * 12;"
" x = x + 1;"
"}"
"return y;",
- 3 * kPointerSize,
+ 2 * kPointerSize,
1,
- 42,
+ 30,
{
B(LdaZero), //
B(Star), R(0), //
B(LdaSmi8), U8(1), //
B(Star), R(1), //
- B(Jump), U8(22), //
- B(Ldar), R(1), //
- B(Star), R(2), //
- B(LdaSmi8), U8(10), //
- B(Mul), R(2), //
+ B(Jump), U8(14), //
+ B(LdaSmi8), U8(12), //
+ B(Mul), R(1), //
B(Star), R(1), //
- B(Ldar), R(0), //
- B(Star), R(2), //
B(LdaSmi8), U8(1), //
- B(Add), R(2), //
+ B(Add), R(0), //
B(Star), R(0), //
- B(Ldar), R(0), //
- B(Star), R(2), //
B(LdaSmi8), U8(10), //
- B(TestLessThan), R(2), //
- B(JumpIfTrue), U8(-28), //
+ B(TestLessThan), R(0), //
+ B(JumpIfTrue), U8(-16), //
B(Ldar), R(1), //
B(Return), //
},
@@ -1676,52 +1643,40 @@ TEST(BasicLoops) {
" i = i + 1;"
"}"
"return i;",
- 2 * kPointerSize,
+ 1 * kPointerSize,
1,
- 80,
+ 56,
{
B(LdaZero), //
B(Star), R(0), //
- B(Jump), U8(71), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(47), //
B(LdaZero), //
- B(TestLessThan), R(1), //
+ B(TestLessThan), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(60), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(40), //
B(LdaSmi8), U8(3), //
- B(TestEqual), R(1), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(51), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(35), //
B(LdaSmi8), U8(4), //
- B(TestEqual), R(1), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(39), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(27), //
B(LdaSmi8), U8(10), //
- B(TestEqual), R(1), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(24), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(16), //
B(LdaSmi8), U8(5), //
- B(TestEqual), R(1), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(15), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(11), //
B(LdaSmi8), U8(1), //
- B(Add), R(1), //
+ B(Add), R(0), //
B(Star), R(0), //
B(LdaTrue), //
- B(JumpIfTrue), U8(-70), //
+ B(JumpIfTrue), U8(-46), //
B(Ldar), R(0), //
- B(Return) //
+ B(Return), //
},
0},
{"var x = 0; var y = 1;"
@@ -1732,43 +1687,33 @@ TEST(BasicLoops) {
" x = x + 1;"
"} while (x < 10);"
"return y;",
- 3 * kPointerSize,
+ 2 * kPointerSize,
1,
- 64,
+ 44,
{
B(LdaZero), //
B(Star), R(0), //
B(LdaSmi8), U8(1), //
B(Star), R(1), //
- B(Ldar), R(1), //
- B(Star), R(2), //
B(LdaSmi8), U8(10), //
- B(Mul), R(2), //
+ B(Mul), R(1), //
B(Star), R(1), //
- B(Ldar), R(0), //
- B(Star), R(2), //
B(LdaSmi8), U8(5), //
- B(TestEqual), R(2), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(34), //
- B(Ldar), R(0), //
- B(Star), R(2), //
+ B(Jump), U8(22), //
B(LdaSmi8), U8(6), //
- B(TestEqual), R(2), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(12), //
- B(Ldar), R(0), //
- B(Star), R(2), //
+ B(Jump), U8(8), //
B(LdaSmi8), U8(1), //
- B(Add), R(2), //
+ B(Add), R(0), //
B(Star), R(0), //
- B(Ldar), R(0), //
- B(Star), R(2), //
B(LdaSmi8), U8(10), //
- B(TestLessThan), R(2), //
- B(JumpIfTrue), U8(-52), //
+ B(TestLessThan), R(0), //
+ B(JumpIfTrue), U8(-32), //
B(Ldar), R(1), //
- B(Return) //
+ B(Return), //
},
0},
{"var x = 0; "
@@ -1776,24 +1721,20 @@ TEST(BasicLoops) {
" if (x == 1) break;"
" x = x + 1;"
"}",
- 2 * kPointerSize,
+ 1 * kPointerSize,
1,
- 29,
+ 21,
{
B(LdaZero), //
B(Star), R(0), //
- B(Ldar), R(0), //
- B(Star), R(1), //
B(LdaSmi8), U8(1), //
- B(TestEqual), R(1), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(14), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(10), //
B(LdaSmi8), U8(1), //
- B(Add), R(1), //
+ B(Add), R(0), //
B(Star), R(0), //
- B(Jump), U8(-22), //
+ B(Jump), U8(-14), //
B(LdaUndefined), //
B(Return), //
},
@@ -1803,31 +1744,25 @@ TEST(BasicLoops) {
" u = u + 1;"
" continue;"
"}",
- 3 * kPointerSize,
+ 2 * kPointerSize,
1,
- 42,
+ 30,
{
B(LdaZero), //
B(Star), R(0), //
B(LdaZero), //
B(Star), R(1), //
- B(Jump), U8(24), //
- B(Ldar), R(0), //
- B(Star), R(2), //
+ B(Jump), U8(16), //
B(LdaSmi8), U8(1), //
- B(Add), R(2), //
+ B(Add), R(0), //
B(Star), R(0), //
B(Jump), U8(2), //
- B(Ldar), R(1), //
- B(Star), R(2), //
B(LdaSmi8), U8(1), //
- B(Add), R(2), //
+ B(Add), R(1), //
B(Star), R(1), //
- B(Ldar), R(1), //
- B(Star), R(2), //
B(LdaSmi8), U8(100), //
- B(TestLessThan), R(2), //
- B(JumpIfTrue), U8(-30), //
+ B(TestLessThan), R(1), //
+ B(JumpIfTrue), U8(-18), //
B(LdaUndefined), //
B(Return), //
},
@@ -1842,38 +1777,30 @@ TEST(BasicLoops) {
" break;"
"}"
"return i;",
- 2 * kPointerSize,
+ 1 * kPointerSize,
1,
- 57,
+ 41,
{
B(LdaZero), //
B(Star), R(0), //
- B(Jump), U8(48), //
- B(Jump), U8(24), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(32), //
+ B(Jump), U8(16), //
B(LdaSmi8), U8(2), //
- B(TestEqual), R(1), //
+ B(TestEqual), R(0), //
B(JumpIfFalse), U8(4), //
- B(Jump), U8(22), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(14), //
B(LdaSmi8), U8(1), //
- B(Add), R(1), //
+ B(Add), R(0), //
B(Star), R(0), //
- B(Ldar), R(0), //
- B(Star), R(1), //
B(LdaSmi8), U8(3), //
- B(TestLessThan), R(1), //
- B(JumpIfTrue), U8(-30), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(TestLessThan), R(0), //
+ B(JumpIfTrue), U8(-18), //
B(LdaSmi8), U8(1), //
- B(Add), R(1), //
+ B(Add), R(0), //
B(Star), R(0), //
B(Jump), U8(5), //
B(LdaTrue), //
- B(JumpIfTrue), U8(-47), //
+ B(JumpIfTrue), U8(-31), //
B(Ldar), R(0), //
B(Return), //
},
@@ -1898,24 +1825,20 @@ TEST(UnaryOperators) {
" x = x + 10;"
"}"
"return x;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 29,
+ 21,
{
B(LdaZero), //
B(Star), R(0), //
- B(Jump), U8(12), //
- B(Ldar), R(0), //
- B(Star), R(1), //
+ B(Jump), U8(8), //
B(LdaSmi8), U8(10), //
- B(Add), R(1), //
+ B(Add), R(0), //
B(Star), R(0), //
- B(Ldar), R(0), //
- B(Star), R(1), //
B(LdaSmi8), U8(10), //
- B(TestEqual), R(1), //
+ B(TestEqual), R(0), //
B(LogicalNot), //
- B(JumpIfTrue), U8(-19), //
+ B(JumpIfTrue), U8(-11), //
B(Ldar), R(0), //
B(Return), //
},
@@ -1925,36 +1848,32 @@ TEST(UnaryOperators) {
" x = !x;"
"} while(x == false);"
"return x;",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 20,
+ 16,
{
- B(LdaFalse), //
- B(Star), R(0), //
- B(Ldar), R(0), //
- B(LogicalNot), //
- B(Star), R(0), //
- B(Ldar), R(0), //
- B(Star), R(1), //
- B(LdaFalse), //
- B(TestEqual), R(1), //
- B(JumpIfTrue), U8(-12), //
- B(Ldar), R(0), //
- B(Return), //
+ B(LdaFalse), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(LogicalNot), //
+ B(Star), R(0), //
+ B(LdaFalse), //
+ B(TestEqual), R(0), //
+ B(JumpIfTrue), U8(-8), //
+ B(Ldar), R(0), //
+ B(Return), //
},
0},
{"var x = 101;"
"return void(x * 3);",
- 2 * kPointerSize,
+ kPointerSize,
1,
- 14,
+ 10,
{
B(LdaSmi8), U8(101), //
B(Star), R(0), //
- B(Ldar), R(0), //
- B(Star), R(1), //
B(LdaSmi8), U8(3), //
- B(Mul), R(1), //
+ B(Mul), R(0), //
B(LdaUndefined), //
B(Return), //
},
@@ -1962,16 +1881,14 @@ TEST(UnaryOperators) {
{"var x = 1234;"
"var y = void (x * x - 1);"
"return y;",
- 4 * kPointerSize,
+ 3 * kPointerSize,
1,
- 24,
+ 20,
{
B(LdaConstant), U8(0), //
B(Star), R(0), //
B(Ldar), R(0), //
- B(Star), R(3), //
- B(Ldar), R(0), //
- B(Mul), R(3), //
+ B(Mul), R(0), //
B(Star), R(2), //
B(LdaSmi8), U8(1), //
B(Sub), R(2), //
@@ -1984,13 +1901,13 @@ TEST(UnaryOperators) {
{1234}},
{"var x = 13;"
"return typeof(x);",
- 1 * kPointerSize,
+ kPointerSize,
1,
8,
{
B(LdaSmi8), U8(13), //
- B(Star), R(0), //
- B(Ldar), R(0), //
+ B(Star), R(0), // TODO(oth): Ldar R(X) following Star R(X)
+ B(Ldar), R(0), // could be culled in bytecode array builder.
B(TypeOf), //
B(Return), //
},
@@ -2161,9 +2078,9 @@ TEST(ArrayLiterals) {
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"var a = 1; return [ a, a + 1 ];",
- 4 * kPointerSize,
+ 3 * kPointerSize,
1,
- 39,
+ 35,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
@@ -2176,13 +2093,11 @@ TEST(ArrayLiterals) {
B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), //
B(LdaSmi8), U8(1), //
B(Star), R(1), //
- B(Ldar), R(0), //
- B(Star), R(3), //
B(LdaSmi8), U8(1), //
- B(Add), R(3), //
+ B(Add), R(0), //
B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot1)), //
B(Ldar), R(2), //
- B(Return) //
+ B(Return), //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
@@ -2198,9 +2113,9 @@ TEST(ArrayLiterals) {
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"var a = 1; return [ [ a, 2 ], [ a + 2 ] ];",
- 6 * kPointerSize,
+ 5 * kPointerSize,
1,
- 71,
+ 67,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
@@ -2225,10 +2140,8 @@ TEST(ArrayLiterals) {
B(Star), R(4), //
B(LdaZero), //
B(Star), R(3), //
- B(Ldar), R(0), //
- B(Star), R(5), //
B(LdaSmi8), U8(2), //
- B(Add), R(5), //
+ B(Add), R(0), //
B(KeyedStoreICSloppy), R(4), R(3), U8(vector->GetIndex(slot2)), //
B(Ldar), R(4), //
B(KeyedStoreICSloppy), R(2), R(1), U8(vector->GetIndex(slot3)), //
@@ -2301,22 +2214,19 @@ TEST(ObjectLiterals) {
{InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
{"var a = 1; return { val: a, val: a + 1 };",
- 4 * kPointerSize,
+ 3 * kPointerSize,
1,
- 32,
+ 26,
{
B(LdaSmi8), U8(1), //
B(Star), R(0), //
B(LdaConstant), U8(0), //
B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
B(Star), R(1), //
- B(Ldar), R(0), //
B(LdaConstant), U8(1), //
B(Star), R(2), //
- B(Ldar), R(0), //
- B(Star), R(3), //
B(LdaSmi8), U8(1), //
- B(Add), R(3), //
+ B(Add), R(0), //
B(StoreICSloppy), R(1), R(2), U8(3), //
B(Ldar), R(1), //
B(Return), //
@@ -2593,7 +2503,7 @@ TEST(ObjectLiterals) {
B(LdaZero), //
B(Star), R(4), //
B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), //
- R(1), U8(4), //
+ R(1), U8(4), //
B(LdaConstant), U8(3), //
B(ToName), //
B(Star), R(2), //
@@ -2603,7 +2513,7 @@ TEST(ObjectLiterals) {
B(LdaZero), //
B(Star), R(4), //
B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), //
- R(1), U8(4), //
+ R(1), U8(4), //
B(Ldar), R(1), //
B(Return), //
},
@@ -2665,7 +2575,7 @@ TEST(TopLevelObjectLiterals) {
B(Star), R(4), //
B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), //
B(LdaUndefined), //
- B(Return), //
+ B(Return),
},
6,
{InstanceType::FIXED_ARRAY_TYPE,
@@ -2691,7 +2601,7 @@ TEST(TryCatch) {
// TODO(rmcilroy): modify tests when we have real try catch support.
ExpectedSnippet<int> snippets[] = {
{"try { return 1; } catch(e) { return 2; }",
- 1 * kPointerSize,
+ kPointerSize,
1,
5,
{
@@ -2718,7 +2628,7 @@ TEST(TryFinally) {
// TODO(rmcilroy): modify tests when we have real try finally support.
ExpectedSnippet<int> snippets[] = {
{"var a = 1; try { a = 2; } finally { a = 3; }",
- 1 * kPointerSize,
+ kPointerSize,
1,
14,
{
@@ -2950,17 +2860,16 @@ TEST(ContextVariables) {
{"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }",
4 * kPointerSize,
1,
- 51,
+ 49,
{
B(CallRuntime), U16(Runtime::kNewFunctionContext), //
R(closure), U8(1), //
B(PushContext), R(0), //
B(LdaTheHole), //
B(StaContextSlot), R(0), U8(first_context_slot), //
- B(LdaConstant), U8(0), //
B(LdaSmi8), U8(1), //
B(StaContextSlot), R(0), U8(first_context_slot), //
- B(LdaConstant), U8(1), //
+ B(LdaConstant), U8(0), //
B(Star), R(2), //
B(Ldar), R(closure), //
B(Star), R(3), //
@@ -2970,7 +2879,7 @@ TEST(ContextVariables) {
B(StaContextSlot), R(1), U8(first_context_slot), //
B(LdaSmi8), U8(2), //
B(StaContextSlot), R(1), U8(first_context_slot), //
- B(LdaConstant), U8(2), //
+ B(LdaConstant), U8(1), //
B(CreateClosure), U8(0), //
B(Return), //
// TODO(rmcilroy): Dead code after this point due to return in nested
@@ -2979,9 +2888,8 @@ TEST(ContextVariables) {
B(LdaUndefined), //
B(Return), //
},
- 3,
- {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
- InstanceType::FIXED_ARRAY_TYPE,
+ 2,
+ {InstanceType::FIXED_ARRAY_TYPE,
InstanceType::SHARED_FUNCTION_INFO_TYPE}},
};
« no previous file with comments | « src/interpreter/bytecodes.h ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698