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

Unified Diff: lib/compiler/implementation/ssa/builder.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/builder.dart
diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart
index 01149a64e0d5b9d5001d68794c98d6cc4d49d3dd..473def66ff819d5558c07989a9dd8da32df9523b 100644
--- a/lib/compiler/implementation/ssa/builder.dart
+++ b/lib/compiler/implementation/ssa/builder.dart
@@ -153,7 +153,9 @@ class SsaBuilderTask extends CompilerTask {
return measure(() {
FunctionElement element = work.element;
HInstruction.idCounter = 0;
- SsaBuilder builder = new SsaBuilder(this, work);
+ FoldingOperations foldingOperations =
+ compiler.constantHandler.foldingOperations;
+ SsaBuilder builder = new SsaBuilder(foldingOperations, this, work);
HGraph graph;
ElementKind kind = element.kind;
if (kind === ElementKind.GENERATIVE_CONSTRUCTOR) {
@@ -797,6 +799,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
final SsaBuilderTask builder;
final Interceptors interceptors;
final WorkItem work;
+ final FoldingOperations foldingOperations;
bool methodInterceptionEnabled;
HGraph graph;
LocalsHandler localsHandler;
@@ -827,7 +830,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
Compiler get compiler() => builder.compiler;
CodeEmitterTask get emitter() => builder.emitter;
- SsaBuilder(SsaBuilderTask builder, WorkItem work)
+ SsaBuilder(this.foldingOperations, SsaBuilderTask builder, WorkItem work)
: this.builder = builder,
this.work = work,
interceptors = builder.interceptors,
@@ -1639,7 +1642,8 @@ class SsaBuilder extends ResolvedVisitor implements Visitor {
// See if we can constant-fold right away. This avoids rewrites later on.
if (operand is HConstant) {
HConstant constant = operand;
- Constant folded = result.operation.fold(constant.constant);
+ Constant folded =
+ result.operation(foldingOperations).fold(constant.constant);
if (folded !== null) {
stack.add(graph.addConstant(folded));
return;

Powered by Google App Engine
This is Rietveld 408576698