Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 const byte* addr = reinterpret_cast<const byte*>(object_); |
| 1892 AllocationSpace space = MemoryChunk::FromAddress(addr)->owner()->identity(); | |
|
Hannes Payer (out of office)
2015/02/25 13:19:33
Please use object->address().
| |
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |