Unflake cctest/test-cpu-profiler/JsNativeJsRuntimeJsSample on Win32 Debug
Profiler is now started from JavaScript. Since we always capture stack trace when starting profiler there should always be at least one expected sample in the profile. Also changed ProfilerEventsProcessor::AddCurrentStack to make sure it call TickSample::Init to instead of custom initialization code. BUG=v8:2920 R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/25686011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17140 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
792dd705af
commit
3228e953f9
@ -64,14 +64,15 @@ void ProfilerEventsProcessor::Enqueue(const CodeEventsContainer& event) {
|
|||||||
|
|
||||||
void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) {
|
void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) {
|
||||||
TickSampleEventRecord record(last_code_event_id_);
|
TickSampleEventRecord record(last_code_event_id_);
|
||||||
TickSample* sample = &record.sample;
|
RegisterState regs;
|
||||||
sample->state = isolate->current_vm_state();
|
StackFrameIterator it(isolate);
|
||||||
sample->pc = reinterpret_cast<Address>(sample); // Not NULL.
|
if (!it.done()) {
|
||||||
for (StackTraceFrameIterator it(isolate);
|
StackFrame* frame = it.frame();
|
||||||
!it.done() && sample->frames_count < TickSample::kMaxFramesCount;
|
regs.sp = frame->sp();
|
||||||
it.Advance()) {
|
regs.fp = frame->fp();
|
||||||
sample->stack[sample->frames_count++] = it.frame()->pc();
|
regs.pc = frame->pc();
|
||||||
}
|
}
|
||||||
|
record.sample.Init(isolate, regs);
|
||||||
ticks_from_vm_buffer_.Enqueue(record);
|
ticks_from_vm_buffer_.Enqueue(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,11 +411,13 @@ TEST(ProfileStartEndTime) {
|
|||||||
static const v8::CpuProfile* RunProfiler(
|
static const v8::CpuProfile* RunProfiler(
|
||||||
LocalContext& env, v8::Handle<v8::Function> function,
|
LocalContext& env, v8::Handle<v8::Function> function,
|
||||||
v8::Handle<v8::Value> argv[], int argc,
|
v8::Handle<v8::Value> argv[], int argc,
|
||||||
unsigned min_js_samples) {
|
unsigned min_js_samples, bool script_will_start_profiler = false) {
|
||||||
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
|
v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler();
|
||||||
v8::Local<v8::String> profile_name = v8::String::New("my_profile");
|
v8::Local<v8::String> profile_name = v8::String::New("my_profile");
|
||||||
|
|
||||||
|
if (!script_will_start_profiler) {
|
||||||
cpu_profiler->StartCpuProfiling(profile_name);
|
cpu_profiler->StartCpuProfiling(profile_name);
|
||||||
|
}
|
||||||
|
|
||||||
i::Sampler* sampler =
|
i::Sampler* sampler =
|
||||||
reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler();
|
reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler();
|
||||||
@ -475,7 +477,12 @@ static const v8::CpuProfileNode* FindChild(const v8::CpuProfileNode* node,
|
|||||||
static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node,
|
static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node,
|
||||||
const char* name) {
|
const char* name) {
|
||||||
const v8::CpuProfileNode* result = FindChild(node, name);
|
const v8::CpuProfileNode* result = FindChild(node, name);
|
||||||
CHECK(result);
|
if (!result) {
|
||||||
|
char buffer[100];
|
||||||
|
i::OS::SNPrintF(Vector<char>(buffer, ARRAY_SIZE(buffer)),
|
||||||
|
"Failed to GetChild: %s", name);
|
||||||
|
FATAL(buffer);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,7 +597,7 @@ static const char* cpu_profiler_test_source2 = "function loop() {}\n"
|
|||||||
" } while (++k < count*100*1000);\n"
|
" } while (++k < count*100*1000);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
// Check that the profile tree doesn't contain unexpecte traces:
|
// Check that the profile tree doesn't contain unexpected traces:
|
||||||
// - 'loop' can be called only by 'delay'
|
// - 'loop' can be called only by 'delay'
|
||||||
// - 'delay' may be called only by 'start'
|
// - 'delay' may be called only by 'start'
|
||||||
// The profile will look like the following:
|
// The profile will look like the following:
|
||||||
@ -1081,7 +1088,13 @@ TEST(FunctionApplySample) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char* js_native_js_test_source = "function foo(iterations) {\n"
|
static const char* js_native_js_test_source =
|
||||||
|
"var is_profiling = false;\n"
|
||||||
|
"function foo(iterations) {\n"
|
||||||
|
" if (!is_profiling) {\n"
|
||||||
|
" is_profiling = true;\n"
|
||||||
|
" startProfiling('my_profile');\n"
|
||||||
|
" }\n"
|
||||||
" var r = 0;\n"
|
" var r = 0;\n"
|
||||||
" for (var i = 0; i < iterations; i++) { r += i; }\n"
|
" for (var i = 0; i < iterations; i++) { r += i; }\n"
|
||||||
" return r;\n"
|
" return r;\n"
|
||||||
@ -1113,7 +1126,9 @@ static void CallJsFunction(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
|||||||
// 55 1 bar #16 5
|
// 55 1 bar #16 5
|
||||||
// 54 54 foo #16 6
|
// 54 54 foo #16 6
|
||||||
TEST(JsNativeJsSample) {
|
TEST(JsNativeJsSample) {
|
||||||
LocalContext env;
|
const char* extensions[] = { "v8/profiler" };
|
||||||
|
v8::ExtensionConfiguration config(1, extensions);
|
||||||
|
LocalContext env(&config);
|
||||||
v8::HandleScope scope(env->GetIsolate());
|
v8::HandleScope scope(env->GetIsolate());
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
|
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
|
||||||
@ -1129,7 +1144,7 @@ TEST(JsNativeJsSample) {
|
|||||||
int32_t duration_ms = 20;
|
int32_t duration_ms = 20;
|
||||||
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
|
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
|
||||||
const v8::CpuProfile* profile =
|
const v8::CpuProfile* profile =
|
||||||
RunProfiler(env, function, args, ARRAY_SIZE(args), 50);
|
RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
|
||||||
|
|
||||||
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
|
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
|
||||||
{
|
{
|
||||||
@ -1157,7 +1172,12 @@ TEST(JsNativeJsSample) {
|
|||||||
|
|
||||||
|
|
||||||
static const char* js_native_js_runtime_js_test_source =
|
static const char* js_native_js_runtime_js_test_source =
|
||||||
|
"var is_profiling = false;\n"
|
||||||
"function foo(iterations) {\n"
|
"function foo(iterations) {\n"
|
||||||
|
" if (!is_profiling) {\n"
|
||||||
|
" is_profiling = true;\n"
|
||||||
|
" startProfiling('my_profile');\n"
|
||||||
|
" }\n"
|
||||||
" var r = 0;\n"
|
" var r = 0;\n"
|
||||||
" for (var i = 0; i < iterations; i++) { r += i; }\n"
|
" for (var i = 0; i < iterations; i++) { r += i; }\n"
|
||||||
" return r;\n"
|
" return r;\n"
|
||||||
@ -1184,7 +1204,9 @@ static const char* js_native_js_runtime_js_test_source =
|
|||||||
// 51 51 foo #16 6
|
// 51 51 foo #16 6
|
||||||
// 2 2 (program) #0 2
|
// 2 2 (program) #0 2
|
||||||
TEST(JsNativeJsRuntimeJsSample) {
|
TEST(JsNativeJsRuntimeJsSample) {
|
||||||
LocalContext env;
|
const char* extensions[] = { "v8/profiler" };
|
||||||
|
v8::ExtensionConfiguration config(1, extensions);
|
||||||
|
LocalContext env(&config);
|
||||||
v8::HandleScope scope(env->GetIsolate());
|
v8::HandleScope scope(env->GetIsolate());
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
|
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
|
||||||
@ -1201,7 +1223,7 @@ TEST(JsNativeJsRuntimeJsSample) {
|
|||||||
int32_t duration_ms = 20;
|
int32_t duration_ms = 20;
|
||||||
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
|
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
|
||||||
const v8::CpuProfile* profile =
|
const v8::CpuProfile* profile =
|
||||||
RunProfiler(env, function, args, ARRAY_SIZE(args), 50);
|
RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
|
||||||
|
|
||||||
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
|
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
|
||||||
ScopedVector<v8::Handle<v8::String> > names(3);
|
ScopedVector<v8::Handle<v8::String> > names(3);
|
||||||
@ -1232,7 +1254,12 @@ static void CallJsFunction2(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
|||||||
|
|
||||||
|
|
||||||
static const char* js_native1_js_native2_js_test_source =
|
static const char* js_native1_js_native2_js_test_source =
|
||||||
|
"var is_profiling = false;\n"
|
||||||
"function foo(iterations) {\n"
|
"function foo(iterations) {\n"
|
||||||
|
" if (!is_profiling) {\n"
|
||||||
|
" is_profiling = true;\n"
|
||||||
|
" startProfiling('my_profile');\n"
|
||||||
|
" }\n"
|
||||||
" var r = 0;\n"
|
" var r = 0;\n"
|
||||||
" for (var i = 0; i < iterations; i++) { r += i; }\n"
|
" for (var i = 0; i < iterations; i++) { r += i; }\n"
|
||||||
" return r;\n"
|
" return r;\n"
|
||||||
@ -1259,7 +1286,9 @@ static const char* js_native1_js_native2_js_test_source =
|
|||||||
// 54 54 foo #16 7
|
// 54 54 foo #16 7
|
||||||
// 2 2 (program) #0 2
|
// 2 2 (program) #0 2
|
||||||
TEST(JsNative1JsNative2JsSample) {
|
TEST(JsNative1JsNative2JsSample) {
|
||||||
LocalContext env;
|
const char* extensions[] = { "v8/profiler" };
|
||||||
|
v8::ExtensionConfiguration config(1, extensions);
|
||||||
|
LocalContext env(&config);
|
||||||
v8::HandleScope scope(env->GetIsolate());
|
v8::HandleScope scope(env->GetIsolate());
|
||||||
|
|
||||||
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
|
v8::Local<v8::FunctionTemplate> func_template = v8::FunctionTemplate::New(
|
||||||
@ -1281,7 +1310,7 @@ TEST(JsNative1JsNative2JsSample) {
|
|||||||
int32_t duration_ms = 20;
|
int32_t duration_ms = 20;
|
||||||
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
|
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
|
||||||
const v8::CpuProfile* profile =
|
const v8::CpuProfile* profile =
|
||||||
RunProfiler(env, function, args, ARRAY_SIZE(args), 50);
|
RunProfiler(env, function, args, ARRAY_SIZE(args), 10, true);
|
||||||
|
|
||||||
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
|
const v8::CpuProfileNode* root = profile->GetTopDownRoot();
|
||||||
ScopedVector<v8::Handle<v8::String> > names(3);
|
ScopedVector<v8::Handle<v8::String> > names(3);
|
||||||
|
Loading…
Reference in New Issue
Block a user