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

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

Issue 1435423002: [Interpreter] Add New, CallRuntime and CallJSRuntime support to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_tf_globals
Patch Set: 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/interpreter/interpreter.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 d7c45d0b1fe3d62bb064dca8ab501f75eae59912..f6a5c875c962ad161010973d3d202db9a315f3ef 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -65,6 +65,7 @@ class BytecodeGraphTester {
i::FLAG_ignition = true;
i::FLAG_always_opt = false;
i::FLAG_vector_stores = true;
+ i::FLAG_allow_natives_syntax = true;
// Set ignition filter flag via SetFlagsFromString to avoid double-free
// (or potential leak with StrDup() based on ownership confusion).
ScopedVector<char> ignition_filter(64);
@@ -369,6 +370,74 @@ TEST(BytecodeGraphBuilderPropertyCall) {
}
+TEST(BytecodeGraphBuilderCallNew) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<0> snippets[] = {
+ {"function counter() { this.count = 20; }\n"
+ "function f() {\n"
+ " var c = new counter();\n"
+ " return c.count;\n"
+ "}; f()",
+ {factory->NewNumberFromInt(20)}},
+ {"function counter(arg0) { this.count = 17; this.x = arg0; }\n"
+ "function f() {\n"
+ " var c = new counter(6);\n"
+ " return c.count + c.x;\n"
+ "}; f()",
+ {factory->NewNumberFromInt(23)}},
+ {"function counter(arg0, arg1) {\n"
+ " this.count = 17; this.x = arg0; this.y = arg1;\n"
+ "}\n"
+ "function f() {\n"
+ " var c = new counter(3, 5);\n"
+ " return c.count + c.x + c.y;\n"
+ "}; f()",
+ {factory->NewNumberFromInt(25)}},
+ };
+
+ 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()));
+ }
+}
+
+
+TEST(BytecodeGraphBuilderCallRuntime) {
+ HandleAndZoneScope scope;
+ Isolate* isolate = scope.main_isolate();
+ Zone* zone = scope.main_zone();
+ Factory* factory = isolate->factory();
+
+ ExpectedSnippet<1> snippets[] = {
+ {"function f(arg0) { return %MaxSmi(); }\nf()",
+ {factory->NewNumberFromInt(Smi::kMaxValue), factory->undefined_value()}},
+ {"function f(arg0) { return %IsArray(arg0) }\nf(undefined)",
+ {factory->true_value(), BytecodeGraphTester::NewObject("[1, 2, 3]")}},
+ {"function f(arg0) { return %Add(arg0, 2) }\nf(1)",
+ {factory->NewNumberFromInt(5), factory->NewNumberFromInt(3)}},
+ {"function f(arg0) { return %spread_arguments(arg0).length }\nf([])",
+ {factory->NewNumberFromInt(3),
+ BytecodeGraphTester::NewObject("[1, 2, 3]")}},
+ };
+
+ 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>>();
+ Handle<Object> return_value =
+ callable(snippets[i].parameter(0)).ToHandleChecked();
+ CHECK(return_value->SameValue(*snippets[i].return_value()));
+ }
+}
+
+
TEST(BytecodeGraphBuilderGlobals) {
HandleAndZoneScope scope;
Isolate* isolate = scope.main_isolate();
@@ -402,7 +471,7 @@ TEST(BytecodeGraphBuilderGlobals) {
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.
+ // TODO(rmcilroy): Add tests for typeof_mode once we have typeof support.
};
size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
« no previous file with comments | « src/interpreter/interpreter.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