| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-create-lowering.h" | 5 #include "src/compiler/js-create-lowering.h" |
| 6 | 6 |
| 7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
| 8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
| 9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
| 10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 return Replace(value); | 863 return Replace(value); |
| 864 } | 864 } |
| 865 } | 865 } |
| 866 } | 866 } |
| 867 | 867 |
| 868 return NoChange(); | 868 return NoChange(); |
| 869 } | 869 } |
| 870 | 870 |
| 871 Reduction JSCreateLowering::ReduceJSCreateFunctionContext(Node* node) { | 871 Reduction JSCreateLowering::ReduceJSCreateFunctionContext(Node* node) { |
| 872 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, node->opcode()); | 872 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, node->opcode()); |
| 873 int slot_count = OpParameter<int>(node->op()); | 873 const CreateFunctionContextParameters& parameters = |
| 874 CreateFunctionContextParametersOf(node->op()); |
| 875 int slot_count = parameters.slot_count(); |
| 876 ScopeType scope_type = parameters.scope_type(); |
| 874 Node* const closure = NodeProperties::GetValueInput(node, 0); | 877 Node* const closure = NodeProperties::GetValueInput(node, 0); |
| 875 | 878 |
| 876 // Use inline allocation for function contexts up to a size limit. | 879 // Use inline allocation for function contexts up to a size limit. |
| 877 if (slot_count < kFunctionContextAllocationLimit) { | 880 if (slot_count < kFunctionContextAllocationLimit) { |
| 878 // JSCreateFunctionContext[slot_count < limit]](fun) | 881 // JSCreateFunctionContext[slot_count < limit]](fun) |
| 879 Node* effect = NodeProperties::GetEffectInput(node); | 882 Node* effect = NodeProperties::GetEffectInput(node); |
| 880 Node* control = NodeProperties::GetControlInput(node); | 883 Node* control = NodeProperties::GetControlInput(node); |
| 881 Node* context = NodeProperties::GetContextInput(node); | 884 Node* context = NodeProperties::GetContextInput(node); |
| 882 Node* extension = jsgraph()->TheHoleConstant(); | 885 Node* extension = jsgraph()->TheHoleConstant(); |
| 883 AllocationBuilder a(jsgraph(), effect, control); | 886 AllocationBuilder a(jsgraph(), effect, control); |
| 884 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. | 887 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 885 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; | 888 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; |
| 886 a.AllocateArray(context_length, factory()->function_context_map()); | 889 Handle<Map> map; |
| 890 switch (scope_type) { |
| 891 case EVAL_SCOPE: |
| 892 map = factory()->eval_context_map(); |
| 893 break; |
| 894 case FUNCTION_SCOPE: |
| 895 map = factory()->function_context_map(); |
| 896 break; |
| 897 default: |
| 898 UNREACHABLE(); |
| 899 } |
| 900 a.AllocateArray(context_length, map); |
| 887 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); | 901 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 888 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); | 902 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| 889 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); | 903 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
| 890 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), | 904 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), |
| 891 jsgraph()->HeapConstant(native_context())); | 905 jsgraph()->HeapConstant(native_context())); |
| 892 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { | 906 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
| 893 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); | 907 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); |
| 894 } | 908 } |
| 895 RelaxControls(node); | 909 RelaxControls(node); |
| 896 a.FinishAndChange(node); | 910 a.FinishAndChange(node); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 return jsgraph()->simplified(); | 1375 return jsgraph()->simplified(); |
| 1362 } | 1376 } |
| 1363 | 1377 |
| 1364 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1378 MachineOperatorBuilder* JSCreateLowering::machine() const { |
| 1365 return jsgraph()->machine(); | 1379 return jsgraph()->machine(); |
| 1366 } | 1380 } |
| 1367 | 1381 |
| 1368 } // namespace compiler | 1382 } // namespace compiler |
| 1369 } // namespace internal | 1383 } // namespace internal |
| 1370 } // namespace v8 | 1384 } // namespace v8 |
| OLD | NEW |