[dart2js] Cleanup some unused paramters in the locals handler.

Change-Id: Ic4fd58ab0c9b3b64a0911b5ae058e05ce311e3b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241880
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
This commit is contained in:
Mayank Patke 2022-04-21 21:10:58 +00:00 committed by Commit Bot
parent 091559359e
commit e085928061
2 changed files with 27 additions and 35 deletions

View file

@ -279,7 +279,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
Local local = _localsMap.getLocalVariable(node);
DartType type = _localsMap.getLocalType(_elementMap, local);
_state.updateLocal(_inferrer, _capturedAndBoxed, local,
_inferrer.typeOfParameter(local), node, type);
_inferrer.typeOfParameter(local), type);
if (isOptional) {
TypeInformation type;
if (node.initializer != null) {
@ -816,10 +816,10 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
DartType type = _localsMap.getLocalType(_elementMap, local);
if (node.initializer == null) {
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, _types.nullType, node, type);
_inferrer, _capturedAndBoxed, local, _types.nullType, type);
} else {
_state.updateLocal(_inferrer, _capturedAndBoxed, local,
visit(node.initializer), node, type);
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, visit(node.initializer), type);
}
if (node.initializer is ir.ThisExpression) {
_state.markThisAsExposed();
@ -844,8 +844,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
}
Local local = _localsMap.getLocalVariable(node.variable);
DartType type = _localsMap.getLocalType(_elementMap, local);
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, rhsType, node, type);
_state.updateLocal(_inferrer, _capturedAndBoxed, local, rhsType, type);
return rhsType;
}
@ -938,7 +937,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
// receiver of the call to `==`, which doesn't happen in this case. Remove
// this when the ssa builder recognizes `== null` directly.
_typeOfReceiver(node, node.expression);
_potentiallyAddNullCheck(node, node.expression);
_potentiallyAddNullCheck(node.expression);
return _types.boolType;
}
@ -996,11 +995,11 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
bool rightIsNull = _types.isNull(rightType);
if (leftIsNull) {
// [right] is `null` if [node] evaluates to `true`.
_potentiallyAddNullCheck(node, right);
_potentiallyAddNullCheck(right);
}
if (rightIsNull) {
// [left] is `null` if [node] evaluates to `true`.
_potentiallyAddNullCheck(node, left);
_potentiallyAddNullCheck(left);
}
if (leftIsNull || rightIsNull) {
// `left == right` where `left` and/or `right` is known to have type
@ -1088,7 +1087,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
// Receiver strengthening to non-null.
DartType type = _localsMap.getLocalType(_elementMap, local);
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, receiverType, node, type,
_inferrer, _capturedAndBoxed, local, receiverType, type,
excludeNull: !selector.appliesToNullWithoutThrow());
}
}
@ -1191,8 +1190,8 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
Local variable = _localsMap.getLocalVariable(node.variable);
DartType variableType = _localsMap.getLocalType(_elementMap, variable);
_state.updateLocal(_inferrer, _capturedAndBoxed, variable, currentType,
node.variable, variableType);
_state.updateLocal(
_inferrer, _capturedAndBoxed, variable, currentType, variableType);
JumpTarget target = _localsMap.getJumpTargetForForIn(node);
return handleLoop(node, target, () {
@ -1564,13 +1563,13 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
// Narrow tested variable to late sentinel on true branch.
stateWhenSentinel.updateLocal(_inferrer, _capturedAndBoxed, local,
_types.lateSentinelType, node, localType);
_types.lateSentinelType, localType);
// Narrow tested variable to not late sentinel on false branch.
TypeInformation currentTypeInformation =
stateWhenNotSentinel.readLocal(_inferrer, _capturedAndBoxed, local);
stateWhenNotSentinel.updateLocal(_inferrer, _capturedAndBoxed, local,
currentTypeInformation, node, localType,
currentTypeInformation, localType,
excludeLateSentinel: true);
_setStateAfter(_state, stateWhenSentinel, stateWhenNotSentinel);
@ -1747,13 +1746,13 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
TypeInformation currentTypeInformation = stateAfterCheckWhenTrue
.readLocal(_inferrer, _capturedAndBoxed, local);
stateAfterCheckWhenTrue.updateLocal(_inferrer, _capturedAndBoxed, local,
currentTypeInformation, node, localType,
currentTypeInformation, localType,
isCast: false);
_setStateAfter(_state, stateAfterCheckWhenTrue, stateAfterCheckWhenFalse);
}
}
void _potentiallyAddNullCheck(ir.Expression node, ir.Expression receiver) {
void _potentiallyAddNullCheck(ir.Expression receiver) {
if (!_accumulateIsChecks) return;
if (receiver is ir.VariableGet) {
Local local = _localsMap.getLocalVariable(receiver.variable);
@ -1762,19 +1761,14 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
LocalState stateAfterCheckWhenNotNull = LocalState.childPath(_state);
// Narrow tested variable to 'Null' on true branch.
stateAfterCheckWhenNull.updateLocal(_inferrer, _capturedAndBoxed, local,
_types.nullType, node, localType);
stateAfterCheckWhenNull.updateLocal(
_inferrer, _capturedAndBoxed, local, _types.nullType, localType);
// Narrow tested variable to 'not null' on false branch.
TypeInformation currentTypeInformation = stateAfterCheckWhenNotNull
.readLocal(_inferrer, _capturedAndBoxed, local);
stateAfterCheckWhenNotNull.updateLocal(
_inferrer,
_capturedAndBoxed,
local,
currentTypeInformation,
node,
_closedWorld.commonElements.objectType,
stateAfterCheckWhenNotNull.updateLocal(_inferrer, _capturedAndBoxed,
local, currentTypeInformation, _closedWorld.commonElements.objectType,
excludeNull: true);
_setStateAfter(
_state, stateAfterCheckWhenNull, stateAfterCheckWhenNotNull);
@ -1930,7 +1924,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
Local local = _localsMap.getLocalVariable(variable);
DartType type = _localsMap.getLocalType(_elementMap, local);
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, localFunctionType, node, type,
_inferrer, _capturedAndBoxed, local, localFunctionType, type,
excludeNull: true);
}
@ -2085,8 +2079,8 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
mask = _types.dynamicType;
}
Local local = _localsMap.getLocalVariable(exception);
_state.updateLocal(_inferrer, _capturedAndBoxed, local, mask, node,
_dartTypes.dynamicType(),
_state.updateLocal(
_inferrer, _capturedAndBoxed, local, mask, _dartTypes.dynamicType(),
excludeNull: true /* `throw null` produces a NullThrownError */);
}
ir.VariableDeclaration stackTrace = node.stackTrace;
@ -2096,7 +2090,7 @@ class KernelTypeGraphBuilder extends ir.Visitor<TypeInformation>
// Note: stack trace may be null if users omit a stack in
// `completer.completeError`.
_state.updateLocal(_inferrer, _capturedAndBoxed, local,
_types.dynamicType, node, _dartTypes.dynamicType());
_types.dynamicType, _dartTypes.dynamicType());
}
visit(node.body);
return null;
@ -2434,7 +2428,7 @@ class LocalState {
if (field != null) {
return inferrer.typeOfMember(field);
} else {
return _locals.use(inferrer, local);
return _locals.use(local);
}
}
@ -2443,7 +2437,6 @@ class LocalState {
Map<Local, FieldEntity> capturedAndBoxed,
Local local,
TypeInformation type,
ir.Node node,
DartType staticType,
{isCast = true,
excludeNull = false,
@ -2458,7 +2451,7 @@ class LocalState {
if (field != null) {
inferrer.recordTypeOfField(field, type);
} else {
_locals.update(inferrer, local, type, node, staticType, _tryBlock);
_locals.update(inferrer, local, type, _tryBlock);
}
}

View file

@ -9,7 +9,6 @@ library locals_handler;
import 'dart:collection' show IterableMixin;
import 'package:kernel/ast.dart' as ir;
import '../elements/entities.dart';
import '../elements/types.dart';
import '../ir/util.dart';
import '../util/util.dart';
import 'inferrer_engine.dart';
@ -342,12 +341,12 @@ class LocalsHandler {
LocalsHandler.deepCopyOf(LocalsHandler other)
: _locals = VariableScope.deepCopyOf(other._locals);
TypeInformation use(InferrerEngine inferrer, Local local) {
TypeInformation use(Local local) {
return _locals[local];
}
void update(InferrerEngine inferrer, Local local, TypeInformation type,
ir.Node node, DartType staticType, LocalsHandler tryBlock) {
LocalsHandler tryBlock) {
if (tryBlock != null) {
// We don't know if an assignment in a try block
// will be executed, so all assignments in that block are