| 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 9167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9178 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta); | 9178 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta); |
| 9179 } | 9179 } |
| 9180 | 9180 |
| 9181 | 9181 |
| 9182 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9182 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
| 9183 return string; | 9183 return string; |
| 9184 } | 9184 } |
| 9185 | 9185 |
| 9186 | 9186 |
| 9187 AllocationMemento* AllocationMemento::FindForHeapObject(HeapObject* object, | 9187 AllocationMemento* AllocationMemento::FindForHeapObject(HeapObject* object, |
| 9188 Heap* heap, |
| 9188 bool in_GC) { | 9189 bool in_GC) { |
| 9189 // AllocationMemento objects are only allocated immediately after objects in | 9190 // AllocationMemento objects are only allocated immediately after objects in |
| 9190 // NewSpace. Detecting whether a memento is present involves carefully | 9191 // NewSpace. Detecting whether a memento is present involves carefully |
| 9191 // checking the object immediately after the current object (if there is one) | 9192 // checking the object immediately after the current object (if there is one) |
| 9192 // to see if it's an AllocationMemento. | 9193 // to see if it's an AllocationMemento. |
| 9193 ASSERT(object->GetHeap()->InNewSpace(object)); | 9194 ASSERT(heap->InNewSpace(object)); |
| 9194 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + | 9195 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + |
| 9195 object->Size(); | 9196 object->Size(); |
| 9196 Address top; | 9197 Address top; |
| 9197 if (in_GC) { | 9198 if (in_GC) { |
| 9198 top = object->GetHeap()->new_space()->FromSpacePageHigh(); | 9199 top = heap->new_space()->FromSpacePageHigh(); |
| 9199 } else { | 9200 } else { |
| 9200 top = object->GetHeap()->NewSpaceTop(); | 9201 top = heap->NewSpaceTop(); |
| 9201 } | 9202 } |
| 9202 if ((ptr_end + AllocationMemento::kSize) <= top) { | 9203 if ((ptr_end + AllocationMemento::kSize) <= top) { |
| 9203 // There is room in newspace for allocation info. Do we have some? | 9204 // There is room in newspace for allocation info. Do we have some? |
| 9204 Map** possible_allocation_memento_map = | 9205 Map** possible_allocation_memento_map = |
| 9205 reinterpret_cast<Map**>(ptr_end); | 9206 reinterpret_cast<Map**>(ptr_end); |
| 9206 if (*possible_allocation_memento_map == | 9207 if (*possible_allocation_memento_map == |
| 9207 object->GetHeap()->allocation_memento_map()) { | 9208 object->GetHeap()->allocation_memento_map()) { |
| 9208 AllocationMemento* memento = AllocationMemento::cast( | 9209 AllocationMemento* memento = AllocationMemento::cast( |
| 9209 reinterpret_cast<Object*>(ptr_end + kHeapObjectTag)); | 9210 reinterpret_cast<Object*>(ptr_end + kHeapObjectTag)); |
| 9210 if (memento->IsValid()) { | 9211 if (memento->IsValid()) { |
| (...skipping 3557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12768 void JSObject::TransitionElementsKind(Handle<JSObject> object, | 12769 void JSObject::TransitionElementsKind(Handle<JSObject> object, |
| 12769 ElementsKind to_kind) { | 12770 ElementsKind to_kind) { |
| 12770 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), | 12771 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), |
| 12771 object->TransitionElementsKind(to_kind)); | 12772 object->TransitionElementsKind(to_kind)); |
| 12772 } | 12773 } |
| 12773 | 12774 |
| 12774 | 12775 |
| 12775 const double AllocationSite::kPretenureRatio = 0.60; | 12776 const double AllocationSite::kPretenureRatio = 0.60; |
| 12776 | 12777 |
| 12777 | 12778 |
| 12779 void AllocationSite::ResetPretenureDecision() { |
| 12780 dependent_code()->DeoptimizeDependentCodeGroup( |
| 12781 GetIsolate(), |
| 12782 DependentCode::kAllocationSiteTenuringChangedGroup); |
| 12783 set_pretenure_decision(Smi::FromInt(kUndecided)); |
| 12784 set_memento_found_count(Smi::FromInt(0)); |
| 12785 set_memento_create_count(Smi::FromInt(0)); |
| 12786 } |
| 12787 |
| 12788 |
| 12789 PretenureFlag AllocationSite::GetPretenureMode() { |
| 12790 int mode = pretenure_decision()->value(); |
| 12791 // Zombie objects "decide" to be untenured. |
| 12792 return (mode == kTenure && GetHeap()->GetPretenureMode() == TENURED) |
| 12793 ? TENURED : NOT_TENURED; |
| 12794 } |
| 12795 |
| 12796 |
| 12778 bool AllocationSite::IsNestedSite() { | 12797 bool AllocationSite::IsNestedSite() { |
| 12779 ASSERT(FLAG_trace_track_allocation_sites); | 12798 ASSERT(FLAG_trace_track_allocation_sites); |
| 12780 Object* current = GetHeap()->allocation_sites_list(); | 12799 Object* current = GetHeap()->allocation_sites_list(); |
| 12781 while (current->IsAllocationSite()) { | 12800 while (current->IsAllocationSite()) { |
| 12782 AllocationSite* current_site = AllocationSite::cast(current); | 12801 AllocationSite* current_site = AllocationSite::cast(current); |
| 12783 if (current_site->nested_site() == this) { | 12802 if (current_site->nested_site() == this) { |
| 12784 return true; | 12803 return true; |
| 12785 } | 12804 } |
| 12786 current = current_site->weak_next(); | 12805 current = current_site->weak_next(); |
| 12787 } | 12806 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12866 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), | 12885 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), |
| 12867 object->UpdateAllocationSite(to_kind)); | 12886 object->UpdateAllocationSite(to_kind)); |
| 12868 } | 12887 } |
| 12869 | 12888 |
| 12870 | 12889 |
| 12871 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { | 12890 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { |
| 12872 if (!IsJSArray()) { | 12891 if (!IsJSArray()) { |
| 12873 return this; | 12892 return this; |
| 12874 } | 12893 } |
| 12875 | 12894 |
| 12876 if (!GetHeap()->InNewSpace(this)) return this; | 12895 Heap* heap = GetHeap(); |
| 12896 if (!heap->InNewSpace(this)) return this; |
| 12877 | 12897 |
| 12878 AllocationMemento* memento = AllocationMemento::FindForHeapObject(this); | 12898 AllocationMemento* memento = AllocationMemento::FindForHeapObject(this, heap); |
| 12879 if (memento == NULL || !memento->IsValid()) { | 12899 if (memento == NULL || !memento->IsValid()) { |
| 12880 return this; | 12900 return this; |
| 12881 } | 12901 } |
| 12882 | 12902 |
| 12883 // Walk through to the Allocation Site | 12903 // Walk through to the Allocation Site |
| 12884 AllocationSite* site = memento->GetAllocationSite(); | 12904 AllocationSite* site = memento->GetAllocationSite(); |
| 12885 return site->DigestTransitionFeedback(to_kind); | 12905 return site->DigestTransitionFeedback(to_kind); |
| 12886 } | 12906 } |
| 12887 | 12907 |
| 12888 | 12908 |
| (...skipping 3751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16640 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16660 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16641 static const char* error_messages_[] = { | 16661 static const char* error_messages_[] = { |
| 16642 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16662 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16643 }; | 16663 }; |
| 16644 #undef ERROR_MESSAGES_TEXTS | 16664 #undef ERROR_MESSAGES_TEXTS |
| 16645 return error_messages_[reason]; | 16665 return error_messages_[reason]; |
| 16646 } | 16666 } |
| 16647 | 16667 |
| 16648 | 16668 |
| 16649 } } // namespace v8::internal | 16669 } } // namespace v8::internal |
| OLD | NEW |