From 158923832977d1a4858d46fffb9f3a66e1464e03 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Thu, 21 Oct 2010 14:19:07 +0000 Subject: [PATCH] Clean up the log-stack-tracer test. Create the functions using the normal API and remove some unnecessary helpers. Review URL: http://codereview.chromium.org/4024003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5688 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- test/cctest/test-log-stack-tracer.cc | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/test/cctest/test-log-stack-tracer.cc b/test/cctest/test-log-stack-tracer.cc index 7d7bd40..65be6bd 100644 --- a/test/cctest/test-log-stack-tracer.cc +++ b/test/cctest/test-log-stack-tracer.cc @@ -199,13 +199,6 @@ static void InitializeVM() { } -static Handle CompileFunction(const char* source) { - Handle result(JSFunction::cast( - *v8::Utils::OpenHandle(*Script::Compile(String::New(source))))); - return result; -} - - static void CheckJSFunctionAtAddress(const char* func_name, Address addr) { i::Object* obj = i::HeapObject::FromAddress(addr); CHECK(obj->IsJSFunction()); @@ -218,16 +211,6 @@ static void CheckJSFunctionAtAddress(const char* func_name, Address addr) { } -static void SetGlobalProperty(const char* name, Local value) { - env->Global()->Set(String::New(name), value); -} - - -static Handle NewString(const char* s) { - return i::Factory::NewStringFromAscii(i::CStrVector(s)); -} - - // This C++ function is called as a constructor, to grab the frame pointer // from the calling function. When this function runs, the stack contains // a C_Entry frame and a Construct frame above the calling function's frame. @@ -273,25 +256,18 @@ static void CreateTraceCallerFunction(const char* func_name, const char* trace_func_name) { i::EmbeddedVector trace_call_buf; i::OS::SNPrintF(trace_call_buf, - "fp = new FPGrabber(); %s(fp.low_bits, fp.high_bits);", - trace_func_name); + "function %s() {" + " fp = new FPGrabber();" + " %s(fp.low_bits, fp.high_bits);" + "}", + func_name, trace_func_name); // Create the FPGrabber function, which grabs the caller's frame pointer // when called as a constructor. CreateFramePointerGrabberConstructor("FPGrabber"); // Compile the script. - Handle func = CompileFunction(trace_call_buf.start()); - CHECK(!func.is_null()); - func->shared()->set_name(*NewString(func_name)); - -#ifdef DEBUG - v8::internal::Code* func_code = func->code(); - CHECK(func_code->IsCode()); - func_code->Print(); -#endif - - SetGlobalProperty(func_name, v8::ToApi(func)); + CompileRun(trace_call_buf.start()); } -- 2.7.4