Fix issue 658: update test-log-stack-tracer after r4211.
authormikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Mar 2010 12:42:47 +0000 (12:42 +0000)
committermikhail.naganov@gmail.com <mikhail.naganov@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Mar 2010 12:42:47 +0000 (12:42 +0000)
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

test/cctest/test-log-stack-tracer.cc

index d744acb3c10b797e89476991c96ef0129e1c5b29..d96e5e787877081c115ce716f05d0000776a4698 100644 (file)
@@ -26,7 +26,6 @@ using v8::internal::byte;
 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;
@@ -78,10 +77,9 @@ static void CheckRetAddrIsInFunction(const char* func_name,
 }
 
 
-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,
@@ -192,16 +190,10 @@ static void InitializeVM() {
 }
 
 
-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;
 }
 
 
@@ -210,19 +202,18 @@ static Local<Value> GetGlobalProperty(const char* name) {
 }
 
 
-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));
 }
 
 
@@ -278,7 +269,7 @@ static void CreateTraceCallerFunction(const char* 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;
 
@@ -289,60 +280,59 @@ static void CreateTraceCallerFunction(const char* func_name,
 #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]);
 }