| Index: test/cctest/compiler/test-tail-calls.cc
|
| diff --git a/test/cctest/compiler/test-tail-calls.cc b/test/cctest/compiler/test-tail-calls.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d6abcf3286f163025d8b226b7206a6cab540c436
|
| --- /dev/null
|
| +++ b/test/cctest/compiler/test-tail-calls.cc
|
| @@ -0,0 +1,118 @@
|
| +// Copyright 2015 the V8 project authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "src/bootstrapper.h"
|
| +#include "test/cctest/compiler/function-tester.h"
|
| +
|
| +#if V8_TURBOFAN_TARGET
|
| +
|
| +using namespace v8::internal;
|
| +using namespace v8::internal::compiler;
|
| +
|
| +TEST(RunTestTailCallAddParameters) {
|
| + FunctionTester T(
|
| + "(function() {"
|
| + " \"use strict\";"
|
| + " function tailed(a1, b1, c1, d1) { return d1; };"
|
| + " return function(a2) {"
|
| + " return %_CallFunction(this, a2, 6, 7, 8, tailed);"
|
| + " }"
|
| + "})();",
|
| + CompilationInfo::kTypingEnabled);
|
| +
|
| + T.CheckCall(T.Val(8), T.Val(5), T.undefined());
|
| +}
|
| +
|
| +
|
| +TEST(RunTestTailCallChangeParameters) {
|
| + FunctionTester T(
|
| + "(function() {"
|
| + " \"use strict\";"
|
| + " function tailed(a1, b1, c1, d1) { return a1; };"
|
| + " return function(a2) {"
|
| + " return %_CallFunction(this, 27, 6, 7, 8, tailed);"
|
| + " }"
|
| + "})();",
|
| + CompilationInfo::kTypingEnabled);
|
| +
|
| + T.CheckCall(T.Val(27), T.Val(5), T.undefined());
|
| +}
|
| +
|
| +
|
| +TEST(RunTestTailCallSwapParameters) {
|
| + FunctionTester T(
|
| + "(function() {"
|
| + " \"use strict\";"
|
| + " function tailed(a1, b1, c1, d1) { return this; };"
|
| + " return function(a2) {"
|
| + " return %_CallFunction(a2, this, 6, 7, 8, tailed);"
|
| + " }"
|
| + "})();",
|
| + CompilationInfo::kTypingEnabled);
|
| +
|
| + T.CheckCall(T.Val(5), T.Val(5), T.undefined());
|
| +}
|
| +
|
| +
|
| +TEST(RunTestTailCallRemoveParameters) {
|
| + FunctionTester T(
|
| + "(function() {"
|
| + " \"use strict\";"
|
| + " function tailed() { return this; };"
|
| + " return function(a2) {"
|
| + " return %_CallFunction(a2, tailed);"
|
| + " }"
|
| + "})();",
|
| + CompilationInfo::kTypingEnabled);
|
| +
|
| + T.CheckCall(T.Val(7), T.Val(7), T.undefined());
|
| +}
|
| +
|
| +
|
| +TEST(RunTestTailCallRemoveMultipleParameters) {
|
| + FunctionTester T(
|
| + "(function() {"
|
| + " \"use strict\";"
|
| + " function tailed() { return this; };"
|
| + " return function(a2, a3) {"
|
| + " return %_CallFunction(a2, tailed);"
|
| + " }"
|
| + "})();",
|
| + CompilationInfo::kTypingEnabled);
|
| +
|
| + T.CheckCall(T.Val(7), T.Val(7), T.undefined());
|
| +}
|
| +
|
| +
|
| +TEST(RunTestTailCallRemoveMultipleAndChangeParameters) {
|
| + FunctionTester T(
|
| + "(function() {"
|
| + " \"use strict\";"
|
| + " function tailed() { return this; };"
|
| + " return function(a2, a3) {"
|
| + " return %_CallFunction(a3, tailed);"
|
| + " }"
|
| + "})();",
|
| + CompilationInfo::kTypingEnabled);
|
| +
|
| + T.CheckCall(T.Val(19), T.Val(7), T.Val(19));
|
| +}
|
| +
|
| +
|
| +TEST(RunTestTailCallUnchangedParameters) {
|
| + FunctionTester T(
|
| + "(function() {"
|
| + " \"use strict\";"
|
| + " function tailed(a2, a3) { return a2; };"
|
| + " return function(a2, a3) {"
|
| + " return %_CallFunction(this, a2, a3, tailed);"
|
| + " }"
|
| + "})();",
|
| + CompilationInfo::kTypingEnabled);
|
| +
|
| + T.CheckCall(T.Val(7), T.Val(7), T.Val(19));
|
| +}
|
| +
|
| +
|
| +#endif // V8_TURBOFAN_TARGET
|
|
|