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

Side by Side Diff: src/serialize.cc

Issue 944923005: Use easier method to determine allocation space when serializing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comment Created 5 years, 10 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
« no previous file with comments | « src/serialize.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 1870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 // The exception are native source code strings, since we can recreate 1881 // The exception are native source code strings, since we can recreate
1882 // their resources. In that case we fall through and leave it to 1882 // their resources. In that case we fall through and leave it to
1883 // VisitExternalOneByteString further down. 1883 // VisitExternalOneByteString further down.
1884 SerializeExternalString(); 1884 SerializeExternalString();
1885 return; 1885 return;
1886 } 1886 }
1887 } 1887 }
1888 1888
1889 int size = object_->Size(); 1889 int size = object_->Size();
1890 Map* map = object_->map(); 1890 Map* map = object_->map();
1891 SerializePrologue(Serializer::SpaceOfObject(object_), size, map); 1891 AllocationSpace space =
1892 MemoryChunk::FromAddress(object_->address())->owner()->identity();
1893 SerializePrologue(space, size, map);
1892 1894
1893 // Serialize the rest of the object. 1895 // Serialize the rest of the object.
1894 CHECK_EQ(0, bytes_processed_so_far_); 1896 CHECK_EQ(0, bytes_processed_so_far_);
1895 bytes_processed_so_far_ = kPointerSize; 1897 bytes_processed_so_far_ = kPointerSize;
1896 1898
1897 object_->IterateBody(map->instance_type(), size, this); 1899 object_->IterateBody(map->instance_type(), size, this);
1898 OutputRawData(object_->address() + size); 1900 OutputRawData(object_->address() + size);
1899 } 1901 }
1900 1902
1901 1903
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 } 2123 }
2122 if (to_skip != 0 && return_skip == kIgnoringReturn) { 2124 if (to_skip != 0 && return_skip == kIgnoringReturn) {
2123 sink_->Put(kSkip, "Skip"); 2125 sink_->Put(kSkip, "Skip");
2124 sink_->PutInt(to_skip, "SkipDistance"); 2126 sink_->PutInt(to_skip, "SkipDistance");
2125 to_skip = 0; 2127 to_skip = 0;
2126 } 2128 }
2127 return to_skip; 2129 return to_skip;
2128 } 2130 }
2129 2131
2130 2132
2131 AllocationSpace Serializer::SpaceOfObject(HeapObject* object) {
2132 for (int i = FIRST_SPACE; i <= LAST_SPACE; i++) {
2133 AllocationSpace s = static_cast<AllocationSpace>(i);
2134 if (object->GetHeap()->InSpace(object, s)) {
2135 DCHECK(i < kNumberOfSpaces);
2136 return s;
2137 }
2138 }
2139 UNREACHABLE();
2140 return FIRST_SPACE;
2141 }
2142
2143
2144 BackReference Serializer::AllocateLargeObject(int size) { 2133 BackReference Serializer::AllocateLargeObject(int size) {
2145 // Large objects are allocated one-by-one when deserializing. We do not 2134 // Large objects are allocated one-by-one when deserializing. We do not
2146 // have to keep track of multiple chunks. 2135 // have to keep track of multiple chunks.
2147 large_objects_total_size_ += size; 2136 large_objects_total_size_ += size;
2148 return BackReference::LargeObjectReference(seen_large_objects_index_++); 2137 return BackReference::LargeObjectReference(seen_large_objects_index_++);
2149 } 2138 }
2150 2139
2151 2140
2152 BackReference Serializer::Allocate(AllocationSpace space, int size) { 2141 BackReference Serializer::Allocate(AllocationSpace space, int size) {
2153 DCHECK(space >= 0 && space < kNumberOfPreallocatedSpaces); 2142 DCHECK(space >= 0 && space < kNumberOfPreallocatedSpaces);
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 DisallowHeapAllocation no_gc; 2653 DisallowHeapAllocation no_gc;
2665 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2654 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2666 SanityCheckResult r = scd->SanityCheck(source); 2655 SanityCheckResult r = scd->SanityCheck(source);
2667 if (r == CHECK_SUCCESS) return scd; 2656 if (r == CHECK_SUCCESS) return scd;
2668 cached_data->Reject(); 2657 cached_data->Reject();
2669 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2658 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2670 delete scd; 2659 delete scd;
2671 return NULL; 2660 return NULL;
2672 } 2661 }
2673 } } // namespace v8::internal 2662 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698