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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 case IrOpcode::kJSCreate: | 203 case IrOpcode::kJSCreate: |
204 return ReduceJSCreate(node); | 204 return ReduceJSCreate(node); |
205 case IrOpcode::kJSCreateArguments: | 205 case IrOpcode::kJSCreateArguments: |
206 return ReduceJSCreateArguments(node); | 206 return ReduceJSCreateArguments(node); |
207 case IrOpcode::kJSCreateArray: | 207 case IrOpcode::kJSCreateArray: |
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::kJSCreateKeyValueArray: | |
214 return ReduceJSCreateKeyValueArray(node); | |
213 case IrOpcode::kJSCreateLiteralArray: | 215 case IrOpcode::kJSCreateLiteralArray: |
214 case IrOpcode::kJSCreateLiteralObject: | 216 case IrOpcode::kJSCreateLiteralObject: |
215 return ReduceJSCreateLiteral(node); | 217 return ReduceJSCreateLiteral(node); |
216 case IrOpcode::kJSCreateFunctionContext: | 218 case IrOpcode::kJSCreateFunctionContext: |
217 return ReduceJSCreateFunctionContext(node); | 219 return ReduceJSCreateFunctionContext(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: |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 jsgraph()->EmptyFixedArrayConstant()); | 716 jsgraph()->EmptyFixedArrayConstant()); |
715 a.Store(AccessBuilder::ForJSObjectElements(), | 717 a.Store(AccessBuilder::ForJSObjectElements(), |
716 jsgraph()->EmptyFixedArrayConstant()); | 718 jsgraph()->EmptyFixedArrayConstant()); |
717 a.Store(AccessBuilder::ForJSIteratorResultValue(), value); | 719 a.Store(AccessBuilder::ForJSIteratorResultValue(), value); |
718 a.Store(AccessBuilder::ForJSIteratorResultDone(), done); | 720 a.Store(AccessBuilder::ForJSIteratorResultDone(), done); |
719 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); | 721 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); |
720 a.FinishAndChange(node); | 722 a.FinishAndChange(node); |
721 return Changed(node); | 723 return Changed(node); |
722 } | 724 } |
723 | 725 |
726 Reduction JSCreateLowering::ReduceJSCreateKeyValueArray(Node* node) { | |
727 DCHECK_EQ(IrOpcode::kJSCreateKeyValueArray, node->opcode()); | |
728 Node* key = NodeProperties::GetValueInput(node, 0); | |
729 Node* value = NodeProperties::GetValueInput(node, 1); | |
730 Node* effect = NodeProperties::GetEffectInput(node); | |
731 | |
732 Node* fixed_array_map = | |
733 jsgraph()->HeapConstant(isolate()->factory()->fixed_array_map()); | |
734 Node* array_map = jsgraph()->HeapConstant( | |
735 handle(native_context()->js_array_fast_elements_map_index())); | |
736 Node* properties = jsgraph()->EmptyFixedArrayConstant(); | |
737 Node* length = jsgraph()->Constant(2); | |
738 | |
739 AllocationBuilder aa(jsgraph(), effect, graph()->start()); | |
740 aa.Allocate(FixedArray::SizeFor(2)); | |
Benedikt Meurer
2016/11/09 20:00:32
Nit: Use AllocateArray instead.
caitp
2016/11/09 20:55:24
Done.
| |
741 aa.Store(AccessBuilder::ForMap(), fixed_array_map); | |
742 aa.Store(AccessBuilder::ForFixedArrayLength(), length); | |
743 aa.Store(AccessBuilder::ForFixedArrayElement(FAST_ELEMENTS), | |
744 jsgraph()->Constant(0), key); | |
745 aa.Store(AccessBuilder::ForFixedArrayElement(FAST_ELEMENTS), | |
746 jsgraph()->Constant(1), value); | |
747 Node* elements = aa.Finish(); | |
748 | |
749 AllocationBuilder a(jsgraph(), elements, graph()->start()); | |
750 a.Allocate(JSArray::kSize); | |
751 a.Store(AccessBuilder::ForMap(), array_map); | |
752 a.Store(AccessBuilder::ForJSObjectProperties(), properties); | |
753 a.Store(AccessBuilder::ForJSObjectElements(), elements); | |
754 a.Store(AccessBuilder::ForJSArrayLength(FAST_ELEMENTS), length); | |
755 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); | |
756 a.FinishAndChange(node); | |
757 return Changed(node); | |
758 } | |
759 | |
724 Reduction JSCreateLowering::ReduceJSCreateLiteral(Node* node) { | 760 Reduction JSCreateLowering::ReduceJSCreateLiteral(Node* node) { |
725 DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray || | 761 DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray || |
726 node->opcode() == IrOpcode::kJSCreateLiteralObject); | 762 node->opcode() == IrOpcode::kJSCreateLiteralObject); |
727 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 763 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
728 Node* effect = NodeProperties::GetEffectInput(node); | 764 Node* effect = NodeProperties::GetEffectInput(node); |
729 Node* control = NodeProperties::GetControlInput(node); | 765 Node* control = NodeProperties::GetControlInput(node); |
730 | 766 |
731 Handle<LiteralsArray> literals_array; | 767 Handle<LiteralsArray> literals_array; |
732 if (GetSpecializationLiterals(node).ToHandle(&literals_array)) { | 768 if (GetSpecializationLiterals(node).ToHandle(&literals_array)) { |
733 Handle<Object> literal(literals_array->literal(p.index()), isolate()); | 769 Handle<Object> literal(literals_array->literal(p.index()), isolate()); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1252 return jsgraph()->simplified(); | 1288 return jsgraph()->simplified(); |
1253 } | 1289 } |
1254 | 1290 |
1255 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1291 MachineOperatorBuilder* JSCreateLowering::machine() const { |
1256 return jsgraph()->machine(); | 1292 return jsgraph()->machine(); |
1257 } | 1293 } |
1258 | 1294 |
1259 } // namespace compiler | 1295 } // namespace compiler |
1260 } // namespace internal | 1296 } // namespace internal |
1261 } // namespace v8 | 1297 } // namespace v8 |
OLD | NEW |