Files
sdk/tests/language/vm/unique_selector_test.dart
T
Florian Schneider e25461c151 VM Propagate receiver type from calls to unique selectors in AOT compilation.
If there is no override of noSuchMethod in any class, we can
propagate the receiver type downwards from calls that call a unique
selector.

This speeds up dart2js by around 3%, a particle simulation benchmark by around 10%.

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2412653002 .
2016-10-11 13:17:47 -07:00

35 lines
715 B
Dart

// Copyright (c) 2016, 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.
import "package:expect/expect.dart";
class A {
_unique_method() => "foo";
bar() => "A";
}
class B {
noSuchMethod(invocation) => "nsm";
bar() => "B";
}
confuse(x) {
try {
throw x;
} catch (e) {
return e;
}
return null;
}
main() {
var a = confuse(new A());
Expect.equals("foo", a._unique_method());
Expect.equals("A", a.bar());
var b = confuse(new B());
Expect.equals("nsm", b._unique_method());
Expect.equals("B", b.bar()); // Don't propagate type A to b.
}