diff --git a/src/builtins/builtins-typedarray-gen.cc b/src/builtins/builtins-typedarray-gen.cc index 2558ec4878..c066a5e935 100644 --- a/src/builtins/builtins-typedarray-gen.cc +++ b/src/builtins/builtins-typedarray-gen.cc @@ -214,7 +214,17 @@ void TypedArrayBuiltinsAssembler::DoInitialize(Node* const holder, Node* length, // Allocate a FixedTypedArray and set the length, base pointer and external // pointer. 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()); StoreObjectFieldNoWriteBarrier(elements, FixedArray::kLengthOffset, length); diff --git a/src/compiler/code-assembler.cc b/src/compiler/code-assembler.cc index 45fdcf56cb..60e0c6f9b7 100644 --- a/src/compiler/code-assembler.cc +++ b/src/compiler/code-assembler.cc @@ -758,6 +758,17 @@ void CodeAssembler::Switch(Node* index, Label* default_label, 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: Isolate* CodeAssembler::isolate() const { return raw_assembler()->isolate(); } diff --git a/src/compiler/code-assembler.h b/src/compiler/code-assembler.h index 81d8c90463..b0f92cec2e 100644 --- a/src/compiler/code-assembler.h +++ b/src/compiler/code-assembler.h @@ -420,6 +420,11 @@ class V8_EXPORT_PRIVATE CodeAssembler { void BreakOnNode(int node_id); + bool UnalignedLoadSupported(const MachineType& machineType, + uint8_t alignment) const; + bool UnalignedStoreSupported(const MachineType& machineType, + uint8_t alignment) const; + protected: void RegisterCallGenerationCallbacks( const CodeAssemblerCallback& call_prologue,