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

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

Issue 1568323002: [Interpreter] Add support for LOOKUP_SLOT_CALL to interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_eval_graph
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility> 5 #include <utility>
6 6
7 #include "src/compiler/pipeline.h" 7 #include "src/compiler/pipeline.h"
8 #include "src/execution.h" 8 #include "src/execution.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/interpreter/bytecode-array-builder.h" 10 #include "src/interpreter/bytecode-array-builder.h"
(...skipping 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 function_epilogue); 1096 function_epilogue);
1097 1097
1098 BytecodeGraphTester tester(isolate, zone, script.start(), "t"); 1098 BytecodeGraphTester tester(isolate, zone, script.start(), "t");
1099 auto callable = tester.GetCallable<>(); 1099 auto callable = tester.GetCallable<>();
1100 Handle<Object> return_value = callable().ToHandleChecked(); 1100 Handle<Object> return_value = callable().ToHandleChecked();
1101 CHECK(return_value->SameValue(*snippets[i].return_value())); 1101 CHECK(return_value->SameValue(*snippets[i].return_value()));
1102 } 1102 }
1103 } 1103 }
1104 1104
1105 1105
1106 TEST(BytecodeGraphBuilderCallLookupSlot) {
1107 HandleAndZoneScope scope;
1108 Isolate* isolate = scope.main_isolate();
1109 Zone* zone = scope.main_zone();
1110
1111 ExpectedSnippet<0> snippets[] = {
1112 {"g = function(){ return 2 }; eval(''); return g();",
1113 {handle(Smi::FromInt(2), isolate)}},
1114 {"g = function(){ return 2 }; eval('g = function() {return 3}');\n"
1115 "return g();",
1116 {handle(Smi::FromInt(3), isolate)}},
1117 {"g = { x: function(){ return this.y }, y: 20 };\n"
1118 "eval('g = { x: g.x, y: 30 }');\n"
1119 "return g.x();",
1120 {handle(Smi::FromInt(30), isolate)}},
1121 };
1122
1123 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1124 for (size_t i = 0; i < num_snippets; i++) {
1125 ScopedVector<char> script(1024);
1126 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1127 snippets[i].code_snippet, kFunctionName);
1128 BytecodeGraphTester tester(isolate, zone, script.start());
1129 auto callable = tester.GetCallable<>();
1130 Handle<Object> return_value = callable().ToHandleChecked();
1131 CHECK(return_value->SameValue(*snippets[i].return_value()));
1132 }
1133 }
1134
1135
1106 TEST(BytecodeGraphBuilderEval) { 1136 TEST(BytecodeGraphBuilderEval) {
1107 HandleAndZoneScope scope; 1137 HandleAndZoneScope scope;
1108 Isolate* isolate = scope.main_isolate(); 1138 Isolate* isolate = scope.main_isolate();
1109 Zone* zone = scope.main_zone(); 1139 Zone* zone = scope.main_zone();
1110 Factory* factory = isolate->factory(); 1140 Factory* factory = isolate->factory();
1111 1141
1112 ExpectedSnippet<0> snippets[] = { 1142 ExpectedSnippet<0> snippets[] = {
1113 {"return eval('1;');", {handle(Smi::FromInt(1), isolate)}}, 1143 {"return eval('1;');", {handle(Smi::FromInt(1), isolate)}},
1114 {"return eval('100 * 20;');", {handle(Smi::FromInt(2000), isolate)}}, 1144 {"return eval('100 * 20;');", {handle(Smi::FromInt(2000), isolate)}},
1115 {"var x = 10; return eval('x + 20;');", 1145 {"var x = 10; return eval('x + 20;');",
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2300 callable(factory->NewNumberFromInt(a)).ToHandleChecked(); 2330 callable(factory->NewNumberFromInt(a)).ToHandleChecked();
2301 static const int results[] = {11, 12, 2}; 2331 static const int results[] = {11, 12, 2};
2302 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]); 2332 CHECK_EQ(Handle<Smi>::cast(return_val)->value(), results[a]);
2303 } 2333 }
2304 } 2334 }
2305 } 2335 }
2306 2336
2307 } // namespace compiler 2337 } // namespace compiler
2308 } // namespace internal 2338 } // namespace internal
2309 } // namespace v8 2339 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698