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

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

Issue 2302363003: No longer store the compilation-context in WorkItem. (Closed)
Patch Set: Created 4 years, 3 months 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
Index: pkg/compiler/lib/src/ssa/optimize.dart
diff --git a/pkg/compiler/lib/src/ssa/optimize.dart b/pkg/compiler/lib/src/ssa/optimize.dart
index 980fb4faa746909e345ebfc653797fa6d8bfddca..2d808c540413c20b548612fe313ea34de532af6c 100644
--- a/pkg/compiler/lib/src/ssa/optimize.dart
+++ b/pkg/compiler/lib/src/ssa/optimize.dart
@@ -20,6 +20,7 @@ import '../universe/selector.dart' show Selector;
import '../universe/side_effects.dart' show SideEffects;
import '../util/util.dart';
import '../world.dart' show ClassWorld, World;
+import 'context.dart';
import 'interceptor_simplifier.dart';
import 'nodes.dart';
import 'types.dart';
@@ -41,7 +42,8 @@ class SsaOptimizerTask extends CompilerTask {
Compiler get compiler => backend.compiler;
Map<HInstruction, Range> ranges = <HInstruction, Range>{};
- void optimize(CodegenWorkItem work, HGraph graph) {
+ void optimize(HGraph graph, CodegenWorkItem work,
+ SsaCompilationContext context) {
void runPhase(OptimizationPhase phase) {
measureSubtask(phase.name, () => phase.visitGraph(graph));
compiler.tracer.traceGraph(phase.name, graph);
@@ -49,25 +51,24 @@ class SsaOptimizerTask extends CompilerTask {
}
ConstantSystem constantSystem = compiler.backend.constantSystem;
- JavaScriptItemCompilationContext context = work.compilationContext;
bool trustPrimitives = compiler.options.trustPrimitives;
measure(() {
List<OptimizationPhase> phases = <OptimizationPhase>[
// Run trivial instruction simplification first to optimize
// some patterns useful for type conversion.
- new SsaInstructionSimplifier(constantSystem, backend, this, work),
+ new SsaInstructionSimplifier(constantSystem, backend, this, context),
new SsaTypeConversionInserter(compiler),
new SsaRedundantPhiEliminator(),
new SsaDeadPhiEliminator(),
new SsaTypePropagator(compiler),
// After type propagation, more instructions can be
// simplified.
- new SsaInstructionSimplifier(constantSystem, backend, this, work),
+ new SsaInstructionSimplifier(constantSystem, backend, this, context),
new SsaCheckInserter(
- trustPrimitives, backend, work, context.boundsChecked),
- new SsaInstructionSimplifier(constantSystem, backend, this, work),
+ trustPrimitives, backend, context.boundsChecked),
+ new SsaInstructionSimplifier(constantSystem, backend, this, context),
new SsaCheckInserter(
- trustPrimitives, backend, work, context.boundsChecked),
+ trustPrimitives, backend, context.boundsChecked),
new SsaTypePropagator(compiler),
// Run a dead code eliminator before LICM because dead
// interceptors are often in the way of LICM'able instructions.
@@ -81,19 +82,20 @@ class SsaOptimizerTask extends CompilerTask {
new SsaRedundantPhiEliminator(),
new SsaDeadPhiEliminator(),
new SsaTypePropagator(compiler),
- new SsaValueRangeAnalyzer(compiler, constantSystem, this, work),
+ new SsaValueRangeAnalyzer(compiler, constantSystem, this),
// Previous optimizations may have generated new
// opportunities for instruction simplification.
- new SsaInstructionSimplifier(constantSystem, backend, this, work),
+ new SsaInstructionSimplifier(constantSystem, backend, this, context),
new SsaCheckInserter(
- trustPrimitives, backend, work, context.boundsChecked),
+ trustPrimitives, backend, context.boundsChecked),
];
phases.forEach(runPhase);
// Simplifying interceptors is not strictly just an optimization, it is
// required for implementation correctness because the code generator
// assumes it is always performed.
- runPhase(new SsaSimplifyInterceptors(compiler, constantSystem, work));
+ runPhase(new SsaSimplifyInterceptors(
+ compiler, constantSystem, work.element));
SsaDeadCodeEliminator dce = new SsaDeadCodeEliminator(compiler, this);
runPhase(dce);
@@ -102,11 +104,11 @@ class SsaOptimizerTask extends CompilerTask {
new SsaTypePropagator(compiler),
new SsaGlobalValueNumberer(compiler),
new SsaCodeMotion(),
- new SsaValueRangeAnalyzer(compiler, constantSystem, this, work),
- new SsaInstructionSimplifier(constantSystem, backend, this, work),
+ new SsaValueRangeAnalyzer(compiler, constantSystem, this),
+ new SsaInstructionSimplifier(constantSystem, backend, this, context),
new SsaCheckInserter(
- trustPrimitives, backend, work, context.boundsChecked),
- new SsaSimplifyInterceptors(compiler, constantSystem, work),
+ trustPrimitives, backend, context.boundsChecked),
+ new SsaSimplifyInterceptors(compiler, constantSystem, work.element),
new SsaDeadCodeEliminator(compiler, this),
];
} else {
@@ -114,7 +116,7 @@ class SsaOptimizerTask extends CompilerTask {
new SsaTypePropagator(compiler),
// Run the simplifier to remove unneeded type checks inserted by
// type propagation.
- new SsaInstructionSimplifier(constantSystem, backend, this, work),
+ new SsaInstructionSimplifier(constantSystem, backend, this, context),
];
}
phases.forEach(runPhase);
@@ -156,14 +158,14 @@ class SsaInstructionSimplifier extends HBaseVisitor
final String name = "SsaInstructionSimplifier";
final JavaScriptBackend backend;
- final CodegenWorkItem work;
final ConstantSystem constantSystem;
HGraph graph;
Compiler get compiler => backend.compiler;
final SsaOptimizerTask optimizer;
+ final SsaCompilationContext context;
SsaInstructionSimplifier(
- this.constantSystem, this.backend, this.optimizer, this.work);
+ this.constantSystem, this.backend, this.optimizer, this.context);
CoreClasses get coreClasses => compiler.coreClasses;
@@ -835,7 +837,6 @@ class SsaInstructionSimplifier extends HBaseVisitor
if (node.isNullCheck) return node;
var receiver = node.receiver;
if (node.element == helpers.jsIndexableLength) {
- JavaScriptItemCompilationContext context = work.compilationContext;
if (context.allocatedFixedLists.contains(receiver)) {
// TODO(ngeoffray): checking if the second input is an integer
// should not be necessary but it currently makes it easier for
@@ -1201,14 +1202,13 @@ class SsaInstructionSimplifier extends HBaseVisitor
class SsaCheckInserter extends HBaseVisitor implements OptimizationPhase {
final Set<HInstruction> boundsChecked;
- final CodegenWorkItem work;
final bool trustPrimitives;
final JavaScriptBackend backend;
final String name = "SsaCheckInserter";
HGraph graph;
SsaCheckInserter(
- this.trustPrimitives, this.backend, this.work, this.boundsChecked);
+ this.trustPrimitives, this.backend, this.boundsChecked);
BackendHelpers get helpers => backend.helpers;

Powered by Google App Engine
This is Rietveld 408576698