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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 // before the function to which it belongs has initialized the slot. | 88 // before the function to which it belongs has initialized the slot. |
89 // We must be conservative and check if the value in the slot is currently the | 89 // We must be conservative and check if the value in the slot is currently the |
90 // hole or undefined. If it is neither of these, then it must be initialized. | 90 // hole or undefined. If it is neither of these, then it must be initialized. |
91 if (value->IsUndefined() || value->IsTheHole()) { | 91 if (value->IsUndefined() || value->IsTheHole()) { |
92 return NoChange(); | 92 return NoChange(); |
93 } | 93 } |
94 | 94 |
95 // Success. The context load can be replaced with the constant. | 95 // Success. The context load can be replaced with the constant. |
96 // TODO(titzer): record the specialization for sharing code across multiple | 96 // TODO(titzer): record the specialization for sharing code across multiple |
97 // contexts that have the same value in the corresponding context slot. | 97 // contexts that have the same value in the corresponding context slot. |
98 if (value->IsConsString()) { | |
99 value = String::Flatten(Handle<String>::cast(value), TENURED); | |
100 } | |
101 Node* constant = jsgraph_->Constant(value); | 98 Node* constant = jsgraph_->Constant(value); |
102 ReplaceWithValue(node, constant); | 99 ReplaceWithValue(node, constant); |
103 return Replace(constant); | 100 return Replace(constant); |
104 } | 101 } |
105 | 102 |
106 | 103 |
107 Reduction JSContextSpecialization::ReduceJSStoreContext(Node* node) { | 104 Reduction JSContextSpecialization::ReduceJSStoreContext(Node* node) { |
108 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); | 105 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); |
109 | 106 |
110 // Get the specialization context from the node. | 107 // Get the specialization context from the node. |
(...skipping 22 matching lines...) Expand all Loading... |
133 } | 130 } |
134 | 131 |
135 | 132 |
136 JSOperatorBuilder* JSContextSpecialization::javascript() const { | 133 JSOperatorBuilder* JSContextSpecialization::javascript() const { |
137 return jsgraph()->javascript(); | 134 return jsgraph()->javascript(); |
138 } | 135 } |
139 | 136 |
140 } // namespace compiler | 137 } // namespace compiler |
141 } // namespace internal | 138 } // namespace internal |
142 } // namespace v8 | 139 } // namespace v8 |
OLD | NEW |