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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } // namespace | 194 } // namespace |
195 | 195 |
196 Reduction JSCreateLowering::Reduce(Node* node) { | 196 Reduction JSCreateLowering::Reduce(Node* node) { |
197 switch (node->opcode()) { | 197 switch (node->opcode()) { |
198 case IrOpcode::kJSCreate: | 198 case IrOpcode::kJSCreate: |
199 return ReduceJSCreate(node); | 199 return ReduceJSCreate(node); |
200 case IrOpcode::kJSCreateArguments: | 200 case IrOpcode::kJSCreateArguments: |
201 return ReduceJSCreateArguments(node); | 201 return ReduceJSCreateArguments(node); |
202 case IrOpcode::kJSCreateArray: | 202 case IrOpcode::kJSCreateArray: |
203 return ReduceJSCreateArray(node); | 203 return ReduceJSCreateArray(node); |
| 204 case IrOpcode::kJSCreateClosure: |
| 205 return ReduceJSCreateClosure(node); |
204 case IrOpcode::kJSCreateIterResultObject: | 206 case IrOpcode::kJSCreateIterResultObject: |
205 return ReduceJSCreateIterResultObject(node); | 207 return ReduceJSCreateIterResultObject(node); |
206 case IrOpcode::kJSCreateLiteralArray: | 208 case IrOpcode::kJSCreateLiteralArray: |
207 case IrOpcode::kJSCreateLiteralObject: | 209 case IrOpcode::kJSCreateLiteralObject: |
208 return ReduceJSCreateLiteral(node); | 210 return ReduceJSCreateLiteral(node); |
209 case IrOpcode::kJSCreateFunctionContext: | 211 case IrOpcode::kJSCreateFunctionContext: |
210 return ReduceJSCreateFunctionContext(node); | 212 return ReduceJSCreateFunctionContext(node); |
211 case IrOpcode::kJSCreateWithContext: | 213 case IrOpcode::kJSCreateWithContext: |
212 return ReduceJSCreateWithContext(node); | 214 return ReduceJSCreateWithContext(node); |
213 case IrOpcode::kJSCreateCatchContext: | 215 case IrOpcode::kJSCreateCatchContext: |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 length_type->Max() <= kElementLoopUnrollLimit) { | 535 length_type->Max() <= kElementLoopUnrollLimit) { |
534 int capacity = static_cast<int>(length_type->Max()); | 536 int capacity = static_cast<int>(length_type->Max()); |
535 return ReduceNewArray(node, length, capacity, site); | 537 return ReduceNewArray(node, length, capacity, site); |
536 } | 538 } |
537 } | 539 } |
538 } | 540 } |
539 | 541 |
540 return NoChange(); | 542 return NoChange(); |
541 } | 543 } |
542 | 544 |
| 545 Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { |
| 546 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); |
| 547 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); |
| 548 Handle<SharedFunctionInfo> shared = p.shared_info(); |
| 549 |
| 550 // Use inline allocation for functions that don't need literals cloning. |
| 551 if (shared->num_literals() == 0) { |
| 552 Node* effect = NodeProperties::GetEffectInput(node); |
| 553 Node* control = NodeProperties::GetControlInput(node); |
| 554 Node* context = NodeProperties::GetContextInput(node); |
| 555 Node* native_context = effect = graph()->NewNode( |
| 556 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
| 557 context, context, effect); |
| 558 int function_map_index = |
| 559 Context::FunctionMapIndex(shared->language_mode(), shared->kind()); |
| 560 Node* function_map = effect = |
| 561 graph()->NewNode(javascript()->LoadContext(0, function_map_index, true), |
| 562 native_context, native_context, effect); |
| 563 // Note that it is only safe to embed the raw entry point of the compile |
| 564 // lazy stub into the code, because that stub is immortal and immovable. |
| 565 Node* compile_entry = jsgraph()->IntPtrConstant(reinterpret_cast<intptr_t>( |
| 566 jsgraph()->isolate()->builtins()->CompileLazy()->entry())); |
| 567 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant(); |
| 568 Node* the_hole = jsgraph()->TheHoleConstant(); |
| 569 Node* undefined = jsgraph()->UndefinedConstant(); |
| 570 AllocationBuilder a(jsgraph(), effect, control); |
| 571 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize); |
| 572 a.Allocate(JSFunction::kSize, p.pretenure()); |
| 573 a.Store(AccessBuilder::ForMap(), function_map); |
| 574 a.Store(AccessBuilder::ForJSObjectProperties(), empty_fixed_array); |
| 575 a.Store(AccessBuilder::ForJSObjectElements(), empty_fixed_array); |
| 576 a.Store(AccessBuilder::ForJSFunctionLiterals(), empty_fixed_array); |
| 577 a.Store(AccessBuilder::ForJSFunctionPrototypeOrInitialMap(), the_hole); |
| 578 a.Store(AccessBuilder::ForJSFunctionSharedFunctionInfo(), shared); |
| 579 a.Store(AccessBuilder::ForJSFunctionContext(), context); |
| 580 a.Store(AccessBuilder::ForJSFunctionCodeEntry(), compile_entry); |
| 581 a.Store(AccessBuilder::ForJSFunctionNextFunctionLink(), undefined); |
| 582 RelaxControls(node); |
| 583 a.FinishAndChange(node); |
| 584 return Changed(node); |
| 585 } |
| 586 |
| 587 return NoChange(); |
| 588 } |
| 589 |
543 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) { | 590 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) { |
544 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode()); | 591 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode()); |
545 Node* value = NodeProperties::GetValueInput(node, 0); | 592 Node* value = NodeProperties::GetValueInput(node, 0); |
546 Node* done = NodeProperties::GetValueInput(node, 1); | 593 Node* done = NodeProperties::GetValueInput(node, 1); |
547 Node* context = NodeProperties::GetContextInput(node); | 594 Node* context = NodeProperties::GetContextInput(node); |
548 Node* effect = NodeProperties::GetEffectInput(node); | 595 Node* effect = NodeProperties::GetEffectInput(node); |
549 | 596 |
550 // Load the JSIteratorResult map for the {context}. | 597 // Load the JSIteratorResult map for the {context}. |
551 Node* native_context = effect = graph()->NewNode( | 598 Node* native_context = effect = graph()->NewNode( |
552 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 599 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 return jsgraph()->simplified(); | 1134 return jsgraph()->simplified(); |
1088 } | 1135 } |
1089 | 1136 |
1090 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1137 MachineOperatorBuilder* JSCreateLowering::machine() const { |
1091 return jsgraph()->machine(); | 1138 return jsgraph()->machine(); |
1092 } | 1139 } |
1093 | 1140 |
1094 } // namespace compiler | 1141 } // namespace compiler |
1095 } // namespace internal | 1142 } // namespace internal |
1096 } // namespace v8 | 1143 } // namespace v8 |
OLD | NEW |