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

Side by Side Diff: src/objects.cc

Issue 136633002: Inline AllocationMemento::FindForHeapObject() into the two call sites. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 months 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 9183 matching lines...) Expand 10 before | Expand all | Expand 10 after
9194 if (Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) { 9194 if (Marking::IsBlack(Marking::MarkBitFrom(start_of_string))) {
9195 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta); 9195 MemoryChunk::IncrementLiveBytesFromMutator(start_of_string, -delta);
9196 } 9196 }
9197 9197
9198 9198
9199 if (new_length == 0) return heap->isolate()->factory()->empty_string(); 9199 if (new_length == 0) return heap->isolate()->factory()->empty_string();
9200 return string; 9200 return string;
9201 } 9201 }
9202 9202
9203 9203
9204 AllocationMemento* AllocationMemento::FindForHeapObject(HeapObject* object,
9205 Heap* heap,
9206 bool in_GC) {
9207 // AllocationMemento objects are only allocated immediately after objects in
9208 // NewSpace. Detecting whether a memento is present involves carefully
9209 // checking the object immediately after the current object (if there is one)
9210 // to see if it's an AllocationMemento.
9211 ASSERT(heap->InNewSpace(object));
9212 Address ptr_end = (reinterpret_cast<Address>(object) - kHeapObjectTag) +
9213 object->Size();
9214 Address top;
9215 if (in_GC) {
9216 top = heap->new_space()->FromSpacePageHigh();
9217 } else {
9218 top = heap->NewSpaceTop();
9219 }
9220 if ((ptr_end + AllocationMemento::kSize) <= top) {
9221 // There is room in newspace for allocation info. Do we have some?
9222 Map** possible_allocation_memento_map =
9223 reinterpret_cast<Map**>(ptr_end);
9224 if (*possible_allocation_memento_map ==
9225 object->GetHeap()->allocation_memento_map()) {
9226 AllocationMemento* memento = AllocationMemento::cast(
9227 reinterpret_cast<Object*>(ptr_end + kHeapObjectTag));
9228 if (memento->IsValid()) {
9229 return memento;
9230 }
9231 }
9232 }
9233 return NULL;
9234 }
9235
9236
9237 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) { 9204 uint32_t StringHasher::MakeArrayIndexHash(uint32_t value, int length) {
9238 // For array indexes mix the length into the hash as an array index could 9205 // For array indexes mix the length into the hash as an array index could
9239 // be zero. 9206 // be zero.
9240 ASSERT(length > 0); 9207 ASSERT(length > 0);
9241 ASSERT(length <= String::kMaxArrayIndexSize); 9208 ASSERT(length <= String::kMaxArrayIndexSize);
9242 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) < 9209 ASSERT(TenToThe(String::kMaxCachedArrayIndexLength) <
9243 (1 << String::kArrayIndexValueBits)); 9210 (1 << String::kArrayIndexValueBits));
9244 9211
9245 value <<= String::kHashShift; 9212 value <<= String::kHashShift;
9246 value |= length << String::kArrayIndexHashLengthShift; 9213 value |= length << String::kArrayIndexHashLengthShift;
(...skipping 3650 matching lines...) Expand 10 before | Expand all | Expand 10 after
12897 12864
12898 12865
12899 void JSObject::UpdateAllocationSite(Handle<JSObject> object, 12866 void JSObject::UpdateAllocationSite(Handle<JSObject> object,
12900 ElementsKind to_kind) { 12867 ElementsKind to_kind) {
12901 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(), 12868 CALL_HEAP_FUNCTION_VOID(object->GetIsolate(),
12902 object->UpdateAllocationSite(to_kind)); 12869 object->UpdateAllocationSite(to_kind));
12903 } 12870 }
12904 12871
12905 12872
12906 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) { 12873 MaybeObject* JSObject::UpdateAllocationSite(ElementsKind to_kind) {
12907 if (!IsJSArray()) { 12874 if (!IsJSArray()) return this;
12908 return this;
12909 }
12910 12875
12911 Heap* heap = GetHeap(); 12876 Heap* heap = GetHeap();
12912 if (!heap->InNewSpace(this)) return this; 12877 if (!heap->InNewSpace(this)) return this;
12913 12878
12914 AllocationMemento* memento = AllocationMemento::FindForHeapObject(this, heap); 12879 // Either object is the last object in the new space, or there is another
12915 if (memento == NULL || !memento->IsValid()) { 12880 // object of at least word size (the header map word) following it, so
12916 return this; 12881 // suffices to compare ptr and top here.
12917 } 12882 Address ptr = address() + JSArray::kSize;
12883 Address top = heap->NewSpaceTop();
12884 ASSERT(ptr == top || ptr + HeapObject::kHeaderSize <= top);
12885 if (ptr == top) return this;
12886
12887 HeapObject* candidate = HeapObject::FromAddress(ptr);
12888 if (candidate->map() != heap->allocation_memento_map()) return this;
12889
12890 AllocationMemento* memento = AllocationMemento::cast(candidate);
12891 if (!memento->IsValid()) return this;
12918 12892
12919 // Walk through to the Allocation Site 12893 // Walk through to the Allocation Site
12920 AllocationSite* site = memento->GetAllocationSite(); 12894 AllocationSite* site = memento->GetAllocationSite();
12921 return site->DigestTransitionFeedback(to_kind); 12895 return site->DigestTransitionFeedback(to_kind);
12922 } 12896 }
12923 12897
12924 12898
12925 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) { 12899 MaybeObject* JSObject::TransitionElementsKind(ElementsKind to_kind) {
12926 ElementsKind from_kind = map()->elements_kind(); 12900 ElementsKind from_kind = map()->elements_kind();
12927 12901
(...skipping 3747 matching lines...) Expand 10 before | Expand all | Expand 10 after
16675 #define ERROR_MESSAGES_TEXTS(C, T) T, 16649 #define ERROR_MESSAGES_TEXTS(C, T) T,
16676 static const char* error_messages_[] = { 16650 static const char* error_messages_[] = {
16677 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16651 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16678 }; 16652 };
16679 #undef ERROR_MESSAGES_TEXTS 16653 #undef ERROR_MESSAGES_TEXTS
16680 return error_messages_[reason]; 16654 return error_messages_[reason];
16681 } 16655 }
16682 16656
16683 16657
16684 } } // namespace v8::internal 16658 } } // 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