| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:_js_helper' as js; | 5 import 'dart:_js_helper' as js; |
| 6 | 6 |
| 7 import 'dart:_foreign_helper' show | 7 import 'dart:_foreign_helper' show |
| 8 JS; | 8 JS; |
| 9 | 9 |
| 10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 m() => d_field; | 33 m() => d_field; |
| 34 } | 34 } |
| 35 | 35 |
| 36 @js.NoSideEffects() | 36 @js.NoSideEffects() |
| 37 @js.NoInline() | 37 @js.NoInline() |
| 38 @js.NoThrows() | 38 @js.NoThrows() |
| 39 baz() { | 39 baz() { |
| 40 throw 'in baz function'; | 40 throw 'in baz function'; |
| 41 } | 41 } |
| 42 | 42 |
| 43 @js.NoInline() |
| 44 geeNoInline() { |
| 45 // Use `gee` several times, so `gee` isn't used only once (and thus inlinable |
| 46 // independently of its size). |
| 47 gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); |
| 48 gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); |
| 49 gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); |
| 50 gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); gee(); |
| 51 } |
| 52 |
| 53 @js.ForceInline() |
| 54 // Big function that would normally not be inlinable. |
| 55 gee([c]) { |
| 56 if (c != null) { |
| 57 x = "in gee function"; |
| 58 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 59 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 60 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 61 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 62 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 63 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 64 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 65 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 66 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 67 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 68 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 69 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 70 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 71 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 72 geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); geeNoInline(); |
| 73 } |
| 74 } |
| 75 |
| 43 main() { | 76 main() { |
| 44 JS('', 'String("in main function")'); | 77 JS('', 'String("in main function")'); |
| 45 var c; | 78 var c; |
| 46 if (new DateTime.now().millisecondsSinceEpoch != 42) { | 79 if (new DateTime.now().millisecondsSinceEpoch != 42) { |
| 47 c = new C(); | 80 c = new C(); |
| 48 print(c.m()); | 81 print(c.m()); |
| 49 foo(c); | 82 foo(c); |
| 50 print(c.m()); | 83 print(c.m()); |
| 51 } else { | 84 } else { |
| 52 var d = new D(); | 85 var d = new D(); |
| 53 print(d.m()); | 86 print(d.m()); |
| 54 bar(d); | 87 bar(d); |
| 55 print(d.m()); | 88 print(d.m()); |
| 56 } | 89 } |
| 57 print(c.m()); | 90 print(c.m()); |
| 58 simple(); | 91 simple(); |
| 59 noinline(); | 92 noinline(); |
| 60 baz(); // This call should be eliminated by the optimizer. | 93 baz(); // This call should be eliminated by the optimizer. |
| 94 gee(new C()); |
| 95 print(x); |
| 61 check(JS('', 'arguments.callee')); | 96 check(JS('', 'arguments.callee')); |
| 62 } | 97 } |
| 63 | 98 |
| 64 @js.NoInline() | 99 @js.NoInline() |
| 65 check(func) { | 100 check(func) { |
| 66 JS('', 'String("in check function")'); | 101 JS('', 'String("in check function")'); |
| 67 var source = JS('String', 'String(#)', func); | 102 var source = JS('String', 'String(#)', func); |
| 68 print(source); | 103 print(source); |
| 69 Expect.isTrue(source.contains('"in main function"'), | 104 Expect.isTrue(source.contains('"in main function"'), |
| 70 "should contain 'main'"); | 105 "should contain 'main'"); |
| 71 Expect.isTrue(source.contains('"in simple function"'), | 106 Expect.isTrue(source.contains('"in simple function"'), |
| 72 "should inline 'simple'"); | 107 "should inline 'simple'"); |
| 73 Expect.isTrue(source.contains('"in foo function"'), | 108 Expect.isTrue(source.contains('"in foo function"'), |
| 74 "should inline 'foo'"); | 109 "should inline 'foo'"); |
| 75 Expect.isFalse(source.contains('"in bar function"'), | 110 Expect.isFalse(source.contains('"in bar function"'), |
| 76 "should not inline 'bar'"); | 111 "should not inline 'bar'"); |
| 77 Expect.isFalse(source.contains('"in check function"'), | 112 Expect.isFalse(source.contains('"in check function"'), |
| 78 "should not inline 'check'"); | 113 "should not inline 'check'"); |
| 79 Expect.isFalse(source.contains('"in noinline function"'), | 114 Expect.isFalse(source.contains('"in noinline function"'), |
| 80 "should not inline 'noinline'"); | 115 "should not inline 'noinline'"); |
| 81 Expect.equals(2, new RegExp(r'\.c_field').allMatches(source).length, | 116 Expect.equals(2, new RegExp(r'\.c_field').allMatches(source).length, |
| 82 "should contain r'\.c_field' exactly twice"); | 117 "should contain r'\.c_field' exactly twice"); |
| 83 Expect.isFalse(source.contains('.d_field'), | 118 Expect.isFalse(source.contains('.d_field'), |
| 84 "should not contain r'\.d_field'"); | 119 "should not contain r'\.d_field'"); |
| 120 Expect.isTrue(source.contains('"in gee function"'), |
| 121 "must inline 'gee'"); |
| 85 } | 122 } |
| 86 | 123 |
| 87 simple() { | 124 simple() { |
| 88 JS('', 'String("in simple function")'); | 125 JS('', 'String("in simple function")'); |
| 89 } | 126 } |
| 90 | 127 |
| 91 @js.NoInline() | 128 @js.NoInline() |
| 92 noinline() { | 129 noinline() { |
| 93 JS('', 'String("in noinline function")'); | 130 JS('', 'String("in noinline function")'); |
| 94 } | 131 } |
| OLD | NEW |