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

Unified Diff: test/cctest/compiler/test-run-bytecode-graph-builder.cc

Issue 1448913002: [Interpreter] Add support for keyed load / store ICs and named store IC to (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@graph_builder_load
Patch Set: Made the binding of return value of the store explicit. Created 5 years, 1 month 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/compiler/bytecode-graph-builder.cc ('k') | test/unittests/compiler/bytecode-graph-builder-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/compiler/test-run-bytecode-graph-builder.cc
diff --git a/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
index d5d9daaffc9a6f720588ff5e8331dbf822a42204..d8e60a771be277922e90471f776df12eb29ba492 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -334,6 +334,172 @@ TEST(BytecodeGraphBuilderNamedLoad) {
}
+TEST(BytecodeGraphBuilderKeyedLoad) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<2> snippets[] = {
+ {"return p1[p2];",
+ {factory->NewNumberFromInt(10),
+ BytecodeGraphTester::NewObject("({val : 10})"),
+ factory->NewStringFromStaticChars("val")}},
+ {"return p1[100];",
+ {factory->NewStringFromStaticChars("abc"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(0)}},
+ {"var b = 100; return p1[b];",
+ {factory->NewStringFromStaticChars("abc"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(0)}},
+ {"'use strict'; return p1[p2];",
+ {factory->NewNumberFromInt(10),
+ BytecodeGraphTester::NewObject("({val : 10 })"),
+ factory->NewStringFromStaticChars("val")}},
+ {"'use strict'; return p1[100];",
+ {factory->NewNumberFromInt(10),
+ BytecodeGraphTester::NewObject("({100 : 10})"),
+ factory->NewNumberFromInt(0)}},
+ {"'use strict'; var b = p2; return p1[b];",
+ {factory->NewStringFromStaticChars("abc"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(100)}},
+ {"var b;\n" REPEAT_127(SPACE, " b = p1[p2]; ") " return p1[p2];\n",
+ {factory->NewStringFromStaticChars("abc"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(100)}},
+ {"'use strict'; var b;\n" REPEAT_127(SPACE,
+ " b = p1[p2]; ") "return p1[p2];\n",
+ {factory->NewStringFromStaticChars("abc"),
+ BytecodeGraphTester::NewObject("({ 100 : 'abc'})"),
+ factory->NewNumberFromInt(100)}},
+ };
+
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
+ ScopedVector<char> script(2048);
+ SNPrintF(script, "function %s(p1, p2) { %s };\n%s(0);", kFunctionName,
+ snippets[i].code_snippet, kFunctionName);
+
+ BytecodeGraphTester tester(isolate, zone, script.start());
+ auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>();
+ Handle<Object> return_value =
+ callable(snippets[i].parameter(0), snippets[i].parameter(1))
+ .ToHandleChecked();
+ CHECK(return_value->SameValue(*snippets[i].return_value()));
+ }
+}
+
+
+TEST(BytecodeGraphBuilderNamedStore) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<1> snippets[] = {
+ {"return p1.val = 20;",
+ {factory->NewNumberFromInt(20),
+ BytecodeGraphTester::NewObject("({val : 10})")}},
+ {"p1.type = 'int'; return p1.type;",
+ {factory->NewStringFromStaticChars("int"),
+ BytecodeGraphTester::NewObject("({val : 10})")}},
+ {"p1.name = 'def'; return p1[\"name\"];",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({name : 'abc'})")}},
+ {"'use strict'; p1.val = 20; return p1.val;",
+ {factory->NewNumberFromInt(20),
+ BytecodeGraphTester::NewObject("({val : 10 })")}},
+ {"'use strict'; return p1.type = 'int';",
+ {factory->NewStringFromStaticChars("int"),
+ BytecodeGraphTester::NewObject("({val : 10})")}},
+ {"'use strict'; p1.val = 20; return p1[\"val\"];",
+ {factory->NewNumberFromInt(20),
+ BytecodeGraphTester::NewObject("({val : 10, name : 'abc'})")}},
+ {"var b = 'abc';\n" REPEAT_127(
+ SPACE, " p1.name = b; ") " p1.name = 'def'; return p1.name;\n",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({name : 'abc'})")}},
+ {"'use strict'; var b = 'def';\n" REPEAT_127(
+ SPACE, " p1.name = 'abc'; ") "p1.name = b; return p1.name;\n",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({ name : 'abc'})")}},
+ };
+
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
+ ScopedVector<char> script(3072);
+ SNPrintF(script, "function %s(p1) { %s };\n%s({});", kFunctionName,
+ snippets[i].code_snippet, kFunctionName);
+
+ BytecodeGraphTester tester(isolate, zone, script.start());
+ auto callable = tester.GetCallable<Handle<Object>>();
+ Handle<Object> return_value =
+ callable(snippets[i].parameter(0)).ToHandleChecked();
+ CHECK(return_value->SameValue(*snippets[i].return_value()));
+ }
+}
+
+
+TEST(BytecodeGraphBuilderKeyedStore) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<2> snippets[] = {
+ {"p1[p2] = 20; return p1[p2];",
+ {factory->NewNumberFromInt(20),
+ BytecodeGraphTester::NewObject("({val : 10})"),
+ factory->NewStringFromStaticChars("val")}},
+ {"return p1[100] = 'def';",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(0)}},
+ {"var b = 100; p1[b] = 'def'; return p1[b];",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(0)}},
+ {"'use strict'; p1[p2] = 20; return p1[p2];",
+ {factory->NewNumberFromInt(20),
+ BytecodeGraphTester::NewObject("({val : 10 })"),
+ factory->NewStringFromStaticChars("val")}},
+ {"'use strict'; return p1[100] = 20;",
+ {factory->NewNumberFromInt(20),
+ BytecodeGraphTester::NewObject("({100 : 10})"),
+ factory->NewNumberFromInt(0)}},
+ {"'use strict'; var b = p2; p1[b] = 'def'; return p1[b];",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(100)}},
+ {"var b;\n" REPEAT_127(
+ SPACE, " b = p1[p2]; ") " p1[p2] = 'def'; return p1[p2];\n",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({100 : 'abc'})"),
+ factory->NewNumberFromInt(100)}},
+ {"'use strict'; var b;\n" REPEAT_127(
+ SPACE, " b = p1[p2]; ") " p1[p2] = 'def'; return p1[p2];\n",
+ {factory->NewStringFromStaticChars("def"),
+ BytecodeGraphTester::NewObject("({ 100 : 'abc'})"),
+ factory->NewNumberFromInt(100)}},
+ };
+
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
+ ScopedVector<char> script(2048);
+ SNPrintF(script, "function %s(p1, p2) { %s };\n%s({});", kFunctionName,
+ snippets[i].code_snippet, kFunctionName);
+
+ BytecodeGraphTester tester(isolate, zone, script.start());
+ auto callable = tester.GetCallable<Handle<Object>>();
+ Handle<Object> return_value =
+ callable(snippets[i].parameter(0)).ToHandleChecked();
+ CHECK(return_value->SameValue(*snippets[i].return_value()));
+ }
+}
+
+
TEST(BytecodeGraphBuilderPropertyCall) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | test/unittests/compiler/bytecode-graph-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698