[dart2js] Remove checks from inlined static call sites
Change-Id: Ib309684efa6c518dd57bff76491484fe7288e628
Reviewed-on: https://dart-review.googlesource.com/55522
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index b46ea02..26834cf 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -5300,14 +5300,37 @@
void _potentiallyCheckInlinedParameterTypes(FunctionEntity function) {
if (!typeBuilder.checkOrTrustTypes) return;
- checkTypeVariableBounds(function);
+ // TODO(sra): Incorporate properties of call site to help determine which
+ // type parameters and value parameters need to be checked.
+ bool trusted = false;
+ if (options.strongMode) {
+ if (function.isStatic ||
+ function.isTopLevel ||
+ function.isConstructor ||
+ function is ConstructorBodyEntity) {
+ // We inline static methods, top-level methods, constructors and
+ // constructor bodies only from direct call sites.
+ trusted = true;
+ }
+ }
+
+ if (!trusted) {
+ checkTypeVariableBounds(function);
+ }
KernelToLocalsMap localsMap = _globalLocalsMap.getLocalsMap(function);
forEachOrderedParameter(_globalLocalsMap, _elementMap, function,
(Local parameter) {
HInstruction argument = localsHandler.readLocal(parameter);
- typeBuilder.potentiallyCheckOrTrustTypeOfParameter(
- argument, localsMap.getLocalType(_elementMap, parameter));
+ DartType type = localsMap.getLocalType(_elementMap, parameter);
+ HInstruction checkedOrTrusted;
+ if (trusted) {
+ checkedOrTrusted = typeBuilder.trustTypeOfParameter(argument, type);
+ } else {
+ checkedOrTrusted =
+ typeBuilder.potentiallyCheckOrTrustTypeOfParameter(argument, type);
+ }
+ localsHandler.updateLocal(parameter, checkedOrTrusted);
});
}
diff --git a/pkg/compiler/lib/src/ssa/type_builder.dart b/pkg/compiler/lib/src/ssa/type_builder.dart
index eb06192..a60c98e 100644
--- a/pkg/compiler/lib/src/ssa/type_builder.dart
+++ b/pkg/compiler/lib/src/ssa/type_builder.dart
@@ -75,6 +75,14 @@
return other;
}
+ HInstruction trustTypeOfParameter(HInstruction original, DartType type) {
+ if (type == null) return original;
+ HInstruction trusted = _trustType(original, type);
+ if (trusted == original) return original;
+ builder.add(trusted);
+ return trusted;
+ }
+
HInstruction potentiallyCheckOrTrustTypeOfParameter(
HInstruction original, DartType type) {
if (type == null) return original;
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index ae902f9..4579ab6 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -549,10 +549,6 @@
bad_override_test/03: MissingCompileTimeError
bit_operations_test: RuntimeError
branch_canonicalization_test: RuntimeError
-call_method_implicit_tear_off_implements_function_test/02: RuntimeError
-call_method_implicit_tear_off_implements_function_test/04: RuntimeError
-call_method_implicit_tear_off_test/02: RuntimeError
-call_method_implicit_tear_off_test/04: RuntimeError
canonical_const2_test: RuntimeError, OK # non JS number semantics
check_member_static_test/02: MissingCompileTimeError
class_cycle_test/02: MissingCompileTimeError
@@ -920,10 +916,6 @@
bad_override_test/03: MissingCompileTimeError
bit_operations_test: RuntimeError
branch_canonicalization_test: RuntimeError
-call_method_implicit_tear_off_implements_function_test/02: RuntimeError
-call_method_implicit_tear_off_implements_function_test/04: RuntimeError
-call_method_implicit_tear_off_test/02: RuntimeError
-call_method_implicit_tear_off_test/04: RuntimeError
call_non_method_field_test/01: MissingCompileTimeError
call_non_method_field_test/02: MissingCompileTimeError
canonical_const2_test: RuntimeError, OK # non JS number semantics
@@ -1471,10 +1463,6 @@
bad_override_test/03: MissingCompileTimeError
bit_operations_test: RuntimeError
branch_canonicalization_test: RuntimeError
-call_method_implicit_tear_off_implements_function_test/02: RuntimeError
-call_method_implicit_tear_off_implements_function_test/04: RuntimeError
-call_method_implicit_tear_off_test/02: RuntimeError
-call_method_implicit_tear_off_test/04: RuntimeError
call_non_method_field_test/01: MissingCompileTimeError
call_non_method_field_test/02: MissingCompileTimeError
call_with_no_such_method_test: RuntimeError