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-profiler.cc

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-profiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009-2010 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
11 // with the distribution. 11 // with the distribution.
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 #ifdef ENABLE_LOGGING_AND_PROFILING 341 #ifdef ENABLE_LOGGING_AND_PROFILING
342 Isolate* isolate = Isolate::Current(); 342 Isolate* isolate = Isolate::Current();
343 delete isolate->heap_profiler(); 343 delete isolate->heap_profiler();
344 isolate->set_heap_profiler(NULL); 344 isolate->set_heap_profiler(NULL);
345 #endif 345 #endif
346 } 346 }
347 347
348 348
349 #ifdef ENABLE_LOGGING_AND_PROFILING 349 #ifdef ENABLE_LOGGING_AND_PROFILING
350 350
351 HeapSnapshot* HeapProfiler::TakeSnapshot(const char* name, int type) { 351 HeapSnapshot* HeapProfiler::TakeSnapshot(const char* name,
352 int type,
353 v8::ActivityControl* control) {
352 ASSERT(Isolate::Current()->heap_profiler() != NULL); 354 ASSERT(Isolate::Current()->heap_profiler() != NULL);
353 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, type); 355 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name,
356 type,
357 control);
354 } 358 }
355 359
356 360
357 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, int type) { 361 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name,
362 int type,
363 v8::ActivityControl* control) {
358 ASSERT(Isolate::Current()->heap_profiler() != NULL); 364 ASSERT(Isolate::Current()->heap_profiler() != NULL);
359 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, type); 365 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name,
366 type,
367 control);
360 } 368 }
361 369
362 370
363 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, int type) { 371 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name,
364 HEAP->CollectAllGarbage(true); 372 int type,
373 v8::ActivityControl* control) {
365 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); 374 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type);
366 HeapSnapshot* result = 375 HeapSnapshot* result =
367 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); 376 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++);
377 bool generation_completed = true;
368 switch (s_type) { 378 switch (s_type) {
369 case HeapSnapshot::kFull: { 379 case HeapSnapshot::kFull: {
370 HeapSnapshotGenerator generator(result); 380 HeapSnapshotGenerator generator(result, control);
371 generator.GenerateSnapshot(); 381 generation_completed = generator.GenerateSnapshot();
372 break; 382 break;
373 } 383 }
374 case HeapSnapshot::kAggregated: { 384 case HeapSnapshot::kAggregated: {
385 HEAP->CollectAllGarbage(true);
375 AggregatedHeapSnapshot agg_snapshot; 386 AggregatedHeapSnapshot agg_snapshot;
376 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); 387 AggregatedHeapSnapshotGenerator generator(&agg_snapshot);
377 generator.GenerateSnapshot(); 388 generator.GenerateSnapshot();
378 generator.FillHeapSnapshot(result); 389 generator.FillHeapSnapshot(result);
379 break; 390 break;
380 } 391 }
381 default: 392 default:
382 UNREACHABLE(); 393 UNREACHABLE();
383 } 394 }
384 snapshots_->SnapshotGenerationFinished(); 395 if (!generation_completed) {
396 delete result;
397 result = NULL;
398 }
399 snapshots_->SnapshotGenerationFinished(result);
385 return result; 400 return result;
386 } 401 }
387 402
388 403
389 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, int type) { 404 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name,
390 return TakeSnapshotImpl(snapshots_->GetName(name), type); 405 int type,
406 v8::ActivityControl* control) {
407 return TakeSnapshotImpl(snapshots_->GetName(name), type, control);
391 } 408 }
392 409
393 410
394 int HeapProfiler::GetSnapshotsCount() { 411 int HeapProfiler::GetSnapshotsCount() {
395 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); 412 HeapProfiler* profiler = Isolate::Current()->heap_profiler();
396 ASSERT(profiler != NULL); 413 ASSERT(profiler != NULL);
397 return profiler->snapshots_->snapshots()->length(); 414 return profiler->snapshots_->snapshots()->length();
398 } 415 }
399 416
400 417
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 808
792 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) { 809 void AggregatedHeapSnapshotGenerator::CollectStats(HeapObject* obj) {
793 InstanceType type = obj->map()->instance_type(); 810 InstanceType type = obj->map()->instance_type();
794 ASSERT(0 <= type && type <= LAST_TYPE); 811 ASSERT(0 <= type && type <= LAST_TYPE);
795 agg_snapshot_->info()[type].increment_number(1); 812 agg_snapshot_->info()[type].increment_number(1);
796 agg_snapshot_->info()[type].increment_bytes(obj->Size()); 813 agg_snapshot_->info()[type].increment_bytes(obj->Size());
797 } 814 }
798 815
799 816
800 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() { 817 void AggregatedHeapSnapshotGenerator::GenerateSnapshot() {
801 HeapIterator iterator(HeapIterator::kPreciseFiltering); 818 HeapIterator iterator(HeapIterator::kFilterFreeListNodes);
802 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 819 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
803 CollectStats(obj); 820 CollectStats(obj);
804 agg_snapshot_->js_cons_profile()->CollectStats(obj); 821 agg_snapshot_->js_cons_profile()->CollectStats(obj);
805 agg_snapshot_->js_retainer_profile()->CollectStats(obj); 822 agg_snapshot_->js_retainer_profile()->CollectStats(obj);
806 } 823 }
807 CalculateStringsStats(); 824 CalculateStringsStats();
808 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate(); 825 agg_snapshot_->js_retainer_profile()->CoarseAndAggregate();
809 } 826 }
810 827
811 828
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 isolate_->global_handles()->MakeWeak(handle.location(), 1114 isolate_->global_handles()->MakeWeak(handle.location(),
1098 static_cast<void*>(stack.start()), 1115 static_cast<void*>(stack.start()),
1099 StackWeakReferenceCallback); 1116 StackWeakReferenceCallback);
1100 } 1117 }
1101 1118
1102 1119
1103 #endif // ENABLE_LOGGING_AND_PROFILING 1120 #endif // ENABLE_LOGGING_AND_PROFILING
1104 1121
1105 1122
1106 } } // namespace v8::internal 1123 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-profiler.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698