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 6491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11176 } | 11183 } |
11177 Handle<FixedArrayBase> old_elements(object->elements()); | 11184 Handle<FixedArrayBase> old_elements(object->elements()); |
11178 ElementsAccessor* accessor = ElementsAccessor::ForKind(new_elements_kind); | 11185 ElementsAccessor* accessor = ElementsAccessor::ForKind(new_elements_kind); |
11179 accessor->CopyElements(object, new_elements, elements_kind); | 11186 accessor->CopyElements(object, new_elements, elements_kind); |
11180 | 11187 |
11181 if (elements_kind != SLOPPY_ARGUMENTS_ELEMENTS) { | 11188 if (elements_kind != SLOPPY_ARGUMENTS_ELEMENTS) { |
11182 Handle<Map> new_map = (new_elements_kind != elements_kind) | 11189 Handle<Map> new_map = (new_elements_kind != elements_kind) |
11183 ? GetElementsTransitionMap(object, new_elements_kind) | 11190 ? GetElementsTransitionMap(object, new_elements_kind) |
11184 : handle(object->map()); | 11191 : handle(object->map()); |
11185 object->ValidateElements(); | 11192 object->ValidateElements(); |
11186 object->set_map_and_elements(*new_map, *new_elements); | 11193 JSObject::SetMapAndElements(object, new_map, new_elements); |
11187 | 11194 |
11188 // Transition through the allocation site as well if present. | 11195 // Transition through the allocation site as well if present. |
11189 JSObject::UpdateAllocationSite(object, new_elements_kind); | 11196 JSObject::UpdateAllocationSite(object, new_elements_kind); |
11190 } else { | 11197 } else { |
11191 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements); | 11198 Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(old_elements); |
11192 parameter_map->set(1, *new_elements); | 11199 parameter_map->set(1, *new_elements); |
11193 } | 11200 } |
11194 | 11201 |
11195 if (FLAG_trace_elements_transitions) { | 11202 if (FLAG_trace_elements_transitions) { |
11196 PrintElementsTransition(stdout, object, elements_kind, old_elements, | 11203 PrintElementsTransition(stdout, object, elements_kind, old_elements, |
(...skipping 25 matching lines...) Expand all Loading... |
11222 new_elements_kind = FAST_DOUBLE_ELEMENTS; | 11229 new_elements_kind = FAST_DOUBLE_ELEMENTS; |
11223 } | 11230 } |
11224 | 11231 |
11225 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind); | 11232 Handle<Map> new_map = GetElementsTransitionMap(object, new_elements_kind); |
11226 | 11233 |
11227 Handle<FixedArrayBase> old_elements(object->elements()); | 11234 Handle<FixedArrayBase> old_elements(object->elements()); |
11228 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); | 11235 ElementsAccessor* accessor = ElementsAccessor::ForKind(FAST_DOUBLE_ELEMENTS); |
11229 accessor->CopyElements(object, elems, elements_kind); | 11236 accessor->CopyElements(object, elems, elements_kind); |
11230 | 11237 |
11231 object->ValidateElements(); | 11238 object->ValidateElements(); |
11232 object->set_map_and_elements(*new_map, *elems); | 11239 JSObject::SetMapAndElements(object, new_map, elems); |
11233 | 11240 |
11234 if (FLAG_trace_elements_transitions) { | 11241 if (FLAG_trace_elements_transitions) { |
11235 PrintElementsTransition(stdout, object, elements_kind, old_elements, | 11242 PrintElementsTransition(stdout, object, elements_kind, old_elements, |
11236 object->GetElementsKind(), elems); | 11243 object->GetElementsKind(), elems); |
11237 } | 11244 } |
11238 | 11245 |
11239 if (object->IsJSArray()) { | 11246 if (object->IsJSArray()) { |
11240 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); | 11247 Handle<JSArray>::cast(object)->set_length(Smi::FromInt(length)); |
11241 } | 11248 } |
11242 } | 11249 } |
(...skipping 3119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14362 Handle<Map> new_map = | 14369 Handle<Map> new_map = |
14363 JSObject::GetElementsTransitionMap(object, FAST_HOLEY_ELEMENTS); | 14370 JSObject::GetElementsTransitionMap(object, FAST_HOLEY_ELEMENTS); |
14364 | 14371 |
14365 PretenureFlag tenure = isolate->heap()->InNewSpace(*object) ? | 14372 PretenureFlag tenure = isolate->heap()->InNewSpace(*object) ? |
14366 NOT_TENURED: TENURED; | 14373 NOT_TENURED: TENURED; |
14367 Handle<FixedArray> fast_elements = | 14374 Handle<FixedArray> fast_elements = |
14368 isolate->factory()->NewFixedArray(dict->NumberOfElements(), tenure); | 14375 isolate->factory()->NewFixedArray(dict->NumberOfElements(), tenure); |
14369 dict->CopyValuesTo(*fast_elements); | 14376 dict->CopyValuesTo(*fast_elements); |
14370 object->ValidateElements(); | 14377 object->ValidateElements(); |
14371 | 14378 |
14372 object->set_map_and_elements(*new_map, *fast_elements); | 14379 JSObject::SetMapAndElements(object, new_map, fast_elements); |
14373 } else if (object->HasExternalArrayElements() || | 14380 } else if (object->HasExternalArrayElements() || |
14374 object->HasFixedTypedArrayElements()) { | 14381 object->HasFixedTypedArrayElements()) { |
14375 // Typed arrays cannot have holes or undefined elements. | 14382 // Typed arrays cannot have holes or undefined elements. |
14376 return handle(Smi::FromInt( | 14383 return handle(Smi::FromInt( |
14377 FixedArrayBase::cast(object->elements())->length()), isolate); | 14384 FixedArrayBase::cast(object->elements())->length()), isolate); |
14378 } else if (!object->HasFastDoubleElements()) { | 14385 } else if (!object->HasFastDoubleElements()) { |
14379 EnsureWritableFastElements(object); | 14386 EnsureWritableFastElements(object); |
14380 } | 14387 } |
14381 ASSERT(object->HasFastSmiOrObjectElements() || | 14388 ASSERT(object->HasFastSmiOrObjectElements() || |
14382 object->HasFastDoubleElements()); | 14389 object->HasFastDoubleElements()); |
(...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16356 isolate->factory()->NewExternalArray( | 16363 isolate->factory()->NewExternalArray( |
16357 fixed_typed_array->length(), typed_array->type(), | 16364 fixed_typed_array->length(), typed_array->type(), |
16358 static_cast<uint8_t*>(buffer->backing_store())); | 16365 static_cast<uint8_t*>(buffer->backing_store())); |
16359 Handle<Map> new_map = JSObject::GetElementsTransitionMap( | 16366 Handle<Map> new_map = JSObject::GetElementsTransitionMap( |
16360 typed_array, | 16367 typed_array, |
16361 FixedToExternalElementsKind(map->elements_kind())); | 16368 FixedToExternalElementsKind(map->elements_kind())); |
16362 | 16369 |
16363 buffer->set_weak_first_view(*typed_array); | 16370 buffer->set_weak_first_view(*typed_array); |
16364 ASSERT(typed_array->weak_next() == isolate->heap()->undefined_value()); | 16371 ASSERT(typed_array->weak_next() == isolate->heap()->undefined_value()); |
16365 typed_array->set_buffer(*buffer); | 16372 typed_array->set_buffer(*buffer); |
16366 typed_array->set_map_and_elements(*new_map, *new_elements); | 16373 JSObject::SetMapAndElements(typed_array, new_map, new_elements); |
16367 | 16374 |
16368 return buffer; | 16375 return buffer; |
16369 } | 16376 } |
16370 | 16377 |
16371 | 16378 |
16372 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { | 16379 Handle<JSArrayBuffer> JSTypedArray::GetBuffer() { |
16373 Handle<Object> result(buffer(), GetIsolate()); | 16380 Handle<Object> result(buffer(), GetIsolate()); |
16374 if (*result != Smi::FromInt(0)) { | 16381 if (*result != Smi::FromInt(0)) { |
16375 ASSERT(IsExternalArrayElementsKind(map()->elements_kind())); | 16382 ASSERT(IsExternalArrayElementsKind(map()->elements_kind())); |
16376 return Handle<JSArrayBuffer>::cast(result); | 16383 return Handle<JSArrayBuffer>::cast(result); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16441 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16448 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16442 static const char* error_messages_[] = { | 16449 static const char* error_messages_[] = { |
16443 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16450 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16444 }; | 16451 }; |
16445 #undef ERROR_MESSAGES_TEXTS | 16452 #undef ERROR_MESSAGES_TEXTS |
16446 return error_messages_[reason]; | 16453 return error_messages_[reason]; |
16447 } | 16454 } |
16448 | 16455 |
16449 | 16456 |
16450 } } // namespace v8::internal | 16457 } } // namespace v8::internal |
OLD | NEW |