| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 NodeProperties::ChangeOp(node, op); | 63 NodeProperties::ChangeOp(node, op); |
| 64 return Changed(node); | 64 return Changed(node); |
| 65 } | 65 } |
| 66 Handle<Object> value = | 66 Handle<Object> value = |
| 67 handle(context->get(static_cast<int>(access.index())), isolate()); | 67 handle(context->get(static_cast<int>(access.index())), isolate()); |
| 68 | 68 |
| 69 // Even though the context slot is immutable, the context might have escaped | 69 // Even though the context slot is immutable, the context might have escaped |
| 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(isolate()) || value->IsTheHole(isolate())) { |
| 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 Node* constant = jsgraph_->Constant(value); | 80 Node* constant = jsgraph_->Constant(value); |
| 81 ReplaceWithValue(node, constant); | 81 ReplaceWithValue(node, constant); |
| 82 return Replace(constant); | 82 return Replace(constant); |
| 83 } | 83 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 JSOperatorBuilder* JSContextSpecialization::javascript() const { | 115 JSOperatorBuilder* JSContextSpecialization::javascript() const { |
| 116 return jsgraph()->javascript(); | 116 return jsgraph()->javascript(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 } // namespace compiler | 119 } // namespace compiler |
| 120 } // namespace internal | 120 } // namespace internal |
| 121 } // namespace v8 | 121 } // namespace v8 |
| OLD | NEW |