| 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-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/js-operator.h" | 9 #include "src/compiler/js-operator.h" |
| 10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // before the function to which it belongs has initialized the slot. | 70 // before the function to which it belongs has initialized the slot. |
| 71 // We must be conservative and check if the value in the slot is currently the | 71 // We must be conservative and check if the value in the slot is currently the |
| 72 // hole or undefined. If it is neither of these, then it must be initialized. | 72 // hole or undefined. If it is neither of these, then it must be initialized. |
| 73 if (value->IsUndefined() || value->IsTheHole()) { | 73 if (value->IsUndefined() || value->IsTheHole()) { |
| 74 return NoChange(); | 74 return NoChange(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Success. The context load can be replaced with the constant. | 77 // Success. The context load can be replaced with the constant. |
| 78 // TODO(titzer): record the specialization for sharing code across multiple | 78 // TODO(titzer): record the specialization for sharing code across multiple |
| 79 // contexts that have the same value in the corresponding context slot. | 79 // contexts that have the same value in the corresponding context slot. |
| 80 if (value->IsConsString()) { | |
| 81 value = String::Flatten(Handle<String>::cast(value), TENURED); | |
| 82 } | |
| 83 Node* constant = jsgraph_->Constant(value); | 80 Node* constant = jsgraph_->Constant(value); |
| 84 ReplaceWithValue(node, constant); | 81 ReplaceWithValue(node, constant); |
| 85 return Replace(constant); | 82 return Replace(constant); |
| 86 } | 83 } |
| 87 | 84 |
| 88 | 85 |
| 89 Reduction JSContextSpecialization::ReduceJSStoreContext(Node* node) { | 86 Reduction JSContextSpecialization::ReduceJSStoreContext(Node* node) { |
| 90 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); | 87 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); |
| 91 | 88 |
| 92 // Get the specialization context from the node. | 89 // Get the specialization context from the node. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 115 } | 112 } |
| 116 | 113 |
| 117 | 114 |
| 118 JSOperatorBuilder* JSContextSpecialization::javascript() const { | 115 JSOperatorBuilder* JSContextSpecialization::javascript() const { |
| 119 return jsgraph()->javascript(); | 116 return jsgraph()->javascript(); |
| 120 } | 117 } |
| 121 | 118 |
| 122 } // namespace compiler | 119 } // namespace compiler |
| 123 } // namespace internal | 120 } // namespace internal |
| 124 } // namespace v8 | 121 } // namespace v8 |
| OLD | NEW |