Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index 4d70b32147318bdd8f27add24dac5245c1dd8230..ba824dd12f4dd4a94445f975963762841fdd41ec 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -28,6 +28,7 @@ |
| #include "v8.h" |
| #include "api.h" |
| +#include "assembler.h" |
|
Mads Ager (chromium)
2011/07/12 12:03:26
objects.cc needs the assembler? Is this for some c
danno
2011/07/13 08:59:52
Done.
|
| #include "arguments.h" |
| #include "bootstrapper.h" |
| #include "codegen.h" |
| @@ -58,11 +59,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; |
| @@ -2815,16 +2811,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() |
| @@ -2837,7 +2835,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) { |
| @@ -2855,7 +2853,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()) { |
| @@ -7320,22 +7318,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()); |
| @@ -7371,6 +7375,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: |
| @@ -7433,7 +7439,9 @@ MaybeObject* JSObject::SetFastDoubleElementsCapacityAndLength( |
| break; |
| } |
| + ASSERT(new_map->has_fast_double_elements()); |
| set_map(new_map); |
| + ASSERT(elems->IsFixedDoubleArray()); |
| set_elements(elems); |
| if (IsJSArray()) { |
| @@ -8410,8 +8418,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) { |
| @@ -8498,6 +8507,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; |
| @@ -8951,10 +8963,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(); |
| @@ -8963,13 +8978,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; |