Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index cad7b6389c7c4160b720f3ed5718b075c2102a7e..c358ee6584525e4415aacce8615efd687acda79e 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -1736,11 +1736,6 @@ void JSObject::initialize_elements() { |
ExternalArray* empty_array = GetHeap()->EmptyExternalArrayForMap(map()); |
ASSERT(!GetHeap()->InNewSpace(empty_array)); |
WRITE_FIELD(this, kElementsOffset, empty_array); |
- } else if (map()->has_fixed_typed_array_elements()) { |
- FixedTypedArrayBase* empty_array = |
- GetHeap()->EmptyFixedTypedArrayForMap(map()); |
- ASSERT(!GetHeap()->InNewSpace(empty_array)); |
- WRITE_FIELD(this, kElementsOffset, empty_array); |
} else { |
UNREACHABLE(); |
} |
@@ -3681,64 +3676,35 @@ void ExternalFloat64Array::set(int index, double value) { |
} |
-void* FixedTypedArrayBase::DataPtr() { |
- return FIELD_ADDR(this, kDataOffset); |
-} |
- |
- |
-int FixedTypedArrayBase::DataSize() { |
+int FixedTypedArrayBase::size() { |
InstanceType instance_type = map()->instance_type(); |
int element_size; |
switch (instance_type) { |
-#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
- case FIXED_##TYPE##_ARRAY_TYPE: \ |
- element_size = size; \ |
+ case FIXED_UINT8_ARRAY_TYPE: |
+ case FIXED_INT8_ARRAY_TYPE: |
+ case FIXED_UINT8_CLAMPED_ARRAY_TYPE: |
+ element_size = 1; |
+ break; |
+ case FIXED_UINT16_ARRAY_TYPE: |
+ case FIXED_INT16_ARRAY_TYPE: |
+ element_size = 2; |
+ break; |
+ case FIXED_UINT32_ARRAY_TYPE: |
+ case FIXED_INT32_ARRAY_TYPE: |
+ case FIXED_FLOAT32_ARRAY_TYPE: |
+ element_size = 4; |
+ break; |
+ case FIXED_FLOAT64_ARRAY_TYPE: |
+ element_size = 8; |
break; |
- |
- TYPED_ARRAYS(TYPED_ARRAY_CASE) |
-#undef TYPED_ARRAY_CASE |
default: |
UNREACHABLE(); |
return 0; |
} |
- return length() * element_size; |
-} |
- |
- |
-int FixedTypedArrayBase::size() { |
- return OBJECT_POINTER_ALIGN(kDataOffset + DataSize()); |
-} |
- |
- |
-uint8_t Uint8ArrayTraits::defaultValue() { return 0; } |
- |
- |
-uint8_t Uint8ClampedArrayTraits::defaultValue() { return 0; } |
- |
- |
-int8_t Int8ArrayTraits::defaultValue() { return 0; } |
- |
- |
-uint16_t Uint16ArrayTraits::defaultValue() { return 0; } |
- |
- |
-int16_t Int16ArrayTraits::defaultValue() { return 0; } |
- |
- |
-uint32_t Uint32ArrayTraits::defaultValue() { return 0; } |
- |
- |
-int32_t Int32ArrayTraits::defaultValue() { return 0; } |
- |
- |
-float Float32ArrayTraits::defaultValue() { |
- return static_cast<float>(OS::nan_value()); |
+ return OBJECT_POINTER_ALIGN(kDataOffset + length() * element_size); |
} |
-double Float64ArrayTraits::defaultValue() { return OS::nan_value(); } |
- |
- |
template <class Traits> |
typename Traits::ElementType FixedTypedArray<Traits>::get_scalar(int index) { |
ASSERT((index >= 0) && (index < this->length())); |
@@ -3774,47 +3740,6 @@ void FixedTypedArray<Float64ArrayTraits>::set( |
template <class Traits> |
-typename Traits::ElementType FixedTypedArray<Traits>::from_int(int value) { |
- return static_cast<ElementType>(value); |
-} |
- |
- |
-template <> inline |
-uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from_int(int value) { |
- if (value < 0) return 0; |
- if (value > 0xFF) return 0xFF; |
- return static_cast<uint8_t>(value); |
-} |
- |
- |
-template <class Traits> |
-typename Traits::ElementType FixedTypedArray<Traits>::from_double( |
- double value) { |
- return static_cast<ElementType>(DoubleToInt32(value)); |
-} |
- |
- |
-template<> inline |
-uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from_double(double value) { |
- if (value < 0) return 0; |
- if (value > 0xFF) return 0xFF; |
- return static_cast<uint8_t>(lrint(value)); |
-} |
- |
- |
-template<> inline |
-float FixedTypedArray<Float32ArrayTraits>::from_double(double value) { |
- return static_cast<float>(value); |
-} |
- |
- |
-template<> inline |
-double FixedTypedArray<Float64ArrayTraits>::from_double(double value) { |
- return value; |
-} |
- |
- |
-template <class Traits> |
MaybeObject* FixedTypedArray<Traits>::get(int index) { |
return Traits::ToObject(GetHeap(), get_scalar(index)); |
} |
@@ -3825,10 +3750,10 @@ MaybeObject* FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) { |
if (index < static_cast<uint32_t>(length())) { |
if (value->IsSmi()) { |
int int_value = Smi::cast(value)->value(); |
- cast_value = from_int(int_value); |
+ cast_value = static_cast<ElementType>(int_value); |
} else if (value->IsHeapNumber()) { |
double double_value = HeapNumber::cast(value)->value(); |
- cast_value = from_double(double_value); |
+ cast_value = static_cast<ElementType>(DoubleToInt32(double_value)); |
} else { |
// Clamp undefined to the default value. All other types have been |
// converted to a number type further up in the call chain. |
@@ -6096,20 +6021,6 @@ bool JSObject::HasFixedTypedArrayElements() { |
} |
-#define FIXED_TYPED_ELEMENTS_CHECK(Type, type, TYPE, ctype, size) \ |
-bool JSObject::HasFixed##Type##Elements() { \ |
- HeapObject* array = elements(); \ |
- ASSERT(array != NULL); \ |
- if (!array->IsHeapObject()) \ |
- return false; \ |
- return array->map()->instance_type() == FIXED_##TYPE##_ARRAY_TYPE; \ |
-} |
- |
-TYPED_ARRAYS(FIXED_TYPED_ELEMENTS_CHECK) |
- |
-#undef FIXED_TYPED_ELEMENTS_CHECK |
- |
- |
bool JSObject::HasNamedInterceptor() { |
return map()->has_named_interceptor(); |
} |