Commit f787bee6 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Benedikt Meurer

[cleanup] Simplify CodeStubAssembler::FillFixedArrayWithValue.

We can just use the same trick here that we use with TurboFan and load
the (signaling) NaN value out of the canonical tagged root. This
improves the loop for initializing double backing stores by hoisting the
load of the constant value out of the loop.

Bug: v8:5267
Change-Id: Idcf07c0e910ecc085a8b89225613f0a8fb50a414
Reviewed-on: https://chromium-review.googlesource.com/778979Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49480}
parent e2403e61
...@@ -3022,7 +3022,6 @@ void CodeStubAssembler::FillPropertyArrayWithUndefined(Node* array, ...@@ -3022,7 +3022,6 @@ void CodeStubAssembler::FillPropertyArrayWithUndefined(Node* array,
CSA_SLOW_ASSERT(this, MatchesParameterMode(from_node, mode)); CSA_SLOW_ASSERT(this, MatchesParameterMode(from_node, mode));
CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode)); CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode));
CSA_SLOW_ASSERT(this, IsPropertyArray(array)); CSA_SLOW_ASSERT(this, IsPropertyArray(array));
STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32);
ElementsKind kind = PACKED_ELEMENTS; ElementsKind kind = PACKED_ELEMENTS;
Node* value = UndefinedConstant(); Node* value = UndefinedConstant();
BuildFastFixedArrayForEach(array, kind, from_node, to_node, BuildFastFixedArrayForEach(array, kind, from_node, to_node,
...@@ -3040,38 +3039,22 @@ void CodeStubAssembler::FillFixedArrayWithValue( ...@@ -3040,38 +3039,22 @@ void CodeStubAssembler::FillFixedArrayWithValue(
CSA_SLOW_ASSERT(this, MatchesParameterMode(from_node, mode)); CSA_SLOW_ASSERT(this, MatchesParameterMode(from_node, mode));
CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode)); CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode));
CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, kind)); CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, kind));
bool is_double = IsDoubleElementsKind(kind);
DCHECK(value_root_index == Heap::kTheHoleValueRootIndex || DCHECK(value_root_index == Heap::kTheHoleValueRootIndex ||
value_root_index == Heap::kUndefinedValueRootIndex); value_root_index == Heap::kUndefinedValueRootIndex);
DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex);
STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32); // Determine the value to initialize the {array} based
Node* double_hole = // on the {value_root_index} and the elements {kind}.
Is64() ? ReinterpretCast<UintPtrT>(Int64Constant(kHoleNanInt64))
: ReinterpretCast<UintPtrT>(Int32Constant(kHoleNanLower32));
Node* value = LoadRoot(value_root_index); Node* value = LoadRoot(value_root_index);
if (IsDoubleElementsKind(kind)) {
value = LoadHeapNumberValue(value);
}
BuildFastFixedArrayForEach( BuildFastFixedArrayForEach(
array, kind, from_node, to_node, array, kind, from_node, to_node,
[this, value, is_double, double_hole](Node* array, Node* offset) { [this, value, kind](Node* array, Node* offset) {
if (is_double) { if (IsDoubleElementsKind(kind)) {
// Don't use doubles to store the hole double, since manipulating the StoreNoWriteBarrier(MachineRepresentation::kFloat64, array, offset,
// signaling NaN used for the hole in C++, e.g. with bit_cast, will value);
// change its value on ia32 (the x87 stack is used to return values
// and stores to the stack silently clear the signalling bit).
//
// TODO(danno): When we have a Float32/Float64 wrapper class that
// preserves double bits during manipulation, remove this code/change
// this to an indexed Float64 store.
if (Is64()) {
StoreNoWriteBarrier(MachineRepresentation::kWord64, array, offset,
double_hole);
} else {
StoreNoWriteBarrier(MachineRepresentation::kWord32, array, offset,
double_hole);
StoreNoWriteBarrier(MachineRepresentation::kWord32, array,
IntPtrAdd(offset, IntPtrConstant(kPointerSize)),
double_hole);
}
} else { } else {
StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset,
value); value);
......
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