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/heap-inl.h

Issue 325553002: --verify-predictable mode added for ensuring that GC behaves deterministically. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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
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 #ifndef V8_HEAP_INL_H_ 5 #ifndef V8_HEAP_INL_H_
6 #define V8_HEAP_INL_H_ 6 #define V8_HEAP_INL_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "src/heap.h" 10 #include "src/heap.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 allocation = map_space_->AllocateRaw(size_in_bytes); 228 allocation = map_space_->AllocateRaw(size_in_bytes);
229 } 229 }
230 if (allocation.IsRetry()) old_gen_exhausted_ = true; 230 if (allocation.IsRetry()) old_gen_exhausted_ = true;
231 if (profiler->is_tracking_allocations() && allocation.To(&object)) { 231 if (profiler->is_tracking_allocations() && allocation.To(&object)) {
232 profiler->AllocationEvent(object->address(), size_in_bytes); 232 profiler->AllocationEvent(object->address(), size_in_bytes);
233 } 233 }
234 return allocation; 234 return allocation;
235 } 235 }
236 236
237 237
238 void Heap::OnAllocationEvent(HeapObject* object, int size_in_bytes) {
239 ++allocations_count_;
240
241 Address object_address = object->address();
242 MemoryChunk* memory_chunk = MemoryChunk::FromAddress(object_address);
243 uint32_t offset =
244 static_cast<uint32_t>(object_address - memory_chunk->address());
245
246 UpdateAllocationsHash(offset);
247 UpdateAllocationsHash(size_in_bytes);
248 UpdateAllocationsHash(memory_chunk->owner()->identity());
249
250 if (FLAG_dump_allocations_digest_at_alloc > 0) {
251 if (--dump_allocations_hash_countdown_ == 0) {
252 dump_allocations_hash_countdown_ = FLAG_dump_allocations_digest_at_alloc;
253 PrintAlloctionsHash();
254 }
255 }
256 }
257
258
259 void Heap::UpdateAllocationsHash(uint32_t value) {
260 uint16_t c1 = static_cast<uint16_t>(value);
261 uint16_t c2 = static_cast<uint16_t>(value >> 16);
262 raw_allocations_hash_ =
263 StringHasher::AddCharacterCore(raw_allocations_hash_, c1);
264 raw_allocations_hash_ =
265 StringHasher::AddCharacterCore(raw_allocations_hash_, c2);
266 }
267
268
269 void Heap::PrintAlloctionsHash() {
270 uint32_t hash = StringHasher::GetHashCore(raw_allocations_hash_);
271 PrintF("\n### Allocations = %u, hash = 0x%08x\n", allocations_count_, hash);
272 }
273
274
238 void Heap::FinalizeExternalString(String* string) { 275 void Heap::FinalizeExternalString(String* string) {
239 ASSERT(string->IsExternalString()); 276 ASSERT(string->IsExternalString());
240 v8::String::ExternalStringResourceBase** resource_addr = 277 v8::String::ExternalStringResourceBase** resource_addr =
241 reinterpret_cast<v8::String::ExternalStringResourceBase**>( 278 reinterpret_cast<v8::String::ExternalStringResourceBase**>(
242 reinterpret_cast<byte*>(string) + 279 reinterpret_cast<byte*>(string) +
243 ExternalString::kResourceOffset - 280 ExternalString::kResourceOffset -
244 kHeapObjectTag); 281 kHeapObjectTag);
245 282
246 // Dispose of the C++ object if it has not already been disposed. 283 // Dispose of the C++ object if it has not already been disposed.
247 if (*resource_addr != NULL) { 284 if (*resource_addr != NULL) {
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 762
726 763
727 double GCTracer::SizeOfHeapObjects() { 764 double GCTracer::SizeOfHeapObjects() {
728 return (static_cast<double>(heap_->SizeOfObjects())) / MB; 765 return (static_cast<double>(heap_->SizeOfObjects())) / MB;
729 } 766 }
730 767
731 768
732 } } // namespace v8::internal 769 } } // namespace v8::internal
733 770
734 #endif // V8_HEAP_INL_H_ 771 #endif // V8_HEAP_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698