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

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

Issue 1490283003: [Interpreter] Adds support for CreateArguments to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Adds frame state to createArguments node. Created 5 years 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
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 1299
1300 BytecodeGraphTester tester(isolate, zone, script.start(), "*"); 1300 BytecodeGraphTester tester(isolate, zone, script.start(), "*");
1301 auto callable = tester.GetCallable<Handle<Object>>("f"); 1301 auto callable = tester.GetCallable<Handle<Object>>("f");
1302 Handle<Object> return_value = 1302 Handle<Object> return_value =
1303 callable(snippets[i].parameter(0)).ToHandleChecked(); 1303 callable(snippets[i].parameter(0)).ToHandleChecked();
1304 CHECK(return_value->SameValue(*snippets[i].return_value())); 1304 CHECK(return_value->SameValue(*snippets[i].return_value()));
1305 } 1305 }
1306 } 1306 }
1307 1307
1308 1308
1309 TEST(BytecodeGraphBuilderCreateArgumentsNoParameters) {
1310 HandleAndZoneScope scope;
1311 Isolate* isolate = scope.main_isolate();
1312 Zone* zone = scope.main_zone();
1313 Factory* factory = isolate->factory();
1314
1315 ExpectedSnippet<0> snippets[] = {
1316 {"function f() {return arguments[0];}", {factory->undefined_value()}},
1317 {"function f(a) {return arguments[0];}", {factory->undefined_value()}},
1318 {"function f() {'use strict'; return arguments[0];}",
1319 {factory->undefined_value()}},
1320 {"function f(a) {'use strict'; return arguments[0];}",
1321 {factory->undefined_value()}},
1322 };
1323
1324 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1325 for (size_t i = 0; i < num_snippets; i++) {
1326 ScopedVector<char> script(1024);
1327 SNPrintF(script, "%s\n%s();", snippets[i].code_snippet, kFunctionName);
1328
1329 BytecodeGraphTester tester(isolate, zone, script.start());
1330 auto callable = tester.GetCallable<>();
1331 Handle<Object> return_value = callable().ToHandleChecked();
1332 CHECK(return_value->SameValue(*snippets[i].return_value()));
1333 }
1334 }
1335
1336
1337 TEST(BytecodeGraphBuilderCreateArguments) {
1338 HandleAndZoneScope scope;
1339 Isolate* isolate = scope.main_isolate();
1340 Zone* zone = scope.main_zone();
1341 Factory* factory = isolate->factory();
1342
1343 ExpectedSnippet<3> snippets[] = {
1344 {"function f(a, b, c) {return arguments[0];}",
1345 {factory->NewNumberFromInt(1), factory->NewNumberFromInt(1),
1346 factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}},
1347 {"function f(a, b, c) {return arguments[3];}",
1348 {factory->undefined_value(), factory->NewNumberFromInt(1),
1349 factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}},
1350 {"function f(a, b, c) { b = c; return arguments[1];}",
1351 {factory->NewNumberFromInt(3), factory->NewNumberFromInt(1),
1352 factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}},
1353 {"function f(a, b, c) {'use strict'; return arguments[0];}",
1354 {factory->NewNumberFromInt(1), factory->NewNumberFromInt(1),
1355 factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}},
1356 {"function f(a, b, c) {'use strict'; return arguments[3];}",
1357 {factory->undefined_value(), factory->NewNumberFromInt(1),
1358 factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}},
1359 {"function f(a, b, c) {'use strict'; b = c; return arguments[1];}",
1360 {factory->NewNumberFromInt(2), factory->NewNumberFromInt(1),
1361 factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}},
1362 {"function inline_func(a, b) { return arguments[0] }"
1363 "function f(a, b, c) {return inline_func(b, c) + arguments[0];}",
1364 {factory->NewNumberFromInt(3), factory->NewNumberFromInt(1),
1365 factory->NewNumberFromInt(2), factory->NewNumberFromInt(30)}},
1366 };
1367
1368 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1369 for (size_t i = 0; i < num_snippets; i++) {
1370 ScopedVector<char> script(1024);
1371 SNPrintF(script, "%s\n%s();", snippets[i].code_snippet, kFunctionName);
1372
1373 BytecodeGraphTester tester(isolate, zone, script.start());
1374 auto callable =
1375 tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>();
1376 Handle<Object> return_value =
1377 callable(snippets[i].parameter(0), snippets[i].parameter(1),
1378 snippets[i].parameter(2))
1379 .ToHandleChecked();
1380 CHECK(return_value->SameValue(*snippets[i].return_value()));
1381 }
1382 }
1383
1384
1309 TEST(BytecodeGraphBuilderRegExpLiterals) { 1385 TEST(BytecodeGraphBuilderRegExpLiterals) {
1310 HandleAndZoneScope scope; 1386 HandleAndZoneScope scope;
1311 Isolate* isolate = scope.main_isolate(); 1387 Isolate* isolate = scope.main_isolate();
1312 Zone* zone = scope.main_zone(); 1388 Zone* zone = scope.main_zone();
1313 Factory* factory = isolate->factory(); 1389 Factory* factory = isolate->factory();
1314 1390
1315 ExpectedSnippet<0> snippets[] = { 1391 ExpectedSnippet<0> snippets[] = {
1316 {"return /abd/.exec('cccabbdd');", {factory->null_value()}}, 1392 {"return /abd/.exec('cccabbdd');", {factory->null_value()}},
1317 {"return /ab+d/.exec('cccabbdd')[0];", 1393 {"return /ab+d/.exec('cccabbdd')[0];",
1318 {factory->NewStringFromStaticChars("abbd")}}, 1394 {factory->NewStringFromStaticChars("abbd")}},
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 {"var n = 'name';\n" 1510 {"var n = 'name';\n"
1435 "return { [n]: 'val', get a() { return 987 } }['a'];", 1511 "return { [n]: 'val', get a() { return 987 } }['a'];",
1436 {factory->NewNumberFromInt(987)}}, 1512 {factory->NewNumberFromInt(987)}},
1437 }; 1513 };
1438 1514
1439 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); 1515 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1440 for (size_t i = 0; i < num_snippets; i++) { 1516 for (size_t i = 0; i < num_snippets; i++) {
1441 ScopedVector<char> script(4096); 1517 ScopedVector<char> script(4096);
1442 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, 1518 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1443 snippets[i].code_snippet, kFunctionName); 1519 snippets[i].code_snippet, kFunctionName);
1444
1445 BytecodeGraphTester tester(isolate, zone, script.start()); 1520 BytecodeGraphTester tester(isolate, zone, script.start());
1446 auto callable = tester.GetCallable<>(); 1521 auto callable = tester.GetCallable<>();
1447 Handle<Object> return_value = callable().ToHandleChecked(); 1522 Handle<Object> return_value = callable().ToHandleChecked();
1448 CHECK(return_value->SameValue(*snippets[i].return_value())); 1523 CHECK(return_value->SameValue(*snippets[i].return_value()));
1449 } 1524 }
1450 } 1525 }
1451 1526
1452 1527
1453 TEST(BytecodeGraphBuilderIf) { 1528 TEST(BytecodeGraphBuilderIf) {
1454 HandleAndZoneScope scope; 1529 HandleAndZoneScope scope;
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 BytecodeGraphTester tester(isolate, zone, script.start()); 1951 BytecodeGraphTester tester(isolate, zone, script.start());
1877 auto callable = tester.GetCallable<>(); 1952 auto callable = tester.GetCallable<>();
1878 Handle<Object> return_value = callable().ToHandleChecked(); 1953 Handle<Object> return_value = callable().ToHandleChecked();
1879 CHECK(return_value->SameValue(*snippets[i].return_value())); 1954 CHECK(return_value->SameValue(*snippets[i].return_value()));
1880 } 1955 }
1881 } 1956 }
1882 1957
1883 } // namespace compiler 1958 } // namespace compiler
1884 } // namespace internal 1959 } // namespace internal
1885 } // namespace v8 1960 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698