OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/compiler/function-tester.h" | 7 #include "test/cctest/compiler/function-tester.h" |
8 | 8 |
9 #if V8_TURBOFAN_TARGET | 9 #if V8_TURBOFAN_TARGET |
10 | 10 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 "function bar(s,t) { return foo(foo(s, 3), 5); };" | 185 "function bar(s,t) { return foo(foo(s, 3), 5); };" |
186 "return bar;" | 186 "return bar;" |
187 "})();", | 187 "})();", |
188 CompilationInfo::kInliningEnabled | | 188 CompilationInfo::kInliningEnabled | |
189 CompilationInfo::kContextSpecializing); | 189 CompilationInfo::kContextSpecializing); |
190 | 190 |
191 InstallAssertStackDepthHelper(CcTest::isolate()); | 191 InstallAssertStackDepthHelper(CcTest::isolate()); |
192 T.CheckCall(T.Val(-329), T.Val(11), T.Val(4)); | 192 T.CheckCall(T.Val(-329), T.Val(11), T.Val(4)); |
193 } | 193 } |
194 | 194 |
| 195 |
| 196 TEST(InlineLoop) { |
| 197 FunctionTester T( |
| 198 "(function () {" |
| 199 "var x = 41;" |
| 200 "function foo(s) { AssertStackDepth(1); while (s > 0) {" |
| 201 " s = s - 1; }; return s; };" |
| 202 "function bar(s,t) { return foo(foo(s)); };" |
| 203 "return bar;" |
| 204 "})();", |
| 205 CompilationInfo::kInliningEnabled | |
| 206 CompilationInfo::kContextSpecializing); |
| 207 |
| 208 InstallAssertStackDepthHelper(CcTest::isolate()); |
| 209 T.CheckCall(T.Val(0.0), T.Val(11), T.Val(4)); |
| 210 } |
| 211 |
| 212 |
| 213 TEST(InlineStrictIntoNonStrict) { |
| 214 FunctionTester T( |
| 215 "(function () {" |
| 216 "var x = Object.create({}, { y: { value:42, writable:false } });" |
| 217 "function foo(s) { 'use strict';" |
| 218 " x.y = 9; };" |
| 219 "function bar(s,t) { return foo(s); };" |
| 220 "return bar;" |
| 221 "})();", |
| 222 CompilationInfo::kInliningEnabled | |
| 223 CompilationInfo::kContextSpecializing); |
| 224 |
| 225 InstallAssertStackDepthHelper(CcTest::isolate()); |
| 226 T.CheckThrows(T.undefined(), T.undefined()); |
| 227 } |
| 228 |
| 229 |
| 230 TEST(InlineNonStrictIntoStrict) { |
| 231 FunctionTester T( |
| 232 "(function () {" |
| 233 "var x = Object.create({}, { y: { value:42, writable:false } });" |
| 234 "function foo(s) { x.y = 9; return x.y; };" |
| 235 "function bar(s,t) { \'use strict\'; return foo(s); };" |
| 236 "return bar;" |
| 237 "})();", |
| 238 CompilationInfo::kInliningEnabled | |
| 239 CompilationInfo::kContextSpecializing); |
| 240 |
| 241 InstallAssertStackDepthHelper(CcTest::isolate()); |
| 242 T.CheckCall(T.Val(42), T.undefined(), T.undefined()); |
| 243 } |
| 244 |
| 245 |
195 #endif // V8_TURBOFAN_TARGET | 246 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |