Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: src/objects.cc

Issue 104903002: Generalize AllocationMemento::FindForHeapObject and remove corresponding new space check. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 9153 matching lines...) Expand 10 before | Expand all | Expand 10 after
9164 if (Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) { 9164 if (Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) {
9165 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta); 9165 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta);
9166 } 9166 }
9167 9167
9168 9168
9169 if (new_length == 0) return heap->isolate()->factory()->empty_string(); 9169 if (new_length == 0) return heap->isolate()->factory()->empty_string();
9170 return string; 9170 return string;
9171 } 9171 }
9172 9172
9173 9173
9174 AllocationMemento* AllocationMemento::FindForJSObject(JSObject* object, 9174 AllocationMemento* AllocationMemento::FindForHeapObject(HeapObject* object,
9175 bool in_GC) { 9175 bool in_GC) {
9176 // Currently, AllocationMemento objects are only allocated immediately 9176 // AllocationMemento objects are only allocated immediately after objects in
9177 // after JSArrays and some JSObjects in NewSpace. Detecting whether a 9177 // NewSpace. Detecting whether a memento is present involves carefully
9178 // memento is present involves carefully checking the object immediately 9178 // checking the object immediately after the current object (if there is one)
9179 // after the current object (if there is one) to see if it's an 9179 // to see if it's an AllocationMemento.
9180 // AllocationMemento. 9180 ASSERT(object->GetHeap()->InNewSpace(object));
9181 if (FLAG_track_allocation_sites && object->GetHeap()->InNewSpace(object)) { 9181 if (FLAG_track_allocation_sites) {
9182 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) + 9182 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) +
9183 object->Size(); 9183 object->Size();
9184 Address top; 9184 Address top;
9185 if (in_GC) { 9185 if (in_GC) {
9186 top = object->GetHeap()->new_space()->FromSpacePageHigh(); 9186 top = object->GetHeap()->new_space()->FromSpacePageHigh();
9187 } else { 9187 } else {
9188 top = object->GetHeap()->NewSpaceTop(); 9188 top = object->GetHeap()->NewSpaceTop();
9189 } 9189 }
9190 if ((ptr_end + AllocationMemento::kSize) <= top) { 9190 if ((ptr_end + AllocationMemento::kSize) <= top) {
9191 // There is room in newspace for allocation info. Do we have some? 9191 // There is room in newspace for allocation info. Do we have some?
(...skipping 3687 matching lines...) Expand 10 before | Expand all | Expand 10 after
12879 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), 12879 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
12880 object->UpdateAllocationSite(to_kind)); 12880 object->UpdateAllocationSite(to_kind));
12881 } 12881 }
12882 12882
12883 12883
12884 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { 12884 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
12885 if (!FLAG_track_allocation_sites || !IsJSArray()) { 12885 if (!FLAG_track_allocation_sites || !IsJSArray()) {
12886 return this; 12886 return this;
12887 } 12887 }
12888 12888
12889 AllocationMemento* memento = AllocationMemento::FindForJSObject(this); 12889 if (!GetHeap()->InNewSpace(this)) return this;
12890
12891 AllocationMemento* memento = AllocationMemento::FindForHeapObject(this);
12890 if (memento == NULL || !memento->IsValid()) { 12892 if (memento == NULL || !memento->IsValid()) {
12891 return this; 12893 return this;
12892 } 12894 }
12893 12895
12894 // Walk through to the Allocation Site 12896 // Walk through to the Allocation Site
12895 AllocationSite* site = memento->GetAllocationSite(); 12897 AllocationSite* site = memento->GetAllocationSite();
12896 return site->DigestTransitionFeedback(to_kind); 12898 return site->DigestTransitionFeedback(to_kind);
12897 } 12899 }
12898 12900
12899 12901
(...skipping 3751 matching lines...) Expand 10 before | Expand all | Expand 10 after
16651 #define ERROR_MESSAGES_TEXTS(C, T) T, 16653 #define ERROR_MESSAGES_TEXTS(C, T) T,
16652 static const char* error_messages_[] = { 16654 static const char* error_messages_[] = {
16653 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16655 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16654 }; 16656 };
16655 #undef ERROR_MESSAGES_TEXTS 16657 #undef ERROR_MESSAGES_TEXTS
16656 return error_messages_[reason]; 16658 return error_messages_[reason];
16657 } 16659 }
16658 16660
16659 16661
16660 } } // namespace v8::internal 16662 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698