| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // VMOptions=--enable-inlining-annotations --optimization-counter-threshold=1000
--no-background-compilation | 5 // VMOptions=--enable-inlining-annotations --optimization-counter-threshold=1000
--no-background-compilation |
| 6 | 6 |
| 7 // Regression test for correct LICM and type propagation. | 7 // Regression test for correct LICM and type propagation. |
| 8 | 8 |
| 9 const AlwaysInline = "AlwaysInline"; | 9 const AlwaysInline = "AlwaysInline"; |
| 10 const NeverInline = "NeverInline"; | 10 const NeverInline = "NeverInline"; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class AName extends Name { | 30 class AName extends Name { |
| 31 AName() : super("abc"); | 31 AName() : super("abc"); |
| 32 final attr = new Attribute(); | 32 final attr = new Attribute(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 class BName extends Name { | 35 class BName extends Name { |
| 36 BName(name) : super(name); | 36 BName(name) : super(name); |
| 37 get attr => null; | 37 get attr => null; |
| 38 } | 38 } |
| 39 | 39 |
| 40 | |
| 41 class Member { | 40 class Member { |
| 42 Member(this.name); | 41 Member(this.name); |
| 43 var name; | 42 var name; |
| 44 } | 43 } |
| 45 | 44 |
| 46 | |
| 47 Member find(List<Member> members, Name name) { | 45 Member find(List<Member> members, Name name) { |
| 48 int low = 0, high = members.length - 1; | 46 int low = 0, high = members.length - 1; |
| 49 while (low <= high) { | 47 while (low <= high) { |
| 50 int mid = low + ((high - low) >> 1); | 48 int mid = low + ((high - low) >> 1); |
| 51 Member pivot = members[mid]; | 49 Member pivot = members[mid]; |
| 52 int comparison = name.compareTo(pivot.name); | 50 int comparison = name.compareTo(pivot.name); |
| 53 if (comparison < 0) { | 51 if (comparison < 0) { |
| 54 high = mid - 1; | 52 high = mid - 1; |
| 55 } else if (comparison > 0) { | 53 } else if (comparison > 0) { |
| 56 low = mid + 1; | 54 low = mid + 1; |
| 57 } else { | 55 } else { |
| 58 return pivot; | 56 return pivot; |
| 59 } | 57 } |
| 60 } | 58 } |
| 61 return null; | 59 return null; |
| 62 } | 60 } |
| 63 | 61 |
| 64 | |
| 65 main() { | 62 main() { |
| 66 var list = [new Member(new AName()), | 63 var list = [ |
| 67 new Member(new BName("a")), | 64 new Member(new AName()), |
| 68 new Member(new BName("b")), | 65 new Member(new BName("a")), |
| 69 new Member(new BName("c")), | 66 new Member(new BName("b")), |
| 70 new Member(new BName("d")) | 67 new Member(new BName("c")), |
| 71 ]; | 68 new Member(new BName("d")) |
| 69 ]; |
| 72 | 70 |
| 73 find(list, new AName()); | 71 find(list, new AName()); |
| 74 find(list, new BName("e")); | 72 find(list, new BName("e")); |
| 75 find(list, new BName("b")); | 73 find(list, new BName("b")); |
| 76 for (var i = 0; i < 1000; ++i) { | 74 for (var i = 0; i < 1000; ++i) { |
| 77 find(list, new BName("b")); | 75 find(list, new BName("b")); |
| 78 find(list, new BName("e")); | 76 find(list, new BName("e")); |
| 79 } | 77 } |
| 80 } | 78 } |
| OLD | NEW |