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