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

Unified Diff: src/compiler/js-context-specialization.cc

Issue 771713002: [turbofan] Make context specialization into a reducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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: 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.
}

Powered by Google App Engine
This is Rietveld 408576698