| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 // Flags: --type-profile --turbo --allow-natives-syntax | 5 // Flags: --type-profile --turbo --allow-natives-syntax |
| 6 | 6 |
| 7 function test(param) { | 7 function testFunction(param, flag) { |
| 8 var my_var1 = param; | 8 // We want to test 2 different return positions in one function. |
| 9 var my_var2 = 17; | 9 if (flag) { |
| 10 var first_var = param; |
| 11 return first_var; |
| 12 } |
| 13 var second_var = param; |
| 14 return second_var; |
| 10 } | 15 } |
| 11 | 16 |
| 12 %PrintTypeProfile(test); | 17 %PrintTypeProfile(testFunction); |
| 13 | 18 |
| 14 test({}); | 19 testFunction({}); |
| 15 test(123); | 20 testFunction(123, true); |
| 16 test('hello'); | 21 testFunction('hello'); |
| 17 test(123); | 22 testFunction(123); |
| 18 %PrintTypeProfile(test); | 23 %PrintTypeProfile(testFunction); |
| 19 | 24 |
| 20 test(undefined); | 25 testFunction(undefined); |
| 21 test('hello'); | 26 testFunction('hello', true); |
| 22 test({x: 12}); | 27 testFunction({x: 12}, true); |
| 23 test({x: 12}); | 28 testFunction({x: 12}); |
| 24 | 29 |
| 25 %PrintTypeProfile(test); | 30 %PrintTypeProfile(testFunction); |
| 26 | 31 |
| 27 class MyClass { | 32 class MyClass { |
| 28 constructor() {} | 33 constructor() {} |
| 29 } | 34 } |
| 30 | 35 |
| 31 | 36 |
| 32 function testConstructorNames(param) { | 37 function testConstructorNames(param) { |
| 33 var my_var = param; | 38 var my_var = param; |
| 34 } | 39 } |
| 35 | 40 |
| 36 testConstructorNames(new MyClass()); | 41 testConstructorNames(new MyClass()); |
| 37 testConstructorNames({}); | 42 testConstructorNames({}); |
| 38 testConstructorNames(2); | 43 testConstructorNames(2); |
| 39 | 44 |
| 45 function testReturnOfNonVariable() { |
| 46 return 32; |
| 47 } |
| 48 |
| 49 testReturnOfNonVariable(); |
| 50 |
| 40 throw "throw otherwise test fails with --stress-opt"; | 51 throw "throw otherwise test fails with --stress-opt"; |
| OLD | NEW |