| 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 4654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4665 int unused_property_fields) { | 4665 int unused_property_fields) { |
| 4666 if (object->HasFastProperties()) return; | 4666 if (object->HasFastProperties()) return; |
| 4667 ASSERT(!object->IsGlobalObject()); | 4667 ASSERT(!object->IsGlobalObject()); |
| 4668 CALL_HEAP_FUNCTION_VOID( | 4668 CALL_HEAP_FUNCTION_VOID( |
| 4669 object->GetIsolate(), | 4669 object->GetIsolate(), |
| 4670 object->property_dictionary()->TransformPropertiesToFastFor( | 4670 object->property_dictionary()->TransformPropertiesToFastFor( |
| 4671 *object, unused_property_fields)); | 4671 *object, unused_property_fields)); |
| 4672 } | 4672 } |
| 4673 | 4673 |
| 4674 | 4674 |
| 4675 void JSObject::ResetElements(Handle<JSObject> object) { |
| 4676 CALL_HEAP_FUNCTION_VOID( |
| 4677 object->GetIsolate(), |
| 4678 object->ResetElements()); |
| 4679 } |
| 4680 |
| 4681 |
| 4675 static Handle<SeededNumberDictionary> CopyFastElementsToDictionary( | 4682 static Handle<SeededNumberDictionary> CopyFastElementsToDictionary( |
| 4676 Handle<FixedArrayBase> array, | 4683 Handle<FixedArrayBase> array, |
| 4677 int length, | 4684 int length, |
| 4678 Handle<SeededNumberDictionary> dictionary) { | 4685 Handle<SeededNumberDictionary> dictionary) { |
| 4679 Isolate* isolate = array->GetIsolate(); | 4686 Isolate* isolate = array->GetIsolate(); |
| 4680 Factory* factory = isolate->factory(); | 4687 Factory* factory = isolate->factory(); |
| 4681 bool has_double_elements = array->IsFixedDoubleArray(); | 4688 bool has_double_elements = array->IsFixedDoubleArray(); |
| 4682 for (int i = 0; i < length; i++) { | 4689 for (int i = 0; i < length; i++) { |
| 4683 Handle<Object> value; | 4690 Handle<Object> value; |
| 4684 if (has_double_elements) { | 4691 if (has_double_elements) { |
| (...skipping 6482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11167 } | 11174 } |
| 11168 Handle<FixedArrayBase> old_elements(object->elements()); | 11175 Handle<FixedArrayBase> old_elements(object->elements()); |
| 11169 ElementsAccessor* accessor = ElementsAccessor::ForKind(new_elements_kind); | 11176 ElementsAccessor* accessor = ElementsAccessor::ForKind(new_elements_kind); |
| 11170 accessor->CopyElements(object, new_elements, elements_kind); | 11177 accessor->CopyElements(object, new_elements, elements_kind); |
| 11171 | 11178 |
| 11172 if (elements_kind != SLOPPY_ARGUMENTS_ELEMENTS) { | 11179 if (elements_kind != SLOPPY_ARGUMENTS_ELEMENTS) { |
| 11173 Handle<Map> new_map = (new_elements_kind != elements_kind) | 11180 Handle<Map> new_map = (new_elements_kind != elements_kind) |
| 11174 ? GetElementsTransitionMap(object, new_elements_kind) | 11181 ? GetElementsTransitionMap(object, new_elements_kind) |
| 11175 : handle(object->map()); | 11182 : handle(object->map()); |
| 11176 object->ValidateElements(); | 11183 object->ValidateElements(); |
| 11177 object->set_map_and_elements(*new_map, *new_elements); | 11184 JSObject::SetMapAndElements(object, new_map, new_elements); |
| 11178 | 11185 |
| 11179 // Transition through the allocation site as well if present. | 11186 // Transition through the allocation site as well if present. |
| 11180 JSObject::UpdateAllocationSite(object, new_elements_kind); | 11187 JSObject::UpdateAllocationSite(object, new_elements_kind); |
| 11181 } else { | 11188 } else { |
| 11182 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements); | 11189 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements); |
| 11183 parameter_map->set(1, *new_elements); | 11190 parameter_map->set(1, *new_elements); |
| 11184 } | 11191 } |
| 11185 | 11192 |
| 11186 if (FLAG_trace_elements_transitions) { | 11193 if (FLAG_trace_elements_transitions) { |
| 11187 PrintElementsTransition(stdout, object, elements_kind, old_elements, | 11194 PrintElementsTransition(stdout, object, elements_kind, old_elements, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 11213 new_elements_kind = FAST_DOUBLE_ELEMENTS; | 11220 new_elements_kind = FAST_DOUBLE_ELEMENTS; |
| 11214 } | 11221 } |
| 11215 | 11222 |
| 11216 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind); | 11223 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind); |
| 11217 | 11224 |
| 11218 Handle<FixedArrayBase> old_elements(object->elements()); | 11225 Handle<FixedArrayBase> old_elements(object->elements()); |
| 11219 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); | 11226 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); |
| 11220 accessor->CopyElements(object, elems, elements_kind); | 11227 accessor->CopyElements(object, elems, elements_kind); |
| 11221 | 11228 |
| 11222 object->ValidateElements(); | 11229 object->ValidateElements(); |
| 11223 object->set_map_and_elements(*new_map, *elems); | 11230 JSObject::SetMapAndElements(object, new_map, elems); |
| 11224 | 11231 |
| 11225 if (FLAG_trace_elements_transitions) { | 11232 if (FLAG_trace_elements_transitions) { |
| 11226 PrintElementsTransition(stdout, object, elements_kind, old_elements, | 11233 PrintElementsTransition(stdout, object, elements_kind, old_elements, |
| 11227 object->GetElementsKind(), elems); | 11234 object->GetElementsKind(), elems); |
| 11228 } | 11235 } |
| 11229 | 11236 |
| 11230 if (object->IsJSArray()) { | 11237 if (object->IsJSArray()) { |
| 11231 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); | 11238 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); |
| 11232 } | 11239 } |
| 11233 } | 11240 } |
| (...skipping 3119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14353 Handle<Map> new_map = | 14360 Handle<Map> new_map = |
| 14354 JSObject::GetElementsTransitionMap(object, FAST_HOLEY_ELEMENTS); | 14361 JSObject::GetElementsTransitionMap(object, FAST_HOLEY_ELEMENTS); |
| 14355 | 14362 |
| 14356 PretenureFlag tenure = isolate->heap()->InNewSpace(*object) ? | 14363 PretenureFlag tenure = isolate->heap()->InNewSpace(*object) ? |
| 14357 NOT_TENURED: TENURED; | 14364 NOT_TENURED: TENURED; |
| 14358 Handle<FixedArray> fast_elements = | 14365 Handle<FixedArray> fast_elements = |
| 14359 isolate->factory()->NewFixedArray(dict->NumberOfElements(), tenure); | 14366 isolate->factory()->NewFixedArray(dict->NumberOfElements(), tenure); |
| 14360 dict->CopyValuesTo(*fast_elements); | 14367 dict->CopyValuesTo(*fast_elements); |
| 14361 object->ValidateElements(); | 14368 object->ValidateElements(); |
| 14362 | 14369 |
| 14363 object->set_map_and_elements(*new_map, *fast_elements); | 14370 JSObject::SetMapAndElements(object, new_map, fast_elements); |
| 14364 } else if (object->HasExternalArrayElements() || | 14371 } else if (object->HasExternalArrayElements() || |
| 14365 object->HasFixedTypedArrayElements()) { | 14372 object->HasFixedTypedArrayElements()) { |
| 14366 // Typed arrays cannot have holes or undefined elements. | 14373 // Typed arrays cannot have holes or undefined elements. |
| 14367 return handle(Smi::FromInt( | 14374 return handle(Smi::FromInt( |
| 14368 FixedArrayBase::cast(object->elements())->length()), isolate); | 14375 FixedArrayBase::cast(object->elements())->length()), isolate); |
| 14369 } else if (!object->HasFastDoubleElements()) { | 14376 } else if (!object->HasFastDoubleElements()) { |
| 14370 EnsureWritableFastElements(object); | 14377 EnsureWritableFastElements(object); |
| 14371 } | 14378 } |
| 14372 ASSERT(object->HasFastSmiOrObjectElements() || | 14379 ASSERT(object->HasFastSmiOrObjectElements() || |
| 14373 object->HasFastDoubleElements()); | 14380 object->HasFastDoubleElements()); |
| (...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16347 isolate->factory()->NewExternalArray( | 16354 isolate->factory()->NewExternalArray( |
| 16348 fixed_typed_array->length(), typed_array->type(), | 16355 fixed_typed_array->length(), typed_array->type(), |
| 16349 static_cast<uint8_t*>(buffer->backing_store())); | 16356 static_cast<uint8_t*>(buffer->backing_store())); |
| 16350 Handle<Map> new_map = JSObject::GetElementsTransitionMap( | 16357 Handle<Map> new_map = JSObject::GetElementsTransitionMap( |
| 16351 typed_array, | 16358 typed_array, |
| 16352 FixedToExternalElementsKind(map->elements_kind())); | 16359 FixedToExternalElementsKind(map->elements_kind())); |
| 16353 | 16360 |
| 16354 buffer->set_weak_first_view(*typed_array); | 16361 buffer->set_weak_first_view(*typed_array); |
| 16355 ASSERT(typed_array->weak_next() == isolate->heap()->undefined_value()); | 16362 ASSERT(typed_array->weak_next() == isolate->heap()->undefined_value()); |
| 16356 typed_array->set_buffer(*buffer); | 16363 typed_array->set_buffer(*buffer); |
| 16357 typed_array->set_map_and_elements(*new_map, *new_elements); | 16364 JSObject::SetMapAndElements(typed_array, new_map, new_elements); |
| 16358 | 16365 |
| 16359 return buffer; | 16366 return buffer; |
| 16360 } | 16367 } |
| 16361 | 16368 |
| 16362 | 16369 |
| 16363 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { | 16370 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { |
| 16364 Handle<Object> result(buffer(), GetIsolate()); | 16371 Handle<Object> result(buffer(), GetIsolate()); |
| 16365 if (*result != Smi::FromInt(0)) { | 16372 if (*result != Smi::FromInt(0)) { |
| 16366 ASSERT(IsExternalArrayElementsKind(map()->elements_kind())); | 16373 ASSERT(IsExternalArrayElementsKind(map()->elements_kind())); |
| 16367 return Handle<JSArrayBuffer>::cast(result); | 16374 return Handle<JSArrayBuffer>::cast(result); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16432 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16439 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16433 static const char* error_messages_[] = { | 16440 static const char* error_messages_[] = { |
| 16434 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16441 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16435 }; | 16442 }; |
| 16436 #undef ERROR_MESSAGES_TEXTS | 16443 #undef ERROR_MESSAGES_TEXTS |
| 16437 return error_messages_[reason]; | 16444 return error_messages_[reason]; |
| 16438 } | 16445 } |
| 16439 | 16446 |
| 16440 | 16447 |
| 16441 } } // namespace v8::internal | 16448 } } // namespace v8::internal |
| OLD | NEW |