| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 11213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11224 // We should never end in here with a pixel or external array. | 11224 // We should never end in here with a pixel or external array. |
| 11225 ASSERT(!HasExternalArrayElements()); | 11225 ASSERT(!HasExternalArrayElements()); |
| 11226 | 11226 |
| 11227 FixedArrayBase* elems; | 11227 FixedArrayBase* elems; |
| 11228 { MaybeObject* maybe_obj = | 11228 { MaybeObject* maybe_obj = |
| 11229 heap->AllocateUninitializedFixedDoubleArray(capacity); | 11229 heap->AllocateUninitializedFixedDoubleArray(capacity); |
| 11230 if (!maybe_obj->To(&elems)) return maybe_obj; | 11230 if (!maybe_obj->To(&elems)) return maybe_obj; |
| 11231 } | 11231 } |
| 11232 | 11232 |
| 11233 ElementsKind elements_kind = GetElementsKind(); | 11233 ElementsKind elements_kind = GetElementsKind(); |
| 11234 CHECK(elements_kind != SLOPPY_ARGUMENTS_ELEMENTS); |
| 11234 ElementsKind new_elements_kind = elements_kind; | 11235 ElementsKind new_elements_kind = elements_kind; |
| 11235 if (IsHoleyElementsKind(elements_kind)) { | 11236 if (IsHoleyElementsKind(elements_kind)) { |
| 11236 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS; | 11237 new_elements_kind = FAST_HOLEY_DOUBLE_ELEMENTS; |
| 11237 } else { | 11238 } else { |
| 11238 new_elements_kind = FAST_DOUBLE_ELEMENTS; | 11239 new_elements_kind = FAST_DOUBLE_ELEMENTS; |
| 11239 } | 11240 } |
| 11240 | 11241 |
| 11241 Map* new_map; | 11242 Map* new_map; |
| 11242 { MaybeObject* maybe_obj = | 11243 { MaybeObject* maybe_obj = |
| 11243 GetElementsTransitionMap(heap->isolate(), new_elements_kind); | 11244 GetElementsTransitionMap(heap->isolate(), new_elements_kind); |
| 11244 if (!maybe_obj->To(&new_map)) return maybe_obj; | 11245 if (!maybe_obj->To(&new_map)) return maybe_obj; |
| 11245 } | 11246 } |
| 11246 | 11247 |
| 11247 FixedArrayBase* old_elements = elements(); | 11248 FixedArrayBase* old_elements = elements(); |
| 11248 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); | 11249 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); |
| 11249 { MaybeObject* maybe_obj = | 11250 { MaybeObject* maybe_obj = |
| 11250 accessor->CopyElements(this, elems, elements_kind); | 11251 accessor->CopyElements(this, elems, elements_kind); |
| 11251 if (maybe_obj->IsFailure()) return maybe_obj; | 11252 if (maybe_obj->IsFailure()) return maybe_obj; |
| 11252 } | 11253 } |
| 11253 if (elements_kind != SLOPPY_ARGUMENTS_ELEMENTS) { | 11254 |
| 11254 ValidateElements(); | 11255 ValidateElements(); |
| 11255 set_map_and_elements(new_map, elems); | 11256 set_map_and_elements(new_map, elems); |
| 11256 } else { | |
| 11257 FixedArray* parameter_map = FixedArray::cast(old_elements); | |
| 11258 parameter_map->set(1, elems); | |
| 11259 } | |
| 11260 | 11257 |
| 11261 if (FLAG_trace_elements_transitions) { | 11258 if (FLAG_trace_elements_transitions) { |
| 11262 PrintElementsTransition(stdout, elements_kind, old_elements, | 11259 PrintElementsTransition(stdout, elements_kind, old_elements, |
| 11263 GetElementsKind(), elems); | 11260 GetElementsKind(), elems); |
| 11264 } | 11261 } |
| 11265 | 11262 |
| 11266 if (IsJSArray()) { | 11263 if (IsJSArray()) { |
| 11267 JSArray::cast(this)->set_length(Smi::FromInt(length)); | 11264 JSArray::cast(this)->set_length(Smi::FromInt(length)); |
| 11268 } | 11265 } |
| 11269 | 11266 |
| (...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13115 } | 13112 } |
| 13116 uint32_t dictionary_size = static_cast<uint32_t>(dictionary->Capacity()) * | 13113 uint32_t dictionary_size = static_cast<uint32_t>(dictionary->Capacity()) * |
| 13117 SeededNumberDictionary::kEntrySize; | 13114 SeededNumberDictionary::kEntrySize; |
| 13118 return 2 * dictionary_size >= array_size; | 13115 return 2 * dictionary_size >= array_size; |
| 13119 } | 13116 } |
| 13120 | 13117 |
| 13121 | 13118 |
| 13122 bool JSObject::ShouldConvertToFastDoubleElements( | 13119 bool JSObject::ShouldConvertToFastDoubleElements( |
| 13123 bool* has_smi_only_elements) { | 13120 bool* has_smi_only_elements) { |
| 13124 *has_smi_only_elements = false; | 13121 *has_smi_only_elements = false; |
| 13122 if (HasSloppyArgumentsElements()) return false; |
| 13125 if (FLAG_unbox_double_arrays) { | 13123 if (FLAG_unbox_double_arrays) { |
| 13126 ASSERT(HasDictionaryElements()); | 13124 ASSERT(HasDictionaryElements()); |
| 13127 SeededNumberDictionary* dictionary = element_dictionary(); | 13125 SeededNumberDictionary* dictionary = element_dictionary(); |
| 13128 bool found_double = false; | 13126 bool found_double = false; |
| 13129 for (int i = 0; i < dictionary->Capacity(); i++) { | 13127 for (int i = 0; i < dictionary->Capacity(); i++) { |
| 13130 Object* key = dictionary->KeyAt(i); | 13128 Object* key = dictionary->KeyAt(i); |
| 13131 if (key->IsNumber()) { | 13129 if (key->IsNumber()) { |
| 13132 Object* value = dictionary->ValueAt(i); | 13130 Object* value = dictionary->ValueAt(i); |
| 13133 if (!value->IsNumber()) return false; | 13131 if (!value->IsNumber()) return false; |
| 13134 if (!value->IsSmi()) { | 13132 if (!value->IsSmi()) { |
| (...skipping 3284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16419 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16417 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16420 static const char* error_messages_[] = { | 16418 static const char* error_messages_[] = { |
| 16421 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16419 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16422 }; | 16420 }; |
| 16423 #undef ERROR_MESSAGES_TEXTS | 16421 #undef ERROR_MESSAGES_TEXTS |
| 16424 return error_messages_[reason]; | 16422 return error_messages_[reason]; |
| 16425 } | 16423 } |
| 16426 | 16424 |
| 16427 | 16425 |
| 16428 } } // namespace v8::internal | 16426 } } // namespace v8::internal |
| OLD | NEW |