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