Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(911)

Side by Side Diff: src/api.cc

Issue 6685084: Add support for CPU and heap profiles deletion. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Implemente per-profile deletion Created 9 years, 9 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 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 5059 matching lines...) Expand 10 before | Expand all | Expand 10 after
5070 5070
5071 const CpuProfileNode* CpuProfileNode::GetChild(int index) const { 5071 const CpuProfileNode* CpuProfileNode::GetChild(int index) const {
5072 i::Isolate* isolate = i::Isolate::Current(); 5072 i::Isolate* isolate = i::Isolate::Current();
5073 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild"); 5073 IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild");
5074 const i::ProfileNode* child = 5074 const i::ProfileNode* child =
5075 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index); 5075 reinterpret_cast<const i::ProfileNode*>(this)->children()->at(index);
5076 return reinterpret_cast<const CpuProfileNode*>(child); 5076 return reinterpret_cast<const CpuProfileNode*>(child);
5077 } 5077 }
5078 5078
5079 5079
5080 void CpuProfile::Delete() const {
5081 i::Isolate* isolate = i::Isolate::Current();
5082 IsDeadCheck(isolate, "v8::CpuProfile::Delete");
5083 i::CpuProfiler::DeleteProfile(
5084 const_cast<i::CpuProfile*>(
Vitaly Repeshko 2011/03/22 14:30:36 Dropping "const" will allow to avoid this const_ca
mnaganov (inactive) 2011/03/22 16:03:09 Done.
5085 reinterpret_cast<const i::CpuProfile*>(this)));
5086 if (i::CpuProfiler::GetProfilesCount() == 0 &&
5087 !i::CpuProfiler::HasDetachedProfiles()) {
5088 // If this was the last profile, clean up all accessory data as well.
5089 i::CpuProfiler::DeleteAllProfiles();
5090 }
5091 }
5092
5093
5080 unsigned CpuProfile::GetUid() const { 5094 unsigned CpuProfile::GetUid() const {
5081 i::Isolate* isolate = i::Isolate::Current(); 5095 i::Isolate* isolate = i::Isolate::Current();
5082 IsDeadCheck(isolate, "v8::CpuProfile::GetUid"); 5096 IsDeadCheck(isolate, "v8::CpuProfile::GetUid");
5083 return reinterpret_cast<const i::CpuProfile*>(this)->uid(); 5097 return reinterpret_cast<const i::CpuProfile*>(this)->uid();
5084 } 5098 }
5085 5099
5086 5100
5087 Handle<String> CpuProfile::GetTitle() const { 5101 Handle<String> CpuProfile::GetTitle() const {
5088 i::Isolate* isolate = i::Isolate::Current(); 5102 i::Isolate* isolate = i::Isolate::Current();
5089 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle"); 5103 IsDeadCheck(isolate, "v8::CpuProfile::GetTitle");
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
5149 Handle<Value> security_token) { 5163 Handle<Value> security_token) {
5150 i::Isolate* isolate = i::Isolate::Current(); 5164 i::Isolate* isolate = i::Isolate::Current();
5151 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); 5165 IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling");
5152 return reinterpret_cast<const CpuProfile*>( 5166 return reinterpret_cast<const CpuProfile*>(
5153 i::CpuProfiler::StopProfiling( 5167 i::CpuProfiler::StopProfiling(
5154 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), 5168 security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token),
5155 *Utils::OpenHandle(*title))); 5169 *Utils::OpenHandle(*title)));
5156 } 5170 }
5157 5171
5158 5172
5173 void CpuProfiler::DeleteAllProfiles() {
5174 i::Isolate* isolate = i::Isolate::Current();
5175 IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles");
5176 i::CpuProfiler::DeleteAllProfiles();
5177 }
5178
5179
5159 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { 5180 static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) {
5160 return const_cast<i::HeapGraphEdge*>( 5181 return const_cast<i::HeapGraphEdge*>(
5161 reinterpret_cast<const i::HeapGraphEdge*>(edge)); 5182 reinterpret_cast<const i::HeapGraphEdge*>(edge));
5162 } 5183 }
5163 5184
5164 HeapGraphEdge::Type HeapGraphEdge::GetType() const { 5185 HeapGraphEdge::Type HeapGraphEdge::GetType() const {
5165 i::Isolate* isolate = i::Isolate::Current(); 5186 i::Isolate* isolate = i::Isolate::Current();
5166 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType"); 5187 IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType");
5167 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type()); 5188 return static_cast<HeapGraphEdge::Type>(ToInternal(this)->type());
5168 } 5189 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
5355 return reinterpret_cast<const HeapGraphNode*>(diff->deletions_root()); 5376 return reinterpret_cast<const HeapGraphNode*>(diff->deletions_root());
5356 } 5377 }
5357 5378
5358 5379
5359 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { 5380 static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) {
5360 return const_cast<i::HeapSnapshot*>( 5381 return const_cast<i::HeapSnapshot*>(
5361 reinterpret_cast<const i::HeapSnapshot*>(snapshot)); 5382 reinterpret_cast<const i::HeapSnapshot*>(snapshot));
5362 } 5383 }
5363 5384
5364 5385
5386 void HeapSnapshot::Delete() const {
5387 i::Isolate* isolate = i::Isolate::Current();
5388 IsDeadCheck(isolate, "v8::HeapSnapshot::Delete");
5389 if (i::HeapProfiler::GetSnapshotsCount() > 1) {
5390 ToInternal(this)->Delete();
5391 } else {
5392 // If this is the last snapshot, clean up all accessory data as well.
5393 i::HeapProfiler::DeleteAllSnapshots();
5394 }
5395 }
5396
5397
5365 HeapSnapshot::Type HeapSnapshot::GetType() const { 5398 HeapSnapshot::Type HeapSnapshot::GetType() const {
5366 i::Isolate* isolate = i::Isolate::Current(); 5399 i::Isolate* isolate = i::Isolate::Current();
5367 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); 5400 IsDeadCheck(isolate, "v8::HeapSnapshot::GetType");
5368 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type()); 5401 return static_cast<HeapSnapshot::Type>(ToInternal(this)->type());
5369 } 5402 }
5370 5403
5371 5404
5372 unsigned HeapSnapshot::GetUid() const { 5405 unsigned HeapSnapshot::GetUid() const {
5373 i::Isolate* isolate = i::Isolate::Current(); 5406 i::Isolate* isolate = i::Isolate::Current();
5374 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); 5407 IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid");
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
5464 break; 5497 break;
5465 default: 5498 default:
5466 UNREACHABLE(); 5499 UNREACHABLE();
5467 } 5500 }
5468 return reinterpret_cast<const HeapSnapshot*>( 5501 return reinterpret_cast<const HeapSnapshot*>(
5469 i::HeapProfiler::TakeSnapshot( 5502 i::HeapProfiler::TakeSnapshot(
5470 *Utils::OpenHandle(*title), internal_type, control)); 5503 *Utils::OpenHandle(*title), internal_type, control));
5471 } 5504 }
5472 5505
5473 5506
5507 void HeapProfiler::DeleteAllSnapshots() {
5508 i::Isolate* isolate = i::Isolate::Current();
5509 IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots");
5510 i::HeapProfiler::DeleteAllSnapshots();
5511 }
5512
5513
5474 void HeapProfiler::DefineWrapperClass(uint16_t class_id, 5514 void HeapProfiler::DefineWrapperClass(uint16_t class_id,
5475 WrapperInfoCallback callback) { 5515 WrapperInfoCallback callback) {
5476 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id, 5516 i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id,
5477 callback); 5517 callback);
5478 } 5518 }
5479 5519
5480 #endif // ENABLE_LOGGING_AND_PROFILING 5520 #endif // ENABLE_LOGGING_AND_PROFILING
5481 5521
5482 5522
5483 v8::Testing::StressType internal::Testing::stress_type_ = 5523 v8::Testing::StressType internal::Testing::stress_type_ =
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
5608 5648
5609 5649
5610 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5650 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5611 HandleScopeImplementer* thread_local = 5651 HandleScopeImplementer* thread_local =
5612 reinterpret_cast<HandleScopeImplementer*>(storage); 5652 reinterpret_cast<HandleScopeImplementer*>(storage);
5613 thread_local->IterateThis(v); 5653 thread_local->IterateThis(v);
5614 return storage + ArchiveSpacePerThread(); 5654 return storage + ArchiveSpacePerThread();
5615 } 5655 }
5616 5656
5617 } } // namespace v8::internal 5657 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698