Commit c20e02e3 authored by ishell's avatar ishell Committed by Commit bot

[stubs] Turn CSA::FillFixedArrayWithHole() to CSA::FillFixedArrayWithValue().

Review-Url: https://codereview.chromium.org/2319563002
Cr-Commit-Position: refs/heads/master@{#39247}
parent fdb0f078
...@@ -1378,8 +1378,9 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, ...@@ -1378,8 +1378,9 @@ Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
elements, FixedArray::kLengthOffset, elements, FixedArray::kLengthOffset,
mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node)); mode == SMI_PARAMETERS ? capacity_node : SmiTag(capacity_node));
FillFixedArrayWithHole(kind, elements, IntPtrConstant(0), capacity_node, // Fill in the elements with holes.
mode); FillFixedArrayWithValue(kind, elements, IntPtrConstant(0), capacity_node,
Heap::kTheHoleValueRootIndex, mode);
return array; return array;
} }
...@@ -1407,18 +1408,19 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, ...@@ -1407,18 +1408,19 @@ Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
return array; return array;
} }
void CodeStubAssembler::FillFixedArrayWithHole(ElementsKind kind, void CodeStubAssembler::FillFixedArrayWithValue(
compiler::Node* array, ElementsKind kind, Node* array, Node* from_node, Node* to_node,
compiler::Node* from_node, Heap::RootListIndex value_root_index, ParameterMode mode) {
compiler::Node* to_node, bool is_double = IsFastDoubleElementsKind(kind);
ParameterMode mode) { DCHECK(value_root_index == Heap::kTheHoleValueRootIndex ||
int const first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; value_root_index == Heap::kUndefinedValueRootIndex);
Heap* heap = isolate()->heap(); DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex);
Node* hole = HeapConstant(Handle<HeapObject>(heap->the_hole_value())); STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32);
Node* double_hole = Node* double_hole =
Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32); Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32);
DCHECK_EQ(kHoleNanLower32, kHoleNanUpper32); Node* value = LoadRoot(value_root_index);
bool is_double = IsFastDoubleElementsKind(kind);
int const first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag;
int32_t to; int32_t to;
bool constant_to = ToInt32Constant(to_node, to); bool constant_to = ToInt32Constant(to_node, to);
int32_t from; int32_t from;
...@@ -1449,7 +1451,7 @@ void CodeStubAssembler::FillFixedArrayWithHole(ElementsKind kind, ...@@ -1449,7 +1451,7 @@ void CodeStubAssembler::FillFixedArrayWithHole(ElementsKind kind,
double_hole); double_hole);
} }
} else { } else {
StoreFixedArrayElement(array, Int32Constant(i), hole, StoreFixedArrayElement(array, Int32Constant(i), value,
SKIP_WRITE_BARRIER); SKIP_WRITE_BARRIER);
} }
} }
...@@ -1484,15 +1486,13 @@ void CodeStubAssembler::FillFixedArrayWithHole(ElementsKind kind, ...@@ -1484,15 +1486,13 @@ void CodeStubAssembler::FillFixedArrayWithHole(ElementsKind kind,
} else { } else {
StoreNoWriteBarrier(MachineRepresentation::kWord32, current.value(), StoreNoWriteBarrier(MachineRepresentation::kWord32, current.value(),
Int32Constant(first_element_offset), double_hole); Int32Constant(first_element_offset), double_hole);
StoreNoWriteBarrier( StoreNoWriteBarrier(MachineRepresentation::kWord32, current.value(),
MachineRepresentation::kWord32, Int32Constant(kPointerSize + first_element_offset),
IntPtrAdd(current.value(), double_hole);
Int32Constant(kPointerSize + first_element_offset)),
double_hole);
} }
} else { } else {
StoreNoWriteBarrier(MachineRepresentation::kTagged, current.value(), StoreNoWriteBarrier(MachineType::PointerRepresentation(), current.value(),
IntPtrConstant(first_element_offset), hole); IntPtrConstant(first_element_offset), value);
} }
Node* compare = WordNotEqual(current.value(), limit); Node* compare = WordNotEqual(current.value(), limit);
Branch(compare, &decrement, &done); Branch(compare, &decrement, &done);
...@@ -1600,7 +1600,8 @@ Node* CodeStubAssembler::CheckAndGrowElementsCapacity(Node* context, ...@@ -1600,7 +1600,8 @@ Node* CodeStubAssembler::CheckAndGrowElementsCapacity(Node* context,
Node* new_elements = AllocateFixedArray(kind, new_capacity, mode); Node* new_elements = AllocateFixedArray(kind, new_capacity, mode);
// Fill in the added capacity in the new store with holes. // Fill in the added capacity in the new store with holes.
FillFixedArrayWithHole(kind, new_elements, capacity, new_capacity, mode); FillFixedArrayWithValue(kind, new_elements, capacity, new_capacity,
Heap::kTheHoleValueRootIndex, mode);
// Copy the elements from the old elements store to the new. // Copy the elements from the old elements store to the new.
CopyFixedArrayElements(kind, elements, new_elements, capacity, CopyFixedArrayElements(kind, elements, new_elements, capacity,
...@@ -2876,7 +2877,7 @@ void CodeStubAssembler::TryLookupElement(Node* object, Node* map, ...@@ -2876,7 +2877,7 @@ void CodeStubAssembler::TryLookupElement(Node* object, Node* map,
GotoUnless(UintPtrLessThan(intptr_index, length), &if_oob); GotoUnless(UintPtrLessThan(intptr_index, length), &if_oob);
if (kPointerSize == kDoubleSize) { if (Is64()) {
Node* element = LoadFixedDoubleArrayElement( Node* element = LoadFixedDoubleArrayElement(
elements, intptr_index, MachineType::Uint64(), 0, INTPTR_PARAMETERS); elements, intptr_index, MachineType::Uint64(), 0, INTPTR_PARAMETERS);
Node* the_hole = Int64Constant(kHoleNanInt64); Node* the_hole = Int64Constant(kHoleNanInt64);
......
...@@ -298,10 +298,11 @@ class CodeStubAssembler : public compiler::CodeAssembler { ...@@ -298,10 +298,11 @@ class CodeStubAssembler : public compiler::CodeAssembler {
ParameterMode mode = INTEGER_PARAMETERS, ParameterMode mode = INTEGER_PARAMETERS,
AllocationFlags flags = kNone); AllocationFlags flags = kNone);
void FillFixedArrayWithHole(ElementsKind kind, compiler::Node* array, void FillFixedArrayWithValue(ElementsKind kind, compiler::Node* array,
compiler::Node* from_index, compiler::Node* from_index,
compiler::Node* to_index, compiler::Node* to_index,
ParameterMode mode = INTEGER_PARAMETERS); Heap::RootListIndex value_root_index,
ParameterMode mode = INTEGER_PARAMETERS);
void CopyFixedArrayElements( void CopyFixedArrayElements(
ElementsKind kind, compiler::Node* from_array, compiler::Node* to_array, ElementsKind kind, compiler::Node* from_array, compiler::Node* to_array,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment