| 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* array_map = jsgraph()->HeapConstant( |
| 733 handle(native_context()->js_array_fast_elements_map_index())); |
| 734 Node* properties = jsgraph()->EmptyFixedArrayConstant(); |
| 735 Node* length = jsgraph()->Constant(2); |
| 736 |
| 737 AllocationBuilder aa(jsgraph(), effect, graph()->start()); |
| 738 aa.AllocateArray(2, factory()->fixed_array_map()); |
| 739 aa.Store(AccessBuilder::ForFixedArrayElement(FAST_ELEMENTS), |
| 740 jsgraph()->Constant(0), key); |
| 741 aa.Store(AccessBuilder::ForFixedArrayElement(FAST_ELEMENTS), |
| 742 jsgraph()->Constant(1), value); |
| 743 Node* elements = aa.Finish(); |
| 744 |
| 745 AllocationBuilder a(jsgraph(), elements, graph()->start()); |
| 746 a.Allocate(JSArray::kSize); |
| 747 a.Store(AccessBuilder::ForMap(), array_map); |
| 748 a.Store(AccessBuilder::ForJSObjectProperties(), properties); |
| 749 a.Store(AccessBuilder::ForJSObjectElements(), elements); |
| 750 a.Store(AccessBuilder::ForJSArrayLength(FAST_ELEMENTS), length); |
| 751 STATIC_ASSERT(JSArray::kSize == 4 * kPointerSize); |
| 752 a.FinishAndChange(node); |
| 753 return Changed(node); |
| 754 } |
| 755 |
| 724 Reduction JSCreateLowering::ReduceJSCreateLiteral(Node* node) { | 756 Reduction JSCreateLowering::ReduceJSCreateLiteral(Node* node) { |
| 725 DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray || | 757 DCHECK(node->opcode() == IrOpcode::kJSCreateLiteralArray || |
| 726 node->opcode() == IrOpcode::kJSCreateLiteralObject); | 758 node->opcode() == IrOpcode::kJSCreateLiteralObject); |
| 727 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); | 759 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op()); |
| 728 Node* effect = NodeProperties::GetEffectInput(node); | 760 Node* effect = NodeProperties::GetEffectInput(node); |
| 729 Node* control = NodeProperties::GetControlInput(node); | 761 Node* control = NodeProperties::GetControlInput(node); |
| 730 | 762 |
| 731 Handle<LiteralsArray> literals_array; | 763 Handle<LiteralsArray> literals_array; |
| 732 if (GetSpecializationLiterals(node).ToHandle(&literals_array)) { | 764 if (GetSpecializationLiterals(node).ToHandle(&literals_array)) { |
| 733 Handle<Object> literal(literals_array->literal(p.index()), isolate()); | 765 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(); | 1284 return jsgraph()->simplified(); |
| 1253 } | 1285 } |
| 1254 | 1286 |
| 1255 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1287 MachineOperatorBuilder* JSCreateLowering::machine() const { |
| 1256 return jsgraph()->machine(); | 1288 return jsgraph()->machine(); |
| 1257 } | 1289 } |
| 1258 | 1290 |
| 1259 } // namespace compiler | 1291 } // namespace compiler |
| 1260 } // namespace internal | 1292 } // namespace internal |
| 1261 } // namespace v8 | 1293 } // namespace v8 |
| OLD | NEW |