| 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/js-context-specialization.h" | 5 #include "src/compiler/js-context-specialization.h" |
| 6 | 6 |
| 7 #include "src/compiler/common-operator.h" | 7 #include "src/compiler/common-operator.h" |
| 8 #include "src/compiler/js-operator.h" | 8 #include "src/compiler/js-operator.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // We must be conservative and check if the value in the slot is currently the | 63 // We must be conservative and check if the value in the slot is currently the |
| 64 // hole or undefined. If it is neither of these, then it must be initialized. | 64 // hole or undefined. If it is neither of these, then it must be initialized. |
| 65 if (value->IsUndefined() || value->IsTheHole()) { | 65 if (value->IsUndefined() || value->IsTheHole()) { |
| 66 return NoChange(); | 66 return NoChange(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Success. The context load can be replaced with the constant. | 69 // Success. The context load can be replaced with the constant. |
| 70 // TODO(titzer): record the specialization for sharing code across multiple | 70 // TODO(titzer): record the specialization for sharing code across multiple |
| 71 // contexts that have the same value in the corresponding context slot. | 71 // contexts that have the same value in the corresponding context slot. |
| 72 Node* constant = jsgraph_->Constant(value); | 72 Node* constant = jsgraph_->Constant(value); |
| 73 NodeProperties::ReplaceWithValue(node, constant); | 73 ReplaceWithValue(node, constant); |
| 74 return Replace(constant); | 74 return Replace(constant); |
| 75 } | 75 } |
| 76 | 76 |
| 77 | 77 |
| 78 Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) { | 78 Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) { |
| 79 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); | 79 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); |
| 80 | 80 |
| 81 HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(node, 0)); | 81 HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(node, 0)); |
| 82 // If the context is not constant, no reduction can occur. | 82 // If the context is not constant, no reduction can occur. |
| 83 if (!m.HasValue()) { | 83 if (!m.HasValue()) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 102 Handle<Object> new_context_handle = | 102 Handle<Object> new_context_handle = |
| 103 Handle<Object>(context, jsgraph_->isolate()); | 103 Handle<Object>(context, jsgraph_->isolate()); |
| 104 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); | 104 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); |
| 105 | 105 |
| 106 return Changed(node); | 106 return Changed(node); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace compiler | 109 } // namespace compiler |
| 110 } // namespace internal | 110 } // namespace internal |
| 111 } // namespace v8 | 111 } // namespace v8 |
| OLD | NEW |