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

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

Issue 1419003002: [Interpreter] Unify global and unallocated variable access. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
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 7524e9c3839afb3c233212d4f13720bb773df71c..974982e8ca10408de4c0fc6f5b742502b3c06128 100644
--- a/test/cctest/interpreter/test-bytecode-generator.cc
+++ b/test/cctest/interpreter/test-bytecode-generator.cc
@@ -730,22 +730,20 @@ TEST(PropertyLoads) {
{"function f(a) { return a.name; }\nf({name : \"test\"})",
0,
2,
- 6,
+ 5,
{
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
- B(Return), //
+ B(LoadICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
+ B(Return), //
},
1,
{"name"}},
{"function f(a) { return a[\"key\"]; }\nf({key : \"test\"})",
0,
2,
- 6,
+ 5,
{
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
- B(Return) //
+ B(LoadICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
+ B(Return) //
},
1,
{"key"}},
@@ -754,9 +752,9 @@ TEST(PropertyLoads) {
2,
6,
{
- B(LdaSmi8), U8(100), //
- B(KeyedLoadICSloppy), A(1, 2), 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\")",
@@ -764,49 +762,47 @@ TEST(PropertyLoads) {
3,
6,
{
- B(Ldar), A(1, 2), //
- B(KeyedLoadICSloppy), A(1, 3), 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 })",
kPointerSize,
2,
- 13,
+ 12,
{
- 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), //
+ B(LoadICSloppy), A(1, 2), U8(0), 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\"})",
0,
2,
- 6,
+ 5,
{
- B(LdaConstant), U8(0), //
- B(LoadICStrict), A(1, 2), U8(vector->GetIndex(slot1)), //
- B(Return), //
+ B(LoadICStrict), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
+ B(Return), //
},
1,
{"name"}},
- {"function f(a, b) { \"use strict\"; return a[b]; }\n"
+ {
+ "function f(a, b) { \"use strict\"; return a[b]; }\n"
"f({arg : \"test\"}, \"arg\")",
0,
3,
6,
{
- B(Ldar), A(2, 3), //
- B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), //
- B(Return), //
+ B(Ldar), A(2, 3), //
+ B(KeyedLoadICStrict), A(1, 3), U8(vector->GetIndex(slot1)), //
+ B(Return), //
},
- 0,
- }};
+ 0, }};
for (size_t i = 0; i < arraysize(snippets); i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
@@ -829,30 +825,26 @@ TEST(PropertyStores) {
ExpectedSnippet<const char*> snippets[] = {
{"function f(a) { a.name = \"val\"; }\nf({name : \"test\"})",
- kPointerSize,
+ 0,
2,
- 12,
+ 8,
{
- 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), //
+ B(LdaConstant), U8(1), //
+ B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
2,
{"name", "val"}},
{"function f(a) { a[\"key\"] = \"val\"; }\nf({key : \"test\"})",
- kPointerSize,
+ 0,
2,
- 12,
+ 8,
{
- 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), //
+ B(LdaConstant), U8(1), //
+ B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
2,
{"key", "val"}},
@@ -861,13 +853,12 @@ TEST(PropertyStores) {
2,
12,
{
- 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), //
+ 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"}},
@@ -876,42 +867,38 @@ TEST(PropertyStores) {
3,
8,
{
- B(LdaConstant), U8(0), //
- B(KeyedStoreICSloppy), //
- A(1, 3), A(2, 3), 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 })",
- kPointerSize,
+ 0,
2,
- 15,
+ 11,
{
- 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), //
+ B(LdaSmi8), U8(-124), //
+ B(KeyedLoadICSloppy), A(1, 2), U8(vector->GetIndex(slot1)), //
+ B(StoreICSloppy), A(1, 2), U8(0), U8(vector->GetIndex(slot2)), //
+ B(LdaUndefined), //
+ B(Return), //
},
1,
{"name"}},
{"function f(a) { \"use strict\"; a.name = \"val\"; }\n"
"f({name : \"test\"})",
- kPointerSize,
+ 0,
2,
- 12,
+ 8,
{
- 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), //
+ B(LdaConstant), U8(1), //
+ B(StoreICStrict), A(1, 2), U8(0), U8(vector->GetIndex(slot1)), //
+ B(LdaUndefined), //
+ B(Return), //
},
2,
{"name", "val"}},
@@ -921,11 +908,11 @@ TEST(PropertyStores) {
3,
8,
{
- B(LdaConstant), U8(0), //
- B(KeyedStoreICStrict), A(1, 3), A(2, 3), //
- 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), //
},
1,
{"val"}}};
@@ -957,54 +944,51 @@ TEST(PropertyCall) {
{"function f(a) { return a.func(); }\nf(" FUNC_ARG ")",
2 * kPointerSize,
2,
- 16,
+ 15,
{
- 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(Ldar), A(1, 2), //
+ B(Star), R(1), //
+ B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(Call), R(0), R(1), U8(0), //
+ B(Return), //
},
1,
{"func"}},
{"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)",
4 * kPointerSize,
4,
- 24,
+ 23,
{
- 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), A(2, 4), //
- B(Star), R(2), //
- B(Ldar), A(3, 4), //
- B(Star), R(3), //
- B(Call), R(0), R(1), U8(2), //
- B(Return) //
+ B(Ldar), A(1, 4), //
+ B(Star), R(1), //
+ B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(Ldar), A(2, 4), //
+ B(Star), R(2), //
+ B(Ldar), A(3, 4), //
+ B(Star), R(3), //
+ B(Call), R(0), R(1), U8(2), //
+ B(Return) //
},
1,
{"func"}},
{"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)",
4 * kPointerSize,
3,
- 26,
+ 25,
{
- 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), A(2, 3), //
- B(Add), A(2, 3), //
- B(Star), R(2), //
- B(Ldar), A(2, 3), //
- B(Star), R(3), //
- B(Call), R(0), R(1), U8(2), //
- B(Return), //
+ B(Ldar), A(1, 3), //
+ B(Star), R(1), //
+ B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(Ldar), A(2, 3), //
+ B(Add), A(2, 3), //
+ B(Star), R(2), //
+ B(Ldar), A(2, 3), //
+ B(Star), R(3), //
+ B(Call), R(0), R(1), U8(2), //
+ B(Return), //
},
1,
{"func"}}};
@@ -1019,182 +1003,125 @@ TEST(PropertyCall) {
TEST(LoadGlobal) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
+ Zone zone;
- if (!FLAG_global_var_shortcuts) return;
-
- ExpectedSnippet<int> snippets[] = {
- {
- "var a = 1;\nfunction f() { return a; }\nf()",
- 0,
- 1,
- 3,
- {
- B(LdaGlobal), _, //
- B(Return) //
- },
- },
- {
- "function t() { }\nfunction f() { return t; }\nf()",
- 0,
- 1,
- 3,
- {
- B(LdaGlobal), _, //
- B(Return) //
- },
- },
- };
-
- for (size_t i = 0; i < arraysize(snippets); i++) {
- Handle<BytecodeArray> bytecode_array =
- helper.MakeBytecode(snippets[i].code_snippet, "f");
- CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
- }
-}
-
-
-TEST(StoreGlobal) {
- InitializedHandleScope handle_scope;
- BytecodeGeneratorHelper helper;
+ FeedbackVectorSpec feedback_spec(&zone);
+ FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
- if (!FLAG_global_var_shortcuts) return;
+ Handle<i::TypeFeedbackVector> vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
- ExpectedSnippet<InstanceType> snippets[] = {
- {
- "var a = 1;\nfunction f() { a = 2; }\nf()",
- 0,
- 1,
- 6,
- {
- B(LdaSmi8), U8(2), //
- B(StaGlobalSloppy), _, //
- B(LdaUndefined), //
- B(Return) //
- },
- },
- {
- "var a = \"test\"; function f(b) { a = b; }\nf(\"global\")",
- 0,
- 2,
- 6,
- {
- B(Ldar), R(helper.kLastParamIndex), //
- B(StaGlobalSloppy), _, //
- B(LdaUndefined), //
- B(Return) //
- },
- },
- {
- "'use strict'; var a = 1;\nfunction f() { a = 2; }\nf()",
- 0,
- 1,
- 6,
- {
- B(LdaSmi8), U8(2), //
- B(StaGlobalStrict), _, //
- B(LdaUndefined), //
- B(Return) //
- },
- },
+ ExpectedSnippet<const char*> snippets[] = {
+ {"var a = 1;\nfunction f() { return a; }\nf()",
+ 0,
+ 1,
+ 4,
+ {
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
+ B(Return) //
+ },
+ 1,
+ {"a"}},
+ {"function t() { }\nfunction f() { return t; }\nf()",
+ 0,
+ 1,
+ 4,
+ {
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
+ B(Return) //
+ },
+ 1,
+ {"t"}},
+ {"'use strict'; var a = 1;\nfunction f() { return a; }\nf()",
+ 0,
+ 1,
+ 4,
+ {
+ B(LdaGlobalStrict), U8(0), U8(vector->GetIndex(slot)), //
+ B(Return) //
+ },
+ 1,
+ {"a"}},
+ {"a = 1;\nfunction f() { return a; }\nf()",
+ 0,
+ 1,
+ 4,
+ {
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
+ B(Return) //
+ },
+ 1,
+ {"a"}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecode(snippets[i].code_snippet, "f");
- CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
- }
-}
-
-
-TEST(CallGlobal) {
- InitializedHandleScope handle_scope;
- BytecodeGeneratorHelper helper;
-
- if (!FLAG_global_var_shortcuts) return;
-
- ExpectedSnippet<int> snippets[] = {
- {
- "function t() { }\nfunction f() { return t(); }\nf()",
- 2 * kPointerSize,
- 1,
- 12,
- {
- B(LdaUndefined), //
- B(Star), R(1), //
- B(LdaGlobal), _, //
- B(Star), R(0), //
- B(Call), R(0), R(1), U8(0), //
- B(Return) //
- },
- },
- {
- "function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()",
- 5 * kPointerSize,
- 1,
- 24,
- {
- B(LdaUndefined), //
- B(Star), R(1), //
- B(LdaGlobal), _, //
- B(Star), R(0), //
- B(LdaSmi8), U8(1), //
- B(Star), R(2), //
- B(LdaSmi8), U8(2), //
- B(Star), R(3), //
- B(LdaSmi8), U8(3), //
- B(Star), R(4), //
- B(Call), R(0), R(1), U8(3), //
- B(Return) //
- },
- },
- };
-
- size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
- for (size_t i = 0; i < num_snippets; i++) {
- Handle<BytecodeArray> bytecode_array =
- helper.MakeBytecode(snippets[i].code_snippet, "f");
- CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
+ CheckBytecodeArrayEqual(snippets[i], bytecode_array);
}
}
-TEST(LoadUnallocated) {
+TEST(StoreGlobal) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
Zone zone;
- int context_reg = Register::function_context().index();
- int global_index = Context::GLOBAL_OBJECT_INDEX;
-
FeedbackVectorSpec feedback_spec(&zone);
- FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot();
+ FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot();
Handle<i::TypeFeedbackVector> vector =
i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
ExpectedSnippet<const char*> snippets[] = {
- {"a = 1;\nfunction f() { return a; }\nf()",
- 1 * kPointerSize,
+ {"var a = 1;\nfunction f() { a = 2; }\nf()",
+ 0,
1,
- 11,
- {B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(0), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
- B(Return)},
+ 7,
+ {
+ B(LdaSmi8), U8(2), //
+ B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
+ B(LdaUndefined), //
+ B(Return) //
+ },
1,
{"a"}},
- {"function f() { return t; }\nt = 1;\nf()",
- 1 * kPointerSize,
+ {"var a = \"test\"; function f(b) { a = b; }\nf(\"global\")",
+ 0,
+ 2,
+ 7,
+ {
+ B(Ldar), R(helper.kLastParamIndex), //
+ B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
+ B(LdaUndefined), //
+ B(Return) //
+ },
1,
- 11,
- {B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(0), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
- B(Return)},
+ {"a"}},
+ {"'use strict'; var a = 1;\nfunction f() { a = 2; }\nf()",
+ 0,
1,
- {"t"}},
+ 7,
+ {
+ B(LdaSmi8), U8(2), //
+ B(StaGlobalStrict), U8(0), U8(vector->GetIndex(slot)), //
+ B(LdaUndefined), //
+ B(Return) //
+ },
+ 1,
+ {"a"}},
+ {"a = 1;\nfunction f() { a = 2; }\nf()",
+ 0,
+ 1,
+ 7,
+ {
+ B(LdaSmi8), U8(2), //
+ B(StaGlobalSloppy), U8(0), U8(vector->GetIndex(slot)), //
+ B(LdaUndefined), //
+ B(Return) //
+ },
+ 1,
+ {"a"}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
@@ -1205,56 +1132,58 @@ TEST(LoadUnallocated) {
}
-TEST(StoreUnallocated) {
+TEST(CallGlobal) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
Zone zone;
- int context_reg = Register::function_context().index();
- int global_index = Context::GLOBAL_OBJECT_INDEX;
-
FeedbackVectorSpec feedback_spec(&zone);
- FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot();
+ FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot();
+ FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
+ USE(slot1);
Handle<i::TypeFeedbackVector> vector =
i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
ExpectedSnippet<const char*> snippets[] = {
- {"a = 1;\nfunction f() { a = 2; }\nf()",
- 3 * kPointerSize,
+ {"function t() { }\nfunction f() { return t(); }\nf()",
+ 2 * kPointerSize,
1,
- 21,
- {B(LdaSmi8), U8(2), //
- B(Star), R(0), //
- B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(Star), R(2), //
- B(Ldar), R(0), //
- B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return)},
+ 13,
+ {
+ B(LdaUndefined), //
+ B(Star), R(1), //
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(Call), R(0), R(1), U8(0), //
+ B(Return) //
+ },
1,
- {"a"}},
- {"function f() { t = 4; }\nf()\nt = 1;",
- 3 * kPointerSize,
+ {"t"}},
+ {"function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()",
+ 5 * kPointerSize,
1,
- 21,
- {B(LdaSmi8), U8(4), //
- B(Star), R(0), //
- B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(Star), R(2), //
- B(Ldar), R(0), //
- B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), //
- B(LdaUndefined), //
- B(Return)},
+ 25,
+ {
+ B(LdaUndefined), //
+ B(Star), R(1), //
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(2), //
+ B(Star), R(3), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(4), //
+ B(Call), R(0), R(1), U8(3), //
+ B(Return) //
+ },
1,
{"t"}},
};
- for (size_t i = 0; i < arraysize(snippets); i++) {
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
Handle<BytecodeArray> bytecode_array =
helper.MakeBytecode(snippets[i].code_snippet, "f");
CheckBytecodeArrayEqual(snippets[i], bytecode_array);
@@ -1480,32 +1409,25 @@ TEST(IfConditions) {
}
-// Tests !FLAG_global_var_shortcuts mode.
TEST(DeclareGlobals) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
Zone zone;
- if (FLAG_global_var_shortcuts) return;
-
- int context_reg = Register::function_context().index();
- int global_index = Context::GLOBAL_OBJECT_INDEX;
-
// Create different feedback vector specs to be precise on slot numbering.
- FeedbackVectorSpec feedback_spec_ss(&zone);
- FeedbackVectorSlot slot_ss_1 = feedback_spec_ss.AddStoreICSlot();
- FeedbackVectorSlot slot_ss_2 = feedback_spec_ss.AddStoreICSlot();
- USE(slot_ss_1);
-
- Handle<i::TypeFeedbackVector> vector_ss =
- i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_ss);
+ FeedbackVectorSpec feedback_spec_stores(&zone);
+ FeedbackVectorSlot store_slot_1 = feedback_spec_stores.AddStoreICSlot();
+ FeedbackVectorSlot store_slot_2 = feedback_spec_stores.AddStoreICSlot();
+ USE(store_slot_1);
- FeedbackVectorSpec feedback_spec_l(&zone);
- FeedbackVectorSlot slot_l_1 = feedback_spec_l.AddLoadICSlot();
+ Handle<i::TypeFeedbackVector> store_vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_stores);
- Handle<i::TypeFeedbackVector> vector_l =
- i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_l);
+ FeedbackVectorSpec feedback_spec_loads(&zone);
+ FeedbackVectorSlot load_slot_1 = feedback_spec_loads.AddLoadICSlot();
+ Handle<i::TypeFeedbackVector> load_vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_loads);
ExpectedSnippet<InstanceType> snippets[] = {
{"var a = 1;",
@@ -1513,21 +1435,20 @@ TEST(DeclareGlobals) {
1,
30,
{
- B(LdaConstant), U8(0), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(LdaSmi8), U8(1), //
- B(Star), R(3), //
- B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), //
- U8(3), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(Star), R(1), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(1), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(3), //
+ B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
+ B(LdaUndefined), //
+ B(Return) //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
@@ -1537,203 +1458,64 @@ TEST(DeclareGlobals) {
1,
14,
{
- B(LdaConstant), U8(0), //
- B(Star), R(0), //
- B(LdaZero), //
- B(Star), R(1), //
- B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaZero), //
+ B(Star), R(1), //
+ B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), //
+ B(LdaUndefined), //
+ B(Return) //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"var a = 1;\na=2;",
4 * kPointerSize,
1,
- 52,
- {
- B(LdaConstant), U8(0), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(LdaSmi8), U8(1), //
- B(Star), R(3), //
- B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), //
- U8(3), //
- B(LdaSmi8), U8(2), //
- B(Star), R(1), //
- B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(2), //
- B(LdaConstant), U8(1), //
- B(Star), R(3), //
- B(Ldar), R(1), //
- B(StoreICSloppy), R(2), R(3), U8(vector_ss->GetIndex(slot_ss_2)), //
- B(Star), R(0), //
- B(Ldar), R(0), //
- B(Return) //
+ 38,
+ {
+ B(LdaConstant), U8(0), //
+ B(Star), R(1), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(1), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(3), //
+ B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
+ B(LdaSmi8), U8(2), //
+ B(StaGlobalSloppy), U8(1), U8(store_vector->GetIndex(store_slot_2)), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(Return) //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
{"function f() {}\nf();",
- 4 * kPointerSize,
- 1,
- 36,
- {
- B(LdaConstant), U8(0), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
- B(LdaUndefined), //
- B(Star), R(2), //
- B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(3), //
- B(LdaConstant), U8(1), //
- B(LoadICSloppy), R(3), U8(vector_l->GetIndex(slot_l_1)), //
- B(Star), R(1), //
- B(Call), R(1), R(2), U8(0), //
- B(Star), R(0), //
- B(Ldar), R(0), //
- B(Return) //
- },
- 2,
- {InstanceType::FIXED_ARRAY_TYPE,
- InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
- };
-
- for (size_t i = 0; i < arraysize(snippets); i++) {
- Handle<BytecodeArray> bytecode_array =
- helper.MakeTopLevelBytecode(snippets[i].code_snippet);
- CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
- }
-}
-
-
-// Tests FLAG_global_var_shortcuts mode.
-// TODO(ishell): remove when FLAG_global_var_shortcuts is removed.
-TEST(DeclareGlobals2) {
- InitializedHandleScope handle_scope;
- BytecodeGeneratorHelper helper;
-
- if (!FLAG_global_var_shortcuts) return;
-
- ExpectedSnippet<InstanceType> snippets[] = {
- {"var a = 1;",
- 5 * kPointerSize,
- 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), //
- },
- 3,
- {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
- InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
- {"function f() {}",
3 * kPointerSize,
1,
29,
{
- B(Ldar), R(Register::function_closure().index()), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(Star), R(2), //
- B(CallRuntime), U16(Runtime::kNewScriptContext), R(1), U8(2), //
- B(PushContext), R(0), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
- B(LdaUndefined), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(Star), R(1), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
+ B(LdaUndefined), //
+ B(Star), R(2), //
+ B(LdaGlobalSloppy), U8(1), U8(load_vector->GetIndex(load_slot_1)), //
+ B(Star), R(1), //
+ B(Call), R(1), R(2), U8(0), //
+ B(Star), R(0), //
+ B(Ldar), R(0), //
+ B(Return) //
},
2,
- {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}},
- {"var a = 1;\na=2;",
- 5 * kPointerSize,
- 1,
- 52,
- {
- 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(LdaSmi8), U8(2), //
- B(StaGlobalSloppy), _, //
- B(Star), R(0), //
- B(Ldar), R(0), //
- B(Return) //
- },
- 3,
- {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE,
+ {InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
- {"function f() {}\nf();",
- 4 * kPointerSize,
- 1,
- 43,
- {
- 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(LdaUndefined), //
- B(Star), R(3), //
- B(LdaGlobal), _, //
- B(Star), R(2), //
- B(Call), R(2), R(3), U8(0), //
- B(Star), R(0), //
- B(Ldar), R(0), //
- B(Return) //
- },
- 2,
- {InstanceType::FIXED_ARRAY_TYPE, InstanceType::FIXED_ARRAY_TYPE}},
};
for (size_t i = 0; i < arraysize(snippets); i++) {
@@ -2143,11 +1925,11 @@ TEST(RegExpLiterals) {
1,
10,
{
- B(LdaConstant), U8(0), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(CreateRegExpLiteral), U8(0), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateRegExpLiteral), U8(0), R(0), //
+ B(Return), //
},
2,
{"", "ab+d"}},
@@ -2156,31 +1938,30 @@ TEST(RegExpLiterals) {
1,
10,
{
- B(LdaConstant), U8(0), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(CreateRegExpLiteral), U8(0), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateRegExpLiteral), U8(0), R(0), //
+ B(Return), //
},
2,
{"i", "(\\w+)\\s(\\w+)"}},
{"return /ab+d/.exec('abdd');",
3 * kPointerSize,
1,
- 27,
- {
- B(LdaConstant), U8(0), //
- B(Star), R(2), //
- B(LdaConstant), U8(1), //
- B(CreateRegExpLiteral), U8(0), R(2), //
- B(Star), R(1), //
- B(LdaConstant), U8(2), //
- B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
- B(Star), R(0), //
- B(LdaConstant), U8(3), //
- B(Star), R(2), //
- B(Call), R(0), R(1), U8(1), //
- B(Return), //
+ 26,
+ {
+ B(LdaConstant), U8(0), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(1), //
+ B(CreateRegExpLiteral), U8(0), R(2), //
+ B(Star), R(1), //
+ B(LoadICSloppy), R(1), U8(2), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(3), //
+ B(Star), R(2), //
+ B(Call), R(0), R(1), U8(1), //
+ B(Return), //
},
4,
{"", "ab+d", "exec", "abdd"}},
@@ -2309,6 +2090,13 @@ TEST(ArrayLiterals) {
TEST(ObjectLiterals) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
+ Zone zone;
+
+ FeedbackVectorSpec feedback_spec(&zone);
+ FeedbackVectorSlot slot1 = feedback_spec.AddStoreICSlot();
+
+ Handle<i::TypeFeedbackVector> vector =
+ i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
int simple_flags = ObjectLiteral::kFastElements |
ObjectLiteral::kShallowProperties |
@@ -2321,9 +2109,9 @@ TEST(ObjectLiterals) {
1,
6,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(simple_flags), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(simple_flags), //
+ B(Return) //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
@@ -2332,88 +2120,80 @@ TEST(ObjectLiterals) {
1,
6,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
- B(Return) //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
+ B(Return) //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
{"var a = 1; return { name: 'string', val: a };",
- 3 * kPointerSize,
+ 2 * kPointerSize,
1,
- 24,
+ 20,
{
- 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(LdaConstant), U8(1), //
- B(Star), R(2), //
- B(Ldar), R(0), //
- B(StoreICSloppy), R(1), R(2), U8(3), //
- B(Ldar), R(1), //
- B(Return), //
+ 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(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
+ B(Ldar), R(1), //
+ B(Return), //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
{"var a = 1; return { val: a, val: a + 1 };",
- 3 * kPointerSize,
+ 2 * kPointerSize,
1,
- 26,
+ 22,
{
- 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(LdaConstant), U8(1), //
- B(Star), R(2), //
- B(LdaSmi8), U8(1), //
- B(Add), R(0), //
- B(StoreICSloppy), R(1), R(2), U8(3), //
- B(Ldar), R(1), //
- B(Return), //
+ 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(LdaSmi8), U8(1), //
+ B(Add), R(0), //
+ B(StoreICSloppy), R(1), U8(1), U8(vector->GetIndex(slot1)), //
+ B(Ldar), R(1), //
+ B(Return), //
},
2,
{InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
{"return { func: function() { } };",
- 2 * kPointerSize,
+ 1 * kPointerSize,
1,
- 22,
+ 18,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaConstant), U8(2), //
- B(CreateClosure), U8(0), //
- B(StoreICSloppy), R(0), R(1), U8(3), //
- B(Ldar), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(2), //
+ B(CreateClosure), U8(0), //
+ B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
+ B(Ldar), R(0), //
+ B(Return), //
},
3,
{InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::SHARED_FUNCTION_INFO_TYPE}},
{"return { func(a) { return a; } };",
- 2 * kPointerSize,
+ 1 * kPointerSize,
1,
- 22,
+ 18,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaConstant), U8(2), //
- B(CreateClosure), U8(0), //
- B(StoreICSloppy), R(0), R(1), U8(3), //
- B(Ldar), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(2), //
+ B(CreateClosure), U8(0), //
+ B(StoreICSloppy), R(0), U8(1), U8(vector->GetIndex(slot1)), //
+ B(Ldar), R(0), //
+ B(Return), //
},
3,
{InstanceType::FIXED_ARRAY_TYPE,
@@ -2424,22 +2204,22 @@ TEST(ObjectLiterals) {
1,
31,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaConstant), U8(2), //
- B(CreateClosure), U8(0), //
- B(Star), R(2), //
- B(LdaNull), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
- R(0), U8(5), //
- B(Ldar), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(1), //
+ B(LdaConstant), U8(2), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(2), //
+ B(LdaNull), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
+ R(0), U8(5), //
+ B(Ldar), R(0), //
+ B(Return), //
},
3,
{InstanceType::FIXED_ARRAY_TYPE,
@@ -2450,23 +2230,23 @@ TEST(ObjectLiterals) {
1,
34,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaConstant), U8(2), //
- B(CreateClosure), U8(0), //
- B(Star), R(2), //
- B(LdaConstant), U8(3), //
- B(CreateClosure), U8(0), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
- R(0), U8(5), //
- B(Ldar), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(1), //
+ B(LdaConstant), U8(2), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(3), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
+ R(0), U8(5), //
+ B(Ldar), R(0), //
+ B(Return), //
},
4,
{InstanceType::FIXED_ARRAY_TYPE,
@@ -2478,22 +2258,22 @@ TEST(ObjectLiterals) {
1,
31,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaNull), //
- B(Star), R(2), //
- B(LdaConstant), U8(2), //
- B(CreateClosure), U8(0), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
- R(0), U8(5), //
- B(Ldar), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(1), //
+ B(LdaNull), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(2), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineAccessorPropertyUnchecked), //
+ R(0), U8(5), //
+ B(Ldar), R(0), //
+ B(Return), //
},
3,
{InstanceType::FIXED_ARRAY_TYPE,
@@ -2504,20 +2284,20 @@ TEST(ObjectLiterals) {
1,
30,
{
- 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(LdaSmi8), U8(1), //
- B(Star), R(2), //
- B(Ldar), R(0), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), //
- B(Ldar), R(1), //
- B(Return), //
+ 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(LdaSmi8), U8(1), //
+ B(Star), R(2), //
+ B(Ldar), R(0), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kSetProperty), R(1), U8(4), //
+ B(Ldar), R(1), //
+ B(Return), //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
@@ -2526,13 +2306,13 @@ TEST(ObjectLiterals) {
1,
18,
{
- B(LdaConstant), U8(0), //
- B(CreateObjectLiteral), U8(0), U8(simple_flags), //
- B(Star), R(0), //
- B(LdaNull), B(Star), R(1), //
- B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), //
- B(Ldar), R(0), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(CreateObjectLiteral), U8(0), U8(simple_flags), //
+ B(Star), R(0), //
+ B(LdaNull), B(Star), R(1), //
+ B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(0), U8(2), //
+ B(Ldar), R(0), //
+ B(Return), //
},
1,
{InstanceType::FIXED_ARRAY_TYPE}},
@@ -2541,22 +2321,22 @@ TEST(ObjectLiterals) {
1,
31,
{
- B(LdaConstant), U8(0), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(CreateObjectLiteral), U8(0), U8(simple_flags), //
- B(Star), R(1), //
- B(Ldar), R(0), //
- B(ToName), //
- B(Star), R(2), //
- B(LdaSmi8), U8(1), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
- U8(4), //
- B(Ldar), R(1), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateObjectLiteral), U8(0), U8(simple_flags), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(ToName), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
+ U8(4), //
+ B(Ldar), R(1), //
+ B(Return), //
},
2,
{InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
@@ -2564,28 +2344,26 @@ TEST(ObjectLiterals) {
{"var a = 'test'; return { val: a, [a]: 1 }",
5 * kPointerSize,
1,
- 41,
- {
- B(LdaConstant), U8(0), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
- B(Star), R(1), //
- B(LdaConstant), U8(2), //
- B(Star), R(2), //
- B(Ldar), R(0), //
- B(StoreICSloppy), R(1), R(2), U8(3), //
- B(Ldar), R(0), //
- B(ToName), //
- B(Star), R(2), //
- B(LdaSmi8), U8(1), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
- U8(4), //
- B(Ldar), R(1), //
- B(Return), //
+ 37,
+ {
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateObjectLiteral), U8(0), U8(deep_elements_flags), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(StoreICSloppy), R(1), U8(2), U8(vector->GetIndex(slot1)), //
+ B(Ldar), R(0), //
+ B(ToName), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
+ U8(4), //
+ B(Ldar), R(1), //
+ B(Return), //
},
3,
{InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
@@ -2596,26 +2374,26 @@ TEST(ObjectLiterals) {
1,
43,
{
- B(LdaConstant), U8(0), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(CreateObjectLiteral), U8(1), U8(simple_flags), //
- B(Star), R(1), //
- B(Ldar), R(0), //
- B(ToName), //
- B(Star), R(2), //
- B(LdaSmi8), U8(1), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
- U8(4), //
- B(LdaConstant), U8(1), //
- B(CreateObjectLiteral), U8(0), U8(13), //
- B(Star), R(2), //
- B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), //
- B(Ldar), R(1), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateObjectLiteral), U8(1), U8(simple_flags), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(ToName), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(1), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
+ U8(4), //
+ B(LdaConstant), U8(1), //
+ B(CreateObjectLiteral), U8(0), U8(13), //
+ B(Star), R(2), //
+ B(CallRuntime), U16(Runtime::kInternalSetPrototype), R(1), U8(2), //
+ B(Ldar), R(1), //
+ B(Return), //
},
2,
{InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
@@ -2625,42 +2403,42 @@ TEST(ObjectLiterals) {
1,
69,
{
- B(LdaConstant), U8(0), //
- B(Star), R(0), //
- B(LdaConstant), U8(1), //
- B(CreateObjectLiteral), U8(0), U8(simple_flags), //
- B(Star), R(1), //
- B(Ldar), R(0), //
- B(ToName), //
- B(Star), R(2), //
- B(LdaConstant), U8(2), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
- U8(4), //
- B(LdaConstant), U8(3), //
- B(ToName), //
- B(Star), R(2), //
- B(LdaConstant), U8(4), //
- B(CreateClosure), U8(0), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), //
- R(1), U8(4), //
- B(LdaConstant), U8(3), //
- B(ToName), //
- B(Star), R(2), //
- B(LdaConstant), U8(5), //
- B(CreateClosure), U8(0), //
- B(Star), R(3), //
- B(LdaZero), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), //
- R(1), U8(4), //
- B(Ldar), R(1), //
- B(Return), //
+ B(LdaConstant), U8(0), //
+ B(Star), R(0), //
+ B(LdaConstant), U8(1), //
+ B(CreateObjectLiteral), U8(0), U8(simple_flags), //
+ B(Star), R(1), //
+ B(Ldar), R(0), //
+ B(ToName), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(2), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineDataPropertyUnchecked), R(1), //
+ U8(4), //
+ B(LdaConstant), U8(3), //
+ B(ToName), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(4), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineGetterPropertyUnchecked), //
+ R(1), U8(4), //
+ B(LdaConstant), U8(3), //
+ B(ToName), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(5), //
+ B(CreateClosure), U8(0), //
+ B(Star), R(3), //
+ B(LdaZero), //
+ B(Star), R(4), //
+ B(CallRuntime), U16(Runtime::kDefineSetterPropertyUnchecked), R(1) //
+ U8(4), //
+ B(Ldar), R(1), //
+ B(Return), //
},
6,
{InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
@@ -2679,112 +2457,43 @@ TEST(ObjectLiterals) {
}
-// Tests !FLAG_global_var_shortcuts mode.
TEST(TopLevelObjectLiterals) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
- if (FLAG_global_var_shortcuts) return;
-
int has_function_flags = ObjectLiteral::kFastElements |
ObjectLiteral::kHasFunction |
ObjectLiteral::kDisableMementos;
ExpectedSnippet<InstanceType> snippets[] = {
{"var a = { func: function() { } };",
- 6 * kPointerSize,
- 1,
- 54,
- {
- B(LdaConstant), U8(0), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
- B(LdaConstant), U8(1), //
- B(Star), R(1), //
- B(LdaZero), //
- B(Star), R(2), //
- B(LdaConstant), U8(2), //
- B(CreateObjectLiteral), U8(0), U8(has_function_flags), //
- B(Star), R(4), //
- B(LdaConstant), U8(3), //
- B(Star), R(5), //
- B(LdaConstant), U8(4), //
- B(CreateClosure), U8(1), //
- B(StoreICSloppy), R(4), R(5), U8(5), //
- B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), //
- B(Ldar), R(4), //
- B(Star), R(3), //
- B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
- B(LdaUndefined), //
- B(Return), //
- },
- 5,
- {InstanceType::FIXED_ARRAY_TYPE,
- InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
- InstanceType::FIXED_ARRAY_TYPE,
- InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
- InstanceType::SHARED_FUNCTION_INFO_TYPE}},
- };
-
- for (size_t i = 0; i < arraysize(snippets); i++) {
- Handle<BytecodeArray> bytecode_array =
- helper.MakeTopLevelBytecode(snippets[i].code_snippet);
- CheckBytecodeArrayEqual(snippets[i], bytecode_array);
- }
-}
-
-
-// Tests FLAG_global_var_shortcuts mode.
-// TODO(ishell): remove when FLAG_global_var_shortcuts is removed.
-TEST(TopLevelObjectLiterals2) {
- InitializedHandleScope handle_scope;
- BytecodeGeneratorHelper helper;
-
- if (!FLAG_global_var_shortcuts) return;
-
- int has_function_flags = ObjectLiteral::kFastElements |
- ObjectLiteral::kHasFunction |
- ObjectLiteral::kDisableMementos;
- ExpectedSnippet<InstanceType> snippets[] = {
- {"var a = { func: function() { } };",
- 7 * kPointerSize,
+ 5 * kPointerSize,
1,
- 69,
- {
- 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(LdaConstant), U8(3), //
- B(CreateObjectLiteral), U8(0), U8(has_function_flags), //
- B(Star), R(5), //
- B(LdaConstant), U8(4), //
- B(Star), R(6), //
- B(LdaConstant), U8(5), //
- B(CreateClosure), U8(1), //
- B(StoreICSloppy), R(5), R(6), U8(3), //
- B(CallRuntime), U16(Runtime::kToFastProperties), R(5), U8(1), //
- B(Ldar), R(5), //
- B(Star), R(4), //
- B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), U8(3), //
- B(LdaUndefined), //
- B(Return),
+ 50,
+ {
+ B(LdaConstant), U8(0), //
+ B(Star), R(1), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
+ B(LdaConstant), U8(1), //
+ B(Star), R(1), //
+ B(LdaZero), //
+ B(Star), R(2), //
+ B(LdaConstant), U8(2), //
+ B(CreateObjectLiteral), U8(0), U8(has_function_flags), //
+ B(Star), R(4), //
+ B(LdaConstant), U8(4), //
+ B(CreateClosure), U8(1), //
+ B(StoreICSloppy), R(4), U8(3), U8(5), //
+ B(CallRuntime), U16(Runtime::kToFastProperties), R(4), U8(1), //
+ B(Ldar), R(4), //
+ B(Star), R(3), //
+ B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), U8(3), //
+ B(LdaUndefined), //
+ B(Return), //
},
- 6,
+ 5,
{InstanceType::FIXED_ARRAY_TYPE,
- InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
InstanceType::FIXED_ARRAY_TYPE,
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
@@ -2922,17 +2631,11 @@ TEST(Throw) {
}
-// Tests !FLAG_global_var_shortcuts mode.
TEST(CallNew) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;
Zone zone;
- if (FLAG_global_var_shortcuts) return;
-
- int context_reg = Register::function_context().index();
- int global_index = Context::GLOBAL_OBJECT_INDEX;
-
FeedbackVectorSpec feedback_spec(&zone);
FeedbackVectorSlot slot1 = feedback_spec.AddGeneralSlot();
FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
@@ -2945,17 +2648,14 @@ TEST(CallNew) {
{"function bar() { this.value = 0; }\n"
"function f() { return new bar(); }\n"
"f()",
- 2 * kPointerSize,
+ 1 * kPointerSize,
1,
- 17,
+ 10,
{
- B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
- B(Star), R(0), //
- B(New), R(0), R(0), U8(0), //
- B(Return), //
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(New), R(0), R(0), U8(0), //
+ B(Return), //
},
1,
{InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
@@ -2964,17 +2664,14 @@ TEST(CallNew) {
"f()",
2 * kPointerSize,
1,
- 21,
+ 14,
{
- B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
- B(Star), R(0), //
- B(LdaSmi8), U8(3), //
- B(Star), R(1), //
- B(New), R(0), R(1), U8(1), //
- B(Return), //
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(1), //
+ B(New), R(0), R(1), U8(1), //
+ B(Return), //
},
1,
{InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
@@ -2988,21 +2685,18 @@ TEST(CallNew) {
"f()",
4 * kPointerSize,
1,
- 29,
+ 22,
{
- B(LdaContextSlot), R(context_reg), U8(global_index), //
- B(Star), R(1), //
- B(LdaConstant), U8(0), //
- B(LoadICSloppy), R(1), U8(vector->GetIndex(slot2)), //
- B(Star), R(0), //
- B(LdaSmi8), U8(3), //
- B(Star), R(1), //
- B(LdaSmi8), U8(4), //
- B(Star), R(2), //
- B(LdaSmi8), U8(5), //
- B(Star), R(3), //
- B(New), R(0), R(1), U8(3), //
- B(Return), //
+ B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
+ B(Star), R(0), //
+ B(LdaSmi8), U8(3), //
+ B(Star), R(1), //
+ B(LdaSmi8), U8(4), //
+ B(Star), R(2), //
+ B(LdaSmi8), U8(5), //
+ B(Star), R(3), //
+ B(New), R(0), R(1), U8(3), //
+ B(Return), //
},
1,
{InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
@@ -3016,76 +2710,6 @@ TEST(CallNew) {
}
-// Tests FLAG_global_var_shortcuts mode.
-// TODO(ishell): remove when FLAG_global_var_shortcuts is removed.
-TEST(CallNew2) {
- InitializedHandleScope handle_scope;
- BytecodeGeneratorHelper helper;
-
- if (!FLAG_global_var_shortcuts) return;
-
- ExpectedSnippet<InstanceType> snippets[] = {
- {"function bar() { this.value = 0; }\n"
- "function f() { return new bar(); }\n"
- "f()",
- kPointerSize,
- 1,
- 9,
- {
- B(LdaGlobal), _, //
- B(Star), R(0), //
- B(New), R(0), R(0), U8(0), //
- B(Return), //
- },
- 0},
- {"function bar(x) { this.value = 18; this.x = x;}\n"
- "function f() { return new bar(3); }\n"
- "f()",
- 2 * kPointerSize,
- 1,
- 13,
- {
- B(LdaGlobal), _, //
- B(Star), R(0), //
- B(LdaSmi8), U8(3), //
- B(Star), R(1), //
- B(New), R(0), R(1), U8(1), //
- B(Return), //
- },
- 0},
- {"function bar(w, x, y, z) {\n"
- " this.value = 18;\n"
- " this.x = x;\n"
- " this.y = y;\n"
- " this.z = z;\n"
- "}\n"
- "function f() { return new bar(3, 4, 5); }\n"
- "f()",
- 4 * kPointerSize,
- 1,
- 21,
- {
- B(LdaGlobal), _, //
- B(Star), R(0), //
- B(LdaSmi8), U8(3), //
- B(Star), R(1), //
- B(LdaSmi8), U8(4), //
- B(Star), R(2), //
- B(LdaSmi8), U8(5), //
- B(Star), R(3), //
- B(New), R(0), R(1), U8(3), //
- B(Return), //
- },
- 0}};
-
- for (size_t i = 0; i < arraysize(snippets); i++) {
- Handle<BytecodeArray> bytecode_array =
- helper.MakeBytecode(snippets[i].code_snippet, "f");
- CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
- }
-}
-
-
TEST(ContextVariables) {
InitializedHandleScope handle_scope;
BytecodeGeneratorHelper helper;

Powered by Google App Engine
This is Rietveld 408576698