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

Side by Side Diff: src/compiler/js-native-context-specialization.cc

Issue 2035893004: [turbofan] Introduce a dedicated CheckBounds operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 4 years, 6 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 | « src/compiler/effect-control-linearizer.cc ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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-native-context-specialization.h" 5 #include "src/compiler/js-native-context-specialization.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 transition_source->elements_kind(), 627 transition_source->elements_kind(),
628 transition_target->elements_kind()); 628 transition_target->elements_kind());
629 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor( 629 CallDescriptor const* const desc = Linkage::GetStubCallDescriptor(
630 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 0, 630 isolate(), graph()->zone(), stub.GetCallInterfaceDescriptor(), 0,
631 CallDescriptor::kNeedsFrameState, node->op()->properties()); 631 CallDescriptor::kNeedsFrameState, node->op()->properties());
632 transition_effect = graph()->NewNode( 632 transition_effect = graph()->NewNode(
633 common()->Call(desc), jsgraph()->HeapConstant(stub.GetCode()), 633 common()->Call(desc), jsgraph()->HeapConstant(stub.GetCode()),
634 receiver, jsgraph()->HeapConstant(transition_target), context, 634 receiver, jsgraph()->HeapConstant(transition_target), context,
635 frame_state, transition_effect, transition_control); 635 frame_state, transition_effect, transition_control);
636 } 636 }
637
637 this_controls.push_back(transition_control); 638 this_controls.push_back(transition_control);
638 this_effects.push_back(transition_effect); 639 this_effects.push_back(transition_effect);
639 } 640 }
640 641
641 // Create single chokepoint for the control. 642 // Create single chokepoint for the control.
642 int const this_control_count = static_cast<int>(this_controls.size()); 643 int const this_control_count = static_cast<int>(this_controls.size());
643 if (this_control_count == 1) { 644 if (this_control_count == 1) {
644 this_control = this_controls.front(); 645 this_control = this_controls.front();
645 this_effect = this_effects.front(); 646 this_effect = this_effects.front();
646 } else { 647 } else {
(...skipping 16 matching lines...) Expand all
663 } 664 }
664 665
665 // Certain stores need a prototype chain check because shape changes 666 // Certain stores need a prototype chain check because shape changes
666 // could allow callbacks on elements in the prototype chain that are 667 // could allow callbacks on elements in the prototype chain that are
667 // not compatible with (monomorphic) keyed stores. 668 // not compatible with (monomorphic) keyed stores.
668 Handle<JSObject> holder; 669 Handle<JSObject> holder;
669 if (access_info.holder().ToHandle(&holder)) { 670 if (access_info.holder().ToHandle(&holder)) {
670 AssumePrototypesStable(receiver_type, native_context, holder); 671 AssumePrototypesStable(receiver_type, native_context, holder);
671 } 672 }
672 673
673 // Check that the {index} is actually a Number.
674 if (!NumberMatcher(this_index).HasValue()) {
675 Node* check =
676 graph()->NewNode(simplified()->ObjectIsNumber(), this_index);
677 this_control = this_effect =
678 graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state,
679 this_effect, this_control);
680 this_index = graph()->NewNode(simplified()->TypeGuard(Type::Number()),
681 this_index, this_control);
682 }
683
684 // Convert the {index} to an unsigned32 value and check if the result is
685 // equal to the original {index}.
686 if (!NumberMatcher(this_index).IsInRange(0.0, kMaxUInt32)) {
687 Node* this_index32 =
688 graph()->NewNode(simplified()->NumberToUint32(), this_index);
689 Node* check = graph()->NewNode(simplified()->NumberEqual(), this_index32,
690 this_index);
691 this_control = this_effect =
692 graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state,
693 this_effect, this_control);
694 this_index = this_index32;
695 }
696
697 // TODO(bmeurer): We currently specialize based on elements kind. We should 674 // TODO(bmeurer): We currently specialize based on elements kind. We should
698 // also be able to properly support strings and other JSObjects here. 675 // also be able to properly support strings and other JSObjects here.
699 ElementsKind elements_kind = access_info.elements_kind(); 676 ElementsKind elements_kind = access_info.elements_kind();
700 677
701 // Load the elements for the {receiver}. 678 // Load the elements for the {receiver}.
702 Node* this_elements = this_effect = graph()->NewNode( 679 Node* this_elements = this_effect = graph()->NewNode(
703 simplified()->LoadField(AccessBuilder::ForJSObjectElements()), 680 simplified()->LoadField(AccessBuilder::ForJSObjectElements()),
704 this_receiver, this_effect, this_control); 681 this_receiver, this_effect, this_control);
705 682
706 // Don't try to store to a copy-on-write backing store. 683 // Don't try to store to a copy-on-write backing store.
(...skipping 15 matching lines...) Expand all
722 receiver_is_jsarray 699 receiver_is_jsarray
723 ? graph()->NewNode( 700 ? graph()->NewNode(
724 simplified()->LoadField( 701 simplified()->LoadField(
725 AccessBuilder::ForJSArrayLength(elements_kind)), 702 AccessBuilder::ForJSArrayLength(elements_kind)),
726 this_receiver, this_effect, this_control) 703 this_receiver, this_effect, this_control)
727 : graph()->NewNode( 704 : graph()->NewNode(
728 simplified()->LoadField(AccessBuilder::ForFixedArrayLength()), 705 simplified()->LoadField(AccessBuilder::ForFixedArrayLength()),
729 this_elements, this_effect, this_control); 706 this_elements, this_effect, this_control);
730 707
731 // Check that the {index} is in the valid range for the {receiver}. 708 // Check that the {index} is in the valid range for the {receiver}.
732 Node* check = graph()->NewNode(simplified()->NumberLessThan(), this_index, 709 this_index = this_effect =
733 this_length); 710 graph()->NewNode(simplified()->CheckBounds(), this_index, this_length,
734 this_control = this_effect =
735 graph()->NewNode(common()->DeoptimizeUnless(), check, frame_state,
736 this_effect, this_control); 711 this_effect, this_control);
737 712
738 // Compute the element access. 713 // Compute the element access.
739 Type* element_type = Type::Any(); 714 Type* element_type = Type::Any();
740 MachineType element_machine_type = MachineType::AnyTagged(); 715 MachineType element_machine_type = MachineType::AnyTagged();
741 if (IsFastDoubleElementsKind(elements_kind)) { 716 if (IsFastDoubleElementsKind(elements_kind)) {
742 element_type = Type::Number(); 717 element_type = Type::Number();
743 element_machine_type = MachineType::Float64(); 718 element_machine_type = MachineType::Float64();
744 } else if (IsFastSmiElementsKind(elements_kind)) { 719 } else if (IsFastSmiElementsKind(elements_kind)) {
745 element_type = type_cache_.kSmi; 720 element_type = type_cache_.kSmi;
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 } 1091 }
1117 1092
1118 1093
1119 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { 1094 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const {
1120 return jsgraph()->simplified(); 1095 return jsgraph()->simplified();
1121 } 1096 }
1122 1097
1123 } // namespace compiler 1098 } // namespace compiler
1124 } // namespace internal 1099 } // namespace internal
1125 } // namespace v8 1100 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/effect-control-linearizer.cc ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698