Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index ca780dbe0ea44bbf81cf337e7494afcd507fd933..1157d723701648c2ee2d05c908c4b338722bbeaa 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -58,11 +58,6 @@ namespace internal { |
const int kGetterIndex = 0; |
const int kSetterIndex = 1; |
-uint64_t FixedDoubleArray::kHoleNanInt64 = -1; |
-uint64_t FixedDoubleArray::kCanonicalNonHoleNanLower32 = 0x7FF00000; |
-uint64_t FixedDoubleArray::kCanonicalNonHoleNanInt64 = |
- kCanonicalNonHoleNanLower32 << 32; |
- |
MUST_USE_RESULT static MaybeObject* CreateJSValue(JSFunction* constructor, |
Object* value) { |
Object* result; |
@@ -2811,16 +2806,18 @@ MaybeObject* JSObject::NormalizeElements() { |
ASSERT(!HasExternalArrayElements()); |
// Find the backing store. |
- FixedArray* array = FixedArray::cast(elements()); |
+ FixedArrayBase* array = FixedArrayBase::cast(elements()); |
Map* old_map = array->map(); |
bool is_arguments = |
(old_map == old_map->heap()->non_strict_arguments_elements_map()); |
if (is_arguments) { |
- array = FixedArray::cast(array->get(1)); |
+ array = FixedArrayBase::cast(FixedArray::cast(array)->get(1)); |
} |
if (array->IsDictionary()) return array; |
- ASSERT(HasFastElements() || HasFastArgumentsElements()); |
+ ASSERT(HasFastElements() || |
+ HasFastDoubleElements() || |
+ HasFastArgumentsElements()); |
// Compute the effective length and allocate a new backing store. |
int length = IsJSArray() |
? Smi::cast(JSArray::cast(this)->length())->value() |
@@ -2833,7 +2830,7 @@ MaybeObject* JSObject::NormalizeElements() { |
} |
// Copy the elements to the new backing store. |
- bool has_double_elements = old_map->has_fast_double_elements(); |
+ bool has_double_elements = array->IsFixedDoubleArray(); |
for (int i = 0; i < length; i++) { |
Object* value = NULL; |
if (has_double_elements) { |
@@ -2851,7 +2848,7 @@ MaybeObject* JSObject::NormalizeElements() { |
} |
} else { |
ASSERT(old_map->has_fast_elements()); |
- value = array->get(i); |
+ value = FixedArray::cast(array)->get(i); |
} |
PropertyDetails details = PropertyDetails(NONE, NORMAL); |
if (!value->IsTheHole()) { |
@@ -7317,22 +7314,28 @@ MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, |
new_map = Map::cast(object); |
} |
- AssertNoAllocation no_gc; |
- WriteBarrierMode mode = new_elements->GetWriteBarrierMode(no_gc); |
switch (GetElementsKind()) { |
- case FAST_ELEMENTS: |
+ case FAST_ELEMENTS: { |
+ AssertNoAllocation no_gc; |
+ WriteBarrierMode mode = new_elements->GetWriteBarrierMode(no_gc); |
CopyFastElementsToFast(FixedArray::cast(elements()), new_elements, mode); |
set_map(new_map); |
set_elements(new_elements); |
break; |
- case DICTIONARY_ELEMENTS: |
+ } |
+ case DICTIONARY_ELEMENTS: { |
+ AssertNoAllocation no_gc; |
+ WriteBarrierMode mode = new_elements->GetWriteBarrierMode(no_gc); |
CopySlowElementsToFast(NumberDictionary::cast(elements()), |
new_elements, |
mode); |
set_map(new_map); |
set_elements(new_elements); |
break; |
+ } |
case NON_STRICT_ARGUMENTS_ELEMENTS: { |
+ AssertNoAllocation no_gc; |
+ WriteBarrierMode mode = new_elements->GetWriteBarrierMode(no_gc); |
// The object's map and the parameter map are unchanged, the unaliased |
// arguments are copied to the new backing store. |
FixedArray* parameter_map = FixedArray::cast(elements()); |
@@ -7368,6 +7371,8 @@ MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity, |
new_elements->set(i, obj, UPDATE_WRITE_BARRIER); |
} |
} |
+ set_map(new_map); |
+ set_elements(new_elements); |
break; |
} |
case EXTERNAL_BYTE_ELEMENTS: |
@@ -7430,7 +7435,9 @@ MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( |
break; |
} |
+ ASSERT(new_map->has_fast_double_elements()); |
set_map(new_map); |
+ ASSERT(elems->IsFixedDoubleArray()); |
set_elements(elems); |
if (IsJSArray()) { |
@@ -8407,8 +8414,9 @@ MaybeObject* JSObject::SetDictionaryElement(uint32_t index, |
} else { |
new_length = dictionary->max_number_key() + 1; |
} |
- MaybeObject* result = |
- SetFastElementsCapacityAndLength(new_length, new_length); |
+ MaybeObject* result = ShouldConvertToFastDoubleElements() |
+ ? SetFastDoubleElementsCapacityAndLength(new_length, new_length) |
+ : SetFastElementsCapacityAndLength(new_length, new_length); |
if (result->IsFailure()) return result; |
#ifdef DEBUG |
if (FLAG_trace_normalization) { |
@@ -8495,6 +8503,9 @@ MUST_USE_RESULT MaybeObject* JSObject::SetFastDoubleElement( |
} |
// Otherwise default to slow case. |
+ ASSERT(HasFastDoubleElements()); |
+ ASSERT(map()->has_fast_double_elements()); |
+ ASSERT(elements()->IsFixedDoubleArray()); |
Object* obj; |
{ MaybeObject* maybe_obj = NormalizeElements(); |
if (!maybe_obj->ToObject(&obj)) return maybe_obj; |
@@ -8948,10 +8959,13 @@ bool JSObject::HasDenseElements() { |
int capacity = 0; |
int number_of_elements = 0; |
- FixedArray* backing_store = FixedArray::cast(elements()); |
+ FixedArrayBase* backing_store_base = FixedArrayBase::cast(elements()); |
+ FixedArray* backing_store = NULL; |
switch (GetElementsKind()) { |
case NON_STRICT_ARGUMENTS_ELEMENTS: |
- backing_store = FixedArray::cast(backing_store->get(1)); |
+ backing_store_base = |
+ FixedArray::cast(FixedArray::cast(backing_store_base)->get(1)); |
+ backing_store = FixedArray::cast(backing_store_base); |
if (backing_store->IsDictionary()) { |
NumberDictionary* dictionary = NumberDictionary::cast(backing_store); |
capacity = dictionary->Capacity(); |
@@ -8960,13 +8974,15 @@ bool JSObject::HasDenseElements() { |
} |
// Fall through. |
case FAST_ELEMENTS: |
+ backing_store = FixedArray::cast(backing_store_base); |
capacity = backing_store->length(); |
for (int i = 0; i < capacity; ++i) { |
if (!backing_store->get(i)->IsTheHole()) ++number_of_elements; |
} |
break; |
case DICTIONARY_ELEMENTS: { |
- NumberDictionary* dictionary = NumberDictionary::cast(backing_store); |
+ NumberDictionary* dictionary = |
+ NumberDictionary::cast(FixedArray::cast(elements())); |
capacity = dictionary->Capacity(); |
number_of_elements = dictionary->NumberOfElements(); |
break; |