From: dcarney@chromium.org Date: Thu, 20 Jun 2013 12:28:27 +0000 (+0000) Subject: remove all old style callbacks - patch 3 X-Git-Tag: upstream/4.7.83~13754 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a74f511e610895a7b64bbd388fffbf46d6895c0c;p=platform%2Fupstream%2Fv8.git remove all old style callbacks - patch 3 TBR=svenpanne@chromium.org BUG= Review URL: https://codereview.chromium.org/17336003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15237 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index b74ccb2..1e3e0d5 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -47,7 +47,7 @@ class PrintExtension : public v8::Extension { PrintExtension() : v8::Extension("v8/print", kSource) { } virtual v8::Handle GetNativeFunction( v8::Handle name); - static v8::Handle Print(const v8::Arguments& args); + static void Print(const v8::FunctionCallbackInfo& args); private: static const char* kSource; }; @@ -62,16 +62,15 @@ v8::Handle PrintExtension::GetNativeFunction( } -v8::Handle PrintExtension::Print(const v8::Arguments& args) { +void PrintExtension::Print(const v8::FunctionCallbackInfo& args) { for (int i = 0; i < args.Length(); i++) { if (i != 0) printf(" "); v8::HandleScope scope(args.GetIsolate()); v8::String::Utf8Value str(args[i]); - if (*str == NULL) return v8::Undefined(); + if (*str == NULL) return; printf("%s", *str); } printf("\n"); - return v8::Undefined(); } diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc index ed79205..17da0d2 100644 --- a/test/cctest/test-debug.cc +++ b/test/cctest/test-debug.cc @@ -4264,43 +4264,46 @@ TEST(NoBreakWhenBootstrapping) { CheckDebuggerUnloaded(); } -static v8::Handle NamedEnum(const v8::AccessorInfo&) { +static void NamedEnum(const v8::PropertyCallbackInfo& info) { v8::Handle result = v8::Array::New(3); result->Set(v8::Integer::New(0), v8::String::New("a")); result->Set(v8::Integer::New(1), v8::String::New("b")); result->Set(v8::Integer::New(2), v8::String::New("c")); - return result; + info.GetReturnValue().Set(result); } -static v8::Handle IndexedEnum(const v8::AccessorInfo&) { +static void IndexedEnum(const v8::PropertyCallbackInfo& info) { v8::Handle result = v8::Array::New(2); result->Set(v8::Integer::New(0), v8::Number::New(1)); result->Set(v8::Integer::New(1), v8::Number::New(10)); - return result; + info.GetReturnValue().Set(result); } -static v8::Handle NamedGetter(v8::Local name, - const v8::AccessorInfo& info) { +static void NamedGetter(v8::Local name, + const v8::PropertyCallbackInfo& info) { v8::String::Utf8Value n(name); if (strcmp(*n, "a") == 0) { - return v8::String::New("AA"); + info.GetReturnValue().Set(v8::String::New("AA")); + return; } else if (strcmp(*n, "b") == 0) { - return v8::String::New("BB"); + info.GetReturnValue().Set(v8::String::New("BB")); + return; } else if (strcmp(*n, "c") == 0) { - return v8::String::New("CC"); + info.GetReturnValue().Set(v8::String::New("CC")); + return; } else { - return v8::Undefined(); + info.GetReturnValue().SetUndefined(); + return; } - - return name; + info.GetReturnValue().Set(name); } -static v8::Handle IndexedGetter(uint32_t index, - const v8::AccessorInfo& info) { - return v8::Number::New(index + 1); +static void IndexedGetter(uint32_t index, + const v8::PropertyCallbackInfo& info) { + info.GetReturnValue().Set(static_cast(index + 1)); } @@ -4530,9 +4533,10 @@ TEST(HiddenPrototypePropertyMirror) { } -static v8::Handle ProtperyXNativeGetter( - v8::Local property, const v8::AccessorInfo& info) { - return v8::Integer::New(10); +static void ProtperyXNativeGetter( + v8::Local property, + const v8::PropertyCallbackInfo& info) { + info.GetReturnValue().Set(10); } @@ -4567,9 +4571,10 @@ TEST(NativeGetterPropertyMirror) { } -static v8::Handle ProtperyXNativeGetterThrowingError( - v8::Local property, const v8::AccessorInfo& info) { - return CompileRun("throw new Error('Error message');"); +static void ProtperyXNativeGetterThrowingError( + v8::Local property, + const v8::PropertyCallbackInfo& info) { + CompileRun("throw new Error('Error message');"); } @@ -5112,9 +5117,9 @@ class DebuggerThread : public v8::internal::Thread { }; -static v8::Handle ThreadedAtBarrier1(const v8::Arguments& args) { +static void ThreadedAtBarrier1( + const v8::FunctionCallbackInfo& args) { threaded_debugging_barriers.barrier_1.Wait(); - return v8::Undefined(); } @@ -5480,28 +5485,27 @@ v8::Handle debugger_call_with_closure; // Function to retrieve the number of JavaScript frames by calling a JavaScript // in the debugger. -static v8::Handle CheckFrameCount(const v8::Arguments& args) { +static void CheckFrameCount(const v8::FunctionCallbackInfo& args) { CHECK(v8::Debug::Call(frame_count)->IsNumber()); CHECK_EQ(args[0]->Int32Value(), v8::Debug::Call(frame_count)->Int32Value()); - return v8::Undefined(); } // Function to retrieve the source line of the top JavaScript frame by calling a // JavaScript function in the debugger. -static v8::Handle CheckSourceLine(const v8::Arguments& args) { +static void CheckSourceLine(const v8::FunctionCallbackInfo& args) { CHECK(v8::Debug::Call(frame_source_line)->IsNumber()); CHECK_EQ(args[0]->Int32Value(), v8::Debug::Call(frame_source_line)->Int32Value()); - return v8::Undefined(); } // Function to test passing an additional parameter to a JavaScript function // called in the debugger. It also tests that functions called in the debugger // can throw exceptions. -static v8::Handle CheckDataParameter(const v8::Arguments& args) { +static void CheckDataParameter( + const v8::FunctionCallbackInfo& args) { v8::Handle data = v8::String::New("Test"); CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString()); @@ -5512,16 +5516,13 @@ static v8::Handle CheckDataParameter(const v8::Arguments& args) { v8::Debug::Call(debugger_call_with_data); CHECK(catcher.HasCaught()); CHECK(catcher.Exception()->IsString()); - - return v8::Undefined(); } // Function to test using a JavaScript with closure in the debugger. -static v8::Handle CheckClosure(const v8::Arguments& args) { +static void CheckClosure(const v8::FunctionCallbackInfo& args) { CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber()); CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value()); - return v8::Undefined(); } @@ -7017,9 +7018,9 @@ v8::Handle debugger_context; // Property getter that checks that current and calling contexts // are both the debugee contexts. -static v8::Handle NamedGetterWithCallingContextCheck( +static void NamedGetterWithCallingContextCheck( v8::Local name, - const v8::AccessorInfo& info) { + const v8::PropertyCallbackInfo& info) { CHECK_EQ(0, strcmp(*v8::String::Utf8Value(name), "a")); v8::Handle current = v8::Context::GetCurrent(); CHECK(current == debugee_context); @@ -7027,7 +7028,7 @@ static v8::Handle NamedGetterWithCallingContextCheck( v8::Handle calling = v8::Context::GetCalling(); CHECK(calling == debugee_context); CHECK(calling != debugger_context); - return v8::Int32::New(1); + info.GetReturnValue().Set(1); } @@ -7302,11 +7303,10 @@ static void DebugEventBreakWithOptimizedStack(v8::DebugEvent event, } -static v8::Handle ScheduleBreak(const v8::Arguments& args) { +static void ScheduleBreak(const v8::FunctionCallbackInfo& args) { v8::Debug::SetDebugEventListener(DebugEventBreakWithOptimizedStack, v8::Undefined()); v8::Debug::DebugBreak(); - return v8::Undefined(); } diff --git a/test/cctest/test-decls.cc b/test/cctest/test-decls.cc index de45cbc..0f6bb8f 100644 --- a/test/cctest/test-decls.cc +++ b/test/cctest/test-decls.cc @@ -88,13 +88,13 @@ class DeclarationContext { // The handlers are called as static functions that forward // to the instance specific virtual methods. - static v8::Handle HandleGet(Local key, - const AccessorInfo& info); - static v8::Handle HandleSet(Local key, - Local value, - const AccessorInfo& info); - static v8::Handle HandleQuery(Local key, - const AccessorInfo& info); + static void HandleGet(Local key, + const v8::PropertyCallbackInfo& info); + static void HandleSet(Local key, + Local value, + const v8::PropertyCallbackInfo& info); + static void HandleQuery(Local key, + const v8::PropertyCallbackInfo& info); private: bool is_initialized_; @@ -104,7 +104,7 @@ class DeclarationContext { int set_count_; int query_count_; - static DeclarationContext* GetInstance(const AccessorInfo& info); + static DeclarationContext* GetInstance(Local data); }; @@ -173,33 +173,36 @@ void DeclarationContext::Check(const char* source, } -v8::Handle DeclarationContext::HandleGet(Local key, - const AccessorInfo& info) { - DeclarationContext* context = GetInstance(info); +void DeclarationContext::HandleGet( + Local key, + const v8::PropertyCallbackInfo& info) { + DeclarationContext* context = GetInstance(info.Data()); context->get_count_++; - return context->Get(key); + info.GetReturnValue().Set(context->Get(key)); } -v8::Handle DeclarationContext::HandleSet(Local key, - Local value, - const AccessorInfo& info) { - DeclarationContext* context = GetInstance(info); +void DeclarationContext::HandleSet( + Local key, + Local value, + const v8::PropertyCallbackInfo& info) { + DeclarationContext* context = GetInstance(info.Data()); context->set_count_++; - return context->Set(key, value); + info.GetReturnValue().Set(context->Set(key, value)); } -v8::Handle DeclarationContext::HandleQuery(Local key, - const AccessorInfo& info) { - DeclarationContext* context = GetInstance(info); +void DeclarationContext::HandleQuery( + Local key, + const v8::PropertyCallbackInfo& info) { + DeclarationContext* context = GetInstance(info.Data()); context->query_count_++; - return context->Query(key); + info.GetReturnValue().Set(context->Query(key)); } -DeclarationContext* DeclarationContext::GetInstance(const AccessorInfo& info) { - void* value = External::Cast(*info.Data())->Value(); +DeclarationContext* DeclarationContext::GetInstance(Local data) { + void* value = Local::Cast(data)->Value(); return static_cast(value); } diff --git a/test/cctest/test-log-stack-tracer.cc b/test/cctest/test-log-stack-tracer.cc index ca6c7ae..4333498 100644 --- a/test/cctest/test-log-stack-tracer.cc +++ b/test/cctest/test-log-stack-tracer.cc @@ -92,12 +92,12 @@ class TraceExtension : public v8::Extension { TraceExtension() : v8::Extension("v8/trace", kSource) { } virtual v8::Handle GetNativeFunction( v8::Handle name); - static v8::Handle Trace(const v8::Arguments& args); - static v8::Handle JSTrace(const v8::Arguments& args); - static v8::Handle JSEntrySP(const v8::Arguments& args); - static v8::Handle JSEntrySPLevel2(const v8::Arguments& args); + static void Trace(const v8::FunctionCallbackInfo& args); + static void JSTrace(const v8::FunctionCallbackInfo& args); + static void JSEntrySP(const v8::FunctionCallbackInfo& args); + static void JSEntrySPLevel2(const v8::FunctionCallbackInfo& args); private: - static Address GetFP(const v8::Arguments& args); + static Address GetFP(const v8::FunctionCallbackInfo& args); static const char* kSource; }; @@ -125,7 +125,7 @@ v8::Handle TraceExtension::GetNativeFunction( } -Address TraceExtension::GetFP(const v8::Arguments& args) { +Address TraceExtension::GetFP(const v8::FunctionCallbackInfo& args) { // Convert frame pointer from encoding as smis in the arguments to a pointer. CHECK_EQ(2, args.Length()); // Ignore second argument on 32-bit platform. #if defined(V8_HOST_ARCH_32_BIT) @@ -142,15 +142,13 @@ Address TraceExtension::GetFP(const v8::Arguments& args) { } -v8::Handle TraceExtension::Trace(const v8::Arguments& args) { +void TraceExtension::Trace(const v8::FunctionCallbackInfo& args) { DoTrace(GetFP(args)); - return v8::Undefined(); } -v8::Handle TraceExtension::JSTrace(const v8::Arguments& args) { +void TraceExtension::JSTrace(const v8::FunctionCallbackInfo& args) { DoTraceHideCEntryFPAddress(GetFP(args)); - return v8::Undefined(); } @@ -160,20 +158,19 @@ static Address GetJsEntrySp() { } -v8::Handle TraceExtension::JSEntrySP(const v8::Arguments& args) { +void TraceExtension::JSEntrySP( + const v8::FunctionCallbackInfo& args) { CHECK_NE(0, GetJsEntrySp()); - return v8::Undefined(); } -v8::Handle TraceExtension::JSEntrySPLevel2( - const v8::Arguments& args) { +void TraceExtension::JSEntrySPLevel2( + const v8::FunctionCallbackInfo& args) { v8::HandleScope scope(args.GetIsolate()); 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(); } @@ -197,7 +194,7 @@ static bool IsAddressWithinFuncCode(const char* func_name, Address addr) { // 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. -static v8::Handle construct_call(const v8::Arguments& args) { +static void construct_call(const v8::FunctionCallbackInfo& args) { i::Isolate* isolate = reinterpret_cast(args.GetIsolate()); i::StackFrameIterator frame_iterator(isolate); CHECK(frame_iterator.frame()->is_exit()); @@ -219,7 +216,7 @@ static v8::Handle construct_call(const v8::Arguments& args) { #else #error Host architecture is neither 32-bit nor 64-bit. #endif - return args.This(); + args.GetReturnValue().Set(args.This()); } diff --git a/test/cctest/test-log.cc b/test/cctest/test-log.cc index 5daf8dd..8615784 100644 --- a/test/cctest/test-log.cc +++ b/test/cctest/test-log.cc @@ -392,8 +392,7 @@ TEST(Issue23768) { } -static v8::Handle ObjMethod1(const v8::Arguments& args) { - return v8::Handle(); +static void ObjMethod1(const v8::FunctionCallbackInfo& args) { } TEST(LogCallbacks) { @@ -431,19 +430,17 @@ TEST(LogCallbacks) { } -static v8::Handle Prop1Getter(v8::Local property, - const v8::AccessorInfo& info) { - return v8::Handle(); +static void Prop1Getter(v8::Local property, + const v8::PropertyCallbackInfo& info) { } static void Prop1Setter(v8::Local property, - v8::Local value, - const v8::AccessorInfo& info) { + v8::Local value, + const v8::PropertyCallbackInfo& info) { } -static v8::Handle Prop2Getter(v8::Local property, - const v8::AccessorInfo& info) { - return v8::Handle(); +static void Prop2Getter(v8::Local property, + const v8::PropertyCallbackInfo& info) { } TEST(LogAccessorCallbacks) { diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index 70091d9..b110ffa 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -804,8 +804,8 @@ class ProfilerExtension : public v8::Extension { ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } virtual v8::Handle GetNativeFunction( v8::Handle name); - static v8::Handle StartProfiling(const v8::Arguments& args); - static v8::Handle StopProfiling(const v8::Arguments& args); + static void StartProfiling(const v8::FunctionCallbackInfo& args); + static void StopProfiling(const v8::FunctionCallbackInfo& args); private: static const char* kSource; }; @@ -828,25 +828,23 @@ v8::Handle ProfilerExtension::GetNativeFunction( } -v8::Handle ProfilerExtension::StartProfiling( - const v8::Arguments& args) { +void ProfilerExtension::StartProfiling( + const v8::FunctionCallbackInfo& args) { v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); if (args.Length() > 0) cpu_profiler->StartCpuProfiling(args[0].As()); else cpu_profiler->StartCpuProfiling(v8::String::New("")); - return v8::Undefined(); } -v8::Handle ProfilerExtension::StopProfiling( - const v8::Arguments& args) { +void ProfilerExtension::StopProfiling( + const v8::FunctionCallbackInfo& args) { v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler(); if (args.Length() > 0) cpu_profiler->StopCpuProfiling(args[0].As()); else cpu_profiler->StopCpuProfiling(v8::String::New("")); - return v8::Undefined(); } diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc index 524a564..50be501 100644 --- a/test/cctest/test-thread-termination.cc +++ b/test/cctest/test-thread-termination.cc @@ -33,37 +33,33 @@ v8::internal::Semaphore* semaphore = NULL; -v8::Handle Signal(const v8::Arguments& args) { +void Signal(const v8::FunctionCallbackInfo& args) { semaphore->Signal(); - return v8::Undefined(); } -v8::Handle TerminateCurrentThread(const v8::Arguments& args) { +void TerminateCurrentThread(const v8::FunctionCallbackInfo& args) { CHECK(!v8::V8::IsExecutionTerminating()); v8::V8::TerminateExecution(); - return v8::Undefined(); } -v8::Handle Fail(const v8::Arguments& args) { +void Fail(const v8::FunctionCallbackInfo& args) { CHECK(false); - return v8::Undefined(); } -v8::Handle Loop(const v8::Arguments& args) { +void Loop(const v8::FunctionCallbackInfo& args) { CHECK(!v8::V8::IsExecutionTerminating()); v8::Handle source = v8::String::New("try { doloop(); fail(); } catch(e) { fail(); }"); v8::Handle result = v8::Script::Compile(source)->Run(); CHECK(result.IsEmpty()); CHECK(v8::V8::IsExecutionTerminating()); - return v8::Undefined(); } -v8::Handle DoLoop(const v8::Arguments& args) { +void DoLoop(const v8::FunctionCallbackInfo& args) { v8::TryCatch try_catch; CHECK(!v8::V8::IsExecutionTerminating()); v8::Script::Compile(v8::String::New("function f() {" @@ -84,11 +80,10 @@ v8::Handle DoLoop(const v8::Arguments& args) { CHECK(try_catch.Message().IsEmpty()); CHECK(!try_catch.CanContinue()); CHECK(v8::V8::IsExecutionTerminating()); - return v8::Undefined(); } -v8::Handle DoLoopNoCall(const v8::Arguments& args) { +void DoLoopNoCall(const v8::FunctionCallbackInfo& args) { v8::TryCatch try_catch; CHECK(!v8::V8::IsExecutionTerminating()); v8::Script::Compile(v8::String::New("var term = true;" @@ -101,13 +96,12 @@ v8::Handle DoLoopNoCall(const v8::Arguments& args) { CHECK(try_catch.Message().IsEmpty()); CHECK(!try_catch.CanContinue()); CHECK(v8::V8::IsExecutionTerminating()); - return v8::Undefined(); } v8::Handle CreateGlobalTemplate( - v8::InvocationCallback terminate, - v8::InvocationCallback doloop) { + v8::FunctionCallback terminate, + v8::FunctionCallback doloop) { v8::Handle global = v8::ObjectTemplate::New(); global->Set(v8::String::New("terminate"), v8::FunctionTemplate::New(terminate)); @@ -268,19 +262,19 @@ TEST(TerminateMultipleV8ThreadsDefaultIsolate) { int call_count = 0; -v8::Handle TerminateOrReturnObject(const v8::Arguments& args) { +void TerminateOrReturnObject(const v8::FunctionCallbackInfo& args) { if (++call_count == 10) { CHECK(!v8::V8::IsExecutionTerminating()); v8::V8::TerminateExecution(); - return v8::Undefined(); + return; } v8::Local result = v8::Object::New(); result->Set(v8::String::New("x"), v8::Integer::New(42)); - return result; + args.GetReturnValue().Set(result); } -v8::Handle LoopGetProperty(const v8::Arguments& args) { +void LoopGetProperty(const v8::FunctionCallbackInfo& args) { v8::TryCatch try_catch; CHECK(!v8::V8::IsExecutionTerminating()); v8::Script::Compile(v8::String::New("function f() {" @@ -299,7 +293,6 @@ v8::Handle LoopGetProperty(const v8::Arguments& args) { CHECK(try_catch.Message().IsEmpty()); CHECK(!try_catch.CanContinue()); CHECK(v8::V8::IsExecutionTerminating()); - return v8::Undefined(); } @@ -329,7 +322,7 @@ TEST(TerminateLoadICException) { v8::Script::Compile(source)->Run(); } -v8::Handle ReenterAfterTermination(const v8::Arguments& args) { +void ReenterAfterTermination(const v8::FunctionCallbackInfo& args) { v8::TryCatch try_catch; CHECK(!v8::V8::IsExecutionTerminating()); v8::Script::Compile(v8::String::New("function f() {" @@ -351,7 +344,6 @@ v8::Handle ReenterAfterTermination(const v8::Arguments& args) { CHECK(!try_catch.CanContinue()); CHECK(v8::V8::IsExecutionTerminating()); v8::Script::Compile(v8::String::New("function f() { fail(); } f()"))->Run(); - return v8::Undefined(); } // Test that reentry into V8 while the termination exception is still pending @@ -373,7 +365,7 @@ TEST(TerminateAndReenterFromThreadItself) { "f()"))->Run()->IsTrue()); } -v8::Handle DoLoopCancelTerminate(const v8::Arguments& args) { +void DoLoopCancelTerminate(const v8::FunctionCallbackInfo& args) { v8::TryCatch try_catch; CHECK(!v8::V8::IsExecutionTerminating()); v8::Script::Compile(v8::String::New("var term = true;" @@ -390,7 +382,6 @@ v8::Handle DoLoopCancelTerminate(const v8::Arguments& args) { CHECK(try_catch.HasTerminated()); v8::V8::CancelTerminateExecution(v8::Isolate::GetCurrent()); CHECK(!v8::V8::IsExecutionTerminating()); - return v8::Undefined(); } // Test that a single thread of JavaScript execution can terminate