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

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

Issue 1456483002: [Interpreter] Add New, CallRuntime and CallJSRuntime support to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@rmcilroy-0001-globals
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/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.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 d8e60a771be277922e90471f776df12eb29ba492..c47db851d28ad059e849fa9f25b81327e4c30852 100644
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc
@@ -64,6 +64,7 @@ class BytecodeGraphTester {
: isolate_(isolate), zone_(zone), script_(script) {
i::FLAG_ignition = true;
i::FLAG_always_opt = false;
+ 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);
@@ -535,6 +536,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();
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698