Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: tests/language/vm/regress_licm_test.dart

Issue 2709093003: Fixup redefinitions before doing code motion (Closed)
Patch Set: fix build Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/precompiler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/vm/regress_licm_test.dart
diff --git a/tests/language/vm/regress_licm_test.dart b/tests/language/vm/regress_licm_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..6d46b8678d0a66610ec75bfda5bdebda48605498
--- /dev/null
+++ b/tests/language/vm/regress_licm_test.dart
@@ -0,0 +1,80 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+//
+// VMOptions=--enable-inlining-annotations --optimization-counter-threshold=1000 --no-background-compilation
+
+// Regression test for correct LICM and type propagation.
+
+const AlwaysInline = "AlwaysInline";
+const NeverInline = "NeverInline";
+
+class Attribute {
+ final id = 123;
+}
+
+class Name {
+ Name(this.name);
+ final String name;
+ get attr;
+
+ @AlwaysInline
+ int compareTo(other) {
+ int nameCompare = name.compareTo(other.name);
+ if (nameCompare != 0) return nameCompare;
+ if (attr == null) return 0;
+ return attr.id - other.attr.id;
+ }
+}
+
+class AName extends Name {
+ AName() : super("abc");
+ final attr = new Attribute();
+}
+
+class BName extends Name {
+ BName(name) : super(name);
+ get attr => null;
+}
+
+
+class Member {
+ Member(this.name);
+ var name;
+}
+
+
+Member find(List<Member> members, Name name) {
+ int low = 0, high = members.length - 1;
+ while (low <= high) {
+ int mid = low + ((high - low) >> 1);
+ Member pivot = members[mid];
+ int comparison = name.compareTo(pivot.name);
+ if (comparison < 0) {
+ high = mid - 1;
+ } else if (comparison > 0) {
+ low = mid + 1;
+ } else {
+ return pivot;
+ }
+ }
+ return null;
+}
+
+
+main() {
+ var list = [new Member(new AName()),
+ new Member(new BName("a")),
+ new Member(new BName("b")),
+ new Member(new BName("c")),
+ new Member(new BName("d"))
+ ];
+
+ find(list, new AName());
+ find(list, new BName("e"));
+ find(list, new BName("b"));
+ for (var i = 0; i < 1000; ++i) {
+ find(list, new BName("b"));
+ find(list, new BName("e"));
+ }
+}
« no previous file with comments | « runtime/vm/precompiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698