Commit d9691952 authored by ivica.bogosavljevic's avatar ivica.bogosavljevic Committed by Commit bot

[builtins] Speed up TypedArrayInitialize in CodeStubAssembler

On those architectures that do support unaligned memory access
there is no need to emit heap alignment code in TypedArrayInitialize.

BUG=chromium:708545

Review-Url: https://codereview.chromium.org/2802003003
Cr-Commit-Position: refs/heads/master@{#44501}
parent 03e260cb
...@@ -214,7 +214,17 @@ void TypedArrayBuiltinsAssembler::DoInitialize(Node* const holder, Node* length, ...@@ -214,7 +214,17 @@ void TypedArrayBuiltinsAssembler::DoInitialize(Node* const holder, Node* length,
// Allocate a FixedTypedArray and set the length, base pointer and external // Allocate a FixedTypedArray and set the length, base pointer and external
// pointer. // pointer.
CSA_ASSERT(this, IsRegularHeapObjectSize(total_size.value())); CSA_ASSERT(this, IsRegularHeapObjectSize(total_size.value()));
Node* elements = AllocateInNewSpace(total_size.value(), kDoubleAlignment);
Node* elements;
int heap_alignment =
ElementSizeLog2Of(MachineType::PointerRepresentation());
if (UnalignedLoadSupported(MachineType::Float64(), heap_alignment) &&
UnalignedStoreSupported(MachineType::Float64(), heap_alignment)) {
elements = AllocateInNewSpace(total_size.value());
} else {
elements = AllocateInNewSpace(total_size.value(), kDoubleAlignment);
}
StoreMapNoWriteBarrier(elements, fixed_typed_map.value()); StoreMapNoWriteBarrier(elements, fixed_typed_map.value());
StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, length); StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, length);
......
...@@ -758,6 +758,17 @@ void CodeAssembler::Switch(Node* index, Label* default_label, ...@@ -758,6 +758,17 @@ void CodeAssembler::Switch(Node* index, Label* default_label,
labels, case_count); labels, case_count);
} }
bool CodeAssembler::UnalignedLoadSupported(const MachineType& machineType,
uint8_t alignment) const {
return raw_assembler()->machine()->UnalignedLoadSupported(machineType,
alignment);
}
bool CodeAssembler::UnalignedStoreSupported(const MachineType& machineType,
uint8_t alignment) const {
return raw_assembler()->machine()->UnalignedStoreSupported(machineType,
alignment);
}
// RawMachineAssembler delegate helpers: // RawMachineAssembler delegate helpers:
Isolate* CodeAssembler::isolate() const { return raw_assembler()->isolate(); } Isolate* CodeAssembler::isolate() const { return raw_assembler()->isolate(); }
......
...@@ -420,6 +420,11 @@ class V8_EXPORT_PRIVATE CodeAssembler { ...@@ -420,6 +420,11 @@ class V8_EXPORT_PRIVATE CodeAssembler {
void BreakOnNode(int node_id); void BreakOnNode(int node_id);
bool UnalignedLoadSupported(const MachineType& machineType,
uint8_t alignment) const;
bool UnalignedStoreSupported(const MachineType& machineType,
uint8_t alignment) const;
protected: protected:
void RegisterCallGenerationCallbacks( void RegisterCallGenerationCallbacks(
const CodeAssemblerCallback& call_prologue, const CodeAssemblerCallback& call_prologue,
......
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