OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 void HeapProfiler::TearDown() { | 341 void HeapProfiler::TearDown() { |
342 #ifdef ENABLE_LOGGING_AND_PROFILING | 342 #ifdef ENABLE_LOGGING_AND_PROFILING |
343 delete singleton_; | 343 delete singleton_; |
344 singleton_ = NULL; | 344 singleton_ = 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(singleton_ != NULL); | 354 ASSERT(singleton_ != NULL); |
353 return singleton_->TakeSnapshotImpl(name, type); | 355 return singleton_->TakeSnapshotImpl(name, type, control); |
354 } | 356 } |
355 | 357 |
356 | 358 |
357 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, int type) { | 359 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, |
| 360 int type, |
| 361 v8::ActivityControl* control) { |
358 ASSERT(singleton_ != NULL); | 362 ASSERT(singleton_ != NULL); |
359 return singleton_->TakeSnapshotImpl(name, type); | 363 return singleton_->TakeSnapshotImpl(name, type, control); |
360 } | 364 } |
361 | 365 |
362 | 366 |
363 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, int type) { | 367 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, |
| 368 int type, |
| 369 v8::ActivityControl* control) { |
364 Heap::CollectAllGarbage(true); | 370 Heap::CollectAllGarbage(true); |
365 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 371 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
366 HeapSnapshot* result = | 372 HeapSnapshot* result = |
367 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 373 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
| 374 bool generation_completed = true; |
368 switch (s_type) { | 375 switch (s_type) { |
369 case HeapSnapshot::kFull: { | 376 case HeapSnapshot::kFull: { |
370 HeapSnapshotGenerator generator(result); | 377 HeapSnapshotGenerator generator(result, control); |
371 generator.GenerateSnapshot(); | 378 generation_completed = generator.GenerateSnapshot(); |
372 break; | 379 break; |
373 } | 380 } |
374 case HeapSnapshot::kAggregated: { | 381 case HeapSnapshot::kAggregated: { |
375 AggregatedHeapSnapshot agg_snapshot; | 382 AggregatedHeapSnapshot agg_snapshot; |
376 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); | 383 AggregatedHeapSnapshotGenerator generator(&agg_snapshot); |
377 generator.GenerateSnapshot(); | 384 generator.GenerateSnapshot(); |
378 generator.FillHeapSnapshot(result); | 385 generator.FillHeapSnapshot(result); |
379 break; | 386 break; |
380 } | 387 } |
381 default: | 388 default: |
382 UNREACHABLE(); | 389 UNREACHABLE(); |
383 } | 390 } |
384 snapshots_->SnapshotGenerationFinished(); | 391 if (!generation_completed) { |
| 392 delete result; |
| 393 result = NULL; |
| 394 } |
| 395 snapshots_->SnapshotGenerationFinished(result); |
385 return result; | 396 return result; |
386 } | 397 } |
387 | 398 |
388 | 399 |
389 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, int type) { | 400 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, |
390 return TakeSnapshotImpl(snapshots_->GetName(name), type); | 401 int type, |
| 402 v8::ActivityControl* control) { |
| 403 return TakeSnapshotImpl(snapshots_->GetName(name), type, control); |
391 } | 404 } |
392 | 405 |
393 | 406 |
394 int HeapProfiler::GetSnapshotsCount() { | 407 int HeapProfiler::GetSnapshotsCount() { |
395 ASSERT(singleton_ != NULL); | 408 ASSERT(singleton_ != NULL); |
396 return singleton_->snapshots_->snapshots()->length(); | 409 return singleton_->snapshots_->snapshots()->length(); |
397 } | 410 } |
398 | 411 |
399 | 412 |
400 HeapSnapshot* HeapProfiler::GetSnapshot(int index) { | 413 HeapSnapshot* HeapProfiler::GetSnapshot(int index) { |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 GlobalHandles::MakeWeak(handle.location(), | 1109 GlobalHandles::MakeWeak(handle.location(), |
1097 static_cast<void*>(stack.start()), | 1110 static_cast<void*>(stack.start()), |
1098 StackWeakReferenceCallback); | 1111 StackWeakReferenceCallback); |
1099 } | 1112 } |
1100 | 1113 |
1101 | 1114 |
1102 #endif // ENABLE_LOGGING_AND_PROFILING | 1115 #endif // ENABLE_LOGGING_AND_PROFILING |
1103 | 1116 |
1104 | 1117 |
1105 } } // namespace v8::internal | 1118 } } // namespace v8::internal |
OLD | NEW |