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" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 for (int i = access.depth(); i > 0; --i) { | 74 for (int i = access.depth(); i > 0; --i) { |
75 context = context->previous(); | 75 context = context->previous(); |
76 } | 76 } |
77 | 77 |
78 // If the access itself is mutable, only fold-in the parent. | 78 // If the access itself is mutable, only fold-in the parent. |
79 if (!access.immutable()) { | 79 if (!access.immutable()) { |
80 // The access does not have to look up a parent, nothing to fold. | 80 // The access does not have to look up a parent, nothing to fold. |
81 if (access.depth() == 0) { | 81 if (access.depth() == 0) { |
82 return Reducer::NoChange(); | 82 return Reducer::NoChange(); |
83 } | 83 } |
84 Operator* op = jsgraph_->javascript()->LoadContext(0, access.index(), | 84 const Operator* op = jsgraph_->javascript()->LoadContext( |
85 access.immutable()); | 85 0, access.index(), access.immutable()); |
86 node->set_op(op); | 86 node->set_op(op); |
87 Handle<Object> context_handle = Handle<Object>(context, info_->isolate()); | 87 Handle<Object> context_handle = Handle<Object>(context, info_->isolate()); |
88 node->ReplaceInput(0, jsgraph_->Constant(context_handle)); | 88 node->ReplaceInput(0, jsgraph_->Constant(context_handle)); |
89 return Reducer::Changed(node); | 89 return Reducer::Changed(node); |
90 } | 90 } |
91 Handle<Object> value = | 91 Handle<Object> value = |
92 Handle<Object>(context->get(access.index()), info_->isolate()); | 92 Handle<Object>(context->get(access.index()), info_->isolate()); |
93 | 93 |
94 // Even though the context slot is immutable, the context might have escaped | 94 // Even though the context slot is immutable, the context might have escaped |
95 // before the function to which it belongs has initialized the slot. | 95 // before the function to which it belongs has initialized the slot. |
(...skipping 25 matching lines...) Expand all Loading... |
121 if (access.depth() == 0) { | 121 if (access.depth() == 0) { |
122 return Reducer::NoChange(); | 122 return Reducer::NoChange(); |
123 } | 123 } |
124 | 124 |
125 // Find the right parent context. | 125 // Find the right parent context. |
126 Context* context = *m.Value().handle(); | 126 Context* context = *m.Value().handle(); |
127 for (int i = access.depth(); i > 0; --i) { | 127 for (int i = access.depth(); i > 0; --i) { |
128 context = context->previous(); | 128 context = context->previous(); |
129 } | 129 } |
130 | 130 |
131 Operator* op = jsgraph_->javascript()->StoreContext(0, access.index()); | 131 const Operator* op = jsgraph_->javascript()->StoreContext(0, access.index()); |
132 node->set_op(op); | 132 node->set_op(op); |
133 Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate()); | 133 Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate()); |
134 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); | 134 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); |
135 | 135 |
136 return Reducer::Changed(node); | 136 return Reducer::Changed(node); |
137 } | 137 } |
138 } | 138 |
139 } | 139 } // namespace compiler |
140 } // namespace v8::internal::compiler | 140 } // namespace internal |
| 141 } // namespace v8 |
OLD | NEW |