#define CODE_POINTER_ALIGN(value) \
(((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask)
+// DOUBLE_POINTER_ALIGN returns the value algined for double pointers.
+#define DOUBLE_POINTER_ALIGN(value) \
+ (((value) + kDoubleAlignmentMask) & ~kDoubleAlignmentMask)
+
// Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk")
// inside a C++ class and new and delete will be overloaded so logging is
// performed.
ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array)
ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space)
-#define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \
- ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kAlignedSize, \
+#define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \
+ ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kSize, \
external_##type##_array)
TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP)
ExternalArrayType array_type,
void* external_pointer,
PretenureFlag pretenure) {
- int size = ExternalArray::kAlignedSize;
+ int size = ExternalArray::kSize;
AllocationSpace space = SelectSpace(size, pretenure);
HeapObject* result;
{
// conversion after allocation but before the new object fields are set.
length = AddUncasted<HForceRepresentation>(length, Representation::Smi());
HValue* elements =
- Add<HAllocate>(
- Add<HConstant>(ExternalArray::kAlignedSize),
- HType::HeapObject(),
- NOT_TENURED,
- external_array_map->instance_type());
+ Add<HAllocate>(Add<HConstant>(ExternalArray::kSize), HType::HeapObject(),
+ NOT_TENURED, external_array_map->instance_type());
AddStoreMapConstant(elements, external_array_map);
Add<HStoreNamedField>(elements,
length = AddUncasted<HForceRepresentation>(length, Representation::Smi());
Handle<Map> fixed_typed_array_map(
isolate()->heap()->MapForFixedTypedArray(array_type));
- HValue* elements =
- Add<HAllocate>(total_size, HType::HeapObject(),
- NOT_TENURED, fixed_typed_array_map->instance_type());
+ HAllocate* elements =
+ Add<HAllocate>(total_size, HType::HeapObject(), NOT_TENURED,
+ fixed_typed_array_map->instance_type());
+
+#ifndef V8_HOST_ARCH_64_BIT
+ if (array_type == kExternalFloat64Array) {
+ elements->MakeDoubleAligned();
+ }
+#endif
+
AddStoreMapConstant(elements, fixed_typed_array_map);
Add<HStoreNamedField>(elements,
}
-template<> inline
-FixedTypedArray<Float64ArrayTraits>::ElementType
- FixedTypedArray<Float64ArrayTraits>::get_scalar(int index) {
- DCHECK((index >= 0) && (index < this->length()));
- return READ_DOUBLE_FIELD(this, ElementOffset(index));
-}
-
-
template <class Traits>
void FixedTypedArray<Traits>::set(int index, ElementType value) {
DCHECK((index >= 0) && (index < this->length()));
}
-template<> inline
-void FixedTypedArray<Float64ArrayTraits>::set(
- int index, Float64ArrayTraits::ElementType value) {
- DCHECK((index >= 0) && (index < this->length()));
- WRITE_DOUBLE_FIELD(this, ElementOffset(index), value);
-}
-
-
template <class Traits>
typename Traits::ElementType FixedTypedArray<Traits>::from_int(int value) {
return static_cast<ElementType>(value);
// ExternalArray headers are not quadword aligned.
static const int kExternalPointerOffset =
POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize);
- static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
- static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
+ static const int kSize = kExternalPointerOffset + kPointerSize;
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray);
public:
DECLARE_CAST(FixedTypedArrayBase)
- static const int kDataOffset = kHeaderSize;
+ static const int kDataOffset = DOUBLE_POINTER_ALIGN(kHeaderSize);
inline int size();
DECLARE_CAST(FixedTypedArray<Traits>)
- static inline int ElementOffset(int index) {
- return kDataOffset + index * sizeof(ElementType);
- }
-
- static inline int SizeFor(int length) {
- return ElementOffset(length);
- }
-
inline ElementType get_scalar(int index);
static inline Handle<Object> get(Handle<FixedTypedArray> array, int index);
inline void set(int index, ElementType value);