Fix issue 658: update test-log-stack-tracer after r4211.

It appears that semi-automatic changes made to test's code were
incorrect. v8::Script::Compile returns wrapped JSFunction,
not SharedFunctionInfo.

Review URL: http://codereview.chromium.org/1169002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4222 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 9dfb673f
...@@ -26,7 +26,6 @@ using v8::internal::byte; ...@@ -26,7 +26,6 @@ using v8::internal::byte;
using v8::internal::Address; using v8::internal::Address;
using v8::internal::Handle; using v8::internal::Handle;
using v8::internal::JSFunction; using v8::internal::JSFunction;
using v8::internal::SharedFunctionInfo;
using v8::internal::StackTracer; using v8::internal::StackTracer;
using v8::internal::TickSample; using v8::internal::TickSample;
using v8::internal::Top; using v8::internal::Top;
...@@ -78,10 +77,9 @@ static void CheckRetAddrIsInFunction(const char* func_name, ...@@ -78,10 +77,9 @@ static void CheckRetAddrIsInFunction(const char* func_name,
} }
static void CheckRetAddrIsInSharedFunctionInfo( static void CheckRetAddrIsInJSFunction(const char* func_name,
const char* func_name, Address ret_addr,
Address ret_addr, Handle<JSFunction> func) {
Handle<SharedFunctionInfo> func) {
v8::internal::Code* func_code = func->code(); v8::internal::Code* func_code = func->code();
CheckRetAddrIsInFunction( CheckRetAddrIsInFunction(
func_name, ret_addr, func_name, ret_addr,
...@@ -192,16 +190,10 @@ static void InitializeVM() { ...@@ -192,16 +190,10 @@ static void InitializeVM() {
} }
static Handle<SharedFunctionInfo> CompileFunction(const char* source) { static Handle<JSFunction> CompileFunction(const char* source) {
Handle<v8::internal::Object> obj = Handle<JSFunction> result(JSFunction::cast(
v8::Utils::OpenHandle(*Script::Compile(String::New(source))); *v8::Utils::OpenHandle(*Script::Compile(String::New(source)))));
Handle<SharedFunctionInfo> shared; return result;
if (obj->IsSharedFunctionInfo()) {
shared = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(*obj));
} else {
shared = Handle<SharedFunctionInfo>(JSFunction::cast(*obj)->shared());
}
return shared;
} }
...@@ -210,19 +202,18 @@ static Local<Value> GetGlobalProperty(const char* name) { ...@@ -210,19 +202,18 @@ static Local<Value> GetGlobalProperty(const char* name) {
} }
static Handle<SharedFunctionInfo> GetGlobalJSFunction(const char* name) { static Handle<JSFunction> GetGlobalJSFunction(const char* name) {
Handle<SharedFunctionInfo> js_func( Handle<JSFunction> result(JSFunction::cast(
SharedFunctionInfo::cast( *v8::Utils::OpenHandle(*GetGlobalProperty(name))));
*(v8::Utils::OpenHandle(*GetGlobalProperty(name))))); return result;
return js_func;
} }
static void CheckRetAddrIsInSharedFunctionInfo(const char* func_name, static void CheckRetAddrIsInJSFunction(const char* func_name,
Address ret_addr) { Address ret_addr) {
CheckRetAddrIsInSharedFunctionInfo(func_name, CheckRetAddrIsInJSFunction(func_name,
ret_addr, ret_addr,
GetGlobalJSFunction(func_name)); GetGlobalJSFunction(func_name));
} }
...@@ -278,7 +269,7 @@ static void CreateTraceCallerFunction(const char* func_name, ...@@ -278,7 +269,7 @@ static void CreateTraceCallerFunction(const char* func_name,
i::CodeGeneratorPatcher patcher; i::CodeGeneratorPatcher patcher;
bool allow_natives_syntax = i::FLAG_allow_natives_syntax; bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
Handle<SharedFunctionInfo> func = CompileFunction(trace_call_buf.start()); Handle<JSFunction> func = CompileFunction(trace_call_buf.start());
CHECK(!func.is_null()); CHECK(!func.is_null());
i::FLAG_allow_natives_syntax = allow_natives_syntax; i::FLAG_allow_natives_syntax = allow_natives_syntax;
...@@ -289,60 +280,59 @@ static void CreateTraceCallerFunction(const char* func_name, ...@@ -289,60 +280,59 @@ static void CreateTraceCallerFunction(const char* func_name,
#endif #endif
SetGlobalProperty(func_name, v8::ToApi<Value>(func)); SetGlobalProperty(func_name, v8::ToApi<Value>(func));
CHECK_EQ(*func, *GetGlobalJSFunction(func_name));
} }
TEST(CFromJSStackTrace) { TEST(CFromJSStackTrace) {
// TODO(657): Fixup test after FunctionBoilerplate removal.
return;
TickSample sample; TickSample sample;
InitTraceEnv(&sample); InitTraceEnv(&sample);
InitializeVM(); InitializeVM();
v8::HandleScope scope; v8::HandleScope scope;
CreateTraceCallerFunction("JSFuncDoTrace", "trace"); CreateTraceCallerFunction("JSFuncDoTrace", "trace");
CompileRun( Local<Value> result = CompileRun(
"function JSTrace() {" "function JSTrace() {"
" JSFuncDoTrace();" " JSFuncDoTrace();"
"};\n" "};\n"
"JSTrace();"); "JSTrace();\n"
"true;");
CHECK(!result.IsEmpty());
CHECK_GT(sample.frames_count, 1); CHECK_GT(sample.frames_count, 1);
// Stack sampling will start from the first JS function, i.e. "JSFuncDoTrace" // Stack sampling will start from the first JS function, i.e. "JSFuncDoTrace"
CheckRetAddrIsInSharedFunctionInfo("JSFuncDoTrace", CheckRetAddrIsInJSFunction("JSFuncDoTrace",
sample.stack[0]); sample.stack[0]);
CheckRetAddrIsInSharedFunctionInfo("JSTrace", CheckRetAddrIsInJSFunction("JSTrace",
sample.stack[1]); sample.stack[1]);
} }
TEST(PureJSStackTrace) { TEST(PureJSStackTrace) {
// TODO(657): Fixup test after FunctionBoilerplate removal.
return;
TickSample sample; TickSample sample;
InitTraceEnv(&sample); InitTraceEnv(&sample);
InitializeVM(); InitializeVM();
v8::HandleScope scope; v8::HandleScope scope;
CreateTraceCallerFunction("JSFuncDoTrace", "js_trace"); CreateTraceCallerFunction("JSFuncDoTrace", "js_trace");
CompileRun( Local<Value> result = CompileRun(
"function JSTrace() {" "function JSTrace() {"
" JSFuncDoTrace();" " JSFuncDoTrace();"
"};\n" "};\n"
"function OuterJSTrace() {" "function OuterJSTrace() {"
" JSTrace();" " JSTrace();"
"};\n" "};\n"
"OuterJSTrace();"); "OuterJSTrace();\n"
"true;");
CHECK(!result.IsEmpty());
// The last JS function called. // The last JS function called.
CHECK_EQ(GetGlobalJSFunction("JSFuncDoTrace")->address(), CHECK_EQ(GetGlobalJSFunction("JSFuncDoTrace")->address(),
sample.function); sample.function);
CHECK_GT(sample.frames_count, 1); CHECK_GT(sample.frames_count, 1);
// Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace" // Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace"
CheckRetAddrIsInSharedFunctionInfo("JSTrace", CheckRetAddrIsInJSFunction("JSTrace",
sample.stack[0]); sample.stack[0]);
CheckRetAddrIsInSharedFunctionInfo("OuterJSTrace", CheckRetAddrIsInJSFunction("OuterJSTrace",
sample.stack[1]); sample.stack[1]);
} }
......
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