Index: src/compiler/js-context-specialization.cc |
diff --git a/src/compiler/js-context-specialization.cc b/src/compiler/js-context-specialization.cc |
index d11bc6671188e5a6de74ee678fc02f48e46b069b..4545343d1430d8f71f14c8f3319b2ac9b526b9dc 100644 |
--- a/src/compiler/js-context-specialization.cc |
+++ b/src/compiler/js-context-specialization.cc |
@@ -6,7 +6,6 @@ |
#include "src/compiler/graph-inl.h" |
#include "src/compiler/js-context-specialization.h" |
#include "src/compiler/js-operator.h" |
-#include "src/compiler/node-aux-data-inl.h" |
#include "src/compiler/node-matchers.h" |
#include "src/compiler/node-properties-inl.h" |
@@ -14,45 +13,20 @@ namespace v8 { |
namespace internal { |
namespace compiler { |
-class ContextSpecializationVisitor : public NullNodeVisitor { |
- public: |
- explicit ContextSpecializationVisitor(JSContextSpecializer* spec) |
- : spec_(spec) {} |
- |
- void Post(Node* node) { |
- switch (node->opcode()) { |
- case IrOpcode::kJSLoadContext: { |
- Reduction r = spec_->ReduceJSLoadContext(node); |
- if (r.Changed() && r.replacement() != node) { |
- NodeProperties::ReplaceWithValue(node, r.replacement()); |
- node->RemoveAllInputs(); |
- } |
- break; |
- } |
- case IrOpcode::kJSStoreContext: { |
- Reduction r = spec_->ReduceJSStoreContext(node); |
- if (r.Changed() && r.replacement() != node) { |
- NodeProperties::ReplaceWithValue(node, r.replacement()); |
- node->RemoveAllInputs(); |
- } |
- break; |
- } |
- default: |
- break; |
- } |
- } |
- |
- private: |
- JSContextSpecializer* spec_; |
-}; |
- |
-void JSContextSpecializer::SpecializeToContext() { |
- NodeProperties::ReplaceWithValue(context_, |
- jsgraph_->Constant(info_->context())); |
- |
- ContextSpecializationVisitor visitor(this); |
- jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); |
+Reduction JSContextSpecializer::Reduce(Node* node) { |
+ if (node == context_) { |
+ Node* constant = jsgraph_->Constant(info_->context()); |
+ NodeProperties::ReplaceWithValue(node, constant); |
+ return Replace(constant); |
+ } |
+ if (node->opcode() == IrOpcode::kJSLoadContext) { |
+ return ReduceJSLoadContext(node); |
+ } |
+ if (node->opcode() == IrOpcode::kJSStoreContext) { |
+ return ReduceJSStoreContext(node); |
+ } |
+ return NoChange(); |
} |
@@ -100,7 +74,9 @@ Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) { |
// Success. The context load can be replaced with the constant. |
// TODO(titzer): record the specialization for sharing code across multiple |
// contexts that have the same value in the corresponding context slot. |
- return Reducer::Replace(jsgraph_->Constant(value)); |
+ Node* constant = jsgraph_->Constant(value); |
+ NodeProperties::ReplaceWithValue(node, constant); |
+ return Reducer::Replace(constant); |
Benedikt Meurer
2014/12/01 17:51:57
Remove Reducer:: prefix.
|
} |