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

Unified Diff: lib/compiler/implementation/ssa/optimize.dart

Issue 10825386: Use JavaScript runtime semantics when constant folding. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove top-level constanst. Created 8 years, 4 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: lib/compiler/implementation/ssa/optimize.dart
diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
index 4faa8e9e2e4ae016ee5352b71ae07b34f8c7f2fd..736454c6883ac5bd1ba0b37a03be76f8886dd3cd 100644
--- a/lib/compiler/implementation/ssa/optimize.dart
+++ b/lib/compiler/implementation/ssa/optimize.dart
@@ -23,15 +23,17 @@ class SsaOptimizerTask extends CompilerTask {
}
void optimize(WorkItem work, HGraph graph) {
+ FoldingOperations foldingOperations =
+ compiler.constantHandler.foldingOperations;
measure(() {
List<OptimizationPhase> phases = <OptimizationPhase>[
// Run trivial constant folding first to optimize
// some patterns useful for type conversion.
- new SsaConstantFolder(backend, work),
+ new SsaConstantFolder(foldingOperations, backend, work),
new SsaTypeConversionInserter(compiler),
new SsaTypePropagator(compiler),
new SsaCheckInserter(backend),
- new SsaConstantFolder(backend, work),
+ new SsaConstantFolder(foldingOperations, backend, work),
new SsaRedundantPhiEliminator(),
new SsaDeadPhiEliminator(),
new SsaGlobalValueNumberer(compiler),
@@ -93,10 +95,11 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
final String name = "SsaConstantFolder";
final JavaScriptBackend backend;
final WorkItem work;
+ final FoldingOperations foldingOperations;
HGraph graph;
Compiler get compiler() => backend.compiler;
- SsaConstantFolder(this.backend, this.work);
+ SsaConstantFolder(this.foldingOperations, this.backend, this.work);
void visitGraph(HGraph visitee) {
graph = visitee;
@@ -165,7 +168,7 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
HInstruction visitInvokeUnary(HInvokeUnary node) {
HInstruction operand = node.operand;
if (operand is HConstant) {
- UnaryOperation operation = node.operation;
+ UnaryOperation operation = node.operation(foldingOperations);
HConstant receiver = operand;
Constant folded = operation.fold(receiver.constant);
if (folded !== null) return graph.addConstant(folded);
@@ -319,8 +322,8 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
HInstruction visitInvokeBinary(HInvokeBinary node) {
HInstruction left = node.left;
HInstruction right = node.right;
+ BinaryOperation operation = node.operation(foldingOperations);
if (left is HConstant && right is HConstant) {
- BinaryOperation operation = node.operation;
HConstant op1 = left;
HConstant op2 = right;
Constant folded = operation.fold(op1.constant, op2.constant);
@@ -328,10 +331,10 @@ class SsaConstantFolder extends HBaseVisitor implements OptimizationPhase {
}
if (!left.canBePrimitive()
- && node.operation.isUserDefinable()
+ && operation.isUserDefinable()
// The equals operation is being optimized in visitEquals.
- && node.operation !== const EqualsOperation()) {
- Selector selector = new Selector.binaryOperator(node.operation.name);
+ && node is! HEquals) {
+ Selector selector = new Selector.binaryOperator(operation.name);
return fromInterceptorToDynamicInvocation(node, selector);
}
return node;
« lib/compiler/implementation/operations.dart ('K') | « lib/compiler/implementation/ssa/nodes.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698