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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 541 } |
542 | 542 |
543 return NoChange(); | 543 return NoChange(); |
544 } | 544 } |
545 | 545 |
546 Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { | 546 Reduction JSCreateLowering::ReduceJSCreateClosure(Node* node) { |
547 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); | 547 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); |
548 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); | 548 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); |
549 Handle<SharedFunctionInfo> shared = p.shared_info(); | 549 Handle<SharedFunctionInfo> shared = p.shared_info(); |
550 | 550 |
551 // Use inline allocation for functions that don't need literals cloning. | 551 Node* effect = NodeProperties::GetEffectInput(node); |
552 if (shared->num_literals() == 0) { | 552 Node* control = NodeProperties::GetControlInput(node); |
553 Node* effect = NodeProperties::GetEffectInput(node); | 553 Node* context = NodeProperties::GetContextInput(node); |
554 Node* control = NodeProperties::GetControlInput(node); | 554 Node* native_context = effect = graph()->NewNode( |
555 Node* context = NodeProperties::GetContextInput(node); | 555 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), |
556 Node* native_context = effect = graph()->NewNode( | 556 context, context, effect); |
557 javascript()->LoadContext(0, Context::NATIVE_CONTEXT_INDEX, true), | 557 int function_map_index = |
558 context, context, effect); | 558 Context::FunctionMapIndex(shared->language_mode(), shared->kind()); |
559 int function_map_index = | 559 Node* function_map = effect = |
560 Context::FunctionMapIndex(shared->language_mode(), shared->kind()); | 560 graph()->NewNode(javascript()->LoadContext(0, function_map_index, true), |
561 Node* function_map = effect = | 561 native_context, native_context, effect); |
562 graph()->NewNode(javascript()->LoadContext(0, function_map_index, true), | 562 // Note that it is only safe to embed the raw entry point of the compile |
563 native_context, native_context, effect); | 563 // lazy stub into the code, because that stub is immortal and immovable. |
564 // Note that it is only safe to embed the raw entry point of the compile | 564 Node* compile_entry = jsgraph()->IntPtrConstant(reinterpret_cast<intptr_t>( |
565 // lazy stub into the code, because that stub is immortal and immovable. | 565 jsgraph()->isolate()->builtins()->CompileLazy()->entry())); |
566 Node* compile_entry = jsgraph()->IntPtrConstant(reinterpret_cast<intptr_t>( | 566 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant(); |
567 jsgraph()->isolate()->builtins()->CompileLazy()->entry())); | 567 Node* empty_literals_array = jsgraph()->EmptyLiteralsArrayConstant(); |
568 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant(); | 568 Node* the_hole = jsgraph()->TheHoleConstant(); |
569 Node* the_hole = jsgraph()->TheHoleConstant(); | 569 Node* undefined = jsgraph()->UndefinedConstant(); |
570 Node* undefined = jsgraph()->UndefinedConstant(); | 570 AllocationBuilder a(jsgraph(), effect, control); |
571 AllocationBuilder a(jsgraph(), effect, control); | 571 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize); |
572 STATIC_ASSERT(JSFunction::kSize == 9 * kPointerSize); | 572 a.Allocate(JSFunction::kSize, p.pretenure()); |
573 a.Allocate(JSFunction::kSize, p.pretenure()); | 573 a.Store(AccessBuilder::ForMap(), function_map); |
574 a.Store(AccessBuilder::ForMap(), function_map); | 574 a.Store(AccessBuilder::ForJSObjectProperties(), empty_fixed_array); |
575 a.Store(AccessBuilder::ForJSObjectProperties(), empty_fixed_array); | 575 a.Store(AccessBuilder::ForJSObjectElements(), empty_fixed_array); |
576 a.Store(AccessBuilder::ForJSObjectElements(), empty_fixed_array); | 576 a.Store(AccessBuilder::ForJSFunctionLiterals(), empty_literals_array); |
577 a.Store(AccessBuilder::ForJSFunctionLiterals(), empty_fixed_array); | 577 a.Store(AccessBuilder::ForJSFunctionPrototypeOrInitialMap(), the_hole); |
578 a.Store(AccessBuilder::ForJSFunctionPrototypeOrInitialMap(), the_hole); | 578 a.Store(AccessBuilder::ForJSFunctionSharedFunctionInfo(), shared); |
579 a.Store(AccessBuilder::ForJSFunctionSharedFunctionInfo(), shared); | 579 a.Store(AccessBuilder::ForJSFunctionContext(), context); |
580 a.Store(AccessBuilder::ForJSFunctionContext(), context); | 580 a.Store(AccessBuilder::ForJSFunctionCodeEntry(), compile_entry); |
581 a.Store(AccessBuilder::ForJSFunctionCodeEntry(), compile_entry); | 581 a.Store(AccessBuilder::ForJSFunctionNextFunctionLink(), undefined); |
582 a.Store(AccessBuilder::ForJSFunctionNextFunctionLink(), undefined); | 582 RelaxControls(node); |
583 RelaxControls(node); | 583 a.FinishAndChange(node); |
584 a.FinishAndChange(node); | 584 return Changed(node); |
585 return Changed(node); | |
586 } | |
587 | |
588 return NoChange(); | |
589 } | 585 } |
590 | 586 |
591 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) { | 587 Reduction JSCreateLowering::ReduceJSCreateIterResultObject(Node* node) { |
592 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode()); | 588 DCHECK_EQ(IrOpcode::kJSCreateIterResultObject, node->opcode()); |
593 Node* value = NodeProperties::GetValueInput(node, 0); | 589 Node* value = NodeProperties::GetValueInput(node, 0); |
594 Node* done = NodeProperties::GetValueInput(node, 1); | 590 Node* done = NodeProperties::GetValueInput(node, 1); |
595 Node* context = NodeProperties::GetContextInput(node); | 591 Node* context = NodeProperties::GetContextInput(node); |
596 Node* effect = NodeProperties::GetEffectInput(node); | 592 Node* effect = NodeProperties::GetEffectInput(node); |
597 | 593 |
598 // Load the JSIteratorResult map for the {context}. | 594 // Load the JSIteratorResult map for the {context}. |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 return jsgraph()->simplified(); | 1127 return jsgraph()->simplified(); |
1132 } | 1128 } |
1133 | 1129 |
1134 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1130 MachineOperatorBuilder* JSCreateLowering::machine() const { |
1135 return jsgraph()->machine(); | 1131 return jsgraph()->machine(); |
1136 } | 1132 } |
1137 | 1133 |
1138 } // namespace compiler | 1134 } // namespace compiler |
1139 } // namespace internal | 1135 } // namespace internal |
1140 } // namespace v8 | 1136 } // namespace v8 |
OLD | NEW |