Files
sdk/tests/language_2/vm/regress_32322_test.dart
T
Vyacheslav Egorov 20f2a4b523 [vm/aot] Add regression test for issue #32322.
This regression test was accidentally omitted from the
CL that fixed the issue itself.

Bug: 32322
Change-Id: I6011752827c4f46ab0602f17e0508a53578993b4
Reviewed-on: https://dart-review.googlesource.com/44301
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2018-02-28 18:37:56 +00:00

33 lines
1013 B
Dart

// Copyright (c) 2018, 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.
// Verify that optimizing compiler does not perform an illegal code motion
// past CheckNull instruction.
import "package:expect/expect.dart";
class C {
final String padding = "";
final String field = "1"; // Note: need padding to hit an object header
// of the next object after [null] object when
// doing illegal null.field read. Need to hit
// object header to cause crash.
}
int foofoo(C p) {
int sum = 0;
for (var i = 0; i < 10; i++) {
// Note: need redundant instructions in the loop to trigger Canonicalize
// after CSE. Canonicalize then would illegally remove the Redefinition.
sum += p.field.length;
sum += p.field.length;
}
return sum;
}
void main() {
Expect.equals(20, foofoo(new C()));
Expect.throwsNoSuchMethodError(() => foofoo(null));
}