| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/bootstrapper.h" |
| 6 #include "test/cctest/compiler/function-tester.h" |
| 7 |
| 8 #if V8_TURBOFAN_TARGET |
| 9 |
| 10 using namespace v8::internal; |
| 11 using namespace v8::internal::compiler; |
| 12 |
| 13 TEST(RunTestTailCallAddParameters) { |
| 14 FunctionTester T( |
| 15 "(function() {" |
| 16 " \"use strict\";" |
| 17 " function tailed(a1, b1, c1, d1) { return d1; };" |
| 18 " return function(a2) {" |
| 19 " return %_CallFunction(this, a2, 6, 7, 8, tailed);" |
| 20 " }" |
| 21 "})();", |
| 22 CompilationInfo::kTypingEnabled); |
| 23 |
| 24 T.CheckCall(T.Val(8), T.Val(5), T.undefined()); |
| 25 } |
| 26 |
| 27 |
| 28 TEST(RunTestTailCallChangeParameters) { |
| 29 FunctionTester T( |
| 30 "(function() {" |
| 31 " \"use strict\";" |
| 32 " function tailed(a1, b1, c1, d1) { return a1; };" |
| 33 " return function(a2) {" |
| 34 " return %_CallFunction(this, 27, 6, 7, 8, tailed);" |
| 35 " }" |
| 36 "})();", |
| 37 CompilationInfo::kTypingEnabled); |
| 38 |
| 39 T.CheckCall(T.Val(27), T.Val(5), T.undefined()); |
| 40 } |
| 41 |
| 42 |
| 43 TEST(RunTestTailCallSwapParameters) { |
| 44 FunctionTester T( |
| 45 "(function() {" |
| 46 " \"use strict\";" |
| 47 " function tailed(a1, b1, c1, d1) { return this; };" |
| 48 " return function(a2) {" |
| 49 " return %_CallFunction(a2, this, 6, 7, 8, tailed);" |
| 50 " }" |
| 51 "})();", |
| 52 CompilationInfo::kTypingEnabled); |
| 53 |
| 54 T.CheckCall(T.Val(5), T.Val(5), T.undefined()); |
| 55 } |
| 56 |
| 57 |
| 58 TEST(RunTestTailCallRemoveParameters) { |
| 59 FunctionTester T( |
| 60 "(function() {" |
| 61 " \"use strict\";" |
| 62 " function tailed() { return this; };" |
| 63 " return function(a2) {" |
| 64 " return %_CallFunction(a2, tailed);" |
| 65 " }" |
| 66 "})();", |
| 67 CompilationInfo::kTypingEnabled); |
| 68 |
| 69 T.CheckCall(T.Val(7), T.Val(7), T.undefined()); |
| 70 } |
| 71 |
| 72 |
| 73 TEST(RunTestTailCallRemoveMultipleParameters) { |
| 74 FunctionTester T( |
| 75 "(function() {" |
| 76 " \"use strict\";" |
| 77 " function tailed() { return this; };" |
| 78 " return function(a2, a3) {" |
| 79 " return %_CallFunction(a2, tailed);" |
| 80 " }" |
| 81 "})();", |
| 82 CompilationInfo::kTypingEnabled); |
| 83 |
| 84 T.CheckCall(T.Val(7), T.Val(7), T.undefined()); |
| 85 } |
| 86 |
| 87 |
| 88 TEST(RunTestTailCallRemoveMultipleAndChangeParameters) { |
| 89 FunctionTester T( |
| 90 "(function() {" |
| 91 " \"use strict\";" |
| 92 " function tailed() { return this; };" |
| 93 " return function(a2, a3) {" |
| 94 " return %_CallFunction(a3, tailed);" |
| 95 " }" |
| 96 "})();", |
| 97 CompilationInfo::kTypingEnabled); |
| 98 |
| 99 T.CheckCall(T.Val(19), T.Val(7), T.Val(19)); |
| 100 } |
| 101 |
| 102 |
| 103 TEST(RunTestTailCallUnchangedParameters) { |
| 104 FunctionTester T( |
| 105 "(function() {" |
| 106 " \"use strict\";" |
| 107 " function tailed(a2, a3) { return a2; };" |
| 108 " return function(a2, a3) {" |
| 109 " return %_CallFunction(this, a2, a3, tailed);" |
| 110 " }" |
| 111 "})();", |
| 112 CompilationInfo::kTypingEnabled); |
| 113 |
| 114 T.CheckCall(T.Val(7), T.Val(7), T.Val(19)); |
| 115 } |
| 116 |
| 117 |
| 118 #endif // V8_TURBOFAN_TARGET |
| OLD | NEW |