From f09d3ac1c691bd9278e2edd96c4db8898be43c1f Mon Sep 17 00:00:00 2001 From: "mikhail.naganov@gmail.com" Date: Fri, 3 Jun 2011 19:45:59 +0000 Subject: [PATCH] Define stubs for implementations of v8-profiler.h API when profiling is disabled TBR=sgjesse@chromium.org BUG=https://bugs.webkit.org/show_bug.cgi?id=62014 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8170 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 3 deletions(-) diff --git a/src/api.cc b/src/api.cc index 09489b8b2c..ecd5101e5e 100644 --- a/src/api.cc +++ b/src/api.cc @@ -5263,9 +5263,8 @@ Local Debug::GetDebugContext() { #endif // ENABLE_DEBUGGER_SUPPORT -#ifdef ENABLE_LOGGING_AND_PROFILING - Handle CpuProfileNode::GetFunctionName() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetFunctionName"); const i::ProfileNode* node = reinterpret_cast(this); @@ -5278,77 +5277,117 @@ Handle CpuProfileNode::GetFunctionName() const { isolate->factory()->LookupAsciiSymbol(entry->name_prefix()), isolate->factory()->LookupAsciiSymbol(entry->name())))); } +#else + return v8::String::Empty(); +#endif } Handle CpuProfileNode::GetScriptResourceName() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetScriptResourceName"); const i::ProfileNode* node = reinterpret_cast(this); return Handle(ToApi(isolate->factory()->LookupAsciiSymbol( node->entry()->resource_name()))); +#else + return v8::String::Empty(); +#endif } int CpuProfileNode::GetLineNumber() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetLineNumber"); return reinterpret_cast(this)->entry()->line_number(); +#else + return 0; +#endif } double CpuProfileNode::GetTotalTime() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalTime"); return reinterpret_cast(this)->GetTotalMillis(); +#else + return 0.0; +#endif } double CpuProfileNode::GetSelfTime() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfTime"); return reinterpret_cast(this)->GetSelfMillis(); +#else + return 0.0; +#endif } double CpuProfileNode::GetTotalSamplesCount() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetTotalSamplesCount"); return reinterpret_cast(this)->total_ticks(); +#else + return 0.0; +#endif } double CpuProfileNode::GetSelfSamplesCount() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetSelfSamplesCount"); return reinterpret_cast(this)->self_ticks(); +#else + return 0.0; +#endif } unsigned CpuProfileNode::GetCallUid() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetCallUid"); return reinterpret_cast(this)->entry()->GetCallUid(); +#else + return 0; +#endif } int CpuProfileNode::GetChildrenCount() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetChildrenCount"); return reinterpret_cast(this)->children()->length(); +#else + return 0; +#endif } const CpuProfileNode* CpuProfileNode::GetChild(int index) const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfileNode::GetChild"); const i::ProfileNode* child = reinterpret_cast(this)->children()->at(index); return reinterpret_cast(child); +#else + return NULL; +#endif } void CpuProfile::Delete() { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfile::Delete"); i::CpuProfiler::DeleteProfile(reinterpret_cast(this)); @@ -5357,108 +5396,153 @@ void CpuProfile::Delete() { // If this was the last profile, clean up all accessory data as well. i::CpuProfiler::DeleteAllProfiles(); } +#endif } unsigned CpuProfile::GetUid() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfile::GetUid"); return reinterpret_cast(this)->uid(); +#else + return 0; +#endif } Handle CpuProfile::GetTitle() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfile::GetTitle"); const i::CpuProfile* profile = reinterpret_cast(this); return Handle(ToApi(isolate->factory()->LookupAsciiSymbol( profile->title()))); +#else + return v8::String::Empty(); +#endif } const CpuProfileNode* CpuProfile::GetBottomUpRoot() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfile::GetBottomUpRoot"); const i::CpuProfile* profile = reinterpret_cast(this); return reinterpret_cast(profile->bottom_up()->root()); +#else + return NULL; +#endif } const CpuProfileNode* CpuProfile::GetTopDownRoot() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfile::GetTopDownRoot"); const i::CpuProfile* profile = reinterpret_cast(this); return reinterpret_cast(profile->top_down()->root()); +#else + return NULL; +#endif } int CpuProfiler::GetProfilesCount() { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::GetProfilesCount"); return i::CpuProfiler::GetProfilesCount(); +#else + return 0; +#endif } const CpuProfile* CpuProfiler::GetProfile(int index, Handle security_token) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::GetProfile"); return reinterpret_cast( i::CpuProfiler::GetProfile( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), index)); +#else + return NULL; +#endif } const CpuProfile* CpuProfiler::FindProfile(unsigned uid, Handle security_token) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::FindProfile"); return reinterpret_cast( i::CpuProfiler::FindProfile( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), uid)); +#else + return NULL; +#endif } void CpuProfiler::StartProfiling(Handle title) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::StartProfiling"); i::CpuProfiler::StartProfiling(*Utils::OpenHandle(*title)); +#endif } const CpuProfile* CpuProfiler::StopProfiling(Handle title, Handle security_token) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::StopProfiling"); return reinterpret_cast( i::CpuProfiler::StopProfiling( security_token.IsEmpty() ? NULL : *Utils::OpenHandle(*security_token), *Utils::OpenHandle(*title))); +#else + return NULL; +#endif } void CpuProfiler::DeleteAllProfiles() { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::CpuProfiler::DeleteAllProfiles"); i::CpuProfiler::DeleteAllProfiles(); +#endif } +#ifdef ENABLE_LOGGING_AND_PROFILING static i::HeapGraphEdge* ToInternal(const HeapGraphEdge* edge) { return const_cast( reinterpret_cast(edge)); } +#endif + HeapGraphEdge::Type HeapGraphEdge::GetType() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphEdge::GetType"); return static_cast(ToInternal(this)->type()); +#else + return static_cast(0); +#endif } Handle HeapGraphEdge::GetName() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphEdge::GetName"); i::HeapGraphEdge* edge = ToInternal(this); @@ -5475,121 +5559,179 @@ Handle HeapGraphEdge::GetName() const { edge->index()))); default: UNREACHABLE(); } +#endif return v8::Undefined(); } const HeapGraphNode* HeapGraphEdge::GetFromNode() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphEdge::GetFromNode"); const i::HeapEntry* from = ToInternal(this)->From(); return reinterpret_cast(from); +#else + return NULL; +#endif } const HeapGraphNode* HeapGraphEdge::GetToNode() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphEdge::GetToNode"); const i::HeapEntry* to = ToInternal(this)->to(); return reinterpret_cast(to); +#else + return NULL; +#endif } +#ifdef ENABLE_LOGGING_AND_PROFILING static i::HeapEntry* ToInternal(const HeapGraphNode* entry) { return const_cast( reinterpret_cast(entry)); } +#endif HeapGraphNode::Type HeapGraphNode::GetType() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphNode::GetType"); return static_cast(ToInternal(this)->type()); +#else + return static_cast(0); +#endif } Handle HeapGraphNode::GetName() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphNode::GetName"); return Handle(ToApi(isolate->factory()->LookupAsciiSymbol( ToInternal(this)->name()))); +#else + return v8::String::Empty(); +#endif } uint64_t HeapGraphNode::GetId() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphNode::GetId"); ASSERT(ToInternal(this)->snapshot()->type() != i::HeapSnapshot::kAggregated); return ToInternal(this)->id(); +#else + return 0; +#endif } int HeapGraphNode::GetInstancesCount() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphNode::GetInstancesCount"); ASSERT(ToInternal(this)->snapshot()->type() == i::HeapSnapshot::kAggregated); return static_cast(ToInternal(this)->id()); +#else + return 0; +#endif } int HeapGraphNode::GetSelfSize() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapGraphNode::GetSelfSize"); return ToInternal(this)->self_size(); +#else + return 0; +#endif } int HeapGraphNode::GetRetainedSize(bool exact) const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainedSize"); return ToInternal(this)->RetainedSize(exact); +#else + return 0; +#endif } int HeapGraphNode::GetChildrenCount() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetChildrenCount"); return ToInternal(this)->children().length(); +#else + return 0; +#endif } const HeapGraphEdge* HeapGraphNode::GetChild(int index) const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetChild"); return reinterpret_cast( &ToInternal(this)->children()[index]); +#else + return NULL; +#endif } int HeapGraphNode::GetRetainersCount() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainersCount"); return ToInternal(this)->retainers().length(); +#else + return 0; +#endif } const HeapGraphEdge* HeapGraphNode::GetRetainer(int index) const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetRetainer"); return reinterpret_cast( ToInternal(this)->retainers()[index]); +#else + return NULL; +#endif } const HeapGraphNode* HeapGraphNode::GetDominatorNode() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetDominatorNode"); return reinterpret_cast(ToInternal(this)->dominator()); +#else + return NULL; +#endif } +#ifdef ENABLE_LOGGING_AND_PROFILING static i::HeapSnapshot* ToInternal(const HeapSnapshot* snapshot) { return const_cast( reinterpret_cast(snapshot)); } +#endif void HeapSnapshot::Delete() { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::Delete"); if (i::HeapProfiler::GetSnapshotsCount() > 1) { @@ -5598,48 +5740,70 @@ void HeapSnapshot::Delete() { // If this is the last snapshot, clean up all accessory data as well. i::HeapProfiler::DeleteAllSnapshots(); } +#endif } HeapSnapshot::Type HeapSnapshot::GetType() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetType"); return static_cast(ToInternal(this)->type()); +#else + return static_cast(0); +#endif } unsigned HeapSnapshot::GetUid() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetUid"); return ToInternal(this)->uid(); +#else + return 0; +#endif } Handle HeapSnapshot::GetTitle() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetTitle"); return Handle(ToApi(isolate->factory()->LookupAsciiSymbol( ToInternal(this)->title()))); +#else + return v8::String::Empty(); +#endif } const HeapGraphNode* HeapSnapshot::GetRoot() const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetHead"); return reinterpret_cast(ToInternal(this)->root()); +#else + return 0; +#endif } const HeapGraphNode* HeapSnapshot::GetNodeById(uint64_t id) const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::GetNodeById"); return reinterpret_cast( ToInternal(this)->GetEntryById(id)); +#else + return NULL; +#endif } void HeapSnapshot::Serialize(OutputStream* stream, HeapSnapshot::SerializationFormat format) const { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapSnapshot::Serialize"); ApiCheck(format == kJSON, @@ -5653,35 +5817,49 @@ void HeapSnapshot::Serialize(OutputStream* stream, "Invalid stream chunk size"); i::HeapSnapshotJSONSerializer serializer(ToInternal(this)); serializer.Serialize(stream); +#endif } int HeapProfiler::GetSnapshotsCount() { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshotsCount"); return i::HeapProfiler::GetSnapshotsCount(); +#else + return 0; +#endif } const HeapSnapshot* HeapProfiler::GetSnapshot(int index) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::GetSnapshot"); return reinterpret_cast( i::HeapProfiler::GetSnapshot(index)); +#else + return NULL; +#endif } const HeapSnapshot* HeapProfiler::FindSnapshot(unsigned uid) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::FindSnapshot"); return reinterpret_cast( i::HeapProfiler::FindSnapshot(uid)); +#else + return NULL; +#endif } const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle title, HeapSnapshot::Type type, ActivityControl* control) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::TakeSnapshot"); i::HeapSnapshot::Type internal_type = i::HeapSnapshot::kFull; @@ -5698,23 +5876,29 @@ const HeapSnapshot* HeapProfiler::TakeSnapshot(Handle title, return reinterpret_cast( i::HeapProfiler::TakeSnapshot( *Utils::OpenHandle(*title), internal_type, control)); +#else + return NULL; +#endif } void HeapProfiler::DeleteAllSnapshots() { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate* isolate = i::Isolate::Current(); IsDeadCheck(isolate, "v8::HeapProfiler::DeleteAllSnapshots"); i::HeapProfiler::DeleteAllSnapshots(); +#endif } void HeapProfiler::DefineWrapperClass(uint16_t class_id, WrapperInfoCallback callback) { +#ifdef ENABLE_LOGGING_AND_PROFILING i::Isolate::Current()->heap_profiler()->DefineWrapperClass(class_id, callback); +#endif } -#endif // ENABLE_LOGGING_AND_PROFILING v8::Testing::StressType internal::Testing::stress_type_ =