Unreviewed. Revert r4766, r4767.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4768 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d32c918f
...@@ -415,13 +415,14 @@ CpuProfiler::~CpuProfiler() { ...@@ -415,13 +415,14 @@ CpuProfiler::~CpuProfiler() {
void CpuProfiler::StartCollectingProfile(const char* title) { void CpuProfiler::StartCollectingProfile(const char* title) {
if (profiles_->StartProfiling(title, next_profile_uid_++)) { if (profiles_->StartProfiling(title, next_profile_uid_++)) {
StartProcessorIfNotStarted(); StartProcessorIfNotStarted();
generator_->AddCurrentStack();
} }
} }
void CpuProfiler::StartCollectingProfile(String* title) { void CpuProfiler::StartCollectingProfile(String* title) {
StartCollectingProfile(profiles_->GetName(title)); if (profiles_->StartProfiling(title, next_profile_uid_++)) {
StartProcessorIfNotStarted();
}
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#ifdef ENABLE_LOGGING_AND_PROFILING #ifdef ENABLE_LOGGING_AND_PROFILING
#include "v8.h" #include "v8.h"
#include "frames-inl.h"
#include "global-handles.h" #include "global-handles.h"
#include "profile-generator-inl.h" #include "profile-generator-inl.h"
...@@ -808,22 +807,6 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) { ...@@ -808,22 +807,6 @@ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
profiles_->AddPathToCurrentProfiles(entries); profiles_->AddPathToCurrentProfiles(entries);
} }
void ProfileGenerator::AddCurrentStack() {
TickSample sample;
sample.state = VMState::current_state();
sample.pc = reinterpret_cast<Address>(&sample); // Not NULL.
sample.frames_count = 0;
for (StackTraceFrameIterator it;
!it.done() && sample.frames_count < TickSample::kMaxFramesCount;
it.Advance()) {
JavaScriptFrame* frame = it.frame();
sample.stack[sample.frames_count++] =
reinterpret_cast<Address>(frame->function());
}
RecordTickSample(sample);
}
} } // namespace v8::internal } } // namespace v8::internal
#endif // ENABLE_LOGGING_AND_PROFILING #endif // ENABLE_LOGGING_AND_PROFILING
...@@ -260,7 +260,6 @@ class CpuProfilesCollection { ...@@ -260,7 +260,6 @@ class CpuProfilesCollection {
CpuProfile* GetProfile(int security_token_id, unsigned uid); CpuProfile* GetProfile(int security_token_id, unsigned uid);
inline bool is_last_profile(); inline bool is_last_profile();
const char* GetName(String* name);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag,
String* name, String* resource_name, int line_number); String* name, String* resource_name, int line_number);
CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name); CodeEntry* NewCodeEntry(Logger::LogEventsAndTags tag, const char* name);
...@@ -275,6 +274,7 @@ class CpuProfilesCollection { ...@@ -275,6 +274,7 @@ class CpuProfilesCollection {
private: private:
INLINE(const char* GetFunctionName(String* name)); INLINE(const char* GetFunctionName(String* name));
INLINE(const char* GetFunctionName(const char* name)); INLINE(const char* GetFunctionName(const char* name));
const char* GetName(String* name);
const char* GetName(int args_count); const char* GetName(int args_count);
List<CpuProfile*>* GetProfilesList(int security_token_id); List<CpuProfile*>* GetProfilesList(int security_token_id);
int TokenToIndex(int security_token_id); int TokenToIndex(int security_token_id);
...@@ -381,9 +381,6 @@ class ProfileGenerator { ...@@ -381,9 +381,6 @@ class ProfileGenerator {
return sample_rate_calc_.ticks_per_ms(); return sample_rate_calc_.ticks_per_ms();
} }
// Samples stack and adds it to current profiles.
void AddCurrentStack();
static const char* kAnonymousFunctionName; static const char* kAnonymousFunctionName;
static const char* kProgramEntryName; static const char* kProgramEntryName;
static const char* kGarbageCollectorEntryName; static const char* kGarbageCollectorEntryName;
......
...@@ -7,14 +7,12 @@ ...@@ -7,14 +7,12 @@
#include "v8.h" #include "v8.h"
#include "profile-generator-inl.h" #include "profile-generator-inl.h"
#include "cctest.h" #include "cctest.h"
#include "../include/v8-profiler.h"
namespace i = v8::internal; namespace i = v8::internal;
using i::CodeEntry; using i::CodeEntry;
using i::CodeMap; using i::CodeMap;
using i::CpuProfile; using i::CpuProfile;
using i::CpuProfiler;
using i::CpuProfilesCollection; using i::CpuProfilesCollection;
using i::ProfileNode; using i::ProfileNode;
using i::ProfileTree; using i::ProfileTree;
...@@ -670,79 +668,4 @@ TEST(SampleRateCalculator) { ...@@ -670,79 +668,4 @@ TEST(SampleRateCalculator) {
CHECK_EQ(kSamplingIntervalMs * 0.66666, calc3.ticks_per_ms()); CHECK_EQ(kSamplingIntervalMs * 0.66666, calc3.ticks_per_ms());
} }
// --- 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> GetNativeFunction(
v8::Handle<v8::String> name);
static v8::Handle<v8::Value> StartProfiling(const v8::Arguments& args);
static v8::Handle<v8::Value> StopProfiling(const v8::Arguments& args);
private:
static const char* kSource;
};
const char* ProfilerExtension::kSource =
"native function startProfiling();"
"native function stopProfiling();";
v8::Handle<v8::FunctionTemplate> ProfilerExtension::GetNativeFunction(
v8::Handle<v8::String> name) {
if (name->Equals(v8::String::New("startProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StartProfiling);
} else if (name->Equals(v8::String::New("stopProfiling"))) {
return v8::FunctionTemplate::New(ProfilerExtension::StopProfiling);
} else {
CHECK(false);
return v8::Handle<v8::FunctionTemplate>();
}
}
v8::Handle<v8::Value> ProfilerExtension::StartProfiling(const v8::Arguments& args) {
if (args.Length() > 0)
v8::CpuProfiler::StartProfiling(args[0].As<v8::String>());
else
v8::CpuProfiler::StartProfiling(v8::String::New(""));
return v8::Undefined();
}
v8::Handle<v8::Value> ProfilerExtension::StopProfiling(const v8::Arguments& args) {
if (args.Length() > 0)
v8::CpuProfiler::StopProfiling(args[0].As<v8::String>());
else
v8::CpuProfiler::StopProfiling(v8::String::New(""));
return v8::Undefined();
}
static ProfilerExtension kProfilerExtension;
v8::DeclareExtension kProfilerExtensionDeclaration(&kProfilerExtension);
static v8::Persistent<v8::Context> env;
TEST(RecordStackTraceAtStartProfiling) {
if (env.IsEmpty()) {
v8::HandleScope scope;
const char* extensions[] = { "v8/profiler" };
v8::ExtensionConfiguration config(1, extensions);
env = v8::Context::New(&config);
}
v8::HandleScope scope;
env->Enter();
CHECK_EQ(0, CpuProfiler::GetProfilesCount());
CompileRun(
"function c() { startProfiling(); }\n"
"function b() { c(); }\n"
"function a() { b(); }\n"
"a();\n"
"stopProfiling();"
);
CHECK_EQ(1, CpuProfiler::GetProfilesCount());
}
#endif // ENABLE_LOGGING_AND_PROFILING #endif // ENABLE_LOGGING_AND_PROFILING
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