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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 node->TrimInputCount(2); | 1252 node->TrimInputCount(2); |
1253 NodeProperties::ChangeOp(node, common()->Finish(1)); | 1253 NodeProperties::ChangeOp(node, common()->Finish(1)); |
1254 return Changed(node); | 1254 return Changed(node); |
1255 } | 1255 } |
1256 return NoChange(); | 1256 return NoChange(); |
1257 } | 1257 } |
1258 | 1258 |
1259 | 1259 |
1260 Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { | 1260 Reduction JSTypedLowering::ReduceJSCreateBlockContext(Node* node) { |
1261 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); | 1261 DCHECK_EQ(IrOpcode::kJSCreateBlockContext, node->opcode()); |
1262 Node* const input = NodeProperties::GetValueInput(node, 0); | 1262 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
1263 HeapObjectMatcher minput(input); | 1263 int context_length = scope_info->ContextLength(); |
1264 DCHECK(minput.HasValue()); // TODO(mstarzinger): Make ScopeInfo static. | |
1265 int context_length = Handle<ScopeInfo>::cast(minput.Value())->ContextLength(); | |
1266 if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) { | 1264 if (FLAG_turbo_allocate && context_length < kBlockContextAllocationLimit) { |
1267 // JSCreateBlockContext(s:scope[length < limit], f) | 1265 // JSCreateBlockContext(s:scope[length < limit], f) |
1268 Node* const effect = NodeProperties::GetEffectInput(node); | 1266 Node* const effect = NodeProperties::GetEffectInput(node); |
1269 Node* const control = NodeProperties::GetControlInput(node); | 1267 Node* const control = NodeProperties::GetControlInput(node); |
1270 Node* const closure = NodeProperties::GetValueInput(node, 1); | 1268 Node* const closure = NodeProperties::GetValueInput(node, 1); |
1271 Node* const context = NodeProperties::GetContextInput(node); | 1269 Node* const context = NodeProperties::GetContextInput(node); |
| 1270 Node* const extension = jsgraph()->Constant(scope_info); |
1272 Node* const load = graph()->NewNode( | 1271 Node* const load = graph()->NewNode( |
1273 simplified()->LoadField( | 1272 simplified()->LoadField( |
1274 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), | 1273 AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)), |
1275 context, effect, control); | 1274 context, effect, control); |
1276 AllocationBuilder a(jsgraph(), simplified(), effect, control); | 1275 AllocationBuilder a(jsgraph(), simplified(), effect, control); |
1277 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 1276 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
1278 a.AllocateArray(context_length, factory()->block_context_map()); | 1277 a.AllocateArray(context_length, factory()->block_context_map()); |
1279 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 1278 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
1280 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 1279 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
1281 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), input); | 1280 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
1282 a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load); | 1281 a.Store(AccessBuilder::ForContextSlot(Context::GLOBAL_OBJECT_INDEX), load); |
1283 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { | 1282 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
1284 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant()); | 1283 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->TheHoleConstant()); |
1285 } | 1284 } |
1286 // TODO(mstarzinger): We could mutate {node} into the allocation instead. | 1285 // TODO(mstarzinger): We could mutate {node} into the allocation instead. |
1287 NodeProperties::SetType(a.allocation(), NodeProperties::GetType(node)); | 1286 NodeProperties::SetType(a.allocation(), NodeProperties::GetType(node)); |
1288 ReplaceWithValue(node, node, a.effect()); | 1287 ReplaceWithValue(node, node, a.effect()); |
1289 node->ReplaceInput(0, a.allocation()); | 1288 node->ReplaceInput(0, a.allocation()); |
1290 node->ReplaceInput(1, a.effect()); | 1289 node->ReplaceInput(1, a.effect()); |
1291 node->TrimInputCount(2); | 1290 node->TrimInputCount(2); |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 } | 1745 } |
1747 | 1746 |
1748 | 1747 |
1749 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1748 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1750 return jsgraph()->machine(); | 1749 return jsgraph()->machine(); |
1751 } | 1750 } |
1752 | 1751 |
1753 } // namespace compiler | 1752 } // namespace compiler |
1754 } // namespace internal | 1753 } // namespace internal |
1755 } // namespace v8 | 1754 } // namespace v8 |
OLD | NEW |