Commit 19b6b7ad authored by yurys@chromium.org's avatar yurys@chromium.org

Delete several deprecated methods on v8::CpuProfiler

All methods for accessing collected profiles by index are deprecated. The indexed storage may well be implemented by the embedder should he need it. CpuProfiler's responsibility is just to create CpuProfile object that contains all collected data and whose lifetime can be managed by the embedder.

BUG=chromium:327298
LOG=Y
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/117353002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18337 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 815a7298
...@@ -96,9 +96,6 @@ class V8_EXPORT CpuProfileNode { ...@@ -96,9 +96,6 @@ class V8_EXPORT CpuProfileNode {
*/ */
class V8_EXPORT CpuProfile { class V8_EXPORT CpuProfile {
public: public:
/** Returns CPU profile UID (assigned by the profiler.) */
unsigned GetUid() const;
/** Returns CPU profile title. */ /** Returns CPU profile title. */
Handle<String> GetTitle() const; Handle<String> GetTitle() const;
...@@ -150,15 +147,6 @@ class V8_EXPORT CpuProfiler { ...@@ -150,15 +147,6 @@ class V8_EXPORT CpuProfiler {
*/ */
void SetSamplingInterval(int us); void SetSamplingInterval(int us);
/**
* Returns the number of profiles collected (doesn't include
* profiles that are being collected at the moment of call.)
*/
int GetProfileCount();
/** Returns a profile by index. */
const CpuProfile* GetCpuProfile(int index);
/** /**
* Starts collecting CPU profile. Title may be an empty string. It * Starts collecting CPU profile. Title may be an empty string. It
* is allowed to have several profiles being collected at * is allowed to have several profiles being collected at
...@@ -178,13 +166,6 @@ class V8_EXPORT CpuProfiler { ...@@ -178,13 +166,6 @@ class V8_EXPORT CpuProfiler {
*/ */
const CpuProfile* StopCpuProfiling(Handle<String> title); const CpuProfile* StopCpuProfiling(Handle<String> title);
/**
* Deletes all existing profiles, also cancelling all profiling
* activity. All previously returned pointers to profiles and their
* contents become invalid after this call.
*/
void DeleteAllCpuProfiles();
/** /**
* Tells the profiler whether the embedder is idle. * Tells the profiler whether the embedder is idle.
*/ */
......
...@@ -6963,11 +6963,6 @@ void CpuProfile::Delete() { ...@@ -6963,11 +6963,6 @@ void CpuProfile::Delete() {
} }
unsigned CpuProfile::GetUid() const {
return reinterpret_cast<const i::CpuProfile*>(this)->uid();
}
Handle<String> CpuProfile::GetTitle() const { Handle<String> CpuProfile::GetTitle() const {
i::Isolate* isolate = i::Isolate::Current(); i::Isolate* isolate = i::Isolate::Current();
const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this); const i::CpuProfile* profile = reinterpret_cast<const i::CpuProfile*>(this);
...@@ -7005,11 +7000,6 @@ int CpuProfile::GetSamplesCount() const { ...@@ -7005,11 +7000,6 @@ int CpuProfile::GetSamplesCount() const {
} }
int CpuProfiler::GetProfileCount() {
return reinterpret_cast<i::CpuProfiler*>(this)->GetProfilesCount();
}
void CpuProfiler::SetSamplingInterval(int us) { void CpuProfiler::SetSamplingInterval(int us) {
ASSERT(us >= 0); ASSERT(us >= 0);
return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval( return reinterpret_cast<i::CpuProfiler*>(this)->set_sampling_interval(
...@@ -7017,12 +7007,6 @@ void CpuProfiler::SetSamplingInterval(int us) { ...@@ -7017,12 +7007,6 @@ void CpuProfiler::SetSamplingInterval(int us) {
} }
const CpuProfile* CpuProfiler::GetCpuProfile(int index) {
return reinterpret_cast<const CpuProfile*>(
reinterpret_cast<i::CpuProfiler*>(this)->GetProfile(index));
}
void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) { void CpuProfiler::StartCpuProfiling(Handle<String> title, bool record_samples) {
reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
*Utils::OpenHandle(*title), record_samples); *Utils::OpenHandle(*title), record_samples);
...@@ -7036,11 +7020,6 @@ const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) { ...@@ -7036,11 +7020,6 @@ const CpuProfile* CpuProfiler::StopCpuProfiling(Handle<String> title) {
} }
void CpuProfiler::DeleteAllCpuProfiles() {
reinterpret_cast<i::CpuProfiler*>(this)->DeleteAllProfiles();
}
void CpuProfiler::SetIdle(bool is_idle) { void CpuProfiler::SetIdle(bool is_idle) {
i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate(); i::Isolate* isolate = reinterpret_cast<i::CpuProfiler*>(this)->isolate();
i::StateTag state = isolate->current_vm_state(); i::StateTag state = isolate->current_vm_state();
......
...@@ -380,7 +380,6 @@ CpuProfiler::CpuProfiler(Isolate* isolate) ...@@ -380,7 +380,6 @@ CpuProfiler::CpuProfiler(Isolate* isolate)
sampling_interval_(TimeDelta::FromMicroseconds( sampling_interval_(TimeDelta::FromMicroseconds(
FLAG_cpu_profiler_sampling_interval)), FLAG_cpu_profiler_sampling_interval)),
profiles_(new CpuProfilesCollection(isolate->heap())), profiles_(new CpuProfilesCollection(isolate->heap())),
next_profile_uid_(1),
generator_(NULL), generator_(NULL),
processor_(NULL), processor_(NULL),
is_profiling_(false) { is_profiling_(false) {
...@@ -395,7 +394,6 @@ CpuProfiler::CpuProfiler(Isolate* isolate, ...@@ -395,7 +394,6 @@ CpuProfiler::CpuProfiler(Isolate* isolate,
sampling_interval_(TimeDelta::FromMicroseconds( sampling_interval_(TimeDelta::FromMicroseconds(
FLAG_cpu_profiler_sampling_interval)), FLAG_cpu_profiler_sampling_interval)),
profiles_(test_profiles), profiles_(test_profiles),
next_profile_uid_(1),
generator_(test_generator), generator_(test_generator),
processor_(test_processor), processor_(test_processor),
is_profiling_(false) { is_profiling_(false) {
...@@ -421,7 +419,7 @@ void CpuProfiler::ResetProfiles() { ...@@ -421,7 +419,7 @@ void CpuProfiler::ResetProfiles() {
void CpuProfiler::StartProfiling(const char* title, bool record_samples) { void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
if (profiles_->StartProfiling(title, next_profile_uid_++, record_samples)) { if (profiles_->StartProfiling(title, record_samples)) {
StartProcessorIfNotStarted(); StartProcessorIfNotStarted();
} }
processor_->AddCurrentStack(isolate_); processor_->AddCurrentStack(isolate_);
......
...@@ -268,7 +268,6 @@ class CpuProfiler : public CodeEventListener { ...@@ -268,7 +268,6 @@ class CpuProfiler : public CodeEventListener {
Isolate* isolate_; Isolate* isolate_;
TimeDelta sampling_interval_; TimeDelta sampling_interval_;
CpuProfilesCollection* profiles_; CpuProfilesCollection* profiles_;
unsigned next_profile_uid_;
ProfileGenerator* generator_; ProfileGenerator* generator_;
ProfilerEventsProcessor* processor_; ProfilerEventsProcessor* processor_;
bool saved_is_logging_; bool saved_is_logging_;
......
...@@ -352,9 +352,8 @@ void ProfileTree::TraverseDepthFirst(Callback* callback) { ...@@ -352,9 +352,8 @@ void ProfileTree::TraverseDepthFirst(Callback* callback) {
} }
CpuProfile::CpuProfile(const char* title, unsigned uid, bool record_samples) CpuProfile::CpuProfile(const char* title, bool record_samples)
: title_(title), : title_(title),
uid_(uid),
record_samples_(record_samples), record_samples_(record_samples),
start_time_(Time::NowFromSystemTime()) { start_time_(Time::NowFromSystemTime()) {
timer_.Start(); timer_.Start();
...@@ -486,7 +485,7 @@ CpuProfilesCollection::~CpuProfilesCollection() { ...@@ -486,7 +485,7 @@ CpuProfilesCollection::~CpuProfilesCollection() {
} }
bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid, bool CpuProfilesCollection::StartProfiling(const char* title,
bool record_samples) { bool record_samples) {
ASSERT(uid > 0); ASSERT(uid > 0);
current_profiles_semaphore_.Wait(); current_profiles_semaphore_.Wait();
...@@ -501,7 +500,7 @@ bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid, ...@@ -501,7 +500,7 @@ bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid,
return false; return false;
} }
} }
current_profiles_.Add(new CpuProfile(title, uid, record_samples)); current_profiles_.Add(new CpuProfile(title, record_samples));
current_profiles_semaphore_.Signal(); current_profiles_semaphore_.Signal();
return true; return true;
} }
...@@ -537,9 +536,8 @@ bool CpuProfilesCollection::IsLastProfile(const char* title) { ...@@ -537,9 +536,8 @@ bool CpuProfilesCollection::IsLastProfile(const char* title) {
void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) { void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) {
// Called from VM thread for a completed profile. // Called from VM thread for a completed profile.
unsigned uid = profile->uid();
for (int i = 0; i < finished_profiles_.length(); i++) { for (int i = 0; i < finished_profiles_.length(); i++) {
if (uid == finished_profiles_[i]->uid()) { if (profile == finished_profiles_[i]) {
finished_profiles_.Remove(i); finished_profiles_.Remove(i);
return; return;
} }
......
...@@ -196,14 +196,13 @@ class ProfileTree { ...@@ -196,14 +196,13 @@ class ProfileTree {
class CpuProfile { class CpuProfile {
public: public:
CpuProfile(const char* title, unsigned uid, bool record_samples); CpuProfile(const char* title, bool record_samples);
// Add pc -> ... -> main() call path to the profile. // Add pc -> ... -> main() call path to the profile.
void AddPath(const Vector<CodeEntry*>& path); void AddPath(const Vector<CodeEntry*>& path);
void CalculateTotalTicksAndSamplingRate(); void CalculateTotalTicksAndSamplingRate();
const char* title() const { return title_; } const char* title() const { return title_; }
unsigned uid() const { return uid_; }
const ProfileTree* top_down() const { return &top_down_; } const ProfileTree* top_down() const { return &top_down_; }
int samples_count() const { return samples_.length(); } int samples_count() const { return samples_.length(); }
...@@ -218,7 +217,6 @@ class CpuProfile { ...@@ -218,7 +217,6 @@ class CpuProfile {
private: private:
const char* title_; const char* title_;
unsigned uid_;
bool record_samples_; bool record_samples_;
Time start_time_; Time start_time_;
Time end_time_; Time end_time_;
...@@ -281,7 +279,7 @@ class CpuProfilesCollection { ...@@ -281,7 +279,7 @@ class CpuProfilesCollection {
explicit CpuProfilesCollection(Heap* heap); explicit CpuProfilesCollection(Heap* heap);
~CpuProfilesCollection(); ~CpuProfilesCollection();
bool StartProfiling(const char* title, unsigned uid, bool record_samples); bool StartProfiling(const char* title, bool record_samples);
CpuProfile* StopProfiling(const char* title); CpuProfile* StopProfiling(const char* title);
List<CpuProfile*>* profiles() { return &finished_profiles_; } List<CpuProfile*>* profiles() { return &finished_profiles_; }
const char* GetName(Name* name) { const char* GetName(Name* name) {
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
'gay-fixed.cc', 'gay-fixed.cc',
'gay-precision.cc', 'gay-precision.cc',
'gay-shortest.cc', 'gay-shortest.cc',
'profiler-extension.cc',
'test-accessors.cc', 'test-accessors.cc',
'test-alloc.cc', 'test-alloc.cc',
'test-api.cc', 'test-api.cc',
......
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Tests of profiles generator and utilities.
#include "profiler-extension.h"
#include "cctest.h"
const v8::CpuProfile* ProfilerExtension::last_profile = NULL;
const char* ProfilerExtension::kSource =
"native function startProfiling();"
"native function stopProfiling();";
v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<v8::String> name) {
if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
} else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
} else {
CHECK(false);
return v8::Handle<v8::FunctionTemplate>();
}
}
void ProfilerExtension::StartProfiling(
const v8::FunctionCallbackInfo<v8::Value>& args) {
last_profile = NULL;
v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
cpu_profiler->StartCpuProfiling((args.Length() > 0)
? args[0].As<v8::String>()
: v8::String::Empty(args.GetIsolate()));
}
void ProfilerExtension::StopProfiling(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
last_profile = cpu_profiler->StopCpuProfiling((args.Length() > 0)
? args[0].As<v8::String>()
: v8::String::Empty(args.GetIsolate()));
}
static ProfilerExtension kProfilerExtension;
v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Tests of profiles generator and utilities.
#include "v8-profiler.h"
class ProfilerExtension : public v8::Extension {
public:
ProfilerExtension() : v8::Extension("v8/profiler", kSource) { }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> name);
static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
static const v8::CpuProfile* last_profile;
private:
static const char* kSource;
};
...@@ -94,7 +94,7 @@ void RunWithProfiler(void (*test)()) { ...@@ -94,7 +94,7 @@ void RunWithProfiler(void (*test)()) {
cpu_profiler->StartCpuProfiling(profile_name); cpu_profiler->StartCpuProfiling(profile_name);
(*test)(); (*test)();
cpu_profiler->DeleteAllCpuProfiles(); reinterpret_cast<i::CpuProfiler*>(cpu_profiler)->DeleteAllProfiles();
} }
......
This diff is collapsed.
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "v8.h" #include "v8.h"
#include "profile-generator-inl.h" #include "profile-generator-inl.h"
#include "profiler-extension.h"
#include "cctest.h" #include "cctest.h"
#include "cpu-profiler.h" #include "cpu-profiler.h"
#include "../include/v8-profiler.h" #include "../include/v8-profiler.h"
...@@ -400,7 +401,7 @@ class TestSetup { ...@@ -400,7 +401,7 @@ class TestSetup {
TEST(RecordTickSample) { TEST(RecordTickSample) {
TestSetup test_setup; TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::heap()); CpuProfilesCollection profiles(CcTest::heap());
profiles.StartProfiling("", 1, false); profiles.StartProfiling("", false);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
...@@ -466,7 +467,7 @@ static void CheckNodeIds(ProfileNode* node, int* expectedId) { ...@@ -466,7 +467,7 @@ static void CheckNodeIds(ProfileNode* node, int* expectedId) {
TEST(SampleIds) { TEST(SampleIds) {
TestSetup test_setup; TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::heap()); CpuProfilesCollection profiles(CcTest::heap());
profiles.StartProfiling("", 1, true); profiles.StartProfiling("", true);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb"); CodeEntry* entry2 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "bbb");
...@@ -514,7 +515,7 @@ TEST(SampleIds) { ...@@ -514,7 +515,7 @@ TEST(SampleIds) {
TEST(NoSamples) { TEST(NoSamples) {
TestSetup test_setup; TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::heap()); CpuProfilesCollection profiles(CcTest::heap());
profiles.StartProfiling("", 1, false); profiles.StartProfiling("", false);
ProfileGenerator generator(&profiles); ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa"); CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200); generator.code_map()->AddCode(ToAddress(0x1500), entry1, 0x200);
...@@ -536,63 +537,6 @@ TEST(NoSamples) { ...@@ -536,63 +537,6 @@ TEST(NoSamples) {
} }
// --- P r o f i l e r E x t e n s i o n ---
class ProfilerExtension : public v8::Extension {
public:
ProfilerExtension() : v8::Extension("v8/profiler", kSource) { }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Handle<v8::String> name);
static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
static const char* kSource;
};
const char* ProfilerExtension::kSource =
"native function startProfiling();"
"native function stopProfiling();";
v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunctionTemplate(
v8::Isolate* isolate, v8::Handle<v8::String> name) {
if (name->Equals(v8::String::NewFromUtf8(isolate, "startProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
} else if (name->Equals(v8::String::NewFromUtf8(isolate, "stopProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
} else {
CHECK(false);
return v8::Handle<v8::FunctionTemplate>();
}
}
void ProfilerExtension::StartProfiling(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
if (args.Length() > 0)
cpu_profiler->StartCpuProfiling(args[0].As<v8::String>());
else
cpu_profiler->StartCpuProfiling(
v8::String::NewFromUtf8(args.GetIsolate(), ""));
}
void ProfilerExtension::StopProfiling(
const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
if (args.Length() > 0)
cpu_profiler->StopCpuProfiling(args[0].As<v8::String>());
else
cpu_profiler->StopCpuProfiling(
v8::String::NewFromUtf8(args.GetIsolate(), ""));
}
static ProfilerExtension kProfilerExtension;
v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
static const ProfileNode* PickChild(const ProfileNode* parent, static const ProfileNode* PickChild(const ProfileNode* parent,
const char* name) { const char* name) {
for (int i = 0; i < parent->children()->length(); ++i) { for (int i = 0; i < parent->children()->length(); ++i) {
...@@ -661,12 +605,10 @@ TEST(Issue51919) { ...@@ -661,12 +605,10 @@ TEST(Issue51919) {
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) { for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
i::Vector<char> title = i::Vector<char>::New(16); i::Vector<char> title = i::Vector<char>::New(16);
i::OS::SNPrintF(title, "%d", i); i::OS::SNPrintF(title, "%d", i);
// UID must be > 0. CHECK(collection.StartProfiling(title.start(), false));
CHECK(collection.StartProfiling(title.start(), i + 1, false));
titles[i] = title.start(); titles[i] = title.start();
} }
CHECK(!collection.StartProfiling( CHECK(!collection.StartProfiling("maximum", false));
"maximum", CpuProfilesCollection::kMaxSimultaneousProfiles + 1, false));
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i)
i::DeleteArray(titles[i]); i::DeleteArray(titles[i]);
} }
...@@ -694,7 +636,8 @@ TEST(ProfileNodeScriptId) { ...@@ -694,7 +636,8 @@ TEST(ProfileNodeScriptId) {
v8::HandleScope hs(env->GetIsolate()); v8::HandleScope hs(env->GetIsolate());
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, profiler->GetProfileCount()); i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::NewFromUtf8( v8::Handle<v8::Script> script_a = v8::Script::Compile(v8::String::NewFromUtf8(
env->GetIsolate(), "function a() { startProfiling(); }\n")); env->GetIsolate(), "function a() { startProfiling(); }\n"));
script_a->Run(); script_a->Run();
...@@ -704,8 +647,8 @@ TEST(ProfileNodeScriptId) { ...@@ -704,8 +647,8 @@ TEST(ProfileNodeScriptId) {
"b();\n" "b();\n"
"stopProfiling();\n")); "stopProfiling();\n"));
script_b->Run(); script_b->Run();
CHECK_EQ(1, profiler->GetProfileCount()); CHECK_EQ(1, iprofiler->GetProfilesCount());
const v8::CpuProfile* profile = profiler->GetCpuProfile(0); const v8::CpuProfile* profile = ProfilerExtension::last_profile;
const v8::CpuProfileNode* current = profile->GetTopDownRoot(); const v8::CpuProfileNode* current = profile->GetTopDownRoot();
reinterpret_cast<ProfileNode*>( reinterpret_cast<ProfileNode*>(
const_cast<v8::CpuProfileNode*>(current))->Print(0); const_cast<v8::CpuProfileNode*>(current))->Print(0);
...@@ -796,7 +739,8 @@ TEST(BailoutReason) { ...@@ -796,7 +739,8 @@ TEST(BailoutReason) {
v8::HandleScope hs(env->GetIsolate()); v8::HandleScope hs(env->GetIsolate());
v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler(); v8::CpuProfiler* profiler = env->GetIsolate()->GetCpuProfiler();
CHECK_EQ(0, profiler->GetProfileCount()); i::CpuProfiler* iprofiler = reinterpret_cast<i::CpuProfiler*>(profiler);
CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Handle<v8::Script> script = v8::Handle<v8::Script> script =
v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(), v8::Script::Compile(v8::String::NewFromUtf8(env->GetIsolate(),
"function TryCatch() {\n" "function TryCatch() {\n"
...@@ -812,8 +756,9 @@ TEST(BailoutReason) { ...@@ -812,8 +756,9 @@ TEST(BailoutReason) {
"TryFinally();\n" "TryFinally();\n"
"stopProfiling();")); "stopProfiling();"));
script->Run(); script->Run();
CHECK_EQ(1, profiler->GetProfileCount()); CHECK_EQ(1, iprofiler->GetProfilesCount());
const v8::CpuProfile* profile = profiler->GetCpuProfile(0); const v8::CpuProfile* profile = ProfilerExtension::last_profile;
CHECK(profile);
const v8::CpuProfileNode* current = profile->GetTopDownRoot(); const v8::CpuProfileNode* current = profile->GetTopDownRoot();
reinterpret_cast<ProfileNode*>( reinterpret_cast<ProfileNode*>(
const_cast<v8::CpuProfileNode*>(current))->Print(0); const_cast<v8::CpuProfileNode*>(current))->Print(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment