mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:17:55 +00:00
[dart2js] dart format --fix in ssa/
Purely mechanical CL. Change-Id: I9515670150f3c99b531128e1e3ca71924f2900e4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213530 Reviewed-by: Mayank Patke <fishythefish@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
d89e42bef5
commit
63f21ac34c
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -266,18 +266,18 @@ class SsaInstructionSelection extends HBaseVisitor with CodegenPhase {
|
|||
if (isMatchingRead(left)) {
|
||||
if (left.usedBy.length == 1) {
|
||||
if (right is HConstant && right.constant.isOne) {
|
||||
HInstruction rmw = new HReadModifyWrite.preOp(
|
||||
HInstruction rmw = HReadModifyWrite.preOp(
|
||||
setter.element, incrementOp, receiver, op.instructionType);
|
||||
return replaceOp(rmw, left);
|
||||
} else {
|
||||
HInstruction rmw = new HReadModifyWrite.assignOp(
|
||||
HInstruction rmw = HReadModifyWrite.assignOp(
|
||||
setter.element, assignOp, receiver, right, op.instructionType);
|
||||
return replaceOp(rmw, left);
|
||||
}
|
||||
} else if (op.usedBy.length == 1 &&
|
||||
right is HConstant &&
|
||||
right.constant.isOne) {
|
||||
HInstruction rmw = new HReadModifyWrite.postOp(
|
||||
HInstruction rmw = HReadModifyWrite.postOp(
|
||||
setter.element, incrementOp, receiver, op.instructionType);
|
||||
block.addAfter(left, rmw);
|
||||
block.remove(setter);
|
||||
|
@ -294,7 +294,7 @@ class SsaInstructionSelection extends HBaseVisitor with CodegenPhase {
|
|||
String assignOp, HInstruction left, HInstruction right) {
|
||||
if (isMatchingRead(left)) {
|
||||
if (left.usedBy.length == 1) {
|
||||
HInstruction rmw = new HReadModifyWrite.assignOp(
|
||||
HInstruction rmw = HReadModifyWrite.assignOp(
|
||||
setter.element, assignOp, receiver, right, op.instructionType);
|
||||
return replaceOp(rmw, left);
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ class SsaInstructionMerger extends HBaseVisitor with CodegenPhase {
|
|||
// The expectedInputs list holds non-trivial instructions that may
|
||||
// be generated at their use site, if they occur in the correct order.
|
||||
if (expectedInputs == null) expectedInputs = <HInstruction>[];
|
||||
if (pureInputs == null) pureInputs = new Set<HInstruction>();
|
||||
if (pureInputs == null) pureInputs = Set<HInstruction>();
|
||||
|
||||
// Pop instructions from expectedInputs until instruction is found.
|
||||
// Return true if it is found, or false if not.
|
||||
|
@ -1133,7 +1133,7 @@ class SsaShareRegionConstants extends HBaseVisitor with CodegenPhase {
|
|||
_cache(
|
||||
HInstruction node, bool Function(HInstruction) cacheable, String name) {
|
||||
var users = node.usedBy.toList();
|
||||
var reference = new HLateValue(node);
|
||||
var reference = HLateValue(node);
|
||||
// TODO(sra): The sourceInformation should really be from the function
|
||||
// entry, not the use of `this`.
|
||||
reference.sourceInformation = node.sourceInformation;
|
||||
|
|
|
@ -117,7 +117,7 @@ class SsaSimplifyInterceptors extends HBaseVisitor
|
|||
return _graph.thisInstruction;
|
||||
}
|
||||
|
||||
ConstantValue constant = new InterceptorConstantValue(constantInterceptor);
|
||||
ConstantValue constant = InterceptorConstantValue(constantInterceptor);
|
||||
return _graph.addConstant(constant, _closedWorld);
|
||||
}
|
||||
|
||||
|
@ -340,7 +340,7 @@ class SsaSimplifyInterceptors extends HBaseVisitor
|
|||
interceptedClasses);
|
||||
if (interceptorClass != null) {
|
||||
HInstruction constantInstruction = _graph.addConstant(
|
||||
new InterceptorConstantValue(interceptorClass), _closedWorld);
|
||||
InterceptorConstantValue(interceptorClass), _closedWorld);
|
||||
node.conditionalConstantInterceptor = constantInstruction;
|
||||
constantInstruction.usedBy.add(node);
|
||||
return false;
|
||||
|
|
|
@ -374,7 +374,7 @@ class BitNotSpecializer extends InvokeDynamicSpecializer {
|
|||
OptimizationTestLog log) {
|
||||
HInstruction input = instruction.inputs[1];
|
||||
if (input.isNumber(closedWorld.abstractValueDomain).isDefinitelyTrue) {
|
||||
HBitNot converted = new HBitNot(
|
||||
HBitNot converted = HBitNot(
|
||||
input, computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
log?.registerBitNot(instruction, converted);
|
||||
return converted;
|
||||
|
@ -420,7 +420,7 @@ class UnaryNegateSpecializer extends InvokeDynamicSpecializer {
|
|||
OptimizationTestLog log) {
|
||||
HInstruction input = instruction.inputs[1];
|
||||
if (input.isNumber(closedWorld.abstractValueDomain).isDefinitelyTrue) {
|
||||
HNegate converted = new HNegate(
|
||||
HNegate converted = HNegate(
|
||||
input, computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
log?.registerUnaryNegate(instruction, converted);
|
||||
return converted;
|
||||
|
@ -459,7 +459,7 @@ class AbsSpecializer extends InvokeDynamicSpecializer {
|
|||
OptimizationTestLog log) {
|
||||
HInstruction input = instruction.inputs[1];
|
||||
if (input.isNumber(closedWorld.abstractValueDomain).isDefinitelyTrue) {
|
||||
HAbs converted = new HAbs(
|
||||
HAbs converted = HAbs(
|
||||
input, computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
log?.registerAbs(instruction, converted);
|
||||
return converted;
|
||||
|
@ -585,7 +585,7 @@ class AddSpecializer extends BinaryArithmeticSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HAdd(instruction.inputs[1], instruction.inputs[2],
|
||||
return HAdd(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -617,7 +617,7 @@ class DivideSpecializer extends BinaryArithmeticSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HDivide(instruction.inputs[1], instruction.inputs[2],
|
||||
return HDivide(instruction.inputs[1], instruction.inputs[2],
|
||||
closedWorld.abstractValueDomain.numType);
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ class ModuloSpecializer extends BinaryArithmeticSpecializer {
|
|||
HInstruction receiver = instruction.getDartReceiver(closedWorld);
|
||||
if (inputsArePositiveIntegers(instruction, closedWorld) &&
|
||||
!canBeNegativeZero(receiver)) {
|
||||
return new HRemainder(instruction.inputs[1], instruction.inputs[2],
|
||||
return HRemainder(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
// TODO(sra):
|
||||
|
@ -700,7 +700,7 @@ class RemainderSpecializer extends BinaryArithmeticSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HRemainder(instruction.inputs[1], instruction.inputs[2],
|
||||
return HRemainder(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -731,7 +731,7 @@ class MultiplySpecializer extends BinaryArithmeticSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HMultiply(instruction.inputs[1], instruction.inputs[2],
|
||||
return HMultiply(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -753,7 +753,7 @@ class SubtractSpecializer extends BinaryArithmeticSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HSubtract(instruction.inputs[1], instruction.inputs[2],
|
||||
return HSubtract(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -858,7 +858,7 @@ class TruncatingDivideSpecializer extends BinaryArithmeticSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HTruncatingDivide(instruction.inputs[1], instruction.inputs[2],
|
||||
return HTruncatingDivide(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -893,8 +893,7 @@ abstract class BinaryBitOpSpecializer extends BinaryArithmeticSpecializer {
|
|||
HConstant rightConstant = instruction;
|
||||
IntConstantValue intConstant = rightConstant.constant;
|
||||
int value = intConstant.intValue.toInt();
|
||||
assert(intConstant.intValue ==
|
||||
new BigInt.from(intConstant.intValue.toInt()));
|
||||
assert(intConstant.intValue == BigInt.from(intConstant.intValue.toInt()));
|
||||
return value >= low && value <= high;
|
||||
}
|
||||
// TODO(sra): Integrate with the bit-width analysis in codegen.dart.
|
||||
|
@ -959,7 +958,7 @@ class ShiftLeftSpecializer extends BinaryBitOpSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HShiftLeft(instruction.inputs[1], instruction.inputs[2],
|
||||
return HShiftLeft(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1029,7 @@ class ShiftRightSpecializer extends BinaryBitOpSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HShiftRight(instruction.inputs[1], instruction.inputs[2],
|
||||
return HShiftRight(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1133,7 @@ class BitOrSpecializer extends BinaryBitOpSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HBitOr(instruction.inputs[1], instruction.inputs[2],
|
||||
return HBitOr(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -1171,7 +1170,7 @@ class BitAndSpecializer extends BinaryBitOpSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HBitAnd(instruction.inputs[1], instruction.inputs[2],
|
||||
return HBitAnd(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -1205,7 +1204,7 @@ class BitXorSpecializer extends BinaryBitOpSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(HInvokeDynamic instruction,
|
||||
GlobalTypeInferenceResults results, JClosedWorld closedWorld) {
|
||||
return new HBitXor(instruction.inputs[1], instruction.inputs[2],
|
||||
return HBitXor(instruction.inputs[1], instruction.inputs[2],
|
||||
computeTypeFromInputTypes(instruction, results, closedWorld));
|
||||
}
|
||||
|
||||
|
@ -1310,7 +1309,7 @@ class EqualsSpecializer extends RelationalSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(
|
||||
HInvokeDynamic instruction, JClosedWorld closedWorld) {
|
||||
return new HIdentity(instruction.inputs[1], instruction.inputs[2],
|
||||
return HIdentity(instruction.inputs[1], instruction.inputs[2],
|
||||
closedWorld.abstractValueDomain.boolType);
|
||||
}
|
||||
|
||||
|
@ -1332,7 +1331,7 @@ class LessSpecializer extends RelationalSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(
|
||||
HInvokeDynamic instruction, JClosedWorld closedWorld) {
|
||||
return new HLess(instruction.inputs[1], instruction.inputs[2],
|
||||
return HLess(instruction.inputs[1], instruction.inputs[2],
|
||||
closedWorld.abstractValueDomain.boolType);
|
||||
}
|
||||
|
||||
|
@ -1354,7 +1353,7 @@ class GreaterSpecializer extends RelationalSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(
|
||||
HInvokeDynamic instruction, JClosedWorld closedWorld) {
|
||||
return new HGreater(instruction.inputs[1], instruction.inputs[2],
|
||||
return HGreater(instruction.inputs[1], instruction.inputs[2],
|
||||
closedWorld.abstractValueDomain.boolType);
|
||||
}
|
||||
|
||||
|
@ -1376,7 +1375,7 @@ class GreaterEqualSpecializer extends RelationalSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(
|
||||
HInvokeDynamic instruction, JClosedWorld closedWorld) {
|
||||
return new HGreaterEqual(instruction.inputs[1], instruction.inputs[2],
|
||||
return HGreaterEqual(instruction.inputs[1], instruction.inputs[2],
|
||||
closedWorld.abstractValueDomain.boolType);
|
||||
}
|
||||
|
||||
|
@ -1398,7 +1397,7 @@ class LessEqualSpecializer extends RelationalSpecializer {
|
|||
@override
|
||||
HInstruction newBuiltinVariant(
|
||||
HInvokeDynamic instruction, JClosedWorld closedWorld) {
|
||||
return new HLessEqual(instruction.inputs[1], instruction.inputs[2],
|
||||
return HLessEqual(instruction.inputs[1], instruction.inputs[2],
|
||||
closedWorld.abstractValueDomain.boolType);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class _JumpHandlerEntry {
|
|||
|
||||
abstract class JumpHandler {
|
||||
factory JumpHandler(KernelSsaGraphBuilder builder, JumpTarget target) {
|
||||
return new TargetJumpHandler(builder, target);
|
||||
return TargetJumpHandler(builder, target);
|
||||
}
|
||||
void generateBreak(SourceInformation sourceInformation,
|
||||
[LabelDefinition label]);
|
||||
|
@ -103,14 +103,14 @@ class TargetJumpHandler implements JumpHandler {
|
|||
HInstruction breakInstruction;
|
||||
if (label == null) {
|
||||
breakInstruction =
|
||||
new HBreak(_abstractValueDomain, target, sourceInformation);
|
||||
HBreak(_abstractValueDomain, target, sourceInformation);
|
||||
} else {
|
||||
breakInstruction =
|
||||
new HBreak.toLabel(_abstractValueDomain, label, sourceInformation);
|
||||
HBreak.toLabel(_abstractValueDomain, label, sourceInformation);
|
||||
}
|
||||
LocalsHandler locals = new LocalsHandler.from(builder.localsHandler);
|
||||
LocalsHandler locals = LocalsHandler.from(builder.localsHandler);
|
||||
builder.close(breakInstruction);
|
||||
jumps.add(new _JumpHandlerEntry(breakInstruction, locals));
|
||||
jumps.add(_JumpHandlerEntry(breakInstruction, locals));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -119,17 +119,17 @@ class TargetJumpHandler implements JumpHandler {
|
|||
HInstruction continueInstruction;
|
||||
if (label == null) {
|
||||
continueInstruction =
|
||||
new HContinue(_abstractValueDomain, target, sourceInformation);
|
||||
HContinue(_abstractValueDomain, target, sourceInformation);
|
||||
} else {
|
||||
continueInstruction =
|
||||
new HContinue.toLabel(_abstractValueDomain, label, sourceInformation);
|
||||
HContinue.toLabel(_abstractValueDomain, label, sourceInformation);
|
||||
// Switch case continue statements must be handled by the
|
||||
// [SwitchCaseJumpHandler].
|
||||
assert(!label.target.isSwitchCase);
|
||||
}
|
||||
LocalsHandler locals = new LocalsHandler.from(builder.localsHandler);
|
||||
LocalsHandler locals = LocalsHandler.from(builder.localsHandler);
|
||||
builder.close(continueInstruction);
|
||||
jumps.add(new _JumpHandlerEntry(continueInstruction, locals));
|
||||
jumps.add(_JumpHandlerEntry(continueInstruction, locals));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -184,7 +184,7 @@ class TargetJumpHandler implements JumpHandler {
|
|||
abstract class SwitchCaseJumpHandler extends TargetJumpHandler {
|
||||
/// Map from switch case targets to indices used to encode the flow of the
|
||||
/// switch case loop.
|
||||
final Map<JumpTarget, int> targetIndexMap = new Map<JumpTarget, int>();
|
||||
final Map<JumpTarget, int> targetIndexMap = Map<JumpTarget, int>();
|
||||
|
||||
SwitchCaseJumpHandler(KernelSsaGraphBuilder builder, JumpTarget target)
|
||||
: super(builder, target);
|
||||
|
@ -197,12 +197,12 @@ abstract class SwitchCaseJumpHandler extends TargetJumpHandler {
|
|||
// for a switch statement with continue statements. See
|
||||
// [SsaFromAstMixin.buildComplexSwitchStatement] for detail.
|
||||
|
||||
HInstruction breakInstruction = new HBreak(
|
||||
HInstruction breakInstruction = HBreak(
|
||||
_abstractValueDomain, target, sourceInformation,
|
||||
breakSwitchContinueLoop: true);
|
||||
LocalsHandler locals = new LocalsHandler.from(builder.localsHandler);
|
||||
LocalsHandler locals = LocalsHandler.from(builder.localsHandler);
|
||||
builder.close(breakInstruction);
|
||||
jumps.add(new _JumpHandlerEntry(breakInstruction, locals));
|
||||
jumps.add(_JumpHandlerEntry(breakInstruction, locals));
|
||||
} else {
|
||||
super.generateBreak(sourceInformation, label);
|
||||
}
|
||||
|
@ -227,10 +227,10 @@ abstract class SwitchCaseJumpHandler extends TargetJumpHandler {
|
|||
|
||||
assert(label.target.labels.contains(label));
|
||||
HInstruction continueInstruction =
|
||||
new HContinue(_abstractValueDomain, target, sourceInformation);
|
||||
LocalsHandler locals = new LocalsHandler.from(builder.localsHandler);
|
||||
HContinue(_abstractValueDomain, target, sourceInformation);
|
||||
LocalsHandler locals = LocalsHandler.from(builder.localsHandler);
|
||||
builder.close(continueInstruction);
|
||||
jumps.add(new _JumpHandlerEntry(continueInstruction, locals));
|
||||
jumps.add(_JumpHandlerEntry(continueInstruction, locals));
|
||||
} else {
|
||||
super.generateContinue(sourceInformation, label);
|
||||
}
|
||||
|
|
|
@ -61,14 +61,14 @@ class KernelStringBuilder extends ir.Visitor<void> with ir.VisitorVoidMixin {
|
|||
|
||||
HInstruction concat(HInstruction left, HInstruction right) {
|
||||
HInstruction instruction =
|
||||
new HStringConcat(left, right, _abstractValueDomain.stringType);
|
||||
HStringConcat(left, right, _abstractValueDomain.stringType);
|
||||
builder.add(instruction);
|
||||
return instruction;
|
||||
}
|
||||
|
||||
HInstruction stringify(HInstruction expression) {
|
||||
HInstruction instruction =
|
||||
new HStringify(expression, _abstractValueDomain.stringType)
|
||||
HStringify(expression, _abstractValueDomain.stringType)
|
||||
..sourceInformation = expression.sourceInformation;
|
||||
builder.add(instruction);
|
||||
return instruction;
|
||||
|
|
|
@ -32,8 +32,8 @@ class LocalsHandler {
|
|||
/// iteration order a function only of insertions and not a function of
|
||||
/// e.g. Element hash codes. I'd prefer to use a SortedMap but some elements
|
||||
/// don't have source locations for [Elements.compareByPosition].
|
||||
Map<Local, HInstruction> directLocals = new Map<Local, HInstruction>();
|
||||
Map<Local, FieldEntity> redirectionMapping = new Map<Local, FieldEntity>();
|
||||
Map<Local, HInstruction> directLocals = Map<Local, HInstruction>();
|
||||
Map<Local, FieldEntity> redirectionMapping = Map<Local, FieldEntity>();
|
||||
final KernelSsaGraphBuilder builder;
|
||||
|
||||
MemberEntity _scopeInfoMember;
|
||||
|
@ -41,7 +41,7 @@ class LocalsHandler {
|
|||
KernelToLocalsMap _localsMap;
|
||||
|
||||
Map<TypeVariableEntity, TypeVariableLocal> typeVariableLocals =
|
||||
new Map<TypeVariableEntity, TypeVariableLocal>();
|
||||
Map<TypeVariableEntity, TypeVariableLocal>();
|
||||
final Entity executableContext;
|
||||
final MemberEntity memberContext;
|
||||
|
||||
|
@ -106,7 +106,7 @@ class LocalsHandler {
|
|||
/// copy the [directLocals], since the other fields can be shared
|
||||
/// throughout the AST visit.
|
||||
LocalsHandler.from(LocalsHandler other)
|
||||
: directLocals = new Map<Local, HInstruction>.from(other.directLocals),
|
||||
: directLocals = Map<Local, HInstruction>.from(other.directLocals),
|
||||
redirectionMapping = other.redirectionMapping,
|
||||
executableContext = other.executableContext,
|
||||
memberContext = other.memberContext,
|
||||
|
@ -148,7 +148,7 @@ class LocalsHandler {
|
|||
}
|
||||
|
||||
HInstruction createBox(SourceInformation sourceInformation) {
|
||||
HInstruction box = new HCreateBox(_abstractValueDomain.nonNullType)
|
||||
HInstruction box = HCreateBox(_abstractValueDomain.nonNullType)
|
||||
..sourceInformation = sourceInformation;
|
||||
builder.add(box);
|
||||
return box;
|
||||
|
@ -158,7 +158,7 @@ class LocalsHandler {
|
|||
/// method creates a box and sets up the redirections.
|
||||
void enterScope(
|
||||
CapturedScope closureInfo, SourceInformation sourceInformation,
|
||||
{bool forGenerativeConstructorBody: false, HInstruction inlinedBox}) {
|
||||
{bool forGenerativeConstructorBody = false, HInstruction inlinedBox}) {
|
||||
// See if any variable in the top-scope of the function is captured. If yes
|
||||
// we need to create a box-object.
|
||||
if (!closureInfo.requiresContextBox) return;
|
||||
|
@ -261,7 +261,7 @@ class LocalsHandler {
|
|||
});
|
||||
// Inside closure redirect references to itself to [:this:].
|
||||
HThis thisInstruction =
|
||||
new HThis(closureData.thisLocal, _abstractValueDomain.nonNullType);
|
||||
HThis(closureData.thisLocal, _abstractValueDomain.nonNullType);
|
||||
builder.graph.thisInstruction = thisInstruction;
|
||||
builder.graph.entry.addAtEntry(thisInstruction);
|
||||
updateLocal(closureData.getClosureEntity(_localsMap), thisInstruction);
|
||||
|
@ -269,7 +269,7 @@ class LocalsHandler {
|
|||
// Once closures have been mapped to classes their instance members might
|
||||
// not have any thisElement if the closure was created inside a static
|
||||
// context.
|
||||
HThis thisInstruction = new HThis(scopeInfo.thisLocal, getTypeOfThis());
|
||||
HThis thisInstruction = HThis(scopeInfo.thisLocal, getTypeOfThis());
|
||||
builder.graph.thisInstruction = thisInstruction;
|
||||
builder.graph.entry.addAtEntry(thisInstruction);
|
||||
directLocals[scopeInfo.thisLocal] = thisInstruction;
|
||||
|
@ -289,7 +289,7 @@ class LocalsHandler {
|
|||
_nativeData.isNativeOrExtendsNative(cls);
|
||||
if (_interceptorData.isInterceptedMethod(element)) {
|
||||
SyntheticLocal parameter = createLocal('receiver');
|
||||
HParameterValue value = new HParameterValue(parameter, getTypeOfThis());
|
||||
HParameterValue value = HParameterValue(parameter, getTypeOfThis());
|
||||
builder.graph.explicitReceiverParameter = value;
|
||||
builder.graph.entry.addAfter(directLocals[scopeInfo.thisLocal], value);
|
||||
if (builder.lastAddedParameter == null) {
|
||||
|
@ -301,7 +301,7 @@ class LocalsHandler {
|
|||
SyntheticLocal parameter = createLocal('receiver');
|
||||
// Unlike `this`, receiver is nullable since direct calls to generative
|
||||
// constructor call the constructor with `null`.
|
||||
HParameterValue value = new HParameterValue(
|
||||
HParameterValue value = HParameterValue(
|
||||
parameter, _closedWorld.abstractValueDomain.createNullableExact(cls));
|
||||
builder.graph.explicitReceiverParameter = value;
|
||||
builder.graph.entry.addAtEntry(value);
|
||||
|
@ -359,7 +359,7 @@ class LocalsHandler {
|
|||
}
|
||||
HInstruction value = directLocals[local];
|
||||
if (sourceInformation != null) {
|
||||
value = new HRef(value, sourceInformation);
|
||||
value = HRef(value, sourceInformation);
|
||||
builder.add(value);
|
||||
}
|
||||
return value;
|
||||
|
@ -372,7 +372,7 @@ class LocalsHandler {
|
|||
? _abstractValueDomain.nonNullType
|
||||
: getTypeOfCapturedVariable(redirect);
|
||||
HInstruction fieldGet =
|
||||
new HFieldGet(redirect, receiver, type, sourceInformation);
|
||||
HFieldGet(redirect, receiver, type, sourceInformation);
|
||||
builder.add(fieldGet);
|
||||
return fieldGet;
|
||||
} else if (isBoxed(local)) {
|
||||
|
@ -389,14 +389,14 @@ class LocalsHandler {
|
|||
assert(localBox != null);
|
||||
|
||||
HInstruction box = readLocal(localBox);
|
||||
HInstruction lookup = new HFieldGet(redirect, box,
|
||||
HInstruction lookup = HFieldGet(redirect, box,
|
||||
getTypeOfCapturedVariable(redirect), sourceInformation);
|
||||
builder.add(lookup);
|
||||
return lookup;
|
||||
} else {
|
||||
assert(_isUsedInTryOrGenerator(local));
|
||||
HLocalValue localValue = getLocal(local);
|
||||
HInstruction instruction = new HLocalGet(local, localValue,
|
||||
HInstruction instruction = HLocalGet(local, localValue,
|
||||
_abstractValueDomain.dynamicType, sourceInformation);
|
||||
builder.add(instruction);
|
||||
return instruction;
|
||||
|
@ -424,7 +424,7 @@ class LocalsHandler {
|
|||
|
||||
return activationVariables.putIfAbsent(local, () {
|
||||
HLocalValue localValue =
|
||||
new HLocalValue(local, _abstractValueDomain.nonNullType)
|
||||
HLocalValue(local, _abstractValueDomain.nonNullType)
|
||||
..sourceInformation = sourceInformation;
|
||||
builder.graph.entry.addAtExit(localValue);
|
||||
return localValue;
|
||||
|
@ -432,8 +432,7 @@ class LocalsHandler {
|
|||
}
|
||||
|
||||
Local getTypeVariableAsLocal(TypeVariableType type) {
|
||||
return typeVariableLocals[type.element] ??=
|
||||
new TypeVariableLocal(type.element);
|
||||
return typeVariableLocals[type.element] ??= TypeVariableLocal(type.element);
|
||||
}
|
||||
|
||||
/// Sets the [element] to [value]. If the element is boxed or stored in a
|
||||
|
@ -462,12 +461,12 @@ class LocalsHandler {
|
|||
// Inside the closure the box is stored in a closure-field and cannot
|
||||
// be accessed directly.
|
||||
HInstruction box = readLocal(localBox);
|
||||
builder.add(new HFieldSet(_abstractValueDomain, redirect, box, value)
|
||||
builder.add(HFieldSet(_abstractValueDomain, redirect, box, value)
|
||||
..sourceInformation = sourceInformation);
|
||||
} else {
|
||||
assert(_isUsedInTryOrGenerator(local));
|
||||
HLocalValue localValue = getLocal(local);
|
||||
builder.add(new HLocalSet(_abstractValueDomain, local, localValue, value)
|
||||
builder.add(HLocalSet(_abstractValueDomain, local, localValue, value)
|
||||
..sourceInformation = sourceInformation);
|
||||
}
|
||||
}
|
||||
|
@ -532,14 +531,14 @@ class LocalsHandler {
|
|||
void beginLoopHeader(HBasicBlock loopEntry) {
|
||||
// Create a copy because we modify the map while iterating over it.
|
||||
Map<Local, HInstruction> savedDirectLocals =
|
||||
new Map<Local, HInstruction>.from(directLocals);
|
||||
Map<Local, HInstruction>.from(directLocals);
|
||||
|
||||
// Create phis for all elements in the definitions environment.
|
||||
savedDirectLocals.forEach((Local local, HInstruction instruction) {
|
||||
if (isAccessedDirectly(local)) {
|
||||
// We know 'this' cannot be modified.
|
||||
if (local != _scopeInfo.thisLocal) {
|
||||
HPhi phi = new HPhi.singleInput(
|
||||
HPhi phi = HPhi.singleInput(
|
||||
local, instruction, _abstractValueDomain.dynamicType);
|
||||
loopEntry.addPhi(phi);
|
||||
directLocals[local] = phi;
|
||||
|
@ -595,7 +594,7 @@ class LocalsHandler {
|
|||
// block. Since variable declarations are scoped the declared
|
||||
// variable cannot be alive outside the block. Note: this is only
|
||||
// true for nodes where we do joins.
|
||||
Map<Local, HInstruction> joinedLocals = new Map<Local, HInstruction>();
|
||||
Map<Local, HInstruction> joinedLocals = Map<Local, HInstruction>();
|
||||
otherLocals.directLocals.forEach((Local local, HInstruction instruction) {
|
||||
// We know 'this' cannot be modified.
|
||||
if (local == _scopeInfo.thisLocal) {
|
||||
|
@ -607,7 +606,7 @@ class LocalsHandler {
|
|||
if (identical(instruction, mine)) {
|
||||
joinedLocals[local] = instruction;
|
||||
} else {
|
||||
HInstruction phi = new HPhi.manyInputs(
|
||||
HInstruction phi = HPhi.manyInputs(
|
||||
local,
|
||||
<HInstruction>[mine, instruction],
|
||||
_abstractValueDomain.dynamicType);
|
||||
|
@ -628,11 +627,11 @@ class LocalsHandler {
|
|||
List<LocalsHandler> localsHandlers, HBasicBlock joinBlock) {
|
||||
assert(localsHandlers.length > 0);
|
||||
if (localsHandlers.length == 1) return localsHandlers.single;
|
||||
Map<Local, HInstruction> joinedLocals = new Map<Local, HInstruction>();
|
||||
Map<Local, HInstruction> joinedLocals = Map<Local, HInstruction>();
|
||||
HInstruction thisValue = null;
|
||||
directLocals.forEach((Local local, HInstruction instruction) {
|
||||
if (local != _scopeInfo.thisLocal) {
|
||||
HPhi phi = new HPhi.noInputs(local, _abstractValueDomain.dynamicType);
|
||||
HPhi phi = HPhi.noInputs(local, _abstractValueDomain.dynamicType);
|
||||
joinedLocals[local] = phi;
|
||||
joinBlock.addPhi(phi);
|
||||
} else {
|
||||
|
@ -656,7 +655,7 @@ class LocalsHandler {
|
|||
}
|
||||
|
||||
// Remove locals that are not in all handlers.
|
||||
directLocals = new Map<Local, HInstruction>();
|
||||
directLocals = Map<Local, HInstruction>();
|
||||
joinedLocals.forEach((Local local, HInstruction instruction) {
|
||||
if (local != _scopeInfo.thisLocal &&
|
||||
instruction.inputs.length != localsHandlers.length) {
|
||||
|
@ -690,7 +689,7 @@ class LocalsHandler {
|
|||
}
|
||||
|
||||
Map<FieldEntity, AbstractValue> cachedTypesOfCapturedVariables =
|
||||
new Map<FieldEntity, AbstractValue>();
|
||||
Map<FieldEntity, AbstractValue>();
|
||||
|
||||
AbstractValue getTypeOfCapturedVariable(FieldEntity element) {
|
||||
return cachedTypesOfCapturedVariables.putIfAbsent(element, () {
|
||||
|
@ -705,7 +704,7 @@ class LocalsHandler {
|
|||
Map<Local, HLocalValue> activationVariables = <Local, HLocalValue>{};
|
||||
|
||||
SyntheticLocal createLocal(String name) {
|
||||
return new SyntheticLocal(name, executableContext, memberContext);
|
||||
return SyntheticLocal(name, executableContext, memberContext);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@ class OptimizationTestLog {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
f(features);
|
||||
entries.add(new OptimizationLogEntry(tag, features));
|
||||
entries.add(OptimizationLogEntry(tag, features));
|
||||
return features;
|
||||
}
|
||||
|
||||
void registerNullCheck(HInstruction original, HNullCheck check) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
if (check.selector != null) {
|
||||
features['selector'] = check.selector.name;
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ class OptimizationTestLog {
|
|||
features['field'] =
|
||||
'${check.field.enclosingClass.name}.${check.field.name}';
|
||||
}
|
||||
entries.add(new OptimizationLogEntry('NullCheck', features));
|
||||
entries.add(OptimizationLogEntry('NullCheck', features));
|
||||
}
|
||||
|
||||
void registerConditionValue(
|
||||
HInstruction original, bool value, String where, int count) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
features['value'] = '$value';
|
||||
features['where'] = where;
|
||||
features['count'] = '$count';
|
||||
|
@ -54,52 +54,52 @@ class OptimizationTestLog {
|
|||
}
|
||||
|
||||
void registerFieldGet(HInvokeDynamicGetter original, HFieldGet converted) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
if (converted.element != null) {
|
||||
features['name'] =
|
||||
'${converted.element.enclosingClass.name}.${converted.element.name}';
|
||||
} else {
|
||||
features['name'] = '<null-guard>';
|
||||
}
|
||||
entries.add(new OptimizationLogEntry('FieldGet', features));
|
||||
entries.add(OptimizationLogEntry('FieldGet', features));
|
||||
}
|
||||
|
||||
void registerFieldSet(HInvokeDynamicSetter original, [HFieldSet converted]) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
if (converted != null) {
|
||||
features['name'] =
|
||||
'${converted.element.enclosingClass.name}.${converted.element.name}';
|
||||
} else {
|
||||
features['removed'] = original.selector.name;
|
||||
}
|
||||
entries.add(new OptimizationLogEntry('FieldSet', features));
|
||||
entries.add(OptimizationLogEntry('FieldSet', features));
|
||||
}
|
||||
|
||||
void registerFieldCall(HInvokeDynamicMethod original, HFieldGet converted) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
if (converted.element != null) {
|
||||
features['name'] =
|
||||
'${converted.element.enclosingClass.name}.${converted.element.name}';
|
||||
} else {
|
||||
features['name'] = '<null-guard>';
|
||||
}
|
||||
entries.add(new OptimizationLogEntry('FieldCall', features));
|
||||
entries.add(OptimizationLogEntry('FieldCall', features));
|
||||
}
|
||||
|
||||
void registerConstantFieldGet(
|
||||
HInvokeDynamicGetter original, FieldEntity field, HConstant converted) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
features['name'] = '${field.enclosingClass.name}.${field.name}';
|
||||
features['value'] = converted.constant.toStructuredText(_dartTypes);
|
||||
entries.add(new OptimizationLogEntry('ConstantFieldGet', features));
|
||||
entries.add(OptimizationLogEntry('ConstantFieldGet', features));
|
||||
}
|
||||
|
||||
void registerConstantFieldCall(
|
||||
HInvokeDynamicMethod original, FieldEntity field, HConstant converted) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
features['name'] = '${field.enclosingClass.name}.${field.name}';
|
||||
features['value'] = converted.constant.toStructuredText(_dartTypes);
|
||||
entries.add(new OptimizationLogEntry('ConstantFieldCall', features));
|
||||
entries.add(OptimizationLogEntry('ConstantFieldCall', features));
|
||||
}
|
||||
|
||||
Features _registerSpecializer(
|
||||
|
@ -218,17 +218,17 @@ class OptimizationTestLog {
|
|||
}
|
||||
|
||||
void registerCodeUnitAt(HInvokeDynamic original) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
features['name'] = original.selector.name;
|
||||
entries.add(new OptimizationLogEntry('CodeUnitAt', features));
|
||||
entries.add(OptimizationLogEntry('CodeUnitAt', features));
|
||||
}
|
||||
|
||||
void registerCompareTo(HInvokeDynamic original, [HConstant converted]) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
if (converted != null) {
|
||||
features['constant'] = converted.constant.toDartText(_dartTypes);
|
||||
}
|
||||
entries.add(new OptimizationLogEntry('CompareTo', features));
|
||||
entries.add(OptimizationLogEntry('CompareTo', features));
|
||||
}
|
||||
|
||||
void registerSubstring(HInvokeDynamic original) {
|
||||
|
@ -252,7 +252,7 @@ class OptimizationTestLog {
|
|||
}
|
||||
|
||||
void registerPrimitiveCheck(HInstruction original, HPrimitiveCheck check) {
|
||||
Features features = new Features();
|
||||
Features features = Features();
|
||||
|
||||
if (check.isReceiverTypeCheck) {
|
||||
features['kind'] = 'receiver';
|
||||
|
@ -262,7 +262,7 @@ class OptimizationTestLog {
|
|||
if (check.typeExpression != null) {
|
||||
features['type'] = '${check.typeExpression}';
|
||||
}
|
||||
entries.add(new OptimizationLogEntry('PrimitiveCheck', features));
|
||||
entries.add(OptimizationLogEntry('PrimitiveCheck', features));
|
||||
}
|
||||
|
||||
String getText() {
|
||||
|
|
|
@ -56,7 +56,7 @@ abstract class LoopHandler {
|
|||
startBlock = initializerBlock;
|
||||
initialize();
|
||||
assert(!builder.isAborted());
|
||||
initializerGraph = new SubExpression(initializerBlock, builder.current);
|
||||
initializerGraph = SubExpression(initializerBlock, builder.current);
|
||||
}
|
||||
|
||||
builder.loopDepth++;
|
||||
|
@ -66,15 +66,15 @@ abstract class LoopHandler {
|
|||
if (startBlock == null) startBlock = conditionBlock;
|
||||
|
||||
HInstruction conditionInstruction = condition();
|
||||
HBasicBlock conditionEndBlock = builder
|
||||
.close(new HLoopBranch(_abstractValueDomain, conditionInstruction));
|
||||
HBasicBlock conditionEndBlock =
|
||||
builder.close(HLoopBranch(_abstractValueDomain, conditionInstruction));
|
||||
SubExpression conditionExpression =
|
||||
new SubExpression(conditionBlock, conditionEndBlock);
|
||||
SubExpression(conditionBlock, conditionEndBlock);
|
||||
|
||||
// Save the values of the local variables at the end of the condition
|
||||
// block. These are the values that will flow to the loop exit if the
|
||||
// condition fails.
|
||||
LocalsHandler savedLocals = new LocalsHandler.from(builder.localsHandler);
|
||||
LocalsHandler savedLocals = LocalsHandler.from(builder.localsHandler);
|
||||
|
||||
// The body.
|
||||
HBasicBlock beginBodyBlock = builder.addNewBlock();
|
||||
|
@ -84,9 +84,9 @@ abstract class LoopHandler {
|
|||
builder.localsHandler.enterLoopBody(loopClosureInfo, sourceInformation);
|
||||
body();
|
||||
|
||||
SubGraph bodyGraph = new SubGraph(beginBodyBlock, builder.lastOpenedBlock);
|
||||
SubGraph bodyGraph = SubGraph(beginBodyBlock, builder.lastOpenedBlock);
|
||||
HBasicBlock bodyBlock = builder.current;
|
||||
if (builder.current != null) builder.close(new HGoto(_abstractValueDomain));
|
||||
if (builder.current != null) builder.close(HGoto(_abstractValueDomain));
|
||||
|
||||
SubExpression updateGraph;
|
||||
|
||||
|
@ -117,14 +117,14 @@ abstract class LoopHandler {
|
|||
List<LabelDefinition> labels = jumpHandler.labels;
|
||||
if (labels.isNotEmpty) {
|
||||
beginBodyBlock.setBlockFlow(
|
||||
new HLabeledBlockInformation(
|
||||
new HSubGraphBlockInformation(bodyGraph), jumpHandler.labels,
|
||||
HLabeledBlockInformation(
|
||||
HSubGraphBlockInformation(bodyGraph), jumpHandler.labels,
|
||||
isContinue: true),
|
||||
updateBlock);
|
||||
} else if (jumpTarget != null && jumpTarget.isContinueTarget) {
|
||||
beginBodyBlock.setBlockFlow(
|
||||
new HLabeledBlockInformation.implicit(
|
||||
new HSubGraphBlockInformation(bodyGraph), jumpTarget,
|
||||
HLabeledBlockInformation.implicit(
|
||||
HSubGraphBlockInformation(bodyGraph), jumpTarget,
|
||||
isContinue: true),
|
||||
updateBlock);
|
||||
}
|
||||
|
@ -134,22 +134,21 @@ abstract class LoopHandler {
|
|||
|
||||
update();
|
||||
|
||||
HBasicBlock updateEndBlock =
|
||||
builder.close(new HGoto(_abstractValueDomain));
|
||||
HBasicBlock updateEndBlock = builder.close(HGoto(_abstractValueDomain));
|
||||
// The back-edge completing the cycle.
|
||||
updateEndBlock.addSuccessor(conditionBlock);
|
||||
updateGraph = new SubExpression(updateBlock, updateEndBlock);
|
||||
updateGraph = SubExpression(updateBlock, updateEndBlock);
|
||||
|
||||
// Avoid a critical edge from the condition to the loop-exit body.
|
||||
HBasicBlock conditionExitBlock = builder.addNewBlock();
|
||||
builder.open(conditionExitBlock);
|
||||
builder.close(new HGoto(_abstractValueDomain));
|
||||
builder.close(HGoto(_abstractValueDomain));
|
||||
conditionEndBlock.addSuccessor(conditionExitBlock);
|
||||
|
||||
endLoop(conditionBlock, conditionExitBlock, jumpHandler, savedLocals);
|
||||
|
||||
conditionBlock.postProcessLoopHeader();
|
||||
HLoopBlockInformation info = new HLoopBlockInformation(
|
||||
HLoopBlockInformation info = HLoopBlockInformation(
|
||||
loopKind(loop),
|
||||
builder.wrapExpressionGraph(initializerGraph),
|
||||
builder.wrapExpressionGraph(conditionExpression),
|
||||
|
@ -174,22 +173,22 @@ abstract class LoopHandler {
|
|||
// label to the if.
|
||||
HBasicBlock elseBlock = builder.addNewBlock();
|
||||
builder.open(elseBlock);
|
||||
builder.close(new HGoto(_abstractValueDomain));
|
||||
builder.close(HGoto(_abstractValueDomain));
|
||||
// Pass the elseBlock as the branchBlock, because that's the block we go
|
||||
// to just before leaving the 'loop'.
|
||||
endLoop(conditionBlock, elseBlock, jumpHandler, savedLocals);
|
||||
|
||||
SubGraph elseGraph = new SubGraph(elseBlock, elseBlock);
|
||||
SubGraph elseGraph = SubGraph(elseBlock, elseBlock);
|
||||
// Remove the loop information attached to the header.
|
||||
conditionBlock.loopInformation = null;
|
||||
|
||||
// Remove the [HLoopBranch] instruction and replace it with
|
||||
// [HIf].
|
||||
HInstruction condition = conditionEndBlock.last.inputs[0];
|
||||
conditionEndBlock.addAtExit(new HIf(_abstractValueDomain, condition));
|
||||
conditionEndBlock.addAtExit(HIf(_abstractValueDomain, condition));
|
||||
conditionEndBlock.addSuccessor(elseBlock);
|
||||
conditionEndBlock.remove(conditionEndBlock.last);
|
||||
HIfBlockInformation info = new HIfBlockInformation(
|
||||
HIfBlockInformation info = HIfBlockInformation(
|
||||
builder.wrapExpressionGraph(conditionExpression),
|
||||
builder.wrapStatementGraph(bodyGraph),
|
||||
builder.wrapStatementGraph(elseGraph));
|
||||
|
@ -203,17 +202,16 @@ abstract class LoopHandler {
|
|||
if (jumpHandler.hasAnyBreak()) {
|
||||
LabelDefinition label =
|
||||
jumpTarget.addLabel('loop', isBreakTarget: true);
|
||||
SubGraph labelGraph = new SubGraph(conditionBlock, builder.current);
|
||||
HLabeledBlockInformation labelInfo = new HLabeledBlockInformation(
|
||||
new HSubGraphBlockInformation(labelGraph),
|
||||
<LabelDefinition>[label]);
|
||||
SubGraph labelGraph = SubGraph(conditionBlock, builder.current);
|
||||
HLabeledBlockInformation labelInfo = HLabeledBlockInformation(
|
||||
HSubGraphBlockInformation(labelGraph), <LabelDefinition>[label]);
|
||||
|
||||
conditionBlock.setBlockFlow(labelInfo, builder.current);
|
||||
|
||||
jumpHandler.forEachBreak((HBreak breakInstruction, _) {
|
||||
HBasicBlock block = breakInstruction.block;
|
||||
block.addAtExit(new HBreak.toLabel(
|
||||
_abstractValueDomain, label, sourceInformation));
|
||||
block.addAtExit(
|
||||
HBreak.toLabel(_abstractValueDomain, label, sourceInformation));
|
||||
block.remove(breakInstruction);
|
||||
});
|
||||
}
|
||||
|
@ -227,7 +225,7 @@ abstract class LoopHandler {
|
|||
/// Also notifies the locals handler that we're entering a loop.
|
||||
JumpHandler beginLoopHeader(ir.TreeNode node, JumpTarget jumpTarget) {
|
||||
assert(!builder.isAborted());
|
||||
HBasicBlock previousBlock = builder.close(new HGoto(_abstractValueDomain));
|
||||
HBasicBlock previousBlock = builder.close(HGoto(_abstractValueDomain));
|
||||
|
||||
JumpHandler jumpHandler =
|
||||
createJumpHandler(node, jumpTarget, isLoopJump: true);
|
||||
|
@ -326,7 +324,7 @@ class KernelLoopHandler extends LoopHandler {
|
|||
builder.createJumpHandler(node, jumpTarget, isLoopJump: isLoopJump);
|
||||
|
||||
@override
|
||||
int loopKind(ir.TreeNode node) => node.accept(new _KernelLoopTypeVisitor());
|
||||
int loopKind(ir.TreeNode node) => node.accept(_KernelLoopTypeVisitor());
|
||||
}
|
||||
|
||||
class _KernelLoopTypeVisitor extends ir.Visitor<int>
|
||||
|
|
|
@ -131,7 +131,7 @@ abstract class HGraphVisitor {
|
|||
// }
|
||||
// visitBasicBlockAndSuccessors(graph.entry);
|
||||
|
||||
_Frame frame = new _Frame(null);
|
||||
_Frame frame = _Frame(null);
|
||||
frame.block = graph.entry;
|
||||
frame.index = 0;
|
||||
|
||||
|
@ -142,7 +142,7 @@ abstract class HGraphVisitor {
|
|||
int index = frame.index;
|
||||
if (index < block.dominatedBlocks.length) {
|
||||
frame.index = index + 1;
|
||||
frame = frame.next ??= new _Frame(frame);
|
||||
frame = frame.next ??= _Frame(frame);
|
||||
frame.block = block.dominatedBlocks[index];
|
||||
frame.index = 0;
|
||||
visitBasicBlock(frame.block);
|
||||
|
@ -164,7 +164,7 @@ abstract class HGraphVisitor {
|
|||
// }
|
||||
// visitBasicBlockAndSuccessors(graph.entry);
|
||||
|
||||
_Frame frame = new _Frame(null);
|
||||
_Frame frame = _Frame(null);
|
||||
frame.block = graph.entry;
|
||||
frame.index = frame.block.dominatedBlocks.length;
|
||||
|
||||
|
@ -173,7 +173,7 @@ abstract class HGraphVisitor {
|
|||
int index = frame.index;
|
||||
if (index > 0) {
|
||||
frame.index = index - 1;
|
||||
frame = frame.next ??= new _Frame(frame);
|
||||
frame = frame.next ??= _Frame(frame);
|
||||
frame.block = block.dominatedBlocks[index - 1];
|
||||
frame.index = frame.block.dominatedBlocks.length;
|
||||
continue;
|
||||
|
@ -240,19 +240,19 @@ class HGraph {
|
|||
/// Nodes containing list allocations for which there is a known fixed length.
|
||||
// TODO(sigmund,sra): consider not storing this explicitly here (e.g. maybe
|
||||
// store it on HInstruction, or maybe this can be computed on demand).
|
||||
final Set<HInstruction> allocatedFixedLists = new Set<HInstruction>();
|
||||
final Set<HInstruction> allocatedFixedLists = Set<HInstruction>();
|
||||
|
||||
SourceInformation sourceInformation;
|
||||
|
||||
// We canonicalize all constants used within a graph so we do not
|
||||
// have to worry about them for global value numbering.
|
||||
Map<ConstantValue, HConstant> constants = new Map<ConstantValue, HConstant>();
|
||||
Map<ConstantValue, HConstant> constants = Map<ConstantValue, HConstant>();
|
||||
|
||||
HGraph() {
|
||||
entry = addNewBlock();
|
||||
// The exit block will be added later, so it has an id that is
|
||||
// after all others in the system.
|
||||
exit = new HBasicBlock();
|
||||
exit = HBasicBlock();
|
||||
}
|
||||
|
||||
void addBlock(HBasicBlock block) {
|
||||
|
@ -263,7 +263,7 @@ class HGraph {
|
|||
}
|
||||
|
||||
HBasicBlock addNewBlock() {
|
||||
HBasicBlock result = new HBasicBlock();
|
||||
HBasicBlock result = HBasicBlock();
|
||||
addBlock(result);
|
||||
return result;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ class HGraph {
|
|||
HBasicBlock addNewLoopHeaderBlock(
|
||||
JumpTarget target, List<LabelDefinition> labels) {
|
||||
HBasicBlock result = addNewBlock();
|
||||
result.loopInformation = new HLoopInformation(result, target, labels);
|
||||
result.loopInformation = HLoopInformation(result, target, labels);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ class HGraph {
|
|||
}
|
||||
AbstractValue type = closedWorld.abstractValueDomain
|
||||
.computeAbstractValueForConstant(constant);
|
||||
result = new HConstant.internal(constant, type)
|
||||
result = HConstant.internal(constant, type)
|
||||
..sourceInformation = sourceInformation;
|
||||
entry.addAtExit(result);
|
||||
constants[constant] = result;
|
||||
|
@ -309,8 +309,7 @@ class HGraph {
|
|||
|
||||
HConstant addConstantIntAsUnsigned(int i, JClosedWorld closedWorld) {
|
||||
return addConstant(
|
||||
constant_system.createInt(new BigInt.from(i).toUnsigned(64)),
|
||||
closedWorld);
|
||||
constant_system.createInt(BigInt.from(i).toUnsigned(64)), closedWorld);
|
||||
}
|
||||
|
||||
HConstant addConstantDouble(double d, JClosedWorld closedWorld) {
|
||||
|
@ -322,8 +321,7 @@ class HGraph {
|
|||
}
|
||||
|
||||
HConstant addConstantStringFromName(js.Name name, JClosedWorld closedWorld) {
|
||||
return addConstant(
|
||||
new JsNameConstantValue(js.quoteName(name)), closedWorld);
|
||||
return addConstant(JsNameConstantValue(js.quoteName(name)), closedWorld);
|
||||
}
|
||||
|
||||
HConstant addConstantBool(bool value, JClosedWorld closedWorld) {
|
||||
|
@ -348,7 +346,7 @@ class HGraph {
|
|||
void finalize(AbstractValueDomain domain) {
|
||||
addBlock(exit);
|
||||
exit.open();
|
||||
exit.close(new HExit(domain));
|
||||
exit.close(HExit(domain));
|
||||
assignDominators();
|
||||
}
|
||||
|
||||
|
@ -375,7 +373,7 @@ class HGraph {
|
|||
// blocks. A dominator has a dfs-in..dfs-out range that includes the range
|
||||
// of the dominated block. See [HGraphVisitor.visitDominatorTree] for
|
||||
// recursion-free schema.
|
||||
_Frame frame = new _Frame(null);
|
||||
_Frame frame = _Frame(null);
|
||||
frame.block = entry;
|
||||
frame.index = 0;
|
||||
|
||||
|
@ -387,7 +385,7 @@ class HGraph {
|
|||
int index = frame.index;
|
||||
if (index < block.dominatedBlocks.length) {
|
||||
frame.index = index + 1;
|
||||
frame = frame.next ??= new _Frame(frame);
|
||||
frame = frame.next ??= _Frame(frame);
|
||||
frame.block = block.dominatedBlocks[index];
|
||||
frame.index = 0;
|
||||
frame.block.dominatorDfsIn = ++dfsNumber;
|
||||
|
@ -399,7 +397,7 @@ class HGraph {
|
|||
}
|
||||
|
||||
bool isValid() {
|
||||
HValidator validator = new HValidator();
|
||||
HValidator validator = HValidator();
|
||||
validator.visitGraph(this);
|
||||
return validator.isValid;
|
||||
}
|
||||
|
@ -765,7 +763,7 @@ class HBasicBlock extends HInstructionList {
|
|||
|
||||
HBasicBlock() : this.withId(null);
|
||||
HBasicBlock.withId(this.id)
|
||||
: phis = new HInstructionList(),
|
||||
: phis = HInstructionList(),
|
||||
predecessors = <HBasicBlock>[],
|
||||
successors = const <HBasicBlock>[],
|
||||
dominatedBlocks = <HBasicBlock>[];
|
||||
|
@ -782,7 +780,7 @@ class HBasicBlock extends HInstructionList {
|
|||
}
|
||||
|
||||
void setBlockFlow(HBlockInformation blockInfo, HBasicBlock continuation) {
|
||||
blockFlow = new HBlockFlow(blockInfo, continuation);
|
||||
blockFlow = HBlockFlow(blockInfo, continuation);
|
||||
}
|
||||
|
||||
bool isLabeledBlock() =>
|
||||
|
@ -1017,7 +1015,7 @@ class HBasicBlock extends HInstructionList {
|
|||
|
||||
bool isValid() {
|
||||
assert(isClosed());
|
||||
HValidator validator = new HValidator();
|
||||
HValidator validator = HValidator();
|
||||
validator.visitBasicBlock(this);
|
||||
return validator.isValid;
|
||||
}
|
||||
|
@ -1045,7 +1043,7 @@ abstract class HInstruction implements Spannable {
|
|||
HInstruction previous = null;
|
||||
HInstruction next = null;
|
||||
|
||||
SideEffects sideEffects = new SideEffects.empty();
|
||||
SideEffects sideEffects = SideEffects.empty();
|
||||
bool _useGvn = false;
|
||||
|
||||
// Type codes.
|
||||
|
@ -1360,7 +1358,7 @@ abstract class HInstruction implements Spannable {
|
|||
bool isInterceptor(JClosedWorld closedWorld) => false;
|
||||
|
||||
bool isValid() {
|
||||
HValidator validator = new HValidator();
|
||||
HValidator validator = HValidator();
|
||||
validator.currentBlock = block;
|
||||
validator.visitInstruction(this);
|
||||
return validator.isValid;
|
||||
|
@ -1424,8 +1422,8 @@ class DominatedUses {
|
|||
/// of a loop with many break statements). If [excludePhiOutEdges] is `true`
|
||||
/// then these edge uses are not included.
|
||||
static DominatedUses of(HInstruction source, HInstruction dominator,
|
||||
{bool excludeDominator: false, bool excludePhiOutEdges: false}) {
|
||||
return new DominatedUses._(source)
|
||||
{bool excludeDominator = false, bool excludePhiOutEdges = false}) {
|
||||
return DominatedUses._(source)
|
||||
.._compute(source, dominator, excludeDominator, excludePhiOutEdges);
|
||||
}
|
||||
|
||||
|
@ -1466,8 +1464,8 @@ class DominatedUses {
|
|||
bool excludeDominator, bool excludePhiOutEdges) {
|
||||
// Keep track of all instructions that we have to deal with later and count
|
||||
// the number of them that are in the current block.
|
||||
Set<HInstruction> users = new Setlet<HInstruction>();
|
||||
Set<HInstruction> seen = new Setlet<HInstruction>();
|
||||
Set<HInstruction> users = Setlet<HInstruction>();
|
||||
Set<HInstruction> seen = Setlet<HInstruction>();
|
||||
int usersInCurrentBlock = 0;
|
||||
|
||||
HBasicBlock dominatorBlock = dominator.block;
|
||||
|
@ -1655,7 +1653,7 @@ class HCreate extends HInstruction {
|
|||
|
||||
HCreate(this.element, List<HInstruction> inputs, AbstractValue type,
|
||||
SourceInformation sourceInformation,
|
||||
{this.instantiatedTypes, this.hasRtiInput: false, this.callMethod})
|
||||
{this.instantiatedTypes, this.hasRtiInput = false, this.callMethod})
|
||||
: super(inputs, type) {
|
||||
this.sourceInformation = sourceInformation;
|
||||
}
|
||||
|
@ -1834,7 +1832,7 @@ class HInvokeDynamicMethod extends HInvokeDynamic {
|
|||
AbstractValue resultType,
|
||||
this.typeArguments,
|
||||
SourceInformation sourceInformation,
|
||||
{bool isIntercepted: false})
|
||||
{bool isIntercepted = false})
|
||||
: super(selector, receiverType, null, inputs, isIntercepted, resultType) {
|
||||
this.sourceInformation = sourceInformation;
|
||||
assert(selector.callStructure.typeArgumentCount == typeArguments.length);
|
||||
|
@ -1946,7 +1944,7 @@ class HInvokeStatic extends HInvoke {
|
|||
|
||||
/// The first input must be the target.
|
||||
HInvokeStatic(this.element, inputs, AbstractValue type, this.typeArguments,
|
||||
{this.targetCanThrow: true, bool isIntercepted: false})
|
||||
{this.targetCanThrow = true, bool isIntercepted = false})
|
||||
: super(inputs, type) {
|
||||
isInterceptedCall = isIntercepted;
|
||||
}
|
||||
|
@ -2411,7 +2409,7 @@ class HForeignCode extends HForeign {
|
|||
NativeThrowBehavior throwBehavior;
|
||||
|
||||
HForeignCode(this.codeTemplate, AbstractValue type, List<HInstruction> inputs,
|
||||
{this.isStatement: false,
|
||||
{this.isStatement = false,
|
||||
SideEffects effects,
|
||||
NativeBehavior nativeBehavior,
|
||||
NativeThrowBehavior throwBehavior})
|
||||
|
@ -2813,7 +2811,7 @@ class HBreak extends HJump {
|
|||
|
||||
HBreak(AbstractValueDomain domain, JumpTarget target,
|
||||
SourceInformation sourceInformation,
|
||||
{bool this.breakSwitchContinueLoop: false})
|
||||
{bool this.breakSwitchContinueLoop = false})
|
||||
: super(domain, target, sourceInformation);
|
||||
|
||||
HBreak.toLabel(AbstractValueDomain domain, LabelDefinition label,
|
||||
|
@ -3207,7 +3205,7 @@ class HAwait extends HInstruction {
|
|||
@override
|
||||
bool canThrow(AbstractValueDomain domain) => true;
|
||||
@override
|
||||
SideEffects sideEffects = new SideEffects();
|
||||
SideEffects sideEffects = SideEffects();
|
||||
}
|
||||
|
||||
class HYield extends HInstruction {
|
||||
|
@ -3224,14 +3222,14 @@ class HYield extends HInstruction {
|
|||
@override
|
||||
bool canThrow(AbstractValueDomain domain) => false;
|
||||
@override
|
||||
SideEffects sideEffects = new SideEffects();
|
||||
SideEffects sideEffects = SideEffects();
|
||||
}
|
||||
|
||||
class HThrow extends HControlFlow {
|
||||
final bool isRethrow;
|
||||
HThrow(AbstractValueDomain domain, HInstruction value,
|
||||
SourceInformation sourceInformation,
|
||||
{this.isRethrow: false})
|
||||
{this.isRethrow = false})
|
||||
: super(domain, <HInstruction>[value]) {
|
||||
this.sourceInformation = sourceInformation;
|
||||
}
|
||||
|
@ -3927,12 +3925,12 @@ class HLabeledBlockInformation implements HStatementInformation {
|
|||
final bool isContinue;
|
||||
|
||||
HLabeledBlockInformation(this.body, List<LabelDefinition> labels,
|
||||
{this.isContinue: false})
|
||||
{this.isContinue = false})
|
||||
: this.labels = labels,
|
||||
this.target = labels[0].target;
|
||||
|
||||
HLabeledBlockInformation.implicit(this.body, this.target,
|
||||
{this.isContinue: false})
|
||||
{this.isContinue = false})
|
||||
: this.labels = const <LabelDefinition>[];
|
||||
|
||||
@override
|
||||
|
|
|
@ -82,83 +82,83 @@ class SsaOptimizerTask extends CompilerTask {
|
|||
if (retainDataForTesting) {
|
||||
loggersForTesting ??= {};
|
||||
loggersForTesting[member] =
|
||||
log = new OptimizationTestLog(closedWorld.dartTypes);
|
||||
log = OptimizationTestLog(closedWorld.dartTypes);
|
||||
}
|
||||
|
||||
measure(() {
|
||||
List<OptimizationPhase> phases = <OptimizationPhase>[
|
||||
// Run trivial instruction simplification first to optimize
|
||||
// some patterns useful for type conversion.
|
||||
new SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
closedWorld, typeRecipeDomain, registry, log),
|
||||
new SsaTypeConversionInserter(closedWorld),
|
||||
new SsaRedundantPhiEliminator(),
|
||||
new SsaDeadPhiEliminator(),
|
||||
new SsaTypePropagator(globalInferenceResults,
|
||||
closedWorld.commonElements, closedWorld, log),
|
||||
SsaInstructionSimplifier(globalInferenceResults, _options, closedWorld,
|
||||
typeRecipeDomain, registry, log),
|
||||
SsaTypeConversionInserter(closedWorld),
|
||||
SsaRedundantPhiEliminator(),
|
||||
SsaDeadPhiEliminator(),
|
||||
SsaTypePropagator(globalInferenceResults, closedWorld.commonElements,
|
||||
closedWorld, log),
|
||||
// After type propagation, more instructions can be
|
||||
// simplified.
|
||||
new SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
closedWorld, typeRecipeDomain, registry, log),
|
||||
new SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
closedWorld, typeRecipeDomain, registry, log),
|
||||
new SsaTypePropagator(globalInferenceResults,
|
||||
closedWorld.commonElements, closedWorld, log),
|
||||
SsaInstructionSimplifier(globalInferenceResults, _options, closedWorld,
|
||||
typeRecipeDomain, registry, log),
|
||||
SsaInstructionSimplifier(globalInferenceResults, _options, closedWorld,
|
||||
typeRecipeDomain, registry, log),
|
||||
SsaTypePropagator(globalInferenceResults, closedWorld.commonElements,
|
||||
closedWorld, log),
|
||||
// Run a dead code eliminator before LICM because dead
|
||||
// interceptors are often in the way of LICM'able instructions.
|
||||
new SsaDeadCodeEliminator(closedWorld, this),
|
||||
new SsaGlobalValueNumberer(closedWorld.abstractValueDomain),
|
||||
SsaDeadCodeEliminator(closedWorld, this),
|
||||
SsaGlobalValueNumberer(closedWorld.abstractValueDomain),
|
||||
// After GVN, some instructions might need their type to be
|
||||
// updated because they now have different inputs.
|
||||
new SsaTypePropagator(globalInferenceResults,
|
||||
closedWorld.commonElements, closedWorld, log),
|
||||
codeMotion = new SsaCodeMotion(closedWorld.abstractValueDomain),
|
||||
loadElimination = new SsaLoadElimination(closedWorld),
|
||||
new SsaRedundantPhiEliminator(),
|
||||
new SsaDeadPhiEliminator(),
|
||||
SsaTypePropagator(globalInferenceResults, closedWorld.commonElements,
|
||||
closedWorld, log),
|
||||
codeMotion = SsaCodeMotion(closedWorld.abstractValueDomain),
|
||||
loadElimination = SsaLoadElimination(closedWorld),
|
||||
SsaRedundantPhiEliminator(),
|
||||
SsaDeadPhiEliminator(),
|
||||
// After GVN and load elimination the same value may be used in code
|
||||
// controlled by a test on the value, so redo 'conversion insertion' to
|
||||
// learn from the refined type.
|
||||
new SsaTypeConversionInserter(closedWorld),
|
||||
new SsaTypePropagator(globalInferenceResults,
|
||||
closedWorld.commonElements, closedWorld, log),
|
||||
new SsaValueRangeAnalyzer(closedWorld, this),
|
||||
SsaTypeConversionInserter(closedWorld),
|
||||
SsaTypePropagator(globalInferenceResults, closedWorld.commonElements,
|
||||
closedWorld, log),
|
||||
SsaValueRangeAnalyzer(closedWorld, this),
|
||||
// Previous optimizations may have generated new
|
||||
// opportunities for instruction simplification.
|
||||
new SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
closedWorld, typeRecipeDomain, registry, log),
|
||||
SsaInstructionSimplifier(globalInferenceResults, _options, closedWorld,
|
||||
typeRecipeDomain, registry, log),
|
||||
];
|
||||
phases.forEach(runPhase);
|
||||
|
||||
// Simplifying interceptors is just an optimization, it is required for
|
||||
// implementation correctness because the code generator assumes it is
|
||||
// always performed to compute the intercepted classes sets.
|
||||
runPhase(new SsaSimplifyInterceptors(closedWorld, member.enclosingClass));
|
||||
runPhase(SsaSimplifyInterceptors(closedWorld, member.enclosingClass));
|
||||
|
||||
SsaDeadCodeEliminator dce = new SsaDeadCodeEliminator(closedWorld, this);
|
||||
SsaDeadCodeEliminator dce = SsaDeadCodeEliminator(closedWorld, this);
|
||||
runPhase(dce);
|
||||
if (codeMotion.movedCode ||
|
||||
dce.eliminatedSideEffects ||
|
||||
dce.newGvnCandidates ||
|
||||
loadElimination.newGvnCandidates) {
|
||||
phases = <OptimizationPhase>[
|
||||
new SsaTypePropagator(globalInferenceResults,
|
||||
closedWorld.commonElements, closedWorld, log),
|
||||
new SsaGlobalValueNumberer(closedWorld.abstractValueDomain),
|
||||
new SsaCodeMotion(closedWorld.abstractValueDomain),
|
||||
new SsaValueRangeAnalyzer(closedWorld, this),
|
||||
new SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
SsaTypePropagator(globalInferenceResults, closedWorld.commonElements,
|
||||
closedWorld, log),
|
||||
SsaGlobalValueNumberer(closedWorld.abstractValueDomain),
|
||||
SsaCodeMotion(closedWorld.abstractValueDomain),
|
||||
SsaValueRangeAnalyzer(closedWorld, this),
|
||||
SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
closedWorld, typeRecipeDomain, registry, log),
|
||||
new SsaSimplifyInterceptors(closedWorld, member.enclosingClass),
|
||||
new SsaDeadCodeEliminator(closedWorld, this),
|
||||
SsaSimplifyInterceptors(closedWorld, member.enclosingClass),
|
||||
SsaDeadCodeEliminator(closedWorld, this),
|
||||
];
|
||||
} else {
|
||||
phases = <OptimizationPhase>[
|
||||
new SsaTypePropagator(globalInferenceResults,
|
||||
closedWorld.commonElements, closedWorld, log),
|
||||
SsaTypePropagator(globalInferenceResults, closedWorld.commonElements,
|
||||
closedWorld, log),
|
||||
// Run the simplifier to remove unneeded type checks inserted by
|
||||
// type propagation.
|
||||
new SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
SsaInstructionSimplifier(globalInferenceResults, _options,
|
||||
closedWorld, typeRecipeDomain, registry, log),
|
||||
];
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
_mostlyEmpty(whenNotNullBlock)) {
|
||||
HInstruction trueConstant = _graph.addConstantBool(true, _closedWorld);
|
||||
HInstruction replacement =
|
||||
new HIdentity(tested, trueConstant, _abstractValueDomain.boolType)
|
||||
HIdentity(tested, trueConstant, _abstractValueDomain.boolType)
|
||||
..sourceElement = phi.sourceElement
|
||||
..sourceInformation = phi.sourceInformation;
|
||||
block.rewrite(phi, replacement);
|
||||
|
@ -397,12 +397,11 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
_mostlyEmpty(whenNotNullBlock)) {
|
||||
HInstruction falseConstant = _graph.addConstantBool(false, _closedWorld);
|
||||
HInstruction compare =
|
||||
new HIdentity(tested, falseConstant, _abstractValueDomain.boolType);
|
||||
HIdentity(tested, falseConstant, _abstractValueDomain.boolType);
|
||||
block.addAtEntry(compare);
|
||||
HInstruction replacement =
|
||||
new HNot(compare, _abstractValueDomain.boolType)
|
||||
..sourceElement = phi.sourceElement
|
||||
..sourceInformation = phi.sourceInformation;
|
||||
HInstruction replacement = HNot(compare, _abstractValueDomain.boolType)
|
||||
..sourceElement = phi.sourceElement
|
||||
..sourceInformation = phi.sourceInformation;
|
||||
block.rewrite(phi, replacement);
|
||||
block.addAfter(compare, replacement);
|
||||
block.removePhi(phi);
|
||||
|
@ -607,7 +606,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
resultType = _abstractValueDomain.uint32Type;
|
||||
}
|
||||
HGetLength result =
|
||||
new HGetLength(actualReceiver, resultType, isAssignable: !isFixed);
|
||||
HGetLength(actualReceiver, resultType, isAssignable: !isFixed);
|
||||
return result;
|
||||
} else if (actualReceiver.isConstantMap()) {
|
||||
HConstant constantInput = actualReceiver;
|
||||
|
@ -673,7 +672,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
HInstruction argument = node.inputs[2];
|
||||
if (argument.isString(_abstractValueDomain).isDefinitelyTrue &&
|
||||
input.isNull(_abstractValueDomain).isDefinitelyFalse) {
|
||||
return new HStringConcat(input, argument, node.instructionType);
|
||||
return HStringConcat(input, argument, node.instructionType);
|
||||
}
|
||||
} else if (applies(commonElements.jsStringToString) &&
|
||||
input.isNull(_abstractValueDomain).isDefinitelyFalse) {
|
||||
|
@ -690,7 +689,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
// bounds check will become explicit, so we won't need this
|
||||
// optimization.
|
||||
// TODO(sra): Fix comment - SsaCheckInserter is deleted.
|
||||
HInvokeDynamicMethod result = new HInvokeDynamicMethod(
|
||||
HInvokeDynamicMethod result = HInvokeDynamicMethod(
|
||||
node.selector,
|
||||
node.receiverType,
|
||||
node.inputs.sublist(1), // Drop interceptor.
|
||||
|
@ -727,7 +726,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
|
||||
AbstractValue resultMask = _abstractValueDomain.growableListType;
|
||||
|
||||
HInvokeDynamicMethod splitInstruction = new HInvokeDynamicMethod(
|
||||
HInvokeDynamicMethod splitInstruction = HInvokeDynamicMethod(
|
||||
node.selector,
|
||||
node.receiverType,
|
||||
node.inputs.sublist(1), // Drop interceptor.
|
||||
|
@ -751,7 +750,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
_abstractValueDomain.dynamicType);
|
||||
node.block.addBefore(node, typeInfo);
|
||||
|
||||
HInvokeStatic tagInstruction = new HInvokeStatic(
|
||||
HInvokeStatic tagInstruction = HInvokeStatic(
|
||||
commonElements.setArrayType,
|
||||
<HInstruction>[splitInstruction, typeInfo],
|
||||
resultMask,
|
||||
|
@ -839,12 +838,12 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
node.block.addBefore(node, load);
|
||||
insertionPoint = load;
|
||||
}
|
||||
Selector callSelector = new Selector.callClosureFrom(node.selector);
|
||||
Selector callSelector = Selector.callClosureFrom(node.selector);
|
||||
List<HInstruction> inputs = <HInstruction>[load]
|
||||
..addAll(node.inputs.skip(node.isInterceptedCall ? 2 : 1));
|
||||
DartType fieldType =
|
||||
_closedWorld.elementEnvironment.getFieldType(field);
|
||||
HInstruction closureCall = new HInvokeClosure(
|
||||
HInstruction closureCall = HInvokeClosure(
|
||||
callSelector,
|
||||
_abstractValueDomain
|
||||
.createFromStaticType(fieldType, nullable: true)
|
||||
|
@ -1129,7 +1128,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
if (constant.constant.isTrue) {
|
||||
return input;
|
||||
} else {
|
||||
return new HNot(input, _abstractValueDomain.boolType);
|
||||
return HNot(input, _abstractValueDomain.boolType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1398,8 +1397,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
isFixedLength(receiver.instructionType, _closedWorld)) {
|
||||
// The input type has changed to fixed-length so change to an unassignable
|
||||
// HGetLength to allow more GVN optimizations.
|
||||
return new HGetLength(receiver, node.instructionType,
|
||||
isAssignable: false);
|
||||
return HGetLength(receiver, node.instructionType, isAssignable: false);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
@ -1599,7 +1597,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
if (parameterStructure.callStructure == node.selector.callStructure) {
|
||||
// TODO(sra): Handle adding optional arguments default values.
|
||||
assert(!node.isInterceptedCall);
|
||||
return new HInvokeStatic(target, node.inputs.skip(1).toList(),
|
||||
return HInvokeStatic(target, node.inputs.skip(1).toList(),
|
||||
node.instructionType, node.typeArguments)
|
||||
..sourceInformation = node.sourceInformation;
|
||||
}
|
||||
|
@ -1615,7 +1613,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
|
||||
if (element == commonElements.identicalFunction) {
|
||||
if (node.inputs.length == 2) {
|
||||
return new HIdentity(
|
||||
return HIdentity(
|
||||
node.inputs[0], node.inputs[1], _abstractValueDomain.boolType)
|
||||
..sourceInformation = node.sourceInformation;
|
||||
}
|
||||
|
@ -1759,7 +1757,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
.createString(leftString.stringValue + rightString.stringValue),
|
||||
_closedWorld);
|
||||
if (prefix == null) return folded;
|
||||
return new HStringConcat(prefix, folded, _abstractValueDomain.stringType);
|
||||
return HStringConcat(prefix, folded, _abstractValueDomain.stringType);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1825,7 +1823,7 @@ class SsaInstructionSimplifier extends HBaseVisitor
|
|||
.isInterceptor(input.instructionType)
|
||||
.isDefinitelyFalse) {
|
||||
var inputs = <HInstruction>[input, input]; // [interceptor, receiver].
|
||||
HInstruction result = new HInvokeDynamicMethod(
|
||||
HInstruction result = HInvokeDynamicMethod(
|
||||
selector,
|
||||
input.instructionType, // receiver type.
|
||||
inputs,
|
||||
|
@ -2311,7 +2309,7 @@ class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase {
|
|||
HGraph _graph;
|
||||
SsaLiveBlockAnalyzer analyzer;
|
||||
Map<HInstruction, bool> trivialDeadStoreReceivers =
|
||||
new Maplet<HInstruction, bool>();
|
||||
Maplet<HInstruction, bool>();
|
||||
bool eliminatedSideEffects = false;
|
||||
bool newGvnCandidates = false;
|
||||
|
||||
|
@ -2425,7 +2423,7 @@ class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase {
|
|||
@override
|
||||
void visitGraph(HGraph graph) {
|
||||
_graph = graph;
|
||||
analyzer = new SsaLiveBlockAnalyzer(graph, closedWorld, optimizer);
|
||||
analyzer = SsaLiveBlockAnalyzer(graph, closedWorld, optimizer);
|
||||
analyzer.analyze();
|
||||
visitPostDominatorTree(graph);
|
||||
cleanPhis();
|
||||
|
@ -2627,7 +2625,7 @@ class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase {
|
|||
|
||||
class SsaLiveBlockAnalyzer extends HBaseVisitor {
|
||||
final HGraph graph;
|
||||
final Set<HBasicBlock> live = new Set<HBasicBlock>();
|
||||
final Set<HBasicBlock> live = Set<HBasicBlock>();
|
||||
final List<HBasicBlock> worklist = <HBasicBlock>[];
|
||||
final SsaOptimizerTask optimizer;
|
||||
final JClosedWorld closedWorld;
|
||||
|
@ -2686,7 +2684,7 @@ class SsaLiveBlockAnalyzer extends HBaseVisitor {
|
|||
IntValue upperValue = switchRange.upper;
|
||||
BigInt lower = lowerValue.value;
|
||||
BigInt upper = upperValue.value;
|
||||
Set<BigInt> liveLabels = new Set<BigInt>();
|
||||
Set<BigInt> liveLabels = Set<BigInt>();
|
||||
for (int pos = 1; pos < node.inputs.length; pos++) {
|
||||
HConstant input = node.inputs[pos];
|
||||
if (!input.isConstantInteger()) continue;
|
||||
|
@ -2697,7 +2695,7 @@ class SsaLiveBlockAnalyzer extends HBaseVisitor {
|
|||
liveLabels.add(label);
|
||||
}
|
||||
}
|
||||
if (new BigInt.from(liveLabels.length) != upper - lower + BigInt.one) {
|
||||
if (BigInt.from(liveLabels.length) != upper - lower + BigInt.one) {
|
||||
markBlockLive(node.defaultTarget);
|
||||
}
|
||||
return;
|
||||
|
@ -2715,7 +2713,7 @@ class SsaDeadPhiEliminator implements OptimizationPhase {
|
|||
void visitGraph(HGraph graph) {
|
||||
final List<HPhi> worklist = <HPhi>[];
|
||||
// A set to keep track of the live phis that we found.
|
||||
final Set<HPhi> livePhis = new Set<HPhi>();
|
||||
final Set<HPhi> livePhis = Set<HPhi>();
|
||||
|
||||
// Add to the worklist all live phis: phis referenced by non-phi
|
||||
// instructions.
|
||||
|
@ -2835,14 +2833,14 @@ class SsaGlobalValueNumberer implements OptimizationPhase {
|
|||
List<int> blockChangesFlags;
|
||||
List<int> loopChangesFlags;
|
||||
|
||||
SsaGlobalValueNumberer(this._abstractValueDomain) : visited = new Set<int>();
|
||||
SsaGlobalValueNumberer(this._abstractValueDomain) : visited = Set<int>();
|
||||
|
||||
@override
|
||||
void visitGraph(HGraph graph) {
|
||||
computeChangesFlags(graph);
|
||||
moveLoopInvariantCode(graph);
|
||||
List<GvnWorkItem> workQueue = <GvnWorkItem>[
|
||||
new GvnWorkItem(graph.entry, new ValueSet())
|
||||
GvnWorkItem(graph.entry, ValueSet())
|
||||
];
|
||||
do {
|
||||
GvnWorkItem item = workQueue.removeLast();
|
||||
|
@ -2976,7 +2974,7 @@ class SsaGlobalValueNumberer implements OptimizationPhase {
|
|||
} while (!workQueue.isEmpty);
|
||||
successorValues.kill(changesFlags);
|
||||
}
|
||||
workQueue.add(new GvnWorkItem(dominated, successorValues));
|
||||
workQueue.add(GvnWorkItem(dominated, successorValues));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2985,8 +2983,8 @@ class SsaGlobalValueNumberer implements OptimizationPhase {
|
|||
// loop changes flags list to zero so we can use bitwise or when
|
||||
// propagating loop changes upwards.
|
||||
final int length = graph.blocks.length;
|
||||
blockChangesFlags = new List<int>.filled(length, null);
|
||||
loopChangesFlags = new List<int>.filled(length, null);
|
||||
blockChangesFlags = List<int>.filled(length, null);
|
||||
loopChangesFlags = List<int>.filled(length, null);
|
||||
for (int i = 0; i < length; i++) loopChangesFlags[i] = 0;
|
||||
|
||||
// Run through all the basic blocks in the graph and fill in the
|
||||
|
@ -3067,9 +3065,9 @@ class SsaCodeMotion extends HBaseVisitor implements OptimizationPhase {
|
|||
|
||||
@override
|
||||
void visitGraph(HGraph graph) {
|
||||
values = new List<ValueSet>.filled(graph.blocks.length, null);
|
||||
values = List<ValueSet>.filled(graph.blocks.length, null);
|
||||
for (int i = 0; i < graph.blocks.length; i++) {
|
||||
values[graph.blocks[i].id] = new ValueSet();
|
||||
values[graph.blocks[i].id] = ValueSet();
|
||||
}
|
||||
visitPostDominatorTree(graph);
|
||||
}
|
||||
|
@ -3198,7 +3196,7 @@ class SsaTypeConversionInserter extends HBaseVisitor
|
|||
}
|
||||
}
|
||||
|
||||
HTypeKnown newInput = new HTypeKnown.pinned(convertedType, input);
|
||||
HTypeKnown newInput = HTypeKnown.pinned(convertedType, input);
|
||||
dominator.addBefore(dominator.first, newInput);
|
||||
dominatedUses.replaceWith(newInput);
|
||||
}
|
||||
|
@ -3344,7 +3342,7 @@ class SsaLoadElimination extends HBaseVisitor implements OptimizationPhase {
|
|||
@override
|
||||
void visitGraph(HGraph graph) {
|
||||
_graph = graph;
|
||||
memories = new List<MemorySet>.filled(graph.blocks.length, null);
|
||||
memories = List<MemorySet>.filled(graph.blocks.length, null);
|
||||
List<HBasicBlock> blocks = graph.blocks;
|
||||
for (int i = 0; i < blocks.length; i++) {
|
||||
HBasicBlock block = blocks[i];
|
||||
|
@ -3366,7 +3364,7 @@ class SsaLoadElimination extends HBaseVisitor implements OptimizationPhase {
|
|||
final indegree = predecessors.length;
|
||||
if (indegree == 0) {
|
||||
// Entry block.
|
||||
memorySet = new MemorySet(_closedWorld);
|
||||
memorySet = MemorySet(_closedWorld);
|
||||
} else if (indegree == 1 && predecessors[0].successors.length == 1) {
|
||||
// No need to clone, there is no other successor for
|
||||
// `block.predecessors[0]`, and this block has only one predecessor. Since
|
||||
|
@ -3693,7 +3691,7 @@ class MemorySet {
|
|||
<HInstruction, Map<HInstruction, HInstruction>>{};
|
||||
|
||||
/// Set of objects that we know don't escape the current function.
|
||||
final Setlet<HInstruction> nonEscapingReceivers = new Setlet<HInstruction>();
|
||||
final Setlet<HInstruction> nonEscapingReceivers = Setlet<HInstruction>();
|
||||
|
||||
MemorySet(this.closedWorld);
|
||||
|
||||
|
@ -3948,7 +3946,7 @@ class MemorySet {
|
|||
phi.instructionType = phiType;
|
||||
return phi;
|
||||
} else {
|
||||
HPhi phi = new HPhi.noInputs(null, phiType);
|
||||
HPhi phi = HPhi.noInputs(null, phiType);
|
||||
block.addPhi(phi);
|
||||
// Previous predecessors had the same input. A phi must have
|
||||
// the same number of inputs as its block has predecessors.
|
||||
|
@ -3963,7 +3961,7 @@ class MemorySet {
|
|||
/// Returns the intersection between [this] and the [other] memory set.
|
||||
MemorySet intersectionFor(
|
||||
MemorySet other, HBasicBlock block, int predecessorIndex) {
|
||||
MemorySet result = new MemorySet(closedWorld);
|
||||
MemorySet result = MemorySet(closedWorld);
|
||||
if (other == null) {
|
||||
// This is the first visit to a loop header ([other] is `null` because we
|
||||
// have not visited the back edge). Copy the nonEscapingReceivers that are
|
||||
|
@ -4043,16 +4041,16 @@ class MemorySet {
|
|||
|
||||
/// Returns a copy of [this] memory set.
|
||||
MemorySet clone() {
|
||||
MemorySet result = new MemorySet(closedWorld);
|
||||
MemorySet result = MemorySet(closedWorld);
|
||||
|
||||
fieldValues.forEach((element, values) {
|
||||
result.fieldValues[element] =
|
||||
new Map<HInstruction, HInstruction>.from(values);
|
||||
Map<HInstruction, HInstruction>.from(values);
|
||||
});
|
||||
|
||||
keyedValues.forEach((receiver, values) {
|
||||
result.keyedValues[receiver] =
|
||||
new Map<HInstruction, HInstruction>.from(values);
|
||||
Map<HInstruction, HInstruction>.from(values);
|
||||
});
|
||||
|
||||
result.nonEscapingReceivers.addAll(nonEscapingReceivers);
|
||||
|
|
|
@ -47,11 +47,11 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
BackendStrategy backendStrategy,
|
||||
Measurer measurer,
|
||||
this.sourceInformationStrategy)
|
||||
: generator = new SsaCodeGeneratorTask(
|
||||
measurer, _options, sourceInformationStrategy),
|
||||
_builder = new SsaBuilderTask(
|
||||
: generator =
|
||||
SsaCodeGeneratorTask(measurer, _options, sourceInformationStrategy),
|
||||
_builder = SsaBuilderTask(
|
||||
measurer, backendStrategy, sourceInformationStrategy),
|
||||
optimizer = new SsaOptimizerTask(measurer, _options);
|
||||
optimizer = SsaOptimizerTask(measurer, _options);
|
||||
|
||||
@override
|
||||
void initialize(GlobalTypeInferenceResults globalInferenceResults,
|
||||
|
@ -67,10 +67,10 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
CodegenResult compile(MemberEntity member) {
|
||||
JClosedWorld closedWorld = _globalInferenceResults.closedWorld;
|
||||
CodegenRegistry registry =
|
||||
new CodegenRegistry(closedWorld.elementEnvironment, member);
|
||||
ModularNamer namer = new ModularNamerImpl(
|
||||
CodegenRegistry(closedWorld.elementEnvironment, member);
|
||||
ModularNamer namer = ModularNamerImpl(
|
||||
registry, closedWorld.commonElements, _codegen.fixedNames);
|
||||
ModularEmitter emitter = new ModularEmitterImpl(namer, registry, _options);
|
||||
ModularEmitter emitter = ModularEmitterImpl(namer, registry, _options);
|
||||
if (member.isConstructor &&
|
||||
member.enclosingClass == closedWorld.commonElements.jsNullClass) {
|
||||
// Work around a problem compiling JSNull's constructor.
|
||||
|
@ -202,7 +202,7 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
List<js.Expression> itemTypeExpression =
|
||||
_fetchItemTypeNewRti(commonElements, registry, elementType);
|
||||
|
||||
AsyncRewriter rewriter = new AsyncRewriter(_reporter, element,
|
||||
AsyncRewriter rewriter = AsyncRewriter(_reporter, element,
|
||||
asyncStart: emitter.staticFunctionAccess(startFunction),
|
||||
asyncAwait:
|
||||
emitter.staticFunctionAccess(commonElements.asyncHelperAwait),
|
||||
|
@ -216,7 +216,7 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
|
||||
bodyName: namer.deriveAsyncBodyName(name));
|
||||
|
||||
registry.registerStaticUse(new StaticUse.staticInvoke(
|
||||
registry.registerStaticUse(StaticUse.staticInvoke(
|
||||
completerFactory,
|
||||
const CallStructure.unnamed(0, 1),
|
||||
[elementEnvironment.getFunctionAsyncOrSyncStarElementType(element)]));
|
||||
|
@ -238,7 +238,7 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
List<js.Expression> itemTypeExpression =
|
||||
_fetchItemTypeNewRti(commonElements, registry, asyncTypeParameter);
|
||||
|
||||
SyncStarRewriter rewriter = new SyncStarRewriter(_reporter, element,
|
||||
SyncStarRewriter rewriter = SyncStarRewriter(_reporter, element,
|
||||
endOfIteration:
|
||||
emitter.staticFunctionAccess(commonElements.endOfIteration),
|
||||
iterableFactory: emitter
|
||||
|
@ -251,7 +251,7 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
safeVariableName: namer.safeVariablePrefixForAsyncRewrite,
|
||||
bodyName: namer.deriveAsyncBodyName(name));
|
||||
|
||||
registry.registerStaticUse(new StaticUse.staticInvoke(
|
||||
registry.registerStaticUse(StaticUse.staticInvoke(
|
||||
commonElements.syncStarIterableFactory,
|
||||
const CallStructure.unnamed(1, 1),
|
||||
[elementEnvironment.getFunctionAsyncOrSyncStarElementType(element)]));
|
||||
|
@ -273,7 +273,7 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
List<js.Expression> itemTypeExpression =
|
||||
_fetchItemTypeNewRti(commonElements, registry, asyncTypeParameter);
|
||||
|
||||
AsyncStarRewriter rewriter = new AsyncStarRewriter(_reporter, element,
|
||||
AsyncStarRewriter rewriter = AsyncStarRewriter(_reporter, element,
|
||||
asyncStarHelper:
|
||||
emitter.staticFunctionAccess(commonElements.asyncStarHelper),
|
||||
streamOfController:
|
||||
|
@ -289,7 +289,7 @@ class SsaFunctionCompiler implements FunctionCompiler {
|
|||
emitter.staticFunctionAccess(commonElements.yieldStar),
|
||||
bodyName: namer.deriveAsyncBodyName(name));
|
||||
|
||||
registry.registerStaticUse(new StaticUse.staticInvoke(
|
||||
registry.registerStaticUse(StaticUse.staticInvoke(
|
||||
commonElements.asyncStarStreamControllerFactory,
|
||||
const CallStructure.unnamed(1, 1),
|
||||
[elementEnvironment.getFunctionAsyncOrSyncStarElementType(element)]));
|
||||
|
|
|
@ -17,7 +17,7 @@ class SsaBranch {
|
|||
LocalsHandler exitLocals;
|
||||
SubGraph graph;
|
||||
|
||||
SsaBranch(this.branchBuilder) : block = new HBasicBlock();
|
||||
SsaBranch(this.branchBuilder) : block = HBasicBlock();
|
||||
}
|
||||
|
||||
class SsaBranchBuilder {
|
||||
|
@ -46,7 +46,7 @@ class SsaBranchBuilder {
|
|||
checkNotAborted();
|
||||
assert(identical(builder.current, builder.lastOpenedBlock));
|
||||
HInstruction conditionValue = builder.popBoolified();
|
||||
HIf branch = new HIf(_abstractValueDomain, conditionValue)
|
||||
HIf branch = HIf(_abstractValueDomain, conditionValue)
|
||||
..sourceInformation = sourceInformation;
|
||||
HBasicBlock conditionExitBlock = builder.current;
|
||||
builder.close(branch);
|
||||
|
@ -59,7 +59,7 @@ class SsaBranchBuilder {
|
|||
mayReuseFromLocals: conditionBranchLocalsCanBeReused);
|
||||
|
||||
conditionBranch.graph =
|
||||
new SubExpression(conditionBranch.block, conditionExitBlock);
|
||||
SubExpression(conditionBranch.block, conditionExitBlock);
|
||||
}
|
||||
|
||||
/// Returns true if the locals of the [fromBranch] may be reused. A [:true:]
|
||||
|
@ -72,7 +72,7 @@ class SsaBranchBuilder {
|
|||
toBranch.startLocals = fromLocals;
|
||||
return false;
|
||||
} else {
|
||||
toBranch.startLocals = new LocalsHandler.from(fromLocals);
|
||||
toBranch.startLocals = LocalsHandler.from(fromLocals);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
@ -91,7 +91,7 @@ class SsaBranchBuilder {
|
|||
SsaBranch joinBranch, bool isExpression) {
|
||||
startBranch(branch);
|
||||
visitBranch();
|
||||
branch.graph = new SubGraph(branch.block, builder.lastOpenedBlock);
|
||||
branch.graph = SubGraph(branch.block, builder.lastOpenedBlock);
|
||||
branch.exitLocals = builder.localsHandler;
|
||||
if (!builder.isAborted()) {
|
||||
builder.goto(builder.current, joinBranch.block);
|
||||
|
@ -163,7 +163,7 @@ class SsaBranchBuilder {
|
|||
boolifiedLeft = builder.popBoolified();
|
||||
builder.stack.add(boolifiedLeft);
|
||||
if (!isAnd) {
|
||||
builder.push(new HNot(builder.pop(), _abstractValueDomain.boolType)
|
||||
builder.push(HNot(builder.pop(), _abstractValueDomain.boolType)
|
||||
..sourceInformation = sourceInformation);
|
||||
}
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ class SsaBranchBuilder {
|
|||
sourceInformation: sourceInformation);
|
||||
HConstant notIsAnd =
|
||||
builder.graph.addConstantBool(!isAnd, builder.closedWorld);
|
||||
HPhi result = new HPhi.manyInputs(
|
||||
HPhi result = HPhi.manyInputs(
|
||||
null,
|
||||
<HInstruction>[boolifiedRight, notIsAnd],
|
||||
_abstractValueDomain.dynamicType)
|
||||
|
@ -189,10 +189,10 @@ class SsaBranchBuilder {
|
|||
void _handleDiamondBranch(
|
||||
void visitCondition(), void visitThen(), void visitElse(),
|
||||
{bool isExpression, SourceInformation sourceInformation}) {
|
||||
SsaBranch conditionBranch = new SsaBranch(this);
|
||||
SsaBranch thenBranch = new SsaBranch(this);
|
||||
SsaBranch elseBranch = new SsaBranch(this);
|
||||
SsaBranch joinBranch = new SsaBranch(this);
|
||||
SsaBranch conditionBranch = SsaBranch(this);
|
||||
SsaBranch thenBranch = SsaBranch(this);
|
||||
SsaBranch elseBranch = SsaBranch(this);
|
||||
SsaBranch joinBranch = SsaBranch(this);
|
||||
|
||||
conditionBranch.startLocals = builder.localsHandler;
|
||||
builder.goto(builder.current, conditionBranch.block);
|
||||
|
@ -206,7 +206,7 @@ class SsaBranchBuilder {
|
|||
|
||||
if (isExpression) {
|
||||
assert(thenValue != null && elseValue != null);
|
||||
HPhi phi = new HPhi.manyInputs(null, <HInstruction>[thenValue, elseValue],
|
||||
HPhi phi = HPhi.manyInputs(null, <HInstruction>[thenValue, elseValue],
|
||||
_abstractValueDomain.dynamicType);
|
||||
joinBranch.block.addPhi(phi);
|
||||
builder.stack.add(phi);
|
||||
|
@ -219,10 +219,10 @@ class SsaBranchBuilder {
|
|||
joinBlock = joinBranch.block;
|
||||
}
|
||||
|
||||
HIfBlockInformation info = new HIfBlockInformation(
|
||||
new HSubExpressionBlockInformation(conditionBranch.graph),
|
||||
new HSubGraphBlockInformation(thenBranch.graph),
|
||||
new HSubGraphBlockInformation(elseBranch.graph));
|
||||
HIfBlockInformation info = HIfBlockInformation(
|
||||
HSubExpressionBlockInformation(conditionBranch.graph),
|
||||
HSubGraphBlockInformation(thenBranch.graph),
|
||||
HSubGraphBlockInformation(elseBranch.graph));
|
||||
|
||||
HBasicBlock conditionStartBlock = conditionBranch.block;
|
||||
conditionStartBlock.setBlockFlow(info, joinBlock);
|
||||
|
|
|
@ -75,7 +75,7 @@ class HTracer extends HGraphVisitor with TracerUtil {
|
|||
@override
|
||||
void visitBasicBlock(HBasicBlock block) {
|
||||
HInstructionStringifier stringifier =
|
||||
new HInstructionStringifier(block, closedWorld);
|
||||
HInstructionStringifier(block, closedWorld);
|
||||
assert(block.id != null);
|
||||
tag("block", () {
|
||||
printProperty("name", "B${block.id}");
|
||||
|
@ -94,7 +94,7 @@ class HTracer extends HGraphVisitor with TracerUtil {
|
|||
printProperty("method", "None");
|
||||
block.forEachPhi((phi) {
|
||||
String phiId = stringifier.temporaryId(phi);
|
||||
StringBuffer inputIds = new StringBuffer();
|
||||
StringBuffer inputIds = StringBuffer();
|
||||
for (int i = 0; i < phi.inputs.length; i++) {
|
||||
inputIds.write(stringifier.temporaryId(phi.inputs[i]));
|
||||
inputIds.write(" ");
|
||||
|
@ -326,7 +326,7 @@ class HInstructionStringifier implements HVisitor<String> {
|
|||
|
||||
String handleGenericInvoke(
|
||||
String invokeType, String functionName, List<HInstruction> arguments) {
|
||||
StringBuffer argumentsString = new StringBuffer();
|
||||
StringBuffer argumentsString = StringBuffer();
|
||||
for (int i = 0; i < arguments.length; i++) {
|
||||
if (i != 0) argumentsString.write(", ");
|
||||
argumentsString.write(temporaryId(arguments[i]));
|
||||
|
@ -445,7 +445,7 @@ class HInstructionStringifier implements HVisitor<String> {
|
|||
|
||||
@override
|
||||
String visitLiteralList(HLiteralList node) {
|
||||
StringBuffer elementsString = new StringBuffer();
|
||||
StringBuffer elementsString = StringBuffer();
|
||||
for (int i = 0; i < node.inputs.length; i++) {
|
||||
if (i != 0) elementsString.write(", ");
|
||||
elementsString.write(temporaryId(node.inputs[i]));
|
||||
|
@ -485,7 +485,7 @@ class HInstructionStringifier implements HVisitor<String> {
|
|||
|
||||
@override
|
||||
String visitPhi(HPhi phi) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuffer buffer = StringBuffer();
|
||||
buffer.write("Phi: ");
|
||||
for (int i = 0; i < phi.inputs.length; i++) {
|
||||
if (i > 0) buffer.write(", ");
|
||||
|
@ -546,7 +546,7 @@ class HInstructionStringifier implements HVisitor<String> {
|
|||
|
||||
@override
|
||||
String visitSwitch(HSwitch node) {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
StringBuffer buf = StringBuffer();
|
||||
buf.write("Switch: (");
|
||||
buf.write(temporaryId(node.inputs[0]));
|
||||
buf.write(") ");
|
||||
|
|
|
@ -12,7 +12,7 @@ class SwitchContinueAnalysis extends ir.Visitor<bool>
|
|||
SwitchContinueAnalysis._();
|
||||
|
||||
static bool containsContinue(ir.Statement switchCaseBody) {
|
||||
return switchCaseBody.accept(new SwitchContinueAnalysis._());
|
||||
return switchCaseBody.accept(SwitchContinueAnalysis._());
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -49,7 +49,7 @@ abstract class TypeBuilder {
|
|||
|
||||
/// Create a type mask for 'trusting' a DartType. Returns `null` if there is
|
||||
/// no approximating type mask (i.e. the type mask would be `dynamic`).
|
||||
AbstractValue trustTypeMask(DartType type, {bool hasLateSentinel: false}) {
|
||||
AbstractValue trustTypeMask(DartType type, {bool hasLateSentinel = false}) {
|
||||
if (type == null) return null;
|
||||
type = builder.localsHandler.substInContext(type);
|
||||
if (_closedWorld.dartTypes.isTopType(type)) return null;
|
||||
|
@ -74,7 +74,7 @@ abstract class TypeBuilder {
|
|||
.isPotentiallyTrue;
|
||||
AbstractValue mask = trustTypeMask(type, hasLateSentinel: hasLateSentinel);
|
||||
if (mask == null) return original;
|
||||
return new HTypeKnown.pinned(mask, original);
|
||||
return HTypeKnown.pinned(mask, original);
|
||||
}
|
||||
|
||||
/// Produces code that checks the runtime type is actually the type specified
|
||||
|
@ -87,7 +87,7 @@ abstract class TypeBuilder {
|
|||
// If it is needed then it seems likely that similar invocations of
|
||||
// `buildAsCheck` in `SsaBuilder.visitAs` should also be followed by a
|
||||
// similar operation on `registry`; otherwise, this one might not be needed.
|
||||
builder.registry?.registerTypeUse(new TypeUse.isCheck(type));
|
||||
builder.registry?.registerTypeUse(TypeUse.isCheck(type));
|
||||
if (other is HAsCheck &&
|
||||
other.isRedundant(builder.closedWorld, builder.options)) {
|
||||
return original;
|
||||
|
@ -104,7 +104,7 @@ abstract class TypeBuilder {
|
|||
return original;
|
||||
}
|
||||
DartType boolType = _closedWorld.commonElements.boolType;
|
||||
builder.registry?.registerTypeUse(new TypeUse.isCheck(boolType));
|
||||
builder.registry?.registerTypeUse(TypeUse.isCheck(boolType));
|
||||
return checkInstruction;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ import 'optimize.dart';
|
|||
// TODO(sra): The InvokeDynamicSpecializer should be consulted for better
|
||||
// targeted conditioning checks.
|
||||
class SsaTypePropagator extends HBaseVisitor implements OptimizationPhase {
|
||||
final Map<int, HInstruction> workmap = new Map<int, HInstruction>();
|
||||
final Map<int, HInstruction> workmap = Map<int, HInstruction>();
|
||||
final List<int> worklist = <int>[];
|
||||
final Map<HInstruction, Function> pendingOptimizations =
|
||||
new Map<HInstruction, Function>();
|
||||
Map<HInstruction, Function>();
|
||||
|
||||
final GlobalTypeInferenceResults results;
|
||||
final CommonElements commonElements;
|
||||
|
@ -248,7 +248,7 @@ class SsaTypePropagator extends HBaseVisitor implements OptimizationPhase {
|
|||
Selector selector = (kind == HPrimitiveCheck.RECEIVER_TYPE_CHECK)
|
||||
? instruction.selector
|
||||
: null;
|
||||
HPrimitiveCheck converted = new HPrimitiveCheck(
|
||||
HPrimitiveCheck converted = HPrimitiveCheck(
|
||||
typeExpression, kind, type, input, instruction.sourceInformation,
|
||||
receiverTypeCheckSelector: selector);
|
||||
instruction.block.addBefore(instruction, converted);
|
||||
|
@ -418,7 +418,7 @@ class SsaTypePropagator extends HBaseVisitor implements OptimizationPhase {
|
|||
// dominated by the call to use that node instead of [receiver].
|
||||
AbstractValue newType = abstractValueDomain.excludeNull(receiverType);
|
||||
HTypeKnown converted =
|
||||
new HTypeKnown.witnessed(newType, receiver, instruction);
|
||||
HTypeKnown.witnessed(newType, receiver, instruction);
|
||||
instruction.block.addBefore(instruction.next, converted);
|
||||
uses.replaceWith(converted);
|
||||
addDependentInstructionsToWorkList(converted);
|
||||
|
|
|
@ -157,7 +157,7 @@ class HValidator extends HInstructionVisitor {
|
|||
static bool everyInstruction(
|
||||
List<HInstruction> instructions, bool Function(HInstruction, int) f) {
|
||||
if (instructions.length > kMaxValidatedInstructionListLength) return true;
|
||||
var copy = new List<HInstruction>.from(instructions);
|
||||
var copy = List<HInstruction>.from(instructions);
|
||||
// TODO(floitsch): there is currently no way to sort HInstructions before
|
||||
// we have assigned an ID. The loop is therefore O(n^2) for now.
|
||||
for (int i = 0; i < copy.length; i++) {
|
||||
|
|
|
@ -18,40 +18,39 @@ class ValueRangeInfo {
|
|||
}
|
||||
|
||||
Value newIntValue(BigInt value) {
|
||||
return new IntValue(value, this);
|
||||
return IntValue(value, this);
|
||||
}
|
||||
|
||||
Value newInstructionValue(HInstruction instruction) {
|
||||
return new InstructionValue(instruction, this);
|
||||
return InstructionValue(instruction, this);
|
||||
}
|
||||
|
||||
Value newPositiveValue(HInstruction instruction) {
|
||||
return new PositiveValue(instruction, this);
|
||||
return PositiveValue(instruction, this);
|
||||
}
|
||||
|
||||
Value newAddValue(Value left, Value right) {
|
||||
return new AddValue(left, right, this);
|
||||
return AddValue(left, right, this);
|
||||
}
|
||||
|
||||
Value newSubtractValue(Value left, Value right) {
|
||||
return new SubtractValue(left, right, this);
|
||||
return SubtractValue(left, right, this);
|
||||
}
|
||||
|
||||
Value newNegateValue(Value value) {
|
||||
return new NegateValue(value, this);
|
||||
return NegateValue(value, this);
|
||||
}
|
||||
|
||||
Range newUnboundRange() {
|
||||
return new Range.unbound(this);
|
||||
return Range.unbound(this);
|
||||
}
|
||||
|
||||
Range newNormalizedRange(Value low, Value up) {
|
||||
return new Range.normalize(low, up, this);
|
||||
return Range.normalize(low, up, this);
|
||||
}
|
||||
|
||||
Range newMarkerRange() {
|
||||
return new Range(
|
||||
new MarkerValue(false, this), new MarkerValue(true, this), this);
|
||||
return Range(MarkerValue(false, this), MarkerValue(true, this), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +183,7 @@ class IntValue extends Value {
|
|||
}
|
||||
|
||||
@override
|
||||
int get hashCode => throw new UnsupportedError('IntValue.hashCode');
|
||||
int get hashCode => throw UnsupportedError('IntValue.hashCode');
|
||||
|
||||
@override
|
||||
String toString() => 'IntValue $value';
|
||||
|
@ -274,7 +273,7 @@ class InstructionValue extends Value {
|
|||
}
|
||||
|
||||
@override
|
||||
int get hashCode => throw new UnsupportedError('InstructionValue.hashCode');
|
||||
int get hashCode => throw UnsupportedError('InstructionValue.hashCode');
|
||||
|
||||
@override
|
||||
Value operator +(Value other) {
|
||||
|
@ -347,7 +346,7 @@ class AddValue extends BinaryOperationValue {
|
|||
}
|
||||
|
||||
@override
|
||||
int get hashCode => throw new UnsupportedError('AddValue.hashCode');
|
||||
int get hashCode => throw UnsupportedError('AddValue.hashCode');
|
||||
|
||||
@override
|
||||
Value operator -() => -left - right;
|
||||
|
@ -402,7 +401,7 @@ class SubtractValue extends BinaryOperationValue {
|
|||
}
|
||||
|
||||
@override
|
||||
int get hashCode => throw new UnsupportedError('SubtractValue.hashCode');
|
||||
int get hashCode => throw UnsupportedError('SubtractValue.hashCode');
|
||||
|
||||
@override
|
||||
Value operator -() => right - left;
|
||||
|
@ -458,7 +457,7 @@ class NegateValue extends Value {
|
|||
}
|
||||
|
||||
@override
|
||||
int get hashCode => throw new UnsupportedError('Negate.hashCode');
|
||||
int get hashCode => throw UnsupportedError('Negate.hashCode');
|
||||
|
||||
@override
|
||||
Value operator +(other) {
|
||||
|
@ -602,7 +601,7 @@ class Range {
|
|||
}
|
||||
|
||||
@override
|
||||
int get hashCode => throw new UnsupportedError('Range.hashCode');
|
||||
int get hashCode => throw UnsupportedError('Range.hashCode');
|
||||
|
||||
bool operator <(Range other) {
|
||||
return upper != other.lower && upper.min(other.lower) == upper;
|
||||
|
@ -642,7 +641,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
|
|||
|
||||
/// Value ranges for integer instructions. This map gets populated by
|
||||
/// the dominator tree visit.
|
||||
final Map<HInstruction, Range> ranges = new Map<HInstruction, Range>();
|
||||
final Map<HInstruction, Range> ranges = Map<HInstruction, Range>();
|
||||
|
||||
final JClosedWorld closedWorld;
|
||||
final ValueRangeInfo info;
|
||||
|
@ -651,7 +650,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
|
|||
HGraph graph;
|
||||
|
||||
SsaValueRangeAnalyzer(JClosedWorld closedWorld, this.optimizer)
|
||||
: info = new ValueRangeInfo(),
|
||||
: info = ValueRangeInfo(),
|
||||
this.closedWorld = closedWorld;
|
||||
|
||||
@override
|
||||
|
@ -719,8 +718,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
|
|||
return info.newUnboundRange();
|
||||
}
|
||||
if (phi.block.isLoopHeader()) {
|
||||
Range range =
|
||||
new LoopUpdateRecognizer(closedWorld, ranges, info).run(phi);
|
||||
Range range = LoopUpdateRecognizer(closedWorld, ranges, info).run(phi);
|
||||
if (range == null) return info.newUnboundRange();
|
||||
return range;
|
||||
}
|
||||
|
@ -750,12 +748,12 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
|
|||
return info.newUnboundRange();
|
||||
}
|
||||
if (constantNum.isMinusZero) {
|
||||
constantNum = new IntConstantValue(BigInt.zero);
|
||||
constantNum = IntConstantValue(BigInt.zero);
|
||||
}
|
||||
|
||||
BigInt intValue = constantNum is IntConstantValue
|
||||
? constantNum.intValue
|
||||
: new BigInt.from(constantNum.doubleValue.toInt());
|
||||
: BigInt.from(constantNum.doubleValue.toInt());
|
||||
Value value = info.newIntValue(intValue);
|
||||
return info.newNormalizedRange(value, value);
|
||||
}
|
||||
|
@ -1018,8 +1016,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
|
|||
|
||||
HInstruction createRangeConversion(
|
||||
HInstruction cursor, HInstruction instruction) {
|
||||
HRangeConversion newInstruction = new HRangeConversion(
|
||||
instruction, closedWorld.abstractValueDomain.intType);
|
||||
HRangeConversion newInstruction =
|
||||
HRangeConversion(instruction, closedWorld.abstractValueDomain.intType);
|
||||
conversions.add(newInstruction);
|
||||
cursor.block.addBefore(cursor, newInstruction);
|
||||
// Update the users of the instruction dominated by [cursor] to
|
||||
|
|
|
@ -9,7 +9,7 @@ class ValueSet {
|
|||
int size = 0;
|
||||
List<HInstruction> table;
|
||||
ValueSetNode collisions;
|
||||
ValueSet() : table = new List<HInstruction>.filled(8, null);
|
||||
ValueSet() : table = List<HInstruction>.filled(8, null);
|
||||
|
||||
bool get isEmpty => size == 0;
|
||||
int get length => size;
|
||||
|
@ -28,7 +28,7 @@ class ValueSet {
|
|||
if (table[index] == null) {
|
||||
table[index] = instruction;
|
||||
} else {
|
||||
collisions = new ValueSetNode(instruction, hashCode, collisions);
|
||||
collisions = ValueSetNode(instruction, hashCode, collisions);
|
||||
}
|
||||
size++;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class ValueSet {
|
|||
}
|
||||
|
||||
ValueSet copy() {
|
||||
return copyTo(new ValueSet(), table, collisions);
|
||||
return copyTo(ValueSet(), table, collisions);
|
||||
}
|
||||
|
||||
List<HInstruction> toList() {
|
||||
|
@ -111,7 +111,7 @@ class ValueSet {
|
|||
|
||||
ValueSet intersection(ValueSet other) {
|
||||
if (size > other.size) return other.intersection(this);
|
||||
ValueSet result = new ValueSet();
|
||||
ValueSet result = ValueSet();
|
||||
// Look in the hash table.
|
||||
for (int index = 0, length = table.length; index < length; index++) {
|
||||
HInstruction instruction = table[index];
|
||||
|
@ -138,7 +138,7 @@ class ValueSet {
|
|||
// Reset the table with a bigger capacity.
|
||||
assert(capacity > table.length);
|
||||
size = 0;
|
||||
table = new List<HInstruction>.filled(capacity, null);
|
||||
table = List<HInstruction>.filled(capacity, null);
|
||||
collisions = null;
|
||||
// Add the old instructions to the new table.
|
||||
copyTo(this, oldTable, oldCollisions);
|
||||
|
|
|
@ -92,18 +92,18 @@ class LiveEnvironment {
|
|||
final Map<HInstruction, LiveInterval> liveIntervals;
|
||||
|
||||
LiveEnvironment(this.liveIntervals, this.endId)
|
||||
: liveInstructions = new Map<HInstruction, int>(),
|
||||
loopMarkers = new Map<HBasicBlock, int>();
|
||||
: liveInstructions = Map<HInstruction, int>(),
|
||||
loopMarkers = Map<HBasicBlock, int>();
|
||||
|
||||
/// Remove an instruction from the liveIn set. This method also
|
||||
/// updates the live interval of [instruction] to contain the new
|
||||
/// range: [id, / id contained in [liveInstructions] /].
|
||||
void remove(HInstruction instruction, int id) {
|
||||
LiveInterval interval =
|
||||
liveIntervals.putIfAbsent(instruction, () => new LiveInterval());
|
||||
liveIntervals.putIfAbsent(instruction, () => LiveInterval());
|
||||
int lastId = liveInstructions[instruction];
|
||||
// If [lastId] is null, then this instruction is not being used.
|
||||
interval.add(new LiveRange(id, lastId == null ? id : lastId));
|
||||
interval.add(LiveRange(id, lastId == null ? id : lastId));
|
||||
// The instruction is defined at [id].
|
||||
interval.start = id;
|
||||
liveInstructions.remove(instruction);
|
||||
|
@ -128,8 +128,8 @@ class LiveEnvironment {
|
|||
// being used in the join block and defined before the if/else.
|
||||
if (existingId == endId) return;
|
||||
LiveInterval range =
|
||||
liveIntervals.putIfAbsent(instruction, () => new LiveInterval());
|
||||
range.add(new LiveRange(other.startId, existingId));
|
||||
liveIntervals.putIfAbsent(instruction, () => LiveInterval());
|
||||
range.add(LiveRange(other.startId, existingId));
|
||||
liveInstructions[instruction] = endId;
|
||||
});
|
||||
other.loopMarkers.forEach((k, v) {
|
||||
|
@ -260,11 +260,11 @@ class SsaLiveIntervalBuilder extends HBaseVisitor with CodegenPhase {
|
|||
HCheck check = instruction;
|
||||
HInstruction checked = checkedInstructionOrNonGenerateAtUseSite(check);
|
||||
if (!generateAtUseSite.contains(checked)) {
|
||||
liveIntervals.putIfAbsent(checked, () => new LiveInterval());
|
||||
liveIntervals.putIfAbsent(checked, () => LiveInterval());
|
||||
// Unconditionally force the live ranges of the HCheck to
|
||||
// be the live ranges of the instruction it is checking.
|
||||
liveIntervals[instruction] =
|
||||
new LiveInterval.forCheck(instructionId, liveIntervals[checked]);
|
||||
LiveInterval.forCheck(instructionId, liveIntervals[checked]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ class SsaLiveIntervalBuilder extends HBaseVisitor with CodegenPhase {
|
|||
// range that covers the loop.
|
||||
env.liveInstructions.forEach((HInstruction instruction, int id) {
|
||||
LiveInterval range =
|
||||
env.liveIntervals.putIfAbsent(instruction, () => new LiveInterval());
|
||||
env.liveIntervals.putIfAbsent(instruction, () => LiveInterval());
|
||||
range.loopUpdate(env.startId, lastId);
|
||||
env.liveInstructions[instruction] = lastId;
|
||||
});
|
||||
|
@ -380,11 +380,11 @@ class CopyHandler {
|
|||
assignments = <Copy<HInstruction>>[];
|
||||
|
||||
void addCopy(HInstruction source, HInstruction destination) {
|
||||
copies.add(new Copy<HInstruction>(source, destination));
|
||||
copies.add(Copy<HInstruction>(source, destination));
|
||||
}
|
||||
|
||||
void addAssignment(HInstruction source, HInstruction destination) {
|
||||
assignments.add(new Copy<HInstruction>(source, destination));
|
||||
assignments.add(Copy<HInstruction>(source, destination));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -413,9 +413,9 @@ class VariableNames {
|
|||
}
|
||||
|
||||
VariableNames()
|
||||
: ownName = new Map<HInstruction, String>(),
|
||||
copyHandlers = new Map<HBasicBlock, CopyHandler>(),
|
||||
allUsedNames = new Set<String>(),
|
||||
: ownName = Map<HInstruction, String>(),
|
||||
copyHandlers = Map<HBasicBlock, CopyHandler>(),
|
||||
allUsedNames = Set<String>(),
|
||||
swapTemp = 't0';
|
||||
|
||||
int get numberOfVariables => allUsedNames.length;
|
||||
|
@ -435,14 +435,12 @@ class VariableNames {
|
|||
bool hasName(HInstruction instruction) => ownName.containsKey(instruction);
|
||||
|
||||
void addCopy(HBasicBlock block, HInstruction source, HPhi destination) {
|
||||
CopyHandler handler =
|
||||
copyHandlers.putIfAbsent(block, () => new CopyHandler());
|
||||
CopyHandler handler = copyHandlers.putIfAbsent(block, () => CopyHandler());
|
||||
handler.addCopy(source, destination);
|
||||
}
|
||||
|
||||
void addAssignment(HBasicBlock block, HInstruction source, HPhi destination) {
|
||||
CopyHandler handler =
|
||||
copyHandlers.putIfAbsent(block, () => new CopyHandler());
|
||||
CopyHandler handler = copyHandlers.putIfAbsent(block, () => CopyHandler());
|
||||
handler.addAssignment(source, destination);
|
||||
}
|
||||
}
|
||||
|
@ -454,10 +452,10 @@ class VariableNamer {
|
|||
final Set<String> usedNames;
|
||||
final List<String> freeTemporaryNames;
|
||||
int temporaryIndex = 0;
|
||||
static final RegExp regexp = new RegExp('t[0-9]+');
|
||||
static final RegExp regexp = RegExp('t[0-9]+');
|
||||
|
||||
VariableNamer(LiveEnvironment environment, this.names, this._namer)
|
||||
: usedNames = new Set<String>(),
|
||||
: usedNames = Set<String>(),
|
||||
freeTemporaryNames = <String>[] {
|
||||
// [VariableNames.swapTemp] is used when there is a cycle in a copy handler.
|
||||
// Therefore we make sure no one uses it.
|
||||
|
@ -579,7 +577,7 @@ class SsaVariableAllocator extends HBaseVisitor with CodegenPhase {
|
|||
|
||||
SsaVariableAllocator(this._namer, this.liveInstructions, this.liveIntervals,
|
||||
this.generateAtUseSite)
|
||||
: this.names = new VariableNames();
|
||||
: this.names = VariableNames();
|
||||
|
||||
@override
|
||||
void visitGraph(HGraph graph) {
|
||||
|
@ -589,7 +587,7 @@ class SsaVariableAllocator extends HBaseVisitor with CodegenPhase {
|
|||
@override
|
||||
void visitBasicBlock(HBasicBlock block) {
|
||||
VariableNamer variableNamer =
|
||||
new VariableNamer(liveInstructions[block], names, _namer);
|
||||
VariableNamer(liveInstructions[block], names, _namer);
|
||||
|
||||
block.forEachPhi((HPhi phi) {
|
||||
handlePhi(phi, variableNamer);
|
||||
|
|
Loading…
Reference in a new issue