| OLD | NEW |
| 1 // Copyright 2009-2010 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 |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, | 361 HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, |
| 362 int type, | 362 int type, |
| 363 v8::ActivityControl* control) { | 363 v8::ActivityControl* control) { |
| 364 ASSERT(Isolate::Current()->heap_profiler() != NULL); | 364 ASSERT(Isolate::Current()->heap_profiler() != NULL); |
| 365 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, | 365 return Isolate::Current()->heap_profiler()->TakeSnapshotImpl(name, |
| 366 type, | 366 type, |
| 367 control); | 367 control); |
| 368 } | 368 } |
| 369 | 369 |
| 370 | 370 |
| 371 void HeapProfiler::DefineWrapperClass( |
| 372 uint16_t class_id, v8::HeapProfiler::WrapperInfoCallback callback) { |
| 373 ASSERT(class_id != v8::HeapProfiler::kPersistentHandleNoClassId); |
| 374 if (wrapper_callbacks_.length() <= class_id) { |
| 375 wrapper_callbacks_.AddBlock( |
| 376 NULL, class_id - wrapper_callbacks_.length() + 1); |
| 377 } |
| 378 wrapper_callbacks_[class_id] = callback; |
| 379 } |
| 380 |
| 381 |
| 382 v8::RetainedObjectInfo* HeapProfiler::ExecuteWrapperClassCallback( |
| 383 uint16_t class_id, Object** wrapper) { |
| 384 if (wrapper_callbacks_.length() <= class_id) return NULL; |
| 385 return wrapper_callbacks_[class_id]( |
| 386 class_id, Utils::ToLocal(Handle<Object>(wrapper))); |
| 387 } |
| 388 |
| 389 |
| 371 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, | 390 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, |
| 372 int type, | 391 int type, |
| 373 v8::ActivityControl* control) { | 392 v8::ActivityControl* control) { |
| 374 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); | 393 HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
| 375 HeapSnapshot* result = | 394 HeapSnapshot* result = |
| 376 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); | 395 snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
| 377 bool generation_completed = true; | 396 bool generation_completed = true; |
| 378 switch (s_type) { | 397 switch (s_type) { |
| 379 case HeapSnapshot::kFull: { | 398 case HeapSnapshot::kFull: { |
| 380 HEAP->CollectAllGarbage(true); | 399 HEAP->CollectAllGarbage(true); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 398 result = NULL; | 417 result = NULL; |
| 399 } | 418 } |
| 400 snapshots_->SnapshotGenerationFinished(result); | 419 snapshots_->SnapshotGenerationFinished(result); |
| 401 return result; | 420 return result; |
| 402 } | 421 } |
| 403 | 422 |
| 404 | 423 |
| 405 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, | 424 HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, |
| 406 int type, | 425 int type, |
| 407 v8::ActivityControl* control) { | 426 v8::ActivityControl* control) { |
| 408 return TakeSnapshotImpl(snapshots_->GetName(name), type, control); | 427 return TakeSnapshotImpl(snapshots_->names()->GetName(name), type, control); |
| 409 } | 428 } |
| 410 | 429 |
| 411 | 430 |
| 412 int HeapProfiler::GetSnapshotsCount() { | 431 int HeapProfiler::GetSnapshotsCount() { |
| 413 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); | 432 HeapProfiler* profiler = Isolate::Current()->heap_profiler(); |
| 414 ASSERT(profiler != NULL); | 433 ASSERT(profiler != NULL); |
| 415 return profiler->snapshots_->snapshots()->length(); | 434 return profiler->snapshots_->snapshots()->length(); |
| 416 } | 435 } |
| 417 | 436 |
| 418 | 437 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 AllocatingConstructorHeapProfileIterator(HeapSnapshot* snapshot, | 891 AllocatingConstructorHeapProfileIterator(HeapSnapshot* snapshot, |
| 873 int* root_child_index) | 892 int* root_child_index) |
| 874 : snapshot_(snapshot), | 893 : snapshot_(snapshot), |
| 875 root_child_index_(root_child_index) { | 894 root_child_index_(root_child_index) { |
| 876 } | 895 } |
| 877 | 896 |
| 878 void Call(const JSObjectsCluster& cluster, | 897 void Call(const JSObjectsCluster& cluster, |
| 879 const NumberAndSizeInfo& number_and_size) { | 898 const NumberAndSizeInfo& number_and_size) { |
| 880 const char* name = cluster.GetSpecialCaseName(); | 899 const char* name = cluster.GetSpecialCaseName(); |
| 881 if (name == NULL) { | 900 if (name == NULL) { |
| 882 name = snapshot_->collection()->GetFunctionName(cluster.constructor()); | 901 name = snapshot_->collection()->names()->GetFunctionName( |
| 902 cluster.constructor()); |
| 883 } | 903 } |
| 884 AddEntryFromAggregatedSnapshot(snapshot_, | 904 AddEntryFromAggregatedSnapshot(snapshot_, |
| 885 root_child_index_, | 905 root_child_index_, |
| 886 HeapEntry::kObject, | 906 HeapEntry::kObject, |
| 887 name, | 907 name, |
| 888 number_and_size.number(), | 908 number_and_size.number(), |
| 889 number_and_size.bytes(), | 909 number_and_size.bytes(), |
| 890 0, | 910 0, |
| 891 0); | 911 0); |
| 892 } | 912 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 : snapshot_(snapshot), root_child_index_(root_child_index) { | 1033 : snapshot_(snapshot), root_child_index_(root_child_index) { |
| 1014 } | 1034 } |
| 1015 ~AggregatedRetainerTreeAllocator() { } | 1035 ~AggregatedRetainerTreeAllocator() { } |
| 1016 | 1036 |
| 1017 HeapEntry* AllocateEntry( | 1037 HeapEntry* AllocateEntry( |
| 1018 HeapThing ptr, int children_count, int retainers_count) { | 1038 HeapThing ptr, int children_count, int retainers_count) { |
| 1019 HeapObject* obj = reinterpret_cast<HeapObject*>(ptr); | 1039 HeapObject* obj = reinterpret_cast<HeapObject*>(ptr); |
| 1020 JSObjectsCluster cluster = HeapObjectAsCluster(obj); | 1040 JSObjectsCluster cluster = HeapObjectAsCluster(obj); |
| 1021 const char* name = cluster.GetSpecialCaseName(); | 1041 const char* name = cluster.GetSpecialCaseName(); |
| 1022 if (name == NULL) { | 1042 if (name == NULL) { |
| 1023 name = snapshot_->collection()->GetFunctionName(cluster.constructor()); | 1043 name = snapshot_->collection()->names()->GetFunctionName( |
| 1044 cluster.constructor()); |
| 1024 } | 1045 } |
| 1025 return AddEntryFromAggregatedSnapshot( | 1046 return AddEntryFromAggregatedSnapshot( |
| 1026 snapshot_, root_child_index_, HeapEntry::kObject, name, | 1047 snapshot_, root_child_index_, HeapEntry::kObject, name, |
| 1027 0, 0, children_count, retainers_count); | 1048 0, 0, children_count, retainers_count); |
| 1028 } | 1049 } |
| 1029 | 1050 |
| 1030 private: | 1051 private: |
| 1031 HeapSnapshot* snapshot_; | 1052 HeapSnapshot* snapshot_; |
| 1032 int* root_child_index_; | 1053 int* root_child_index_; |
| 1033 }; | 1054 }; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 isolate_->global_handles()->MakeWeak(handle.location(), | 1145 isolate_->global_handles()->MakeWeak(handle.location(), |
| 1125 static_cast<void*>(stack.start()), | 1146 static_cast<void*>(stack.start()), |
| 1126 StackWeakReferenceCallback); | 1147 StackWeakReferenceCallback); |
| 1127 } | 1148 } |
| 1128 | 1149 |
| 1129 | 1150 |
| 1130 #endif // ENABLE_LOGGING_AND_PROFILING | 1151 #endif // ENABLE_LOGGING_AND_PROFILING |
| 1131 | 1152 |
| 1132 | 1153 |
| 1133 } } // namespace v8::internal | 1154 } } // namespace v8::internal |
| OLD | NEW |