Commit d9f26340 authored by Benedikt Meurer's avatar Benedikt Meurer Committed by Commit Bot

[turbofan] Use word indices for NewFast*Elements lowering.

Avoid the zero-extensions required for int32 based addressing on 64-bit
architectures by restructuring the initialization loops to work on
words. This recovers a bit of the regression on the Kraken audio-fft and
audio-beat-detection benchmarks that was introduced by the initial CL.

Bug: chromium:772669, v8:6399, v8:6901
Change-Id: I4753c254be89f2bcc7b0ea5073e469e3507408bd
Reviewed-on: https://chromium-review.googlesource.com/707098Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48377}
parent 475af49d
...@@ -2296,26 +2296,28 @@ Node* EffectControlLinearizer::LowerNewFastDoubleElements(Node* node) { ...@@ -2296,26 +2296,28 @@ Node* EffectControlLinearizer::LowerNewFastDoubleElements(Node* node) {
// Initialize the backing store with holes. // Initialize the backing store with holes.
STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset); STATIC_ASSERT(HeapNumber::kValueOffset == Oddball::kToNumberRawOffset);
Node* limit = ChangeUint32ToUintPtr(length);
Node* the_hole = Node* the_hole =
__ LoadField(AccessBuilder::ForHeapNumberValue(), __ TheHoleConstant()); __ LoadField(AccessBuilder::ForHeapNumberValue(), __ TheHoleConstant());
auto loop = __ MakeLoopLabel(MachineRepresentation::kWord32); auto loop = __ MakeLoopLabel(MachineType::PointerRepresentation());
auto done_loop = __ MakeLabel(); auto done_loop = __ MakeLabel();
__ Goto(&loop, __ Int32Constant(0)); __ Goto(&loop, __ IntPtrConstant(0));
__ Bind(&loop); __ Bind(&loop);
{ {
// Check if we've initialized everything. // Check if we've initialized everything.
Node* index = loop.PhiAt(0); Node* index = loop.PhiAt(0);
Node* check = __ Int32LessThan(index, length); Node* check = __ UintLessThan(index, limit);
__ GotoIfNot(check, &done_loop); __ GotoIfNot(check, &done_loop);
// Storing "the_hole" doesn't need a write barrier. // Storing "the_hole" doesn't need a write barrier.
ElementAccess const access = {kTaggedBase, FixedDoubleArray::kHeaderSize, StoreRepresentation rep(MachineRepresentation::kFloat64, kNoWriteBarrier);
Type::NumberOrHole(), MachineType::Float64(), Node* offset = __ IntAdd(
kNoWriteBarrier}; __ WordShl(index, __ IntPtrConstant(kDoubleSizeLog2)),
__ StoreElement(access, result, index, the_hole); __ IntPtrConstant(FixedDoubleArray::kHeaderSize - kHeapObjectTag));
__ Store(rep, result, offset, the_hole);
// Advance the {index}. // Advance the {index}.
index = __ Int32Add(index, __ Int32Constant(1)); index = __ IntAdd(index, __ IntPtrConstant(1));
__ Goto(&loop, index); __ Goto(&loop, index);
} }
...@@ -2339,25 +2341,27 @@ Node* EffectControlLinearizer::LowerNewFastSmiOrObjectElements(Node* node) { ...@@ -2339,25 +2341,27 @@ Node* EffectControlLinearizer::LowerNewFastSmiOrObjectElements(Node* node) {
ChangeInt32ToSmi(length)); ChangeInt32ToSmi(length));
// Initialize the backing store with holes. // Initialize the backing store with holes.
Node* limit = ChangeUint32ToUintPtr(length);
Node* the_hole = __ TheHoleConstant(); Node* the_hole = __ TheHoleConstant();
auto loop = __ MakeLoopLabel(MachineRepresentation::kWord32); auto loop = __ MakeLoopLabel(MachineType::PointerRepresentation());
auto done_loop = __ MakeLabel(); auto done_loop = __ MakeLabel();
__ Goto(&loop, __ Int32Constant(0)); __ Goto(&loop, __ IntPtrConstant(0));
__ Bind(&loop); __ Bind(&loop);
{ {
// Check if we've initialized everything. // Check if we've initialized everything.
Node* index = loop.PhiAt(0); Node* index = loop.PhiAt(0);
Node* check = __ Int32LessThan(index, length); Node* check = __ UintLessThan(index, limit);
__ GotoIfNot(check, &done_loop); __ GotoIfNot(check, &done_loop);
// Storing "the_hole" doesn't need a write barrier. // Storing "the_hole" doesn't need a write barrier.
ElementAccess const access = {kTaggedBase, FixedArray::kHeaderSize, StoreRepresentation rep(MachineRepresentation::kTagged, kNoWriteBarrier);
Type::Any(), MachineType::AnyTagged(), Node* offset =
kNoWriteBarrier}; __ IntAdd(__ WordShl(index, __ IntPtrConstant(kPointerSizeLog2)),
__ StoreElement(access, result, index, the_hole); __ IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag));
__ Store(rep, result, offset, the_hole);
// Advance the {index}. // Advance the {index}.
index = __ Int32Add(index, __ Int32Constant(1)); index = __ IntAdd(index, __ IntPtrConstant(1));
__ Goto(&loop, index); __ Goto(&loop, index);
} }
......
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