using v8::internal::Address;
using v8::internal::Handle;
using v8::internal::JSFunction;
-using v8::internal::SharedFunctionInfo;
using v8::internal::StackTracer;
using v8::internal::TickSample;
using v8::internal::Top;
}
-static void CheckRetAddrIsInSharedFunctionInfo(
- const char* func_name,
- Address ret_addr,
- Handle<SharedFunctionInfo> func) {
+static void CheckRetAddrIsInJSFunction(const char* func_name,
+ Address ret_addr,
+ Handle<JSFunction> func) {
v8::internal::Code* func_code = func->code();
CheckRetAddrIsInFunction(
func_name, ret_addr,
}
-static Handle<SharedFunctionInfo> CompileFunction(const char* source) {
- Handle<v8::internal::Object> obj =
- v8::Utils::OpenHandle(*Script::Compile(String::New(source)));
- Handle<SharedFunctionInfo> shared;
- if (obj->IsSharedFunctionInfo()) {
- shared = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(*obj));
- } else {
- shared = Handle<SharedFunctionInfo>(JSFunction::cast(*obj)->shared());
- }
- return shared;
+static Handle<JSFunction> CompileFunction(const char* source) {
+ Handle<JSFunction> result(JSFunction::cast(
+ *v8::Utils::OpenHandle(*Script::Compile(String::New(source)))));
+ return result;
}
}
-static Handle<SharedFunctionInfo> GetGlobalJSFunction(const char* name) {
- Handle<SharedFunctionInfo> js_func(
- SharedFunctionInfo::cast(
- *(v8::Utils::OpenHandle(*GetGlobalProperty(name)))));
- return js_func;
+static Handle<JSFunction> GetGlobalJSFunction(const char* name) {
+ Handle<JSFunction> result(JSFunction::cast(
+ *v8::Utils::OpenHandle(*GetGlobalProperty(name))));
+ return result;
}
-static void CheckRetAddrIsInSharedFunctionInfo(const char* func_name,
+static void CheckRetAddrIsInJSFunction(const char* func_name,
Address ret_addr) {
- CheckRetAddrIsInSharedFunctionInfo(func_name,
- ret_addr,
- GetGlobalJSFunction(func_name));
+ CheckRetAddrIsInJSFunction(func_name,
+ ret_addr,
+ GetGlobalJSFunction(func_name));
}
i::CodeGeneratorPatcher patcher;
bool allow_natives_syntax = i::FLAG_allow_natives_syntax;
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());
i::FLAG_allow_natives_syntax = allow_natives_syntax;
#endif
SetGlobalProperty(func_name, v8::ToApi<Value>(func));
+ CHECK_EQ(*func, *GetGlobalJSFunction(func_name));
}
TEST(CFromJSStackTrace) {
- // TODO(657): Fixup test after FunctionBoilerplate removal.
- return;
-
TickSample sample;
InitTraceEnv(&sample);
InitializeVM();
v8::HandleScope scope;
CreateTraceCallerFunction("JSFuncDoTrace", "trace");
- CompileRun(
+ Local<Value> result = CompileRun(
"function JSTrace() {"
" JSFuncDoTrace();"
"};\n"
- "JSTrace();");
+ "JSTrace();\n"
+ "true;");
+ CHECK(!result.IsEmpty());
CHECK_GT(sample.frames_count, 1);
// Stack sampling will start from the first JS function, i.e. "JSFuncDoTrace"
- CheckRetAddrIsInSharedFunctionInfo("JSFuncDoTrace",
- sample.stack[0]);
- CheckRetAddrIsInSharedFunctionInfo("JSTrace",
- sample.stack[1]);
+ CheckRetAddrIsInJSFunction("JSFuncDoTrace",
+ sample.stack[0]);
+ CheckRetAddrIsInJSFunction("JSTrace",
+ sample.stack[1]);
}
TEST(PureJSStackTrace) {
- // TODO(657): Fixup test after FunctionBoilerplate removal.
- return;
-
TickSample sample;
InitTraceEnv(&sample);
InitializeVM();
v8::HandleScope scope;
CreateTraceCallerFunction("JSFuncDoTrace", "js_trace");
- CompileRun(
+ Local<Value> result = CompileRun(
"function JSTrace() {"
" JSFuncDoTrace();"
"};\n"
"function OuterJSTrace() {"
" JSTrace();"
"};\n"
- "OuterJSTrace();");
+ "OuterJSTrace();\n"
+ "true;");
+ CHECK(!result.IsEmpty());
// The last JS function called.
CHECK_EQ(GetGlobalJSFunction("JSFuncDoTrace")->address(),
sample.function);
CHECK_GT(sample.frames_count, 1);
// Stack sampling will start from the caller of JSFuncDoTrace, i.e. "JSTrace"
- CheckRetAddrIsInSharedFunctionInfo("JSTrace",
- sample.stack[0]);
- CheckRetAddrIsInSharedFunctionInfo("OuterJSTrace",
- sample.stack[1]);
+ CheckRetAddrIsInJSFunction("JSTrace",
+ sample.stack[0]);
+ CheckRetAddrIsInJSFunction("OuterJSTrace",
+ sample.stack[1]);
}