[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>
This commit is contained in:
Stephen Adams 2018-05-17 00:03:24 +00:00 committed by commit-bot@chromium.org
parent 6363cf6d3d
commit 6d55ba3037
3 changed files with 34 additions and 15 deletions

View file

@ -5300,14 +5300,37 @@ class KernelSsaGraphBuilder extends ir.Visitor
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);
});
}

View file

@ -75,6 +75,14 @@ abstract class TypeBuilder {
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;

View file

@ -549,10 +549,6 @@ async_star_test/none: RuntimeError
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/02: MissingCompileTimeError
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/02: MissingCompileTimeError
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