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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2321543003: [stubs] CSA::LoadFixedDoubleArrayElement() is now able to do a hole check. (Closed)
Patch Set: Created 4 years, 3 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/code-stub-assembler.h ('k') | src/machine-type.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 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/code-stub-assembler.h" 5 #include "src/code-stub-assembler.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/frames-inl.h" 7 #include "src/frames-inl.h"
8 #include "src/frames.h" 8 #include "src/frames.h"
9 #include "src/ic/handler-configuration.h" 9 #include "src/ic/handler-configuration.h"
10 #include "src/ic/stub-cache.h" 10 #include "src/ic/stub-cache.h"
(...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 parameter_mode, header_size); 1132 parameter_mode, header_size);
1133 if (Is64()) { 1133 if (Is64()) {
1134 return Load(MachineType::Int32(), object, offset); 1134 return Load(MachineType::Int32(), object, offset);
1135 } else { 1135 } else {
1136 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset)); 1136 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset));
1137 } 1137 }
1138 } 1138 }
1139 1139
1140 Node* CodeStubAssembler::LoadFixedDoubleArrayElement( 1140 Node* CodeStubAssembler::LoadFixedDoubleArrayElement(
1141 Node* object, Node* index_node, MachineType machine_type, 1141 Node* object, Node* index_node, MachineType machine_type,
1142 int additional_offset, ParameterMode parameter_mode) { 1142 int additional_offset, ParameterMode parameter_mode, Label* if_hole) {
1143 int32_t header_size = 1143 int32_t header_size =
1144 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; 1144 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag;
1145 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS, 1145 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS,
1146 parameter_mode, header_size); 1146 parameter_mode, header_size);
1147 return Load(machine_type, object, offset); 1147 return LoadDoubleWithHoleCheck(object, offset, if_hole, machine_type);
1148 }
1149
1150 Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset,
1151 Label* if_hole,
1152 MachineType machine_type) {
1153 if (if_hole) {
1154 Node* element_upper =
1155 Load(MachineType::Uint32(), base,
1156 IntPtrAdd(offset, IntPtrConstant(kIeeeDoubleExponentWordOffset)));
1157 GotoIf(Word32Equal(element_upper, Int32Constant(kHoleNanUpper32)), if_hole);
1158 }
1159 if (machine_type.IsNone()) {
1160 // This means the actual value is not needed.
1161 return nullptr;
1162 }
1163 return Load(machine_type, base, offset);
1148 } 1164 }
1149 1165
1150 Node* CodeStubAssembler::LoadNativeContext(Node* context) { 1166 Node* CodeStubAssembler::LoadNativeContext(Node* context) {
1151 return LoadFixedArrayElement(context, 1167 return LoadFixedArrayElement(context,
1152 IntPtrConstant(Context::NATIVE_CONTEXT_INDEX)); 1168 IntPtrConstant(Context::NATIVE_CONTEXT_INDEX));
1153 } 1169 }
1154 1170
1155 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, 1171 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind,
1156 Node* native_context) { 1172 Node* native_context) {
1157 return LoadFixedArrayElement(native_context, 1173 return LoadFixedArrayElement(native_context,
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 Heap::RootListIndex value_root_index, ParameterMode mode) { 1423 Heap::RootListIndex value_root_index, ParameterMode mode) {
1408 bool is_double = IsFastDoubleElementsKind(kind); 1424 bool is_double = IsFastDoubleElementsKind(kind);
1409 DCHECK(value_root_index == Heap::kTheHoleValueRootIndex || 1425 DCHECK(value_root_index == Heap::kTheHoleValueRootIndex ||
1410 value_root_index == Heap::kUndefinedValueRootIndex); 1426 value_root_index == Heap::kUndefinedValueRootIndex);
1411 DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex); 1427 DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex);
1412 STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32); 1428 STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32);
1413 Node* double_hole = 1429 Node* double_hole =
1414 Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32); 1430 Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32);
1415 Node* value = LoadRoot(value_root_index); 1431 Node* value = LoadRoot(value_root_index);
1416 1432
1417 int const first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; 1433 const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag;
1418 int32_t to; 1434 int32_t to;
1419 bool constant_to = ToInt32Constant(to_node, to); 1435 bool constant_to = ToInt32Constant(to_node, to);
1420 int32_t from; 1436 int32_t from;
1421 bool constant_from = ToInt32Constant(from_node, from); 1437 bool constant_from = ToInt32Constant(from_node, from);
1422 if (constant_to && constant_from && 1438 if (constant_to && constant_from &&
1423 (to - from) <= kElementLoopUnrollThreshold) { 1439 (to - from) <= kElementLoopUnrollThreshold) {
1424 for (int i = from; i < to; ++i) { 1440 for (int i = from; i < to; ++i) {
1425 Node* index = IntPtrConstant(i); 1441 Node* index = IntPtrConstant(i);
1426 if (is_double) { 1442 if (is_double) {
1427 Node* offset = ElementOffsetFromIndex(index, kind, INTPTR_PARAMETERS, 1443 Node* offset = ElementOffsetFromIndex(index, kind, INTPTR_PARAMETERS,
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
2889 Node* the_hole = TheHoleConstant(); 2905 Node* the_hole = TheHoleConstant();
2890 Branch(WordEqual(element, the_hole), if_not_found, if_found); 2906 Branch(WordEqual(element, the_hole), if_not_found, if_found);
2891 } 2907 }
2892 Bind(&if_isdouble); 2908 Bind(&if_isdouble);
2893 { 2909 {
2894 Node* elements = LoadElements(object); 2910 Node* elements = LoadElements(object);
2895 Node* length = LoadAndUntagFixedArrayBaseLength(elements); 2911 Node* length = LoadAndUntagFixedArrayBaseLength(elements);
2896 2912
2897 GotoUnless(UintPtrLessThan(intptr_index, length), &if_oob); 2913 GotoUnless(UintPtrLessThan(intptr_index, length), &if_oob);
2898 2914
2899 if (Is64()) { 2915 // Check if the element is a double hole, but don't load it.
2900 Node* element = LoadFixedDoubleArrayElement( 2916 LoadFixedDoubleArrayElement(elements, intptr_index, MachineType::None(), 0,
2901 elements, intptr_index, MachineType::Uint64(), 0, INTPTR_PARAMETERS); 2917 INTPTR_PARAMETERS, if_not_found);
2902 Node* the_hole = Int64Constant(kHoleNanInt64); 2918 Goto(if_found);
2903 Branch(Word64Equal(element, the_hole), if_not_found, if_found);
2904 } else {
2905 Node* element_upper = LoadFixedDoubleArrayElement(
2906 elements, intptr_index, MachineType::Uint32(),
2907 kIeeeDoubleExponentWordOffset, INTPTR_PARAMETERS);
2908 Branch(Word32Equal(element_upper, Int32Constant(kHoleNanUpper32)),
2909 if_not_found, if_found);
2910 }
2911 } 2919 }
2912 Bind(&if_isdictionary); 2920 Bind(&if_isdictionary);
2913 { 2921 {
2914 Variable var_entry(this, MachineType::PointerRepresentation()); 2922 Variable var_entry(this, MachineType::PointerRepresentation());
2915 Node* elements = LoadElements(object); 2923 Node* elements = LoadElements(object);
2916 NumberDictionaryLookup<SeededNumberDictionary>( 2924 NumberDictionaryLookup<SeededNumberDictionary>(
2917 elements, intptr_index, if_found, &var_entry, if_not_found); 2925 elements, intptr_index, if_found, &var_entry, if_not_found);
2918 } 2926 }
2919 Bind(&if_isfaststringwrapper); 2927 Bind(&if_isfaststringwrapper);
2920 { 2928 {
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
3586 { 3594 {
3587 Comment("packed double elements"); 3595 Comment("packed double elements");
3588 var_double_value->Bind(LoadFixedDoubleArrayElement( 3596 var_double_value->Bind(LoadFixedDoubleArrayElement(
3589 elements, intptr_index, MachineType::Float64(), 0, INTPTR_PARAMETERS)); 3597 elements, intptr_index, MachineType::Float64(), 0, INTPTR_PARAMETERS));
3590 Goto(rebox_double); 3598 Goto(rebox_double);
3591 } 3599 }
3592 3600
3593 Bind(&if_fast_holey_double); 3601 Bind(&if_fast_holey_double);
3594 { 3602 {
3595 Comment("holey double elements"); 3603 Comment("holey double elements");
3596 if (kPointerSize == kDoubleSize) { 3604 Node* value = LoadFixedDoubleArrayElement(elements, intptr_index,
3597 Node* raw_element = LoadFixedDoubleArrayElement( 3605 MachineType::Float64(), 0,
3598 elements, intptr_index, MachineType::Uint64(), 0, INTPTR_PARAMETERS); 3606 INTPTR_PARAMETERS, if_hole);
3599 Node* the_hole = Int64Constant(kHoleNanInt64); 3607 var_double_value->Bind(value);
3600 GotoIf(Word64Equal(raw_element, the_hole), if_hole);
3601 } else {
3602 Node* element_upper = LoadFixedDoubleArrayElement(
3603 elements, intptr_index, MachineType::Uint32(),
3604 kIeeeDoubleExponentWordOffset, INTPTR_PARAMETERS);
3605 GotoIf(Word32Equal(element_upper, Int32Constant(kHoleNanUpper32)),
3606 if_hole);
3607 }
3608 var_double_value->Bind(LoadFixedDoubleArrayElement(
3609 elements, intptr_index, MachineType::Float64(), 0, INTPTR_PARAMETERS));
3610 Goto(rebox_double); 3608 Goto(rebox_double);
3611 } 3609 }
3612 3610
3613 Bind(&if_nonfast); 3611 Bind(&if_nonfast);
3614 { 3612 {
3615 STATIC_ASSERT(LAST_ELEMENTS_KIND == LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND); 3613 STATIC_ASSERT(LAST_ELEMENTS_KIND == LAST_FIXED_TYPED_ARRAY_ELEMENTS_KIND);
3616 GotoIf(IntPtrGreaterThanOrEqual( 3614 GotoIf(IntPtrGreaterThanOrEqual(
3617 elements_kind, 3615 elements_kind,
3618 IntPtrConstant(FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND)), 3616 IntPtrConstant(FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND)),
3619 &if_typed_array); 3617 &if_typed_array);
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
4207 Heap::kTheHoleValueRootIndex); 4205 Heap::kTheHoleValueRootIndex);
4208 4206
4209 // Store the WeakCell in the feedback vector. 4207 // Store the WeakCell in the feedback vector.
4210 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 4208 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
4211 CodeStubAssembler::SMI_PARAMETERS); 4209 CodeStubAssembler::SMI_PARAMETERS);
4212 return cell; 4210 return cell;
4213 } 4211 }
4214 4212
4215 } // namespace internal 4213 } // namespace internal
4216 } // namespace v8 4214 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/machine-type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698