Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: test/cctest/test-log-ia32.cc

Issue 112082: Fix determining of JS lower stack bottom used in profiler's JS stack tracer to work with Chromium. (Closed)
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/top.h ('K') | « src/top.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-log-ia32.cc
diff --git a/test/cctest/test-log-ia32.cc b/test/cctest/test-log-ia32.cc
index 7312901ccaa20f3b7df206d4b64db91ca3244c11..a40a800ee3a55c070eddafcf5ee7c05b8b9d6cfd 100644
--- a/test/cctest/test-log-ia32.cc
+++ b/test/cctest/test-log-ia32.cc
@@ -37,13 +37,11 @@ static v8::Persistent<v8::Context> env;
static struct {
- StackTracer* tracer;
TickSample* sample;
-} trace_env = { NULL, NULL };
+} trace_env = { NULL };
-static void InitTraceEnv(StackTracer* tracer, TickSample* sample) {
- trace_env.tracer = tracer;
+static void InitTraceEnv(TickSample* sample) {
trace_env.sample = sample;
}
@@ -53,7 +51,7 @@ static void DoTrace(Address fp) {
// sp is only used to define stack high bound
trace_env.sample->sp =
reinterpret_cast<unsigned int>(trace_env.sample) - 10240;
- trace_env.tracer->Trace(trace_env.sample);
+ StackTracer::Trace(trace_env.sample);
}
@@ -99,6 +97,8 @@ class TraceExtension : public v8::Extension {
v8::Handle<String> name);
static v8::Handle<v8::Value> Trace(const v8::Arguments& args);
static v8::Handle<v8::Value> JSTrace(const v8::Arguments& args);
+ static v8::Handle<v8::Value> JSEntrySP(const v8::Arguments& args);
+ static v8::Handle<v8::Value> JSEntrySPLevel2(const v8::Arguments& args);
private:
static Address GetFP(const v8::Arguments& args);
static const char* kSource;
@@ -107,8 +107,9 @@ class TraceExtension : public v8::Extension {
const char* TraceExtension::kSource =
"native function trace();"
- "native function js_trace();";
-
+ "native function js_trace();"
+ "native function js_entry_sp();"
+ "native function js_entry_sp_level2();";
v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunction(
v8::Handle<String> name) {
@@ -116,6 +117,10 @@ v8::Handle<v8::FunctionTemplate> TraceExtension::GetNativeFunction(
return v8::FunctionTemplate::New(TraceExtension::Trace);
} else if (name->Equals(String::New("js_trace"))) {
return v8::FunctionTemplate::New(TraceExtension::JSTrace);
+ } else if (name->Equals(String::New("js_entry_sp"))) {
+ return v8::FunctionTemplate::New(TraceExtension::JSEntrySP);
+ } else if (name->Equals(String::New("js_entry_sp_level2"))) {
+ return v8::FunctionTemplate::New(TraceExtension::JSEntrySPLevel2);
} else {
CHECK(false);
return v8::Handle<v8::FunctionTemplate>();
@@ -143,6 +148,34 @@ v8::Handle<v8::Value> TraceExtension::JSTrace(const v8::Arguments& args) {
}
+static Address GetJsEntrySp() {
+ CHECK_NE(NULL, Top::GetCurrentThread());
+ return Top::js_entry_sp(Top::GetCurrentThread());
+}
+
+
+v8::Handle<v8::Value> TraceExtension::JSEntrySP(const v8::Arguments& args) {
+ CHECK_NE(0, GetJsEntrySp());
+ return v8::Undefined();
+}
+
+
+static void CompileRun(const char* source) {
+ Script::Compile(String::New(source))->Run();
+}
+
+
+v8::Handle<v8::Value> TraceExtension::JSEntrySPLevel2(
+ const v8::Arguments& args) {
+ v8::HandleScope scope;
+ const Address js_entry_sp = GetJsEntrySp();
+ CHECK_NE(0, js_entry_sp);
+ CompileRun("js_entry_sp();");
+ CHECK_EQ(js_entry_sp, GetJsEntrySp());
+ return v8::Undefined();
+}
+
+
static TraceExtension kTraceExtension;
v8::DeclareExtension kTraceExtensionDeclaration(&kTraceExtension);
@@ -164,11 +197,6 @@ static Handle<JSFunction> CompileFunction(const char* source) {
}
-static void CompileRun(const char* source) {
- Script::Compile(String::New(source))->Run();
-}
-
-
static Local<Value> GetGlobalProperty(const char* name) {
return env->Global()->Get(String::New(name));
}
@@ -255,8 +283,7 @@ static void CreateTraceCallerFunction(const char* func_name,
TEST(CFromJSStackTrace) {
TickSample sample;
- StackTracer tracer(reinterpret_cast<uintptr_t>(&sample));
- InitTraceEnv(&tracer, &sample);
+ InitTraceEnv(&sample);
InitializeVM();
v8::HandleScope scope;
@@ -277,8 +304,7 @@ TEST(CFromJSStackTrace) {
TEST(PureJSStackTrace) {
TickSample sample;
- StackTracer tracer(reinterpret_cast<uintptr_t>(&sample));
- InitTraceEnv(&tracer, &sample);
+ InitTraceEnv(&sample);
InitializeVM();
v8::HandleScope scope;
@@ -323,11 +349,22 @@ static int CFunc(int depth) {
TEST(PureCStackTrace) {
TickSample sample;
- StackTracer tracer(reinterpret_cast<uintptr_t>(&sample));
- InitTraceEnv(&tracer, &sample);
+ InitTraceEnv(&sample);
// Check that sampler doesn't crash
CHECK_EQ(10, CFunc(10));
}
+TEST(JsEntrySp) {
+ InitializeVM();
+ v8::HandleScope scope;
+ CHECK_EQ(0, GetJsEntrySp());
+ CompileRun("a = 1; b = a + 1;");
+ CHECK_EQ(0, GetJsEntrySp());
+ CompileRun("js_entry_sp();");
+ CHECK_EQ(0, GetJsEntrySp());
+ CompileRun("js_entry_sp_level2();");
+ CHECK_EQ(0, GetJsEntrySp());
+}
+
#endif // ENABLE_LOGGING_AND_PROFILING
« src/top.h ('K') | « src/top.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698