PrintExtension() : v8::Extension("v8/print", kSource) { }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name);
- static v8::Handle<v8::Value> Print(const v8::Arguments& args);
+ static void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
static const char* kSource;
};
}
-v8::Handle<v8::Value> PrintExtension::Print(const v8::Arguments& args) {
+void PrintExtension::Print(const v8::FunctionCallbackInfo<v8::Value>& 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();
}
CheckDebuggerUnloaded();
}
-static v8::Handle<v8::Array> NamedEnum(const v8::AccessorInfo&) {
+static void NamedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
v8::Handle<v8::Array> 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<v8::Array> IndexedEnum(const v8::AccessorInfo&) {
+static void IndexedEnum(const v8::PropertyCallbackInfo<v8::Array>& info) {
v8::Handle<v8::Array> 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<v8::Value> NamedGetter(v8::Local<v8::String> name,
- const v8::AccessorInfo& info) {
+static void NamedGetter(v8::Local<v8::String> name,
+ const v8::PropertyCallbackInfo<v8::Value>& 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<v8::Value> IndexedGetter(uint32_t index,
- const v8::AccessorInfo& info) {
- return v8::Number::New(index + 1);
+static void IndexedGetter(uint32_t index,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ info.GetReturnValue().Set(static_cast<double>(index + 1));
}
}
-static v8::Handle<v8::Value> ProtperyXNativeGetter(
- v8::Local<v8::String> property, const v8::AccessorInfo& info) {
- return v8::Integer::New(10);
+static void ProtperyXNativeGetter(
+ v8::Local<v8::String> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ info.GetReturnValue().Set(10);
}
}
-static v8::Handle<v8::Value> ProtperyXNativeGetterThrowingError(
- v8::Local<v8::String> property, const v8::AccessorInfo& info) {
- return CompileRun("throw new Error('Error message');");
+static void ProtperyXNativeGetterThrowingError(
+ v8::Local<v8::String> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ CompileRun("throw new Error('Error message');");
}
};
-static v8::Handle<v8::Value> ThreadedAtBarrier1(const v8::Arguments& args) {
+static void ThreadedAtBarrier1(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
threaded_debugging_barriers.barrier_1.Wait();
- return v8::Undefined();
}
// Function to retrieve the number of JavaScript frames by calling a JavaScript
// in the debugger.
-static v8::Handle<v8::Value> CheckFrameCount(const v8::Arguments& args) {
+static void CheckFrameCount(const v8::FunctionCallbackInfo<v8::Value>& 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<v8::Value> CheckSourceLine(const v8::Arguments& args) {
+static void CheckSourceLine(const v8::FunctionCallbackInfo<v8::Value>& 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<v8::Value> CheckDataParameter(const v8::Arguments& args) {
+static void CheckDataParameter(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Handle<v8::String> data = v8::String::New("Test");
CHECK(v8::Debug::Call(debugger_call_with_data, data)->IsString());
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<v8::Value> CheckClosure(const v8::Arguments& args) {
+static void CheckClosure(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(v8::Debug::Call(debugger_call_with_closure)->IsNumber());
CHECK_EQ(3, v8::Debug::Call(debugger_call_with_closure)->Int32Value());
- return v8::Undefined();
}
// Property getter that checks that current and calling contexts
// are both the debugee contexts.
-static v8::Handle<v8::Value> NamedGetterWithCallingContextCheck(
+static void NamedGetterWithCallingContextCheck(
v8::Local<v8::String> name,
- const v8::AccessorInfo& info) {
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
CHECK_EQ(0, strcmp(*v8::String::Utf8Value(name), "a"));
v8::Handle<v8::Context> current = v8::Context::GetCurrent();
CHECK(current == debugee_context);
v8::Handle<v8::Context> calling = v8::Context::GetCalling();
CHECK(calling == debugee_context);
CHECK(calling != debugger_context);
- return v8::Int32::New(1);
+ info.GetReturnValue().Set(1);
}
}
-static v8::Handle<v8::Value> ScheduleBreak(const v8::Arguments& args) {
+static void ScheduleBreak(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Debug::SetDebugEventListener(DebugEventBreakWithOptimizedStack,
v8::Undefined());
v8::Debug::DebugBreak();
- return v8::Undefined();
}
// The handlers are called as static functions that forward
// to the instance specific virtual methods.
- static v8::Handle<Value> HandleGet(Local<String> key,
- const AccessorInfo& info);
- static v8::Handle<Value> HandleSet(Local<String> key,
- Local<Value> value,
- const AccessorInfo& info);
- static v8::Handle<Integer> HandleQuery(Local<String> key,
- const AccessorInfo& info);
+ static void HandleGet(Local<String> key,
+ const v8::PropertyCallbackInfo<v8::Value>& info);
+ static void HandleSet(Local<String> key,
+ Local<Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info);
+ static void HandleQuery(Local<String> key,
+ const v8::PropertyCallbackInfo<v8::Integer>& info);
private:
bool is_initialized_;
int set_count_;
int query_count_;
- static DeclarationContext* GetInstance(const AccessorInfo& info);
+ static DeclarationContext* GetInstance(Local<Value> data);
};
}
-v8::Handle<Value> DeclarationContext::HandleGet(Local<String> key,
- const AccessorInfo& info) {
- DeclarationContext* context = GetInstance(info);
+void DeclarationContext::HandleGet(
+ Local<String> key,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ DeclarationContext* context = GetInstance(info.Data());
context->get_count_++;
- return context->Get(key);
+ info.GetReturnValue().Set(context->Get(key));
}
-v8::Handle<Value> DeclarationContext::HandleSet(Local<String> key,
- Local<Value> value,
- const AccessorInfo& info) {
- DeclarationContext* context = GetInstance(info);
+void DeclarationContext::HandleSet(
+ Local<String> key,
+ Local<Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ DeclarationContext* context = GetInstance(info.Data());
context->set_count_++;
- return context->Set(key, value);
+ info.GetReturnValue().Set(context->Set(key, value));
}
-v8::Handle<Integer> DeclarationContext::HandleQuery(Local<String> key,
- const AccessorInfo& info) {
- DeclarationContext* context = GetInstance(info);
+void DeclarationContext::HandleQuery(
+ Local<String> key,
+ const v8::PropertyCallbackInfo<v8::Integer>& 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<Value> data) {
+ void* value = Local<External>::Cast(data)->Value();
return static_cast<DeclarationContext*>(value);
}
TraceExtension() : v8::Extension("v8/trace", kSource) { }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<String> name);
- static v8::Handle<v8::Value> Trace(const v8::Arguments& args);
- static v8::Handle<v8::Value> JSTrace(const v8::Arguments& args);
- static v8::Handle<v8::Value> JSEntrySP(const v8::Arguments& args);
- static v8::Handle<v8::Value> JSEntrySPLevel2(const v8::Arguments& args);
+ static void Trace(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void JSEntrySP(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void JSEntrySPLevel2(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
- static Address GetFP(const v8::Arguments& args);
+ static Address GetFP(const v8::FunctionCallbackInfo<v8::Value>& args);
static const char* kSource;
};
}
-Address TraceExtension::GetFP(const v8::Arguments& args) {
+Address TraceExtension::GetFP(const v8::FunctionCallbackInfo<v8::Value>& 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)
}
-v8::Handle<v8::Value> TraceExtension::Trace(const v8::Arguments& args) {
+void TraceExtension::Trace(const v8::FunctionCallbackInfo<v8::Value>& args) {
DoTrace(GetFP(args));
- return v8::Undefined();
}
-v8::Handle<v8::Value> TraceExtension::JSTrace(const v8::Arguments& args) {
+void TraceExtension::JSTrace(const v8::FunctionCallbackInfo<v8::Value>& args) {
DoTraceHideCEntryFPAddress(GetFP(args));
- return v8::Undefined();
}
}
-v8::Handle<v8::Value> TraceExtension::JSEntrySP(const v8::Arguments& args) {
+void TraceExtension::JSEntrySP(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK_NE(0, GetJsEntrySp());
- return v8::Undefined();
}
-v8::Handle<v8::Value> TraceExtension::JSEntrySPLevel2(
- const v8::Arguments& args) {
+void TraceExtension::JSEntrySPLevel2(
+ const v8::FunctionCallbackInfo<v8::Value>& 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();
}
// 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<Value> construct_call(const v8::Arguments& args) {
+static void construct_call(const v8::FunctionCallbackInfo<v8::Value>& args) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(args.GetIsolate());
i::StackFrameIterator frame_iterator(isolate);
CHECK(frame_iterator.frame()->is_exit());
#else
#error Host architecture is neither 32-bit nor 64-bit.
#endif
- return args.This();
+ args.GetReturnValue().Set(args.This());
}
}
-static v8::Handle<v8::Value> ObjMethod1(const v8::Arguments& args) {
- return v8::Handle<v8::Value>();
+static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
TEST(LogCallbacks) {
}
-static v8::Handle<v8::Value> Prop1Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo& info) {
- return v8::Handle<v8::Value>();
+static void Prop1Getter(v8::Local<v8::String> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
}
static void Prop1Setter(v8::Local<v8::String> property,
- v8::Local<v8::Value> value,
- const v8::AccessorInfo& info) {
+ v8::Local<v8::Value> value,
+ const v8::PropertyCallbackInfo<void>& info) {
}
-static v8::Handle<v8::Value> Prop2Getter(v8::Local<v8::String> property,
- const v8::AccessorInfo& info) {
- return v8::Handle<v8::Value>();
+static void Prop2Getter(v8::Local<v8::String> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
}
TEST(LogAccessorCallbacks) {
ProfilerExtension() : v8::Extension("v8/profiler", kSource) { }
virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
v8::Handle<v8::String> name);
- static v8::Handle<v8::Value> StartProfiling(const v8::Arguments& args);
- static v8::Handle<v8::Value> StopProfiling(const v8::Arguments& args);
+ static void StartProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
+ static void StopProfiling(const v8::FunctionCallbackInfo<v8::Value>& args);
private:
static const char* kSource;
};
}
-v8::Handle<v8::Value> ProfilerExtension::StartProfiling(
- const v8::Arguments& args) {
+void ProfilerExtension::StartProfiling(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
if (args.Length() > 0)
cpu_profiler->StartCpuProfiling(args[0].As<v8::String>());
else
cpu_profiler->StartCpuProfiling(v8::String::New(""));
- return v8::Undefined();
}
-v8::Handle<v8::Value> ProfilerExtension::StopProfiling(
- const v8::Arguments& args) {
+void ProfilerExtension::StopProfiling(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::CpuProfiler* cpu_profiler = args.GetIsolate()->GetCpuProfiler();
if (args.Length() > 0)
cpu_profiler->StopCpuProfiling(args[0].As<v8::String>());
else
cpu_profiler->StopCpuProfiling(v8::String::New(""));
- return v8::Undefined();
}
v8::internal::Semaphore* semaphore = NULL;
-v8::Handle<v8::Value> Signal(const v8::Arguments& args) {
+void Signal(const v8::FunctionCallbackInfo<v8::Value>& args) {
semaphore->Signal();
- return v8::Undefined();
}
-v8::Handle<v8::Value> TerminateCurrentThread(const v8::Arguments& args) {
+void TerminateCurrentThread(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(!v8::V8::IsExecutionTerminating());
v8::V8::TerminateExecution();
- return v8::Undefined();
}
-v8::Handle<v8::Value> Fail(const v8::Arguments& args) {
+void Fail(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(false);
- return v8::Undefined();
}
-v8::Handle<v8::Value> Loop(const v8::Arguments& args) {
+void Loop(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK(!v8::V8::IsExecutionTerminating());
v8::Handle<v8::String> source =
v8::String::New("try { doloop(); fail(); } catch(e) { fail(); }");
v8::Handle<v8::Value> result = v8::Script::Compile(source)->Run();
CHECK(result.IsEmpty());
CHECK(v8::V8::IsExecutionTerminating());
- return v8::Undefined();
}
-v8::Handle<v8::Value> DoLoop(const v8::Arguments& args) {
+void DoLoop(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating());
v8::Script::Compile(v8::String::New("function f() {"
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
CHECK(v8::V8::IsExecutionTerminating());
- return v8::Undefined();
}
-v8::Handle<v8::Value> DoLoopNoCall(const v8::Arguments& args) {
+void DoLoopNoCall(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating());
v8::Script::Compile(v8::String::New("var term = true;"
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
CHECK(v8::V8::IsExecutionTerminating());
- return v8::Undefined();
}
v8::Handle<v8::ObjectTemplate> CreateGlobalTemplate(
- v8::InvocationCallback terminate,
- v8::InvocationCallback doloop) {
+ v8::FunctionCallback terminate,
+ v8::FunctionCallback doloop) {
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
global->Set(v8::String::New("terminate"),
v8::FunctionTemplate::New(terminate));
int call_count = 0;
-v8::Handle<v8::Value> TerminateOrReturnObject(const v8::Arguments& args) {
+void TerminateOrReturnObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (++call_count == 10) {
CHECK(!v8::V8::IsExecutionTerminating());
v8::V8::TerminateExecution();
- return v8::Undefined();
+ return;
}
v8::Local<v8::Object> result = v8::Object::New();
result->Set(v8::String::New("x"), v8::Integer::New(42));
- return result;
+ args.GetReturnValue().Set(result);
}
-v8::Handle<v8::Value> LoopGetProperty(const v8::Arguments& args) {
+void LoopGetProperty(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating());
v8::Script::Compile(v8::String::New("function f() {"
CHECK(try_catch.Message().IsEmpty());
CHECK(!try_catch.CanContinue());
CHECK(v8::V8::IsExecutionTerminating());
- return v8::Undefined();
}
v8::Script::Compile(source)->Run();
}
-v8::Handle<v8::Value> ReenterAfterTermination(const v8::Arguments& args) {
+void ReenterAfterTermination(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating());
v8::Script::Compile(v8::String::New("function f() {"
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
"f()"))->Run()->IsTrue());
}
-v8::Handle<v8::Value> DoLoopCancelTerminate(const v8::Arguments& args) {
+void DoLoopCancelTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::TryCatch try_catch;
CHECK(!v8::V8::IsExecutionTerminating());
v8::Script::Compile(v8::String::New("var term = true;"
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