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 8c0922933c0b84b0077766316160e02536082117..a9e689555440aed7156cc3a613e36b0d574ec6b0 100644 |
--- a/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
+++ b/test/cctest/compiler/test-run-bytecode-graph-builder.cc |
@@ -1306,6 +1306,82 @@ TEST(BytecodeGraphBuilderLoadContext) { |
} |
+TEST(BytecodeGraphBuilderCreateArgumentsNoParameters) { |
+ HandleAndZoneScope scope; |
+ Isolate* isolate = scope.main_isolate(); |
+ Zone* zone = scope.main_zone(); |
+ Factory* factory = isolate->factory(); |
+ |
+ ExpectedSnippet<0> snippets[] = { |
+ {"function f() {return arguments[0];}", {factory->undefined_value()}}, |
+ {"function f(a) {return arguments[0];}", {factory->undefined_value()}}, |
+ {"function f() {'use strict'; return arguments[0];}", |
+ {factory->undefined_value()}}, |
+ {"function f(a) {'use strict'; return arguments[0];}", |
+ {factory->undefined_value()}}, |
+ }; |
+ |
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
+ for (size_t i = 0; i < num_snippets; i++) { |
+ ScopedVector<char> script(1024); |
+ SNPrintF(script, "%s\n%s();", snippets[i].code_snippet, kFunctionName); |
+ |
+ BytecodeGraphTester tester(isolate, zone, script.start()); |
+ auto callable = tester.GetCallable<>(); |
+ Handle<Object> return_value = callable().ToHandleChecked(); |
+ CHECK(return_value->SameValue(*snippets[i].return_value())); |
+ } |
+} |
+ |
+ |
+TEST(BytecodeGraphBuilderCreateArguments) { |
+ HandleAndZoneScope scope; |
+ Isolate* isolate = scope.main_isolate(); |
+ Zone* zone = scope.main_zone(); |
+ Factory* factory = isolate->factory(); |
+ |
+ ExpectedSnippet<3> snippets[] = { |
+ {"function f(a, b, c) {return arguments[0];}", |
+ {factory->NewNumberFromInt(1), factory->NewNumberFromInt(1), |
+ factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}}, |
+ {"function f(a, b, c) {return arguments[3];}", |
+ {factory->undefined_value(), factory->NewNumberFromInt(1), |
+ factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}}, |
+ {"function f(a, b, c) { b = c; return arguments[1];}", |
+ {factory->NewNumberFromInt(3), factory->NewNumberFromInt(1), |
+ factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}}, |
+ {"function f(a, b, c) {'use strict'; return arguments[0];}", |
+ {factory->NewNumberFromInt(1), factory->NewNumberFromInt(1), |
+ factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}}, |
+ {"function f(a, b, c) {'use strict'; return arguments[3];}", |
+ {factory->undefined_value(), factory->NewNumberFromInt(1), |
+ factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}}, |
+ {"function f(a, b, c) {'use strict'; b = c; return arguments[1];}", |
+ {factory->NewNumberFromInt(2), factory->NewNumberFromInt(1), |
+ factory->NewNumberFromInt(2), factory->NewNumberFromInt(3)}}, |
+ {"function inline_func(a, b) { return arguments[0] }" |
+ "function f(a, b, c) {return inline_func(b, c) + arguments[0];}", |
+ {factory->NewNumberFromInt(3), factory->NewNumberFromInt(1), |
+ factory->NewNumberFromInt(2), factory->NewNumberFromInt(30)}}, |
+ }; |
+ |
+ size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); |
+ for (size_t i = 0; i < num_snippets; i++) { |
+ ScopedVector<char> script(1024); |
+ SNPrintF(script, "%s\n%s();", snippets[i].code_snippet, kFunctionName); |
+ |
+ BytecodeGraphTester tester(isolate, zone, script.start()); |
+ auto callable = |
+ tester.GetCallable<Handle<Object>, Handle<Object>, Handle<Object>>(); |
+ Handle<Object> return_value = |
+ callable(snippets[i].parameter(0), snippets[i].parameter(1), |
+ snippets[i].parameter(2)) |
+ .ToHandleChecked(); |
+ CHECK(return_value->SameValue(*snippets[i].return_value())); |
+ } |
+} |
+ |
+ |
TEST(BytecodeGraphBuilderRegExpLiterals) { |
HandleAndZoneScope scope; |
Isolate* isolate = scope.main_isolate(); |
@@ -1441,7 +1517,6 @@ TEST(BytecodeGraphBuilderObjectLiterals) { |
ScopedVector<char> script(4096); |
SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName, |
snippets[i].code_snippet, kFunctionName); |
- |
BytecodeGraphTester tester(isolate, zone, script.start()); |
auto callable = tester.GetCallable<>(); |
Handle<Object> return_value = callable().ToHandleChecked(); |