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 10865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10876 | 10876 |
10877 if (elements_kind != NON_STRICT_ARGUMENTS_ELEMENTS) { | 10877 if (elements_kind != NON_STRICT_ARGUMENTS_ELEMENTS) { |
10878 Map* new_map = map(); | 10878 Map* new_map = map(); |
10879 if (new_elements_kind != elements_kind) { | 10879 if (new_elements_kind != elements_kind) { |
10880 MaybeObject* maybe = | 10880 MaybeObject* maybe = |
10881 GetElementsTransitionMap(GetIsolate(), new_elements_kind); | 10881 GetElementsTransitionMap(GetIsolate(), new_elements_kind); |
10882 if (!maybe->To(&new_map)) return maybe; | 10882 if (!maybe->To(&new_map)) return maybe; |
10883 } | 10883 } |
10884 ValidateElements(); | 10884 ValidateElements(); |
10885 set_map_and_elements(new_map, new_elements); | 10885 set_map_and_elements(new_map, new_elements); |
| 10886 |
| 10887 // Transition through the allocation site as well if present. |
| 10888 maybe_obj = UpdateAllocationSite(new_elements_kind); |
| 10889 if (maybe_obj->IsFailure()) return maybe_obj; |
10886 } else { | 10890 } else { |
10887 FixedArray* parameter_map = FixedArray::cast(old_elements); | 10891 FixedArray* parameter_map = FixedArray::cast(old_elements); |
10888 parameter_map->set(1, new_elements); | 10892 parameter_map->set(1, new_elements); |
10889 } | 10893 } |
10890 | 10894 |
10891 if (FLAG_trace_elements_transitions) { | 10895 if (FLAG_trace_elements_transitions) { |
10892 PrintElementsTransition(stdout, elements_kind, old_elements, | 10896 PrintElementsTransition(stdout, elements_kind, old_elements, |
10893 GetElementsKind(), new_elements); | 10897 GetElementsKind(), new_elements); |
10894 } | 10898 } |
10895 | 10899 |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12399 | 12403 |
12400 // Walk through to the Allocation Site | 12404 // Walk through to the Allocation Site |
12401 AllocationSite* site = memento->GetAllocationSite(); | 12405 AllocationSite* site = memento->GetAllocationSite(); |
12402 if (site->IsLiteralSite()) { | 12406 if (site->IsLiteralSite()) { |
12403 JSArray* transition_info = JSArray::cast(site->transition_info()); | 12407 JSArray* transition_info = JSArray::cast(site->transition_info()); |
12404 ElementsKind kind = transition_info->GetElementsKind(); | 12408 ElementsKind kind = transition_info->GetElementsKind(); |
12405 // if kind is holey ensure that to_kind is as well. | 12409 // if kind is holey ensure that to_kind is as well. |
12406 if (IsHoleyElementsKind(kind)) { | 12410 if (IsHoleyElementsKind(kind)) { |
12407 to_kind = GetHoleyElementsKind(to_kind); | 12411 to_kind = GetHoleyElementsKind(to_kind); |
12408 } | 12412 } |
12409 if (AllocationSite::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { | 12413 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
12410 // If the array is huge, it's not likely to be defined in a local | 12414 // If the array is huge, it's not likely to be defined in a local |
12411 // function, so we shouldn't make new instances of it very often. | 12415 // function, so we shouldn't make new instances of it very often. |
12412 uint32_t length = 0; | 12416 uint32_t length = 0; |
12413 CHECK(transition_info->length()->ToArrayIndex(&length)); | 12417 CHECK(transition_info->length()->ToArrayIndex(&length)); |
12414 if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { | 12418 if (length <= AllocationSite::kMaximumArrayBytesToPretransition) { |
12415 if (FLAG_trace_track_allocation_sites) { | 12419 if (FLAG_trace_track_allocation_sites) { |
12416 PrintF( | 12420 PrintF( |
12417 "AllocationSite: JSArray %p boilerplate updated %s->%s\n", | 12421 "AllocationSite: JSArray %p boilerplate updated %s->%s\n", |
12418 reinterpret_cast<void*>(this), | 12422 reinterpret_cast<void*>(this), |
12419 ElementsKindToString(kind), | 12423 ElementsKindToString(kind), |
12420 ElementsKindToString(to_kind)); | 12424 ElementsKindToString(to_kind)); |
12421 } | 12425 } |
12422 return transition_info->TransitionElementsKind(to_kind); | 12426 return transition_info->TransitionElementsKind(to_kind); |
12423 } | 12427 } |
12424 } | 12428 } |
12425 } else { | 12429 } else { |
12426 ElementsKind kind = site->GetElementsKind(); | 12430 ElementsKind kind = site->GetElementsKind(); |
12427 // if kind is holey ensure that to_kind is as well. | 12431 // if kind is holey ensure that to_kind is as well. |
12428 if (IsHoleyElementsKind(kind)) { | 12432 if (IsHoleyElementsKind(kind)) { |
12429 to_kind = GetHoleyElementsKind(to_kind); | 12433 to_kind = GetHoleyElementsKind(to_kind); |
12430 } | 12434 } |
12431 if (AllocationSite::GetMode(kind, to_kind) == TRACK_ALLOCATION_SITE) { | 12435 if (IsMoreGeneralElementsKindTransition(kind, to_kind)) { |
12432 if (FLAG_trace_track_allocation_sites) { | 12436 if (FLAG_trace_track_allocation_sites) { |
12433 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", | 12437 PrintF("AllocationSite: JSArray %p site updated %s->%s\n", |
12434 reinterpret_cast<void*>(this), | 12438 reinterpret_cast<void*>(this), |
12435 ElementsKindToString(kind), | 12439 ElementsKindToString(kind), |
12436 ElementsKindToString(to_kind)); | 12440 ElementsKindToString(to_kind)); |
12437 } | 12441 } |
12438 site->set_transition_info(Smi::FromInt(to_kind)); | 12442 site->set_transition_info(Smi::FromInt(to_kind)); |
12439 } | 12443 } |
12440 } | 12444 } |
12441 return this; | 12445 return this; |
(...skipping 3540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15982 #define ERROR_MESSAGES_TEXTS(C, T) T, | 15986 #define ERROR_MESSAGES_TEXTS(C, T) T, |
15983 static const char* error_messages_[] = { | 15987 static const char* error_messages_[] = { |
15984 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 15988 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
15985 }; | 15989 }; |
15986 #undef ERROR_MESSAGES_TEXTS | 15990 #undef ERROR_MESSAGES_TEXTS |
15987 return error_messages_[reason]; | 15991 return error_messages_[reason]; |
15988 } | 15992 } |
15989 | 15993 |
15990 | 15994 |
15991 } } // namespace v8::internal | 15995 } } // namespace v8::internal |
OLD | NEW |