| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
| 6 #include "src/compiler/generic-node-inl.h" | 6 #include "src/compiler/generic-node-inl.h" |
| 7 #include "src/compiler/graph-inl.h" | 7 #include "src/compiler/graph-inl.h" |
| 8 #include "src/compiler/js-context-specialization.h" | 8 #include "src/compiler/js-context-specialization.h" |
| 9 #include "src/compiler/js-operator.h" | 9 #include "src/compiler/js-operator.h" |
| 10 #include "src/compiler/node-aux-data-inl.h" | 10 #include "src/compiler/node-aux-data-inl.h" |
| 11 #include "src/compiler/node-matchers.h" | 11 #include "src/compiler/node-matchers.h" |
| 12 #include "src/compiler/node-properties-inl.h" | 12 #include "src/compiler/node-properties-inl.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 namespace compiler { | 16 namespace compiler { |
| 17 | 17 |
| 18 class ContextSpecializationVisitor : public NullNodeVisitor { | 18 class ContextSpecializationVisitor : public NullNodeVisitor { |
| 19 public: | 19 public: |
| 20 explicit ContextSpecializationVisitor(JSContextSpecializer* spec) | 20 explicit ContextSpecializationVisitor(JSContextSpecializer* spec) |
| 21 : spec_(spec) {} | 21 : spec_(spec) {} |
| 22 | 22 |
| 23 GenericGraphVisit::Control Post(Node* node) { | 23 void Post(Node* node) { |
| 24 switch (node->opcode()) { | 24 switch (node->opcode()) { |
| 25 case IrOpcode::kJSLoadContext: { | 25 case IrOpcode::kJSLoadContext: { |
| 26 Reduction r = spec_->ReduceJSLoadContext(node); | 26 Reduction r = spec_->ReduceJSLoadContext(node); |
| 27 if (r.Changed() && r.replacement() != node) { | 27 if (r.Changed() && r.replacement() != node) { |
| 28 NodeProperties::ReplaceWithValue(node, r.replacement()); | 28 NodeProperties::ReplaceWithValue(node, r.replacement()); |
| 29 node->RemoveAllInputs(); | 29 node->RemoveAllInputs(); |
| 30 } | 30 } |
| 31 break; | 31 break; |
| 32 } | 32 } |
| 33 case IrOpcode::kJSStoreContext: { | 33 case IrOpcode::kJSStoreContext: { |
| 34 Reduction r = spec_->ReduceJSStoreContext(node); | 34 Reduction r = spec_->ReduceJSStoreContext(node); |
| 35 if (r.Changed() && r.replacement() != node) { | 35 if (r.Changed() && r.replacement() != node) { |
| 36 NodeProperties::ReplaceWithValue(node, r.replacement()); | 36 NodeProperties::ReplaceWithValue(node, r.replacement()); |
| 37 node->RemoveAllInputs(); | 37 node->RemoveAllInputs(); |
| 38 } | 38 } |
| 39 break; | 39 break; |
| 40 } | 40 } |
| 41 default: | 41 default: |
| 42 break; | 42 break; |
| 43 } | 43 } |
| 44 return GenericGraphVisit::CONTINUE; | |
| 45 } | 44 } |
| 46 | 45 |
| 47 private: | 46 private: |
| 48 JSContextSpecializer* spec_; | 47 JSContextSpecializer* spec_; |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 | 50 |
| 52 void JSContextSpecializer::SpecializeToContext() { | 51 void JSContextSpecializer::SpecializeToContext() { |
| 53 NodeProperties::ReplaceWithValue(context_, | 52 NodeProperties::ReplaceWithValue(context_, |
| 54 jsgraph_->Constant(info_->context())); | 53 jsgraph_->Constant(info_->context())); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 node->set_op(op); | 131 node->set_op(op); |
| 133 Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate()); | 132 Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate()); |
| 134 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); | 133 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); |
| 135 | 134 |
| 136 return Reducer::Changed(node); | 135 return Reducer::Changed(node); |
| 137 } | 136 } |
| 138 | 137 |
| 139 } // namespace compiler | 138 } // namespace compiler |
| 140 } // namespace internal | 139 } // namespace internal |
| 141 } // namespace v8 | 140 } // namespace v8 |
| OLD | NEW |