Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index 12b0e2f6cc97d38eb8986ec3f8a19b923ba008a3..86df9f5319ce6271a32867cf748c614fe1b2d774 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -14,17 +14,6 @@ namespace internal { |
namespace compiler { |
-// Helper method that assumes replacement nodes are pure values that don't |
-// produce an effect. Replaces {node} with {reduction} and relaxes effects. |
-static Reduction ReplaceWithPureReduction(Node* node, Reduction reduction) { |
- if (reduction.Changed()) { |
- NodeProperties::ReplaceWithValue(node, reduction.replacement()); |
- return reduction; |
- } |
- return Reducer::NoChange(); |
-} |
- |
- |
// Helper class to access JSCallFunction nodes that are potential candidates |
// for reduction when they have a BuiltinFunctionId associated with them. |
class JSCallReduction { |
@@ -96,8 +85,10 @@ class JSCallReduction { |
}; |
-JSBuiltinReducer::JSBuiltinReducer(JSGraph* jsgraph) |
- : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {} |
+JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph) |
+ : AdvancedReducer(editor), |
+ jsgraph_(jsgraph), |
+ simplified_(jsgraph->zone()) {} |
// ECMA-262, section 15.8.2.11. |
@@ -153,21 +144,30 @@ Reduction JSBuiltinReducer::ReduceMathFround(Node* node) { |
Reduction JSBuiltinReducer::Reduce(Node* node) { |
+ Reduction reduction = NoChange(); |
JSCallReduction r(node); |
// Dispatch according to the BuiltinFunctionId if present. |
if (!r.HasBuiltinFunctionId()) return NoChange(); |
switch (r.GetBuiltinFunctionId()) { |
case kMathMax: |
- return ReplaceWithPureReduction(node, ReduceMathMax(node)); |
+ reduction = ReduceMathMax(node); |
+ break; |
case kMathImul: |
- return ReplaceWithPureReduction(node, ReduceMathImul(node)); |
+ reduction = ReduceMathImul(node); |
+ break; |
case kMathFround: |
- return ReplaceWithPureReduction(node, ReduceMathFround(node)); |
+ reduction = ReduceMathFround(node); |
+ break; |
default: |
break; |
} |
- return NoChange(); |
+ |
+ // Replace builtin call assuming replacement nodes are pure values that don't |
+ // produce an effect. Replaces {node} with {reduction} and relaxes effects. |
+ if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement()); |
+ |
+ return reduction; |
} |