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

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

Issue 1449373002: [Interpreter] Add support for global loads / stores / calls to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@rmcilroy-0000
Patch Set: Rebase. 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/objects.h ('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 14a6990168e7ac04b26a2316dde63956a9118495..db08c675d144fa04e8aeb7536e93ee2ba8c285b2 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -156,6 +156,8 @@ struct ExpectedSnippet {
}
inline Handle<Object> parameter(int i) const {
+ DCHECK_GE(i, 0);
+ DCHECK_LT(i, N);
return return_value_and_parameters[1 + i];
}
};
@@ -366,6 +368,52 @@ TEST(BytecodeGraphBuilderPropertyCall) {
}
}
+
+TEST(BytecodeGraphBuilderGlobals) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<0> snippets[] = {
+ {"var global = 321;\n function f() { return global; };\n f();",
+ {factory->NewNumberFromInt(321)}},
+ {"var global = 321;\n"
+ "function f() { global = 123; return global };\n f();",
+ {factory->NewNumberFromInt(123)}},
+ {"var global = function() { return 'abc'};\n"
+ "function f() { return global(); };\n f();",
+ {factory->NewStringFromStaticChars("abc")}},
+ {"var global = 456;\n"
+ "function f() { 'use strict'; return global; };\n f();",
+ {factory->NewNumberFromInt(456)}},
+ {"var global = 987;\n"
+ "function f() { 'use strict'; global = 789; return global };\n f();",
+ {factory->NewNumberFromInt(789)}},
+ {"var global = function() { return 'xyz'};\n"
+ "function f() { 'use strict'; return global(); };\n f();",
+ {factory->NewStringFromStaticChars("xyz")}},
+ {"var global = 'abc'; var global_obj = {val:123};\n"
+ "function f() {\n" REPEAT_127(
+ SPACE, " var b = global_obj.name;\n") "return global; };\n f();\n",
+ {factory->NewStringFromStaticChars("abc")}},
+ {"var global = 'abc'; var global_obj = {val:123};\n"
+ "function f() { 'use strict';\n" REPEAT_127(
+ SPACE, " var b = global_obj.name;\n") "global = 'xyz'; return "
+ "global };\n f();\n",
+ {factory->NewStringFromStaticChars("xyz")}},
+ // TODO(rmcilroy): Add tests for typeof_mode once we have typeof support.
+ };
+
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
+ for (size_t i = 0; i < num_snippets; i++) {
+ BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
+ auto callable = tester.GetCallable<>();
+ Handle<Object> return_value = callable().ToHandleChecked();
+ CHECK(return_value->SameValue(*snippets[i].return_value()));
+ }
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
« no previous file with comments | « src/objects.h ('k') | test/unittests/compiler/bytecode-graph-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698