OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 14698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14709 JSArray* array; | 14709 JSArray* array; |
14710 MaybeObject* maybe_array; | 14710 MaybeObject* maybe_array; |
14711 if (!site.is_null() && can_use_type_feedback) { | 14711 if (!site.is_null() && can_use_type_feedback) { |
14712 ElementsKind to_kind = site->GetElementsKind(); | 14712 ElementsKind to_kind = site->GetElementsKind(); |
14713 if (holey && !IsFastHoleyElementsKind(to_kind)) { | 14713 if (holey && !IsFastHoleyElementsKind(to_kind)) { |
14714 to_kind = GetHoleyElementsKind(to_kind); | 14714 to_kind = GetHoleyElementsKind(to_kind); |
14715 // Update the allocation site info to reflect the advice alteration. | 14715 // Update the allocation site info to reflect the advice alteration. |
14716 site->SetElementsKind(to_kind); | 14716 site->SetElementsKind(to_kind); |
14717 } | 14717 } |
14718 | 14718 |
14719 maybe_array = isolate->heap()->AllocateJSObjectWithAllocationSite( | 14719 // We should allocate with an initial map that reflects the allocation site |
14720 *constructor, site); | 14720 // advice. Therefore we use AllocateJSObjectFromMap instead of passing |
| 14721 // the constructor. |
| 14722 Map* initial_map = constructor->initial_map(); |
| 14723 if (to_kind != initial_map->elements_kind()) { |
| 14724 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind); |
| 14725 if (!maybe_new_map->To(&initial_map)) return maybe_new_map; |
| 14726 } |
| 14727 |
| 14728 // If we don't care to track arrays of to_kind ElementsKind, then |
| 14729 // don't emit a memento for them. |
| 14730 AllocationSite* allocation_site = |
| 14731 (AllocationSite::GetMode(to_kind) == TRACK_ALLOCATION_SITE) |
| 14732 ? *site |
| 14733 : NULL; |
| 14734 |
| 14735 maybe_array = isolate->heap()->AllocateJSObjectFromMap(initial_map, |
| 14736 NOT_TENURED, |
| 14737 true, |
| 14738 allocation_site); |
14721 if (!maybe_array->To(&array)) return maybe_array; | 14739 if (!maybe_array->To(&array)) return maybe_array; |
14722 } else { | 14740 } else { |
14723 maybe_array = isolate->heap()->AllocateJSObject(*constructor); | 14741 maybe_array = isolate->heap()->AllocateJSObject(*constructor); |
14724 if (!maybe_array->To(&array)) return maybe_array; | 14742 if (!maybe_array->To(&array)) return maybe_array; |
14725 // We might need to transition to holey | 14743 // We might need to transition to holey |
14726 ElementsKind kind = constructor->initial_map()->elements_kind(); | 14744 ElementsKind kind = constructor->initial_map()->elements_kind(); |
14727 if (holey && !IsFastHoleyElementsKind(kind)) { | 14745 if (holey && !IsFastHoleyElementsKind(kind)) { |
14728 kind = GetHoleyElementsKind(kind); | 14746 kind = GetHoleyElementsKind(kind); |
14729 maybe_array = array->TransitionElementsKind(kind); | 14747 maybe_array = array->TransitionElementsKind(kind); |
14730 if (maybe_array->IsFailure()) return maybe_array; | 14748 if (maybe_array->IsFailure()) return maybe_array; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14891 // Handle last resort GC and make sure to allow future allocations | 14909 // Handle last resort GC and make sure to allow future allocations |
14892 // to grow the heap without causing GCs (if possible). | 14910 // to grow the heap without causing GCs (if possible). |
14893 isolate->counters()->gc_last_resort_from_js()->Increment(); | 14911 isolate->counters()->gc_last_resort_from_js()->Increment(); |
14894 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 14912 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
14895 "Runtime::PerformGC"); | 14913 "Runtime::PerformGC"); |
14896 } | 14914 } |
14897 } | 14915 } |
14898 | 14916 |
14899 | 14917 |
14900 } } // namespace v8::internal | 14918 } } // namespace v8::internal |
OLD | NEW |