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 } | 70 } |
71 | 71 |
72 // If the access itself is mutable, only fold-in the parent. | 72 // If the access itself is mutable, only fold-in the parent. |
73 if (!access.immutable()) { | 73 if (!access.immutable()) { |
74 // The access does not have to look up a parent, nothing to fold. | 74 // The access does not have to look up a parent, nothing to fold. |
75 if (access.depth() == 0) { | 75 if (access.depth() == 0) { |
76 return NoChange(); | 76 return NoChange(); |
77 } | 77 } |
78 const Operator* op = jsgraph_->javascript()->LoadContext( | 78 const Operator* op = jsgraph_->javascript()->LoadContext( |
79 0, access.index(), access.immutable()); | 79 0, access.index(), access.immutable()); |
80 node->set_op(op); | |
81 node->ReplaceInput(0, jsgraph_->Constant(context)); | 80 node->ReplaceInput(0, jsgraph_->Constant(context)); |
| 81 NodeProperties::ChangeOp(node, op); |
82 return Changed(node); | 82 return Changed(node); |
83 } | 83 } |
84 Handle<Object> value = | 84 Handle<Object> value = |
85 handle(context->get(static_cast<int>(access.index())), isolate()); | 85 handle(context->get(static_cast<int>(access.index())), isolate()); |
86 | 86 |
87 // Even though the context slot is immutable, the context might have escaped | 87 // Even though the context slot is immutable, the context might have escaped |
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()) { |
(...skipping 20 matching lines...) Expand all Loading... |
112 const ContextAccess& access = ContextAccessOf(node->op()); | 112 const ContextAccess& access = ContextAccessOf(node->op()); |
113 if (access.depth() == 0) { | 113 if (access.depth() == 0) { |
114 return NoChange(); | 114 return NoChange(); |
115 } | 115 } |
116 | 116 |
117 // Find the right parent context. | 117 // Find the right parent context. |
118 for (size_t i = access.depth(); i > 0; --i) { | 118 for (size_t i = access.depth(); i > 0; --i) { |
119 context = handle(context->previous(), isolate()); | 119 context = handle(context->previous(), isolate()); |
120 } | 120 } |
121 | 121 |
122 node->set_op(javascript()->StoreContext(0, access.index())); | |
123 node->ReplaceInput(0, jsgraph_->Constant(context)); | 122 node->ReplaceInput(0, jsgraph_->Constant(context)); |
| 123 NodeProperties::ChangeOp(node, javascript()->StoreContext(0, access.index())); |
124 return Changed(node); | 124 return Changed(node); |
125 } | 125 } |
126 | 126 |
127 | 127 |
128 Isolate* JSContextSpecialization::isolate() const { | 128 Isolate* JSContextSpecialization::isolate() const { |
129 return jsgraph()->isolate(); | 129 return jsgraph()->isolate(); |
130 } | 130 } |
131 | 131 |
132 | 132 |
133 JSOperatorBuilder* JSContextSpecialization::javascript() const { | 133 JSOperatorBuilder* JSContextSpecialization::javascript() const { |
134 return jsgraph()->javascript(); | 134 return jsgraph()->javascript(); |
135 } | 135 } |
136 | 136 |
137 } // namespace compiler | 137 } // namespace compiler |
138 } // namespace internal | 138 } // namespace internal |
139 } // namespace v8 | 139 } // namespace v8 |
OLD | NEW |