Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: src/compiler/js-create-lowering.cc

Issue 2821453002: [turbofan] Mark Array constructor calls as no-write if possible. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 a.Store(AccessBuilder::ForJSArrayLength(elements_kind), length); 591 a.Store(AccessBuilder::ForJSArrayLength(elements_kind), length);
592 RelaxControls(node); 592 RelaxControls(node);
593 a.FinishAndChange(node); 593 a.FinishAndChange(node);
594 return Changed(node); 594 return Changed(node);
595 } 595 }
596 596
597 Reduction JSCreateLowering::ReduceNewArrayToStubCall( 597 Reduction JSCreateLowering::ReduceNewArrayToStubCall(
598 Node* node, Handle<AllocationSite> site) { 598 Node* node, Handle<AllocationSite> site) {
599 CreateArrayParameters const& p = CreateArrayParametersOf(node->op()); 599 CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
600 int const arity = static_cast<int>(p.arity()); 600 int const arity = static_cast<int>(p.arity());
601 Node* target = NodeProperties::GetValueInput(node, 0);
602 Node* new_target = NodeProperties::GetValueInput(node, 1);
603 Type* new_target_type = NodeProperties::GetType(new_target);
601 604
602 ElementsKind elements_kind = site->GetElementsKind(); 605 ElementsKind elements_kind = site->GetElementsKind();
603 AllocationSiteOverrideMode override_mode = 606 AllocationSiteOverrideMode override_mode =
604 (AllocationSite::GetMode(elements_kind) == TRACK_ALLOCATION_SITE) 607 (AllocationSite::GetMode(elements_kind) == TRACK_ALLOCATION_SITE)
605 ? DISABLE_ALLOCATION_SITES 608 ? DISABLE_ALLOCATION_SITES
606 : DONT_OVERRIDE; 609 : DONT_OVERRIDE;
607 610
611 // The Array constructor can only trigger an observable side-effect
612 // if the new.target may be a proxy.
613 Operator::Properties const properties =
614 (new_target != target || new_target_type->Maybe(Type::Proxy()))
615 ? Operator::kNoDeopt
616 : Operator::kNoDeopt | Operator::kNoWrite;
617
608 if (arity == 0) { 618 if (arity == 0) {
609 ArrayNoArgumentConstructorStub stub(isolate(), elements_kind, 619 ArrayNoArgumentConstructorStub stub(isolate(), elements_kind,
610 override_mode); 620 override_mode);
611 CallDescriptor* desc = Linkage::GetStubCallDescriptor( 621 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
612 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 1, 622 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 1,
613 CallDescriptor::kNeedsFrameState); 623 CallDescriptor::kNeedsFrameState, properties);
614 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode())); 624 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
615 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site)); 625 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site));
616 node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(0)); 626 node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(0));
617 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant()); 627 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
618 NodeProperties::ChangeOp(node, common()->Call(desc)); 628 NodeProperties::ChangeOp(node, common()->Call(desc));
619 return Changed(node); 629 return Changed(node);
620 } else if (arity == 1) { 630 } else if (arity == 1) {
621 AllocationSiteOverrideMode override_mode = 631 AllocationSiteOverrideMode override_mode =
622 (AllocationSite::GetMode(elements_kind) == TRACK_ALLOCATION_SITE) 632 (AllocationSite::GetMode(elements_kind) == TRACK_ALLOCATION_SITE)
623 ? DISABLE_ALLOCATION_SITES 633 ? DISABLE_ALLOCATION_SITES
624 : DONT_OVERRIDE; 634 : DONT_OVERRIDE;
625 635
626 if (IsHoleyElementsKind(elements_kind)) { 636 if (IsHoleyElementsKind(elements_kind)) {
627 ArraySingleArgumentConstructorStub stub(isolate(), elements_kind, 637 ArraySingleArgumentConstructorStub stub(isolate(), elements_kind,
628 override_mode); 638 override_mode);
629 CallDescriptor* desc = Linkage::GetStubCallDescriptor( 639 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
630 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2, 640 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2,
631 CallDescriptor::kNeedsFrameState); 641 CallDescriptor::kNeedsFrameState, properties);
632 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode())); 642 node->ReplaceInput(0, jsgraph()->HeapConstant(stub.GetCode()));
633 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site)); 643 node->InsertInput(graph()->zone(), 2, jsgraph()->HeapConstant(site));
634 node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(1)); 644 node->InsertInput(graph()->zone(), 3, jsgraph()->Constant(1));
635 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant()); 645 node->InsertInput(graph()->zone(), 4, jsgraph()->UndefinedConstant());
636 NodeProperties::ChangeOp(node, common()->Call(desc)); 646 NodeProperties::ChangeOp(node, common()->Call(desc));
637 return Changed(node); 647 return Changed(node);
638 } 648 }
639 649
640 Node* effect = NodeProperties::GetEffectInput(node); 650 Node* effect = NodeProperties::GetEffectInput(node);
641 Node* control = NodeProperties::GetControlInput(node); 651 Node* control = NodeProperties::GetControlInput(node);
642 Node* length = NodeProperties::GetValueInput(node, 2); 652 Node* length = NodeProperties::GetValueInput(node, 2);
643 Node* equal = graph()->NewNode(simplified()->ReferenceEqual(), length, 653 Node* equal = graph()->NewNode(simplified()->ReferenceEqual(), length,
644 jsgraph()->ZeroConstant()); 654 jsgraph()->ZeroConstant());
645 655
646 Node* branch = 656 Node* branch =
647 graph()->NewNode(common()->Branch(BranchHint::kFalse), equal, control); 657 graph()->NewNode(common()->Branch(BranchHint::kFalse), equal, control);
648 Node* call_holey; 658 Node* call_holey;
649 Node* call_packed; 659 Node* call_packed;
650 Node* context = NodeProperties::GetContextInput(node); 660 Node* context = NodeProperties::GetContextInput(node);
651 Node* frame_state = NodeProperties::GetFrameStateInput(node); 661 Node* frame_state = NodeProperties::GetFrameStateInput(node);
652 Node* if_equal = graph()->NewNode(common()->IfTrue(), branch); 662 Node* if_equal = graph()->NewNode(common()->IfTrue(), branch);
653 { 663 {
654 ArraySingleArgumentConstructorStub stub(isolate(), elements_kind, 664 ArraySingleArgumentConstructorStub stub(isolate(), elements_kind,
655 override_mode); 665 override_mode);
656 CallDescriptor* desc = Linkage::GetStubCallDescriptor( 666 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
657 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2, 667 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2,
658 CallDescriptor::kNeedsFrameState); 668 CallDescriptor::kNeedsFrameState, properties);
659 669
660 Node* inputs[] = {jsgraph()->HeapConstant(stub.GetCode()), 670 Node* inputs[] = {jsgraph()->HeapConstant(stub.GetCode()),
661 node->InputAt(1), 671 node->InputAt(1),
662 jsgraph()->HeapConstant(site), 672 jsgraph()->HeapConstant(site),
663 jsgraph()->Constant(1), 673 jsgraph()->Constant(1),
664 jsgraph()->UndefinedConstant(), 674 jsgraph()->UndefinedConstant(),
665 length, 675 length,
666 context, 676 context,
667 frame_state, 677 frame_state,
668 effect, 678 effect,
669 if_equal}; 679 if_equal};
670 680
671 call_holey = 681 call_holey =
672 graph()->NewNode(common()->Call(desc), arraysize(inputs), inputs); 682 graph()->NewNode(common()->Call(desc), arraysize(inputs), inputs);
673 } 683 }
674 Node* if_not_equal = graph()->NewNode(common()->IfFalse(), branch); 684 Node* if_not_equal = graph()->NewNode(common()->IfFalse(), branch);
675 { 685 {
676 // Require elements kind to "go holey." 686 // Require elements kind to "go holey."
677 ArraySingleArgumentConstructorStub stub( 687 ArraySingleArgumentConstructorStub stub(
678 isolate(), GetHoleyElementsKind(elements_kind), override_mode); 688 isolate(), GetHoleyElementsKind(elements_kind), override_mode);
679 CallDescriptor* desc = Linkage::GetStubCallDescriptor( 689 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
680 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2, 690 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 2,
681 CallDescriptor::kNeedsFrameState); 691 CallDescriptor::kNeedsFrameState, properties);
682 692
683 Node* inputs[] = {jsgraph()->HeapConstant(stub.GetCode()), 693 Node* inputs[] = {jsgraph()->HeapConstant(stub.GetCode()),
684 node->InputAt(1), 694 node->InputAt(1),
685 jsgraph()->HeapConstant(site), 695 jsgraph()->HeapConstant(site),
686 jsgraph()->Constant(1), 696 jsgraph()->Constant(1),
687 jsgraph()->UndefinedConstant(), 697 jsgraph()->UndefinedConstant(),
688 length, 698 length,
689 context, 699 context,
690 frame_state, 700 frame_state,
691 effect, 701 effect,
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 return jsgraph()->simplified(); 1345 return jsgraph()->simplified();
1336 } 1346 }
1337 1347
1338 MachineOperatorBuilder* JSCreateLowering::machine() const { 1348 MachineOperatorBuilder* JSCreateLowering::machine() const {
1339 return jsgraph()->machine(); 1349 return jsgraph()->machine();
1340 } 1350 }
1341 1351
1342 } // namespace compiler 1352 } // namespace compiler
1343 } // namespace internal 1353 } // namespace internal
1344 } // namespace v8 1354 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698