Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: pkg/compiler/lib/src/ssa/value_range_analyzer.dart

Issue 2563443007: Reduce use of Compiler.closedWorld (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/ssa/types_propagation.dart ('k') | pkg/compiler/lib/src/types/masks.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/value_range_analyzer.dart
diff --git a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
index 1882fc6bb1f65d2ee84d7735a1589c1c95b19af2..67e861eb2d8eb7015107c12c98e5a0ab5f50bb08 100644
--- a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
+++ b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart
@@ -7,6 +7,7 @@ import '../constant_system_dart.dart';
import '../constants/constant_system.dart';
import '../constants/values.dart';
import '../js_backend/js_backend.dart';
+import '../world.dart' show ClosedWorld;
import 'nodes.dart';
import 'optimize.dart';
@@ -611,6 +612,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
: info = new ValueRangeInfo(constantSystem),
this.constantSystem = constantSystem;
+ ClosedWorld get closedWorld => compiler.closedWorld;
+
void visitGraph(HGraph graph) {
this.graph = graph;
visitDominatorTree(graph);
@@ -632,7 +635,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
void visitBasicBlock(HBasicBlock block) {
void visit(HInstruction instruction) {
Range range = instruction.accept(this);
- if (instruction.isInteger(compiler)) {
+ if (instruction.isInteger(closedWorld)) {
assert(range != null);
ranges[instruction] = range;
}
@@ -643,10 +646,10 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
Range visitInstruction(HInstruction instruction) {
- if (instruction.isPositiveInteger(compiler)) {
+ if (instruction.isPositiveInteger(closedWorld)) {
return info.newNormalizedRange(
info.intZero, info.newPositiveValue(instruction));
- } else if (instruction.isInteger(compiler)) {
+ } else if (instruction.isInteger(closedWorld)) {
InstructionValue value = info.newInstructionValue(instruction);
return info.newNormalizedRange(value, value);
} else {
@@ -655,16 +658,17 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
Range visitPhi(HPhi phi) {
- if (!phi.isInteger(compiler)) return info.newUnboundRange();
+ if (!phi.isInteger(closedWorld)) return info.newUnboundRange();
// Some phases may replace instructions that change the inputs of
// this phi. Only the [SsaTypesPropagation] phase will update the
// phi type. Play it safe by assuming the [SsaTypesPropagation]
// phase is not necessarily run before the [ValueRangeAnalyzer].
- if (phi.inputs.any((i) => !i.isInteger(compiler))) {
+ if (phi.inputs.any((i) => !i.isInteger(closedWorld))) {
return info.newUnboundRange();
}
if (phi.block.isLoopHeader()) {
- Range range = new LoopUpdateRecognizer(compiler, ranges, info).run(phi);
+ Range range =
+ new LoopUpdateRecognizer(closedWorld, ranges, info).run(phi);
if (range == null) return info.newUnboundRange();
return range;
}
@@ -677,7 +681,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
Range visitConstant(HConstant hConstant) {
- if (!hConstant.isInteger(compiler)) return info.newUnboundRange();
+ if (!hConstant.isInteger(closedWorld)) return info.newUnboundRange();
ConstantValue constant = hConstant.constant;
NumConstantValue constantNum;
if (constant is DeferredConstantValue) {
@@ -694,8 +698,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
Range visitFieldGet(HFieldGet fieldGet) {
- if (!fieldGet.isInteger(compiler)) return info.newUnboundRange();
- if (!fieldGet.receiver.isIndexablePrimitive(compiler)) {
+ if (!fieldGet.isInteger(closedWorld)) return info.newUnboundRange();
+ if (!fieldGet.receiver.isIndexablePrimitive(closedWorld)) {
return visitInstruction(fieldGet);
}
JavaScriptBackend backend = compiler.backend;
@@ -715,7 +719,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
Range lengthRange = ranges[check.length];
if (indexRange == null) {
indexRange = info.newUnboundRange();
- assert(!check.index.isInteger(compiler));
+ assert(!check.index.isInteger(closedWorld));
}
if (lengthRange == null) {
// We might have lost the length range due to a type conversion that
@@ -723,7 +727,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
// get to this point anyway, so no need to try and refine ranges.
return indexRange;
}
- assert(check.length.isInteger(compiler));
+ assert(check.length.isInteger(closedWorld));
// Check if the index is strictly below the upper bound of the length
// range.
@@ -776,8 +780,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
Range visitRelational(HRelational relational) {
HInstruction right = relational.right;
HInstruction left = relational.left;
- if (!left.isInteger(compiler)) return info.newUnboundRange();
- if (!right.isInteger(compiler)) return info.newUnboundRange();
+ if (!left.isInteger(closedWorld)) return info.newUnboundRange();
+ if (!right.isInteger(closedWorld)) return info.newUnboundRange();
BinaryOperation operation = relational.operation(constantSystem);
Range rightRange = ranges[relational.right];
Range leftRange = ranges[relational.left];
@@ -812,7 +816,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
if (divisor != null) {
// For Integer values we can be precise in the upper bound,
// so special case those.
- if (left.isInteger(compiler) && right.isInteger(compiler)) {
+ if (left.isInteger(closedWorld) && right.isInteger(closedWorld)) {
if (divisor.isPositive) {
return info.newNormalizedRange(
info.intZero, divisor.upper - info.intOne);
@@ -820,7 +824,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
return info.newNormalizedRange(
info.intZero, info.newNegateValue(divisor.lower) - info.intOne);
}
- } else if (left.isNumber(compiler) && right.isNumber(compiler)) {
+ } else if (left.isNumber(closedWorld) && right.isNumber(closedWorld)) {
if (divisor.isPositive) {
return info.newNormalizedRange(info.intZero, divisor.upper);
} else if (divisor.isNegative) {
@@ -839,7 +843,7 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
Range handleBinaryOperation(HBinaryArithmetic instruction) {
- if (!instruction.isInteger(compiler)) return info.newUnboundRange();
+ if (!instruction.isInteger(closedWorld)) return info.newUnboundRange();
return instruction
.operation(constantSystem)
.apply(ranges[instruction.left], ranges[instruction.right]);
@@ -854,10 +858,10 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
}
Range visitBitAnd(HBitAnd node) {
- if (!node.isInteger(compiler)) return info.newUnboundRange();
+ if (!node.isInteger(closedWorld)) return info.newUnboundRange();
HInstruction right = node.right;
HInstruction left = node.left;
- if (left.isInteger(compiler) && right.isInteger(compiler)) {
+ if (left.isInteger(closedWorld) && right.isInteger(closedWorld)) {
return ranges[left] & ranges[right];
}
@@ -871,9 +875,9 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
return info.newUnboundRange();
}
- if (left.isInteger(compiler)) {
+ if (left.isInteger(closedWorld)) {
return tryComputeRange(left);
- } else if (right.isInteger(compiler)) {
+ } else if (right.isInteger(closedWorld)) {
return tryComputeRange(right);
}
return info.newUnboundRange();
@@ -888,9 +892,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
HInstruction createRangeConversion(
HInstruction cursor, HInstruction instruction) {
- JavaScriptBackend backend = compiler.backend;
HRangeConversion newInstruction =
- new HRangeConversion(instruction, backend.intType);
+ new HRangeConversion(instruction, closedWorld.commonMasks.intType);
conversions.add(newInstruction);
cursor.block.addBefore(cursor, newInstruction);
// Update the users of the instruction dominated by [cursor] to
@@ -953,8 +956,8 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
if (condition is HIdentity) return info.newUnboundRange();
HInstruction right = condition.right;
HInstruction left = condition.left;
- if (!left.isInteger(compiler)) return info.newUnboundRange();
- if (!right.isInteger(compiler)) return info.newUnboundRange();
+ if (!left.isInteger(closedWorld)) return info.newUnboundRange();
+ if (!right.isInteger(closedWorld)) return info.newUnboundRange();
Range rightRange = ranges[right];
Range leftRange = ranges[left];
@@ -1016,10 +1019,10 @@ class SsaValueRangeAnalyzer extends HBaseVisitor implements OptimizationPhase {
* Tries to find a range for the update instruction of a loop phi.
*/
class LoopUpdateRecognizer extends HBaseVisitor {
- final Compiler compiler;
+ final ClosedWorld closedWorld;
final Map<HInstruction, Range> ranges;
final ValueRangeInfo info;
- LoopUpdateRecognizer(this.compiler, this.ranges, this.info);
+ LoopUpdateRecognizer(this.closedWorld, this.ranges, this.info);
Range run(HPhi loopPhi) {
// Create a marker range for the loop phi, so that if the update
@@ -1044,7 +1047,7 @@ class LoopUpdateRecognizer extends HBaseVisitor {
}
Range visit(HInstruction instruction) {
- if (!instruction.isInteger(compiler)) return null;
+ if (!instruction.isInteger(closedWorld)) return null;
if (ranges[instruction] != null) return ranges[instruction];
return instruction.accept(this);
}
« no previous file with comments | « pkg/compiler/lib/src/ssa/types_propagation.dart ('k') | pkg/compiler/lib/src/types/masks.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698