Revision: 17140
Author: [email protected]
Date: Thu Oct 10 13:03:41 2013 UTC
Log: 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
[email protected]
Review URL: https://codereview.chromium.org/25686011
http://code.google.com/p/v8/source/detail?r=17140
Modified:
/branches/bleeding_edge/src/cpu-profiler.cc
/branches/bleeding_edge/test/cctest/test-cpu-profiler.cc
=======================================
--- /branches/bleeding_edge/src/cpu-profiler.cc Tue Sep 17 15:26:18 2013 UTC
+++ /branches/bleeding_edge/src/cpu-profiler.cc Thu Oct 10 13:03:41 2013 UTC
@@ -64,14 +64,15 @@
void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) {
TickSampleEventRecord record(last_code_event_id_);
- TickSample* sample = &record.sample;
- sample->state = isolate->current_vm_state();
- sample->pc = reinterpret_cast<Address>(sample); // Not NULL.
- for (StackTraceFrameIterator it(isolate);
- !it.done() && sample->frames_count < TickSample::kMaxFramesCount;
- it.Advance()) {
- sample->stack[sample->frames_count++] = it.frame()->pc();
+ RegisterState regs;
+ StackFrameIterator it(isolate);
+ if (!it.done()) {
+ StackFrame* frame = it.frame();
+ regs.sp = frame->sp();
+ regs.fp = frame->fp();
+ regs.pc = frame->pc();
}
+ record.sample.Init(isolate, regs);
ticks_from_vm_buffer_.Enqueue(record);
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Thu Sep 19
09:46:15 2013 UTC
+++ /branches/bleeding_edge/test/cctest/test-cpu-profiler.cc Thu Oct 10
13:03:41 2013 UTC
@@ -411,11 +411,13 @@
static const v8::CpuProfile* RunProfiler(
LocalContext& env, v8::Handle<v8::Function> function,
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::Local<v8::String> profile_name = v8::String::New("my_profile");
- cpu_profiler->StartCpuProfiling(profile_name);
+ if (!script_will_start_profiler) {
+ cpu_profiler->StartCpuProfiling(profile_name);
+ }
i::Sampler* sampler =
reinterpret_cast<i::Isolate*>(env->GetIsolate())->logger()->sampler();
@@ -475,7 +477,12 @@
static const v8::CpuProfileNode* GetChild(const v8::CpuProfileNode* node,
const char* 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;
}
@@ -590,7 +597,7 @@
" } while (++k < count*100*1000);\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'
// - 'delay' may be called only by 'start'
// The profile will look like the following:
@@ -1081,7 +1088,13 @@
}
-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"
" for (var i = 0; i < iterations; i++) { r += i; }\n"
" return r;\n"
@@ -1113,7 +1126,9 @@
// 55 1 bar #16 5
// 54 54 foo #16 6
TEST(JsNativeJsSample) {
- LocalContext env;
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ LocalContext env(&config);
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(
@@ -1129,7 +1144,7 @@
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
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();
{
@@ -1157,7 +1172,12 @@
static const char* js_native_js_runtime_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"
" for (var i = 0; i < iterations; i++) { r += i; }\n"
" return r;\n"
@@ -1184,7 +1204,9 @@
// 51 51 foo #16 6
// 2 2 (program) #0 2
TEST(JsNativeJsRuntimeJsSample) {
- LocalContext env;
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ LocalContext env(&config);
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(
@@ -1201,7 +1223,7 @@
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
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();
ScopedVector<v8::Handle<v8::String> > names(3);
@@ -1232,7 +1254,12 @@
static const char* js_native1_js_native2_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"
" for (var i = 0; i < iterations; i++) { r += i; }\n"
" return r;\n"
@@ -1259,7 +1286,9 @@
// 54 54 foo #16 7
// 2 2 (program) #0 2
TEST(JsNative1JsNative2JsSample) {
- LocalContext env;
+ const char* extensions[] = { "v8/profiler" };
+ v8::ExtensionConfiguration config(1, extensions);
+ LocalContext env(&config);
v8::HandleScope scope(env->GetIsolate());
v8::Local<v8::FunctionTemplate> func_template =
v8::FunctionTemplate::New(
@@ -1281,7 +1310,7 @@
int32_t duration_ms = 20;
v8::Handle<v8::Value> args[] = { v8::Integer::New(duration_ms) };
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();
ScopedVector<v8::Handle<v8::String> > names(3);
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.