| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import "package:expect/expect.dart"; |
| 6 import 'dart:_foreign_helper' show JS; |
| 7 import 'dart:_js_helper' show IrRepresentation, NoInline; |
| 8 |
| 9 // The function ast01 is built by an SsaFromAstBuilder. |
| 10 // Ir functions are inlined by an SsaFromIrInliner. |
| 11 |
| 12 @NoInline() |
| 13 @IrRepresentation(false) |
| 14 ast01() { |
| 15 checkAst01(JS('', 'arguments.callee')); |
| 16 print(ir01()); |
| 17 print(ir02()); |
| 18 return ast02(11); |
| 19 } |
| 20 |
| 21 @IrRepresentation(true) |
| 22 ir01() => ir04(); |
| 23 |
| 24 @IrRepresentation(true) |
| 25 ir02() => ast06(10, 20); |
| 26 |
| 27 @IrRepresentation(false) |
| 28 ast06(a,b) { |
| 29 JS('', 'String("in ast06")'); |
| 30 return 3*a + b; |
| 31 } |
| 32 |
| 33 @IrRepresentation(true) |
| 34 ir04() => ir05(); |
| 35 |
| 36 @IrRepresentation(true) |
| 37 ir05() => ast07(1, 22); |
| 38 |
| 39 @IrRepresentation(false) |
| 40 ast07(i, j) { |
| 41 var x = 0; |
| 42 return ast08(i,j) ? i : j; |
| 43 } |
| 44 |
| 45 @IrRepresentation(false) |
| 46 ast08(x,y) { |
| 47 JS('', 'String("in ast08")'); |
| 48 return x - y < 0; |
| 49 } |
| 50 |
| 51 @IrRepresentation(false) |
| 52 ast02(x) { |
| 53 print(x); |
| 54 ir06(); |
| 55 print(ir07()); |
| 56 } |
| 57 |
| 58 @IrRepresentation(true) |
| 59 ir06() => ast04(1,2,3); |
| 60 |
| 61 @IrRepresentation(false) |
| 62 ast04(a, b, c) { |
| 63 print(a + b - c); |
| 64 JS('', 'String("in ast04")'); |
| 65 } |
| 66 |
| 67 @IrRepresentation(true) |
| 68 ir07() => ir03(); |
| 69 |
| 70 @IrRepresentation(true) |
| 71 ir03() => ast05(1,3); |
| 72 |
| 73 @IrRepresentation(false) |
| 74 ast05(a, b) { |
| 75 JS('', 'String("in ast05")'); |
| 76 return (a+b)/2; |
| 77 } |
| 78 |
| 79 // The function ir08 is built by an SsaFromIrBuilder. |
| 80 // Ast functions are inlined by an SsaFromAstInliner. |
| 81 |
| 82 @NoInline() |
| 83 @IrRepresentation(true) |
| 84 ir08() => ir09(); |
| 85 |
| 86 ir09() => ast09(); |
| 87 |
| 88 ast09() { |
| 89 checkIr08(JS('', 'arguments.callee')); |
| 90 JS('', 'String("in ast09")'); |
| 91 print(ir01()); |
| 92 print(ir02()); |
| 93 print(ast02(11)); |
| 94 } |
| 95 |
| 96 main() { |
| 97 ast01(); |
| 98 ir08(); |
| 99 } |
| 100 |
| 101 @NoInline() |
| 102 check(func, names) { |
| 103 var source = JS('String', 'String(#)', func); |
| 104 print(source); |
| 105 for (var f in names) { |
| 106 Expect.isTrue(source.contains('"in $f"'), "should inline '$f'"); |
| 107 } |
| 108 } |
| 109 |
| 110 @NoInline |
| 111 checkAst01(func) { |
| 112 var names = ["ast04", "ast05", "ast06", "ast08"]; |
| 113 check(func, names); |
| 114 } |
| 115 |
| 116 checkIr08(func) { |
| 117 var names = ["ast09", "ast04", "ast05", "ast06", "ast08"]; |
| 118 check(func, names); |
| 119 } |
| OLD | NEW |