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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 return ReduceJSCreateArray(node); | 208 return ReduceJSCreateArray(node); |
209 case IrOpcode::kJSCreateClosure: | 209 case IrOpcode::kJSCreateClosure: |
210 return ReduceJSCreateClosure(node); | 210 return ReduceJSCreateClosure(node); |
211 case IrOpcode::kJSCreateIterResultObject: | 211 case IrOpcode::kJSCreateIterResultObject: |
212 return ReduceJSCreateIterResultObject(node); | 212 return ReduceJSCreateIterResultObject(node); |
213 case IrOpcode::kJSCreateLiteralArray: | 213 case IrOpcode::kJSCreateLiteralArray: |
214 case IrOpcode::kJSCreateLiteralObject: | 214 case IrOpcode::kJSCreateLiteralObject: |
215 return ReduceJSCreateLiteral(node); | 215 return ReduceJSCreateLiteral(node); |
216 case IrOpcode::kJSCreateFunctionContext: | 216 case IrOpcode::kJSCreateFunctionContext: |
217 return ReduceJSCreateFunctionContext(node); | 217 return ReduceJSCreateFunctionContext(node); |
| 218 case IrOpcode::kJSCreateEvalContext: |
| 219 return ReduceJSCreateEvalContext(node); |
218 case IrOpcode::kJSCreateWithContext: | 220 case IrOpcode::kJSCreateWithContext: |
219 return ReduceJSCreateWithContext(node); | 221 return ReduceJSCreateWithContext(node); |
220 case IrOpcode::kJSCreateCatchContext: | 222 case IrOpcode::kJSCreateCatchContext: |
221 return ReduceJSCreateCatchContext(node); | 223 return ReduceJSCreateCatchContext(node); |
222 case IrOpcode::kJSCreateBlockContext: | 224 case IrOpcode::kJSCreateBlockContext: |
223 return ReduceJSCreateBlockContext(node); | 225 return ReduceJSCreateBlockContext(node); |
224 default: | 226 default: |
225 break; | 227 break; |
226 } | 228 } |
227 return NoChange(); | 229 return NoChange(); |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); | 778 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); |
777 } | 779 } |
778 RelaxControls(node); | 780 RelaxControls(node); |
779 a.FinishAndChange(node); | 781 a.FinishAndChange(node); |
780 return Changed(node); | 782 return Changed(node); |
781 } | 783 } |
782 | 784 |
783 return NoChange(); | 785 return NoChange(); |
784 } | 786 } |
785 | 787 |
| 788 Reduction JSCreateLowering::ReduceJSCreateEvalContext(Node* node) { |
| 789 DCHECK_EQ(IrOpcode::kJSCreateEvalContext, node->opcode()); |
| 790 int slot_count = OpParameter<int>(node->op()); |
| 791 Node* const closure = NodeProperties::GetValueInput(node, 0); |
| 792 |
| 793 // Use inline allocation for function contexts up to a size limit. |
| 794 if (slot_count < kFunctionContextAllocationLimit) { |
| 795 // JSCreateFunctionContext[slot_count < limit]](fun) |
| 796 Node* effect = NodeProperties::GetEffectInput(node); |
| 797 Node* control = NodeProperties::GetControlInput(node); |
| 798 Node* context = NodeProperties::GetContextInput(node); |
| 799 Node* extension = jsgraph()->TheHoleConstant(); |
| 800 AllocationBuilder a(jsgraph(), effect, control); |
| 801 STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == 4); // Ensure fully covered. |
| 802 int context_length = slot_count + Context::MIN_CONTEXT_SLOTS; |
| 803 a.AllocateArray(context_length, factory()->eval_context_map()); |
| 804 a.Store(AccessBuilder::ForContextSlot(Context::CLOSURE_INDEX), closure); |
| 805 a.Store(AccessBuilder::ForContextSlot(Context::PREVIOUS_INDEX), context); |
| 806 a.Store(AccessBuilder::ForContextSlot(Context::EXTENSION_INDEX), extension); |
| 807 a.Store(AccessBuilder::ForContextSlot(Context::NATIVE_CONTEXT_INDEX), |
| 808 jsgraph()->HeapConstant(native_context())); |
| 809 for (int i = Context::MIN_CONTEXT_SLOTS; i < context_length; ++i) { |
| 810 a.Store(AccessBuilder::ForContextSlot(i), jsgraph()->UndefinedConstant()); |
| 811 } |
| 812 RelaxControls(node); |
| 813 a.FinishAndChange(node); |
| 814 return Changed(node); |
| 815 } |
| 816 |
| 817 return NoChange(); |
| 818 } |
| 819 |
786 Reduction JSCreateLowering::ReduceJSCreateWithContext(Node* node) { | 820 Reduction JSCreateLowering::ReduceJSCreateWithContext(Node* node) { |
787 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); | 821 DCHECK_EQ(IrOpcode::kJSCreateWithContext, node->opcode()); |
788 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); | 822 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node); |
789 Node* object = NodeProperties::GetValueInput(node, 0); | 823 Node* object = NodeProperties::GetValueInput(node, 0); |
790 Node* closure = NodeProperties::GetValueInput(node, 1); | 824 Node* closure = NodeProperties::GetValueInput(node, 1); |
791 Node* effect = NodeProperties::GetEffectInput(node); | 825 Node* effect = NodeProperties::GetEffectInput(node); |
792 Node* control = NodeProperties::GetControlInput(node); | 826 Node* control = NodeProperties::GetControlInput(node); |
793 Node* context = NodeProperties::GetContextInput(node); | 827 Node* context = NodeProperties::GetContextInput(node); |
794 | 828 |
795 AllocationBuilder aa(jsgraph(), effect, control); | 829 AllocationBuilder aa(jsgraph(), effect, control); |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 return jsgraph()->simplified(); | 1286 return jsgraph()->simplified(); |
1253 } | 1287 } |
1254 | 1288 |
1255 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1289 MachineOperatorBuilder* JSCreateLowering::machine() const { |
1256 return jsgraph()->machine(); | 1290 return jsgraph()->machine(); |
1257 } | 1291 } |
1258 | 1292 |
1259 } // namespace compiler | 1293 } // namespace compiler |
1260 } // namespace internal | 1294 } // namespace internal |
1261 } // namespace v8 | 1295 } // namespace v8 |
OLD | NEW |