diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index fa6302b1b2..d9b4e18849 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -195,7 +195,7 @@ static void ares_sockstate_cb(void* data, ares_socket_t sock, static Local HostentToAddresses(struct hostent* host) { - HandleScope scope; + HandleScope scope(node_isolate); Local addresses = Array::New(); char ip[INET6_ADDRSTRLEN]; @@ -203,7 +203,7 @@ static Local HostentToAddresses(struct hostent* host) { uv_inet_ntop(host->h_addrtype, host->h_addr_list[i], ip, sizeof(ip)); Local address = String::New(ip); - addresses->Set(Integer::New(i), address); + addresses->Set(Integer::New(i, node_isolate), address); } return scope.Close(addresses); @@ -211,12 +211,12 @@ static Local HostentToAddresses(struct hostent* host) { static Local HostentToNames(struct hostent* host) { - HandleScope scope; + HandleScope scope(node_isolate); Local names = Array::New(); for (int i = 0; host->h_aliases[i]; ++i) { Local address = String::New(host->h_aliases[i]); - names->Set(Integer::New(i), address); + names->Set(Integer::New(i, node_isolate), address); } return scope.Close(names); @@ -260,7 +260,7 @@ static const char* AresErrnoString(int errorno) { static void SetAresErrno(int errorno) { - HandleScope scope; + HandleScope scope(node_isolate); Local key = String::NewSymbol("_errno"); Local value = String::NewSymbol(AresErrnoString(errorno)); node::process->Set(key, value); @@ -270,7 +270,7 @@ static void SetAresErrno(int errorno) { class QueryWrap { public: QueryWrap() { - HandleScope scope; + HandleScope scope(node_isolate); object_ = Persistent::New(node_isolate, Object::New()); } @@ -336,14 +336,14 @@ class QueryWrap { } void CallOnComplete(Local answer) { - HandleScope scope; - Local argv[2] = { Integer::New(0), answer }; + HandleScope scope(node_isolate); + Local argv[2] = { Integer::New(0, node_isolate), answer }; MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); } void CallOnComplete(Local answer, Local family) { - HandleScope scope; - Local argv[3] = { Integer::New(0), answer, family }; + HandleScope scope(node_isolate); + Local argv[3] = { Integer::New(0, node_isolate), answer, family }; MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); } @@ -351,8 +351,8 @@ class QueryWrap { assert(status != ARES_SUCCESS); SetAresErrno(status); - HandleScope scope; - Local argv[1] = { Integer::New(-1) }; + HandleScope scope(node_isolate); + Local argv[1] = { Integer::New(-1, node_isolate) }; MakeCallback(object_, oncomplete_sym, ARRAY_SIZE(argv), argv); } @@ -379,7 +379,7 @@ class QueryAWrap: public QueryWrap { protected: void Parse(unsigned char* buf, int len) { - HandleScope scope; + HandleScope scope(node_isolate); struct hostent* host; @@ -411,7 +411,7 @@ class QueryAaaaWrap: public QueryWrap { protected: void Parse(unsigned char* buf, int len) { - HandleScope scope; + HandleScope scope(node_isolate); struct hostent* host; @@ -443,7 +443,7 @@ class QueryCnameWrap: public QueryWrap { protected: void Parse(unsigned char* buf, int len) { - HandleScope scope; + HandleScope scope(node_isolate); struct hostent* host; @@ -473,7 +473,7 @@ class QueryMxWrap: public QueryWrap { protected: void Parse(unsigned char* buf, int len) { - HandleScope scope; + HandleScope scope(node_isolate); struct ares_mx_reply* mx_start; int status = ares_parse_mx_reply(buf, len, &mx_start); @@ -492,8 +492,8 @@ class QueryMxWrap: public QueryWrap { Local mx_record = Object::New(); mx_record->Set(exchange_symbol, String::New(mx_current->host)); mx_record->Set(priority_symbol, - Integer::New(mx_current->priority)); - mx_records->Set(Integer::New(i++), mx_record); + Integer::New(mx_current->priority, node_isolate)); + mx_records->Set(Integer::New(i++, node_isolate), mx_record); } ares_free_data(mx_start); @@ -550,7 +550,7 @@ class QueryTxtWrap: public QueryWrap { struct ares_txt_reply *current = txt_out; for (int i = 0; current; ++i, current = current->next) { Local txt = String::New(reinterpret_cast(current->txt)); - txt_records->Set(Integer::New(i), txt); + txt_records->Set(Integer::New(i, node_isolate), txt); } ares_free_data(txt_out); @@ -574,7 +574,7 @@ class QuerySrvWrap: public QueryWrap { protected: void Parse(unsigned char* buf, int len) { - HandleScope scope; + HandleScope scope(node_isolate); struct ares_srv_reply* srv_start; int status = ares_parse_srv_reply(buf, len, &srv_start); @@ -595,12 +595,12 @@ class QuerySrvWrap: public QueryWrap { Local srv_record = Object::New(); srv_record->Set(name_symbol, String::New(srv_current->host)); srv_record->Set(port_symbol, - Integer::New(srv_current->port)); + Integer::New(srv_current->port, node_isolate)); srv_record->Set(priority_symbol, - Integer::New(srv_current->priority)); + Integer::New(srv_current->priority, node_isolate)); srv_record->Set(weight_symbol, - Integer::New(srv_current->weight)); - srv_records->Set(Integer::New(i++), srv_record); + Integer::New(srv_current->weight, node_isolate)); + srv_records->Set(Integer::New(i++, node_isolate), srv_record); } ares_free_data(srv_start); @@ -623,7 +623,7 @@ class QueryNaptrWrap: public QueryWrap { protected: void Parse(unsigned char* buf, int len) { - HandleScope scope; + HandleScope scope(node_isolate); ares_naptr_reply* naptr_start; int status = ares_parse_naptr_reply(buf, len, &naptr_start); @@ -656,11 +656,12 @@ class QueryNaptrWrap: public QueryWrap { String::New(reinterpret_cast(naptr_current->regexp))); naptr_record->Set(replacement_symbol, String::New(naptr_current->replacement)); - naptr_record->Set(order_symbol, Integer::New(naptr_current->order)); + naptr_record->Set(order_symbol, Integer::New(naptr_current->order, + node_isolate)); naptr_record->Set(preference_symbol, - Integer::New(naptr_current->preference)); + Integer::New(naptr_current->preference, node_isolate)); - naptr_records->Set(Integer::New(i++), naptr_record); + naptr_records->Set(Integer::New(i++, node_isolate), naptr_record); } ares_free_data(naptr_start); @@ -697,7 +698,7 @@ class GetHostByAddrWrap: public QueryWrap { protected: void Parse(struct hostent* host) { - HandleScope scope; + HandleScope scope(node_isolate); this->CallOnComplete(HostentToNames(host)); } @@ -713,10 +714,10 @@ class GetHostByNameWrap: public QueryWrap { protected: void Parse(struct hostent* host) { - HandleScope scope; + HandleScope scope(node_isolate); Local addresses = HostentToAddresses(host); - Local family = Integer::New(host->h_addrtype); + Local family = Integer::New(host->h_addrtype, node_isolate); this->CallOnComplete(addresses, family); } @@ -725,7 +726,7 @@ class GetHostByNameWrap: public QueryWrap { template static Handle Query(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); assert(!args.IsConstructCall()); assert(args.Length() >= 2); @@ -737,7 +738,7 @@ static Handle Query(const Arguments& args) { // We must cache the wrap's js object here, because cares might make the // callback from the wrap->Send stack. This will destroy the wrap's internal // object reference, causing wrap->GetObject() to return undefined. - Local object = Local::New(wrap->GetObject()); + Local object = Local::New(node_isolate, wrap->GetObject()); String::Utf8Value name(args[0]); @@ -745,7 +746,7 @@ static Handle Query(const Arguments& args) { if (r) { SetAresErrno(r); delete wrap; - return scope.Close(v8::Null()); + return scope.Close(v8::Null(node_isolate)); } else { return scope.Close(object); } @@ -754,7 +755,7 @@ static Handle Query(const Arguments& args) { template static Handle QueryWithFamily(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); assert(!args.IsConstructCall()); assert(args.Length() >= 3); @@ -766,7 +767,7 @@ static Handle QueryWithFamily(const Arguments& args) { // We must cache the wrap's js object here, because cares might make the // callback from the wrap->Send stack. This will destroy the wrap's internal // object reference, causing wrap->GetObject() to return undefined. - Local object = Local::New(wrap->GetObject()); + Local object = Local::New(node_isolate, wrap->GetObject()); String::Utf8Value name(args[0]); int family = args[1]->Int32Value(); @@ -775,7 +776,7 @@ static Handle QueryWithFamily(const Arguments& args) { if (r) { SetAresErrno(r); delete wrap; - return scope.Close(v8::Null()); + return scope.Close(v8::Null(node_isolate)); } else { return scope.Close(object); } @@ -783,7 +784,7 @@ static Handle QueryWithFamily(const Arguments& args) { void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { - HandleScope scope; + HandleScope scope(node_isolate); GetAddrInfoReqWrap* req_wrap = (GetAddrInfoReqWrap*) req->data; @@ -792,7 +793,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { if (status) { // Error SetErrno(uv_last_error(uv_default_loop())); - argv[0] = Local::New(Null()); + argv[0] = Local::New(node_isolate, Null(node_isolate)); } else { // Success struct addrinfo *address; @@ -878,25 +879,25 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) { static Handle IsIP(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); String::AsciiValue ip(args[0]); char address_buffer[sizeof(struct in6_addr)]; if (uv_inet_pton(AF_INET, *ip, &address_buffer).code == UV_OK) { - return scope.Close(v8::Integer::New(4)); + return scope.Close(v8::Integer::New(4, node_isolate)); } if (uv_inet_pton(AF_INET6, *ip, &address_buffer).code == UV_OK) { - return scope.Close(v8::Integer::New(6)); + return scope.Close(v8::Integer::New(6, node_isolate)); } - return scope.Close(v8::Integer::New(0)); + return scope.Close(v8::Integer::New(0, node_isolate)); } static Handle GetAddrInfo(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); String::Utf8Value hostname(args[0]); @@ -931,7 +932,7 @@ static Handle GetAddrInfo(const Arguments& args) { if (r) { SetErrno(uv_last_error(uv_default_loop())); delete req_wrap; - return scope.Close(v8::Null()); + return scope.Close(v8::Null(node_isolate)); } else { return scope.Close(req_wrap->object_); } @@ -939,7 +940,7 @@ static Handle GetAddrInfo(const Arguments& args) { static void Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); int r; r = ares_library_init(ARES_LIB_INIT_ALL); @@ -976,11 +977,11 @@ static void Initialize(Handle target) { NODE_SET_METHOD(target, "isIP", IsIP); target->Set(String::NewSymbol("AF_INET"), - Integer::New(AF_INET)); + Integer::New(AF_INET, node_isolate)); target->Set(String::NewSymbol("AF_INET6"), - Integer::New(AF_INET6)); + Integer::New(AF_INET6, node_isolate)); target->Set(String::NewSymbol("AF_UNSPEC"), - Integer::New(AF_UNSPEC)); + Integer::New(AF_UNSPEC, node_isolate)); oncomplete_sym = NODE_PSYMBOL("oncomplete"); } diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc index f85f12c812..0df58c727f 100644 --- a/src/fs_event_wrap.cc +++ b/src/fs_event_wrap.cc @@ -64,7 +64,7 @@ FSEventWrap::~FSEventWrap() { void FSEventWrap::Initialize(Handle target) { HandleWrap::Initialize(target); - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(New); t->InstanceTemplate()->SetInternalFieldCount(1); @@ -80,7 +80,7 @@ void FSEventWrap::Initialize(Handle target) { Handle FSEventWrap::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); assert(args.IsConstructCall()); new FSEventWrap(args.This()); @@ -90,7 +90,7 @@ Handle FSEventWrap::New(const Arguments& args) { Handle FSEventWrap::Start(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); UNWRAP(FSEventWrap) @@ -111,13 +111,13 @@ Handle FSEventWrap::Start(const Arguments& args) { SetErrno(uv_last_error(uv_default_loop())); } - return scope.Close(Integer::New(r)); + return scope.Close(Integer::New(r, node_isolate)); } void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, int events, int status) { - HandleScope scope; + HandleScope scope(node_isolate); Local eventStr; FSEventWrap* wrap = static_cast(handle->data); @@ -137,7 +137,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, // unreasonable, right? Still, we should revisit this before v1.0. if (status) { SetErrno(uv_last_error(uv_default_loop())); - eventStr = String::Empty(); + eventStr = String::Empty(node_isolate); } else if (events & UV_RENAME) { eventStr = String::New("rename"); @@ -151,10 +151,10 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, } Local argv[3] = { - Integer::New(status), + Integer::New(status, node_isolate), eventStr, filename ? static_cast >(String::New(filename)) - : Local::New(v8::Null()) + : Local::New(node_isolate, v8::Null(node_isolate)) }; if (onchange_sym.IsEmpty()) { @@ -166,7 +166,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename, Handle FSEventWrap::Close(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); // Unwrap manually here. The UNWRAP() macro asserts that wrap != NULL. // That usually indicates an error but not here: double closes are possible @@ -177,7 +177,7 @@ Handle FSEventWrap::Close(const Arguments& args) { FSEventWrap* wrap = static_cast(ptr); if (wrap == NULL || wrap->initialized_ == false) { - return Undefined(); + return Undefined(node_isolate); } wrap->initialized_ = false; diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 99fb6bf853..49daa4e5e6 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -53,7 +53,7 @@ void HandleWrap::Initialize(Handle target) { Handle HandleWrap::Ref(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); UNWRAP_NO_ABORT(HandleWrap) @@ -62,12 +62,12 @@ Handle HandleWrap::Ref(const Arguments& args) { wrap->flags_ &= ~kUnref; } - return v8::Undefined(); + return v8::Undefined(node_isolate); } Handle HandleWrap::Unref(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); UNWRAP_NO_ABORT(HandleWrap) @@ -76,19 +76,19 @@ Handle HandleWrap::Unref(const Arguments& args) { wrap->flags_ |= kUnref; } - return v8::Undefined(); + return v8::Undefined(node_isolate); } Handle HandleWrap::Close(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); HandleWrap *wrap = static_cast( args.Holder()->GetAlignedPointerFromInternalField(0)); // guard against uninitialized handle or double close if (wrap == NULL || wrap->handle__ == NULL) { - return Undefined(); + return Undefined(node_isolate); } assert(!wrap->object_.IsEmpty()); @@ -101,7 +101,7 @@ Handle HandleWrap::Close(const Arguments& args) { wrap->flags_ |= kCloseCallback; } - return Undefined(); + return Undefined(node_isolate); } @@ -112,7 +112,7 @@ HandleWrap::HandleWrap(Handle object, uv_handle_t* h) { h->data = this; } - HandleScope scope; + HandleScope scope(node_isolate); assert(object_.IsEmpty()); assert(object->InternalFieldCount() > 0); object_ = v8::Persistent::New(node_isolate, object); diff --git a/src/node.cc b/src/node.cc index a8587deb5a..629c84c688 100644 --- a/src/node.cc +++ b/src/node.cc @@ -186,7 +186,7 @@ static void Spin(uv_idle_t* handle, int status) { uv_idle_stop(&tick_spinner); - HandleScope scope; + HandleScope scope(node_isolate); if (process_tickFromSpinner.IsEmpty()) { Local cb_v = process->Get(String::New("_tickFromSpinner")); @@ -211,7 +211,7 @@ static void Spin(uv_idle_t* handle, int status) { static Handle NeedTickCallback(const Arguments& args) { need_tick_cb = true; uv_idle_start(&tick_spinner, Spin); - return Undefined(); + return Undefined(node_isolate); } @@ -219,7 +219,7 @@ static void CheckImmediate(uv_check_t* handle, int status) { assert(handle == &check_immediate_watcher); assert(status == 0); - HandleScope scope; + HandleScope scope(node_isolate); if (immediate_callback_sym.IsEmpty()) { immediate_callback_sym = NODE_PSYMBOL("_immediateCallback"); @@ -747,7 +747,7 @@ Local ErrnoException(int errorno, Local obj = e->ToObject(); - obj->Set(errno_symbol, Integer::New(errorno)); + obj->Set(errno_symbol, Integer::New(errorno, node_isolate)); obj->Set(code_symbol, estring); if (path) obj->Set(errpath_symbol, String::New(path)); if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall)); @@ -819,7 +819,7 @@ Local UVException(int errorno, Local obj = e->ToObject(); // TODO errno should probably go - obj->Set(errno_symbol, Integer::New(errorno)); + obj->Set(errno_symbol, Integer::New(errorno, node_isolate)); obj->Set(code_symbol, estring); if (path) obj->Set(errpath_symbol, path_str); if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall)); @@ -880,7 +880,7 @@ Local WinapiErrnoException(int errorno, Local obj = e->ToObject(); - obj->Set(errno_symbol, Integer::New(errorno)); + obj->Set(errno_symbol, Integer::New(errorno, node_isolate)); if (path) obj->Set(errpath_symbol, String::New(path)); if (syscall) obj->Set(syscall_symbol, String::NewSymbol(syscall)); return e; @@ -890,7 +890,7 @@ Local WinapiErrnoException(int errorno, Handle FromConstructorTemplate(Persistent t, const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Local argv[32]; unsigned argc = args.Length(); if (argc > ARRAY_SIZE(argv)) argc = ARRAY_SIZE(argv); @@ -933,7 +933,7 @@ MakeDomainCallback(const Handle object, assert(!domain.IsEmpty()); if (domain->Get(disposed_symbol)->IsTrue()) { // domain has been disposed of. - return Undefined(); + return Undefined(node_isolate); } enter = Local::Cast(domain->Get(enter_symbol)); assert(!enter.IsEmpty()); @@ -941,14 +941,14 @@ MakeDomainCallback(const Handle object, if (try_catch.HasCaught()) { FatalException(try_catch); - return Undefined(); + return Undefined(node_isolate); } Local ret = callback->Call(object, argc, argv); if (try_catch.HasCaught()) { FatalException(try_catch); - return Undefined(); + return Undefined(node_isolate); } exit = Local::Cast(domain->Get(exit_symbol)); @@ -957,7 +957,7 @@ MakeDomainCallback(const Handle object, if (try_catch.HasCaught()) { FatalException(try_catch); - return Undefined(); + return Undefined(node_isolate); } if (tick_infobox.length == 0) { @@ -971,7 +971,7 @@ MakeDomainCallback(const Handle object, if (try_catch.HasCaught()) { FatalException(try_catch); - return Undefined(); + return Undefined(node_isolate); } return ret; @@ -983,7 +983,7 @@ MakeCallback(const Handle object, const Handle symbol, int argc, Handle argv[]) { - HandleScope scope; + HandleScope scope(node_isolate); Local callback = object->Get(symbol).As(); Local domain = object->Get(domain_symbol); @@ -1011,7 +1011,7 @@ MakeCallback(const Handle object, if (try_catch.HasCaught()) { FatalException(try_catch); - return Undefined(); + return Undefined(node_isolate); } if (tick_infobox.length == 0) { @@ -1025,7 +1025,7 @@ MakeCallback(const Handle object, if (try_catch.HasCaught()) { FatalException(try_catch); - return Undefined(); + return Undefined(node_isolate); } return scope.Close(ret); @@ -1037,7 +1037,7 @@ MakeCallback(const Handle object, const char* method, int argc, Handle argv[]) { - HandleScope scope; + HandleScope scope(node_isolate); Handle ret = MakeCallback(object, String::NewSymbol(method), argc, argv); @@ -1047,7 +1047,7 @@ MakeCallback(const Handle object, void SetErrno(uv_err_t err) { - HandleScope scope; + HandleScope scope(node_isolate); static Persistent errno_symbol; if (errno_symbol.IsEmpty()) { @@ -1065,7 +1065,7 @@ void SetErrno(uv_err_t err) { enum encoding ParseEncoding(Handle encoding_v, enum encoding _default) { - HandleScope scope; + HandleScope scope(node_isolate); if (!encoding_v->IsString()) return _default; @@ -1111,14 +1111,14 @@ enum encoding ParseEncoding(Handle encoding_v, enum encoding _default) { } Local Encode(const void *buf, size_t len, enum encoding encoding) { - HandleScope scope; + HandleScope scope(node_isolate); if (encoding == BUFFER) { return scope.Close( Buffer::New(static_cast(buf), len)->handle_); } - if (!len) return scope.Close(String::Empty()); + if (!len) return scope.Close(String::Empty(node_isolate)); if (encoding == BINARY) { const unsigned char *cbuf = static_cast(buf); @@ -1139,7 +1139,7 @@ Local Encode(const void *buf, size_t len, enum encoding encoding) { // Returns -1 if the handle was not valid for decoding ssize_t DecodeBytes(v8::Handle val, enum encoding encoding) { - HandleScope scope; + HandleScope scope(node_isolate); if (val->IsArray()) { fprintf(stderr, "'raw' encoding (array of integers) has been removed. " @@ -1170,7 +1170,7 @@ ssize_t DecodeWrite(char *buf, size_t buflen, v8::Handle val, enum encoding encoding) { - HandleScope scope; + HandleScope scope(node_isolate); // XXX // A lot of improvement can be made here. See: @@ -1243,7 +1243,7 @@ void DisplayExceptionLine (TryCatch &try_catch) { if (displayed_error) return; displayed_error = true; - HandleScope scope; + HandleScope scope(node_isolate); Handle message = try_catch.Message(); @@ -1301,7 +1301,7 @@ void DisplayExceptionLine (TryCatch &try_catch) { static void ReportException(TryCatch &try_catch, bool show_line) { - HandleScope scope; + HandleScope scope(node_isolate); if (show_line) DisplayExceptionLine(try_catch); @@ -1334,7 +1334,7 @@ static void ReportException(TryCatch &try_catch, bool show_line) { // Executes a str within the current v8 context. Local ExecuteString(Handle source, Handle filename) { - HandleScope scope; + HandleScope scope(node_isolate); TryCatch try_catch; Local script = v8::Script::Compile(source, filename); @@ -1354,7 +1354,7 @@ Local ExecuteString(Handle source, Handle filename) { static Handle GetActiveRequests(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Local ary = Array::New(); ngx_queue_t* q = NULL; @@ -1373,7 +1373,7 @@ static Handle GetActiveRequests(const Arguments& args) { // Non-static, friend of HandleWrap. Could have been a HandleWrap method but // implemented here for consistency with GetActiveRequests(). Handle GetActiveHandles(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Local ary = Array::New(); ngx_queue_t* q = NULL; @@ -1395,12 +1395,12 @@ Handle GetActiveHandles(const Arguments& args) { static Handle Abort(const Arguments& args) { abort(); - return Undefined(); + return Undefined(node_isolate); } static Handle Chdir(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() != 1 || !args[0]->IsString()) { return ThrowException(Exception::Error(String::New("Bad argument."))); @@ -1414,12 +1414,12 @@ static Handle Chdir(const Arguments& args) { return ThrowException(UVException(r.code, "uv_chdir")); } - return Undefined(); + return Undefined(node_isolate); } static Handle Cwd(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); #ifdef _WIN32 /* MAX_PATH is in characters, not bytes. Make sure we have enough headroom. */ char buf[MAX_PATH * 4 + 1]; @@ -1440,7 +1440,7 @@ static Handle Cwd(const Arguments& args) { static Handle Umask(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); unsigned int old; if (args.Length() < 1 || args[0]->IsUndefined()) { @@ -1473,7 +1473,7 @@ static Handle Umask(const Arguments& args) { old = umask(static_cast(oct)); } - return scope.Close(Uint32::New(old)); + return scope.Close(Uint32::New(old, node_isolate)); } @@ -1582,21 +1582,21 @@ static gid_t gid_by_name(Handle value) { static Handle GetUid(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int uid = getuid(); - return scope.Close(Integer::New(uid)); + return scope.Close(Integer::New(uid, node_isolate)); } static Handle GetGid(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int gid = getgid(); - return scope.Close(Integer::New(gid)); + return scope.Close(Integer::New(gid, node_isolate)); } static Handle SetGid(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsUint32() && !args[0]->IsString()) { return ThrowTypeError("setgid argument must be a number or a string"); @@ -1612,12 +1612,12 @@ static Handle SetGid(const Arguments& args) { return ThrowException(ErrnoException(errno, "setgid")); } - return Undefined(); + return Undefined(node_isolate); } static Handle SetUid(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsUint32() && !args[0]->IsString()) { return ThrowTypeError("setuid argument must be a number or a string"); @@ -1633,12 +1633,12 @@ static Handle SetUid(const Arguments& args) { return ThrowException(ErrnoException(errno, "setuid")); } - return Undefined(); + return Undefined(node_isolate); } static Handle GetGroups(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int ngroups = getgroups(0, NULL); @@ -1660,14 +1660,14 @@ static Handle GetGroups(const Arguments& args) { gid_t egid = getegid(); for (int i = 0; i < ngroups; i++) { - groups_list->Set(i, Integer::New(groups[i])); + groups_list->Set(i, Integer::New(groups[i], node_isolate)); if (groups[i] == egid) seen_egid = true; } delete[] groups; if (seen_egid == false) { - groups_list->Set(ngroups, Integer::New(egid)); + groups_list->Set(ngroups, Integer::New(egid, node_isolate)); } return scope.Close(groups_list); @@ -1675,7 +1675,7 @@ static Handle GetGroups(const Arguments& args) { static Handle SetGroups(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsArray()) { return ThrowTypeError("argument 1 must be an array"); @@ -1703,12 +1703,12 @@ static Handle SetGroups(const Arguments& args) { return ThrowException(ErrnoException(errno, "setgroups")); } - return Undefined(); + return Undefined(node_isolate); } static Handle InitGroups(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsUint32() && !args[0]->IsString()) { return ThrowTypeError("argument 1 must be a number or a string"); @@ -1752,27 +1752,27 @@ static Handle InitGroups(const Arguments& args) { return ThrowException(ErrnoException(errno, "initgroups")); } - return Undefined(); + return Undefined(node_isolate); } #endif // __POSIX__ v8::Handle Exit(const v8::Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); exit(args[0]->IntegerValue()); - return Undefined(); + return Undefined(node_isolate); } static Handle Uptime(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); double uptime; uv_err_t err = uv_uptime(&uptime); if (err.code != UV_OK) { - return Undefined(); + return Undefined(node_isolate); } return scope.Close(Number::New(uptime - prog_start_time)); @@ -1780,7 +1780,7 @@ static Handle Uptime(const Arguments& args) { v8::Handle MemoryUsage(const v8::Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); size_t rss; @@ -1804,16 +1804,18 @@ v8::Handle MemoryUsage(const v8::Arguments& args) { HeapStatistics v8_heap_stats; node_isolate->GetHeapStatistics(&v8_heap_stats); info->Set(heap_total_symbol, - Integer::NewFromUnsigned(v8_heap_stats.total_heap_size())); + Integer::NewFromUnsigned(v8_heap_stats.total_heap_size(), + node_isolate)); info->Set(heap_used_symbol, - Integer::NewFromUnsigned(v8_heap_stats.used_heap_size())); + Integer::NewFromUnsigned(v8_heap_stats.used_heap_size(), + node_isolate)); return scope.Close(info); } Handle Kill(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() != 2) { return ThrowException(Exception::Error(String::New("Bad argument."))); @@ -1825,10 +1827,10 @@ Handle Kill(const Arguments& args) { if (err.code != UV_OK) { SetErrno(err); - return scope.Close(Integer::New(-1)); + return scope.Close(Integer::New(-1, node_isolate)); } - return Undefined(); + return Undefined(node_isolate); } // used in Hrtime() below @@ -1840,7 +1842,7 @@ Handle Kill(const Arguments& args) { // and nanoseconds, to avoid any integer overflow possibility. // Pass in an Array from a previous hrtime() call to instead get a time diff. Handle Hrtime(const v8::Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); uint64_t t = uv_hrtime(); @@ -1858,8 +1860,8 @@ Handle Hrtime(const v8::Arguments& args) { } Local tuple = Array::New(2); - tuple->Set(0, Integer::NewFromUnsigned(t / NANOS_PER_SEC)); - tuple->Set(1, Integer::NewFromUnsigned(t % NANOS_PER_SEC)); + tuple->Set(0, Integer::NewFromUnsigned(t / NANOS_PER_SEC, node_isolate)); + tuple->Set(1, Integer::NewFromUnsigned(t % NANOS_PER_SEC, node_isolate)); return scope.Close(tuple); } @@ -1870,7 +1872,7 @@ typedef void (UV_DYNAMIC* extInit)(Handle exports); // DLOpen is process.dlopen(module, filename). // Used to load 'module.node' dynamically shared objects. Handle DLOpen(const v8::Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); char symbol[1024], *base, *pos; uv_lib_t lib; int r; @@ -1959,7 +1961,7 @@ Handle DLOpen(const v8::Arguments& args) { // Tell coverity that 'handle' should not be freed when we return. // coverity[leaked_storage] - return Undefined(); + return Undefined(node_isolate); } @@ -1973,7 +1975,7 @@ static void OnFatalError(const char* location, const char* message) { } void FatalException(TryCatch &try_catch) { - HandleScope scope; + HandleScope scope(node_isolate); if (fatal_exception_symbol.IsEmpty()) fatal_exception_symbol = NODE_PSYMBOL("_fatalException"); @@ -2014,7 +2016,7 @@ Persistent binding_cache; Persistent module_load_list; static Handle Binding(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Local module = args[0]->ToString(); String::Utf8Value module_v(module); @@ -2041,7 +2043,7 @@ static Handle Binding(const Arguments& args) { exports = Object::New(); // Internal bindings don't have a "module" object, // only exports. - modp->register_func(exports, Undefined()); + modp->register_func(exports, Undefined(node_isolate)); binding_cache->Set(module, exports); } else if (!strcmp(*module_v, "constants")) { @@ -2065,7 +2067,7 @@ static Handle Binding(const Arguments& args) { static Handle ProcessTitleGetter(Local property, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); char buffer[512]; uv_get_process_title(buffer, sizeof(buffer)); return scope.Close(String::New(buffer)); @@ -2075,7 +2077,7 @@ static Handle ProcessTitleGetter(Local property, static void ProcessTitleSetter(Local property, Local value, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); String::Utf8Value title(value); // TODO: protect with a lock uv_set_process_title(*title); @@ -2084,7 +2086,7 @@ static void ProcessTitleSetter(Local property, static Handle EnvGetter(Local property, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); #ifdef __POSIX__ String::Utf8Value key(property); const char* val = getenv(*key); @@ -2113,7 +2115,7 @@ static Handle EnvGetter(Local property, static Handle EnvSetter(Local property, Local value, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); #ifdef __POSIX__ String::Utf8Value key(property); String::Utf8Value val(value); @@ -2134,11 +2136,11 @@ static Handle EnvSetter(Local property, static Handle EnvQuery(Local property, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); #ifdef __POSIX__ String::Utf8Value key(property); if (getenv(*key)) { - return scope.Close(Integer::New(0)); + return scope.Close(Integer::New(0, node_isolate)); } #else // _WIN32 String::Value key(property); @@ -2149,9 +2151,10 @@ static Handle EnvQuery(Local property, // Environment variables that start with '=' are hidden and read-only. return scope.Close(Integer::New(v8::ReadOnly || v8::DontDelete || - v8::DontEnum)); + v8::DontEnum, + node_isolate)); } else { - return scope.Close(Integer::New(0)); + return scope.Close(Integer::New(0, node_isolate)); } } #endif @@ -2162,12 +2165,12 @@ static Handle EnvQuery(Local property, static Handle EnvDeleter(Local property, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); #ifdef __POSIX__ String::Utf8Value key(property); - if (!getenv(*key)) return False(); + if (!getenv(*key)) return False(node_isolate); unsetenv(*key); // can't check return value, it's void on some platforms - return True(); + return True(node_isolate); #else String::Value key(property); WCHAR* key_ptr = reinterpret_cast(*key); @@ -2178,13 +2181,13 @@ static Handle EnvDeleter(Local property, GetLastError() != ERROR_SUCCESS; return scope.Close(Boolean::New(rv)); } - return True(); + return True(node_isolate); #endif } static Handle EnvEnumerator(const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); #ifdef __POSIX__ int size = 0; while (environ[size]) size++; @@ -2228,19 +2231,19 @@ static Handle EnvEnumerator(const AccessorInfo& info) { static Handle GetFeatures() { - HandleScope scope; + HandleScope scope(node_isolate); Local obj = Object::New(); obj->Set(String::NewSymbol("debug"), #if defined(DEBUG) && DEBUG - True() + True(node_isolate) #else - False() + False(node_isolate) #endif ); - obj->Set(String::NewSymbol("uv"), True()); - obj->Set(String::NewSymbol("ipv6"), True()); // TODO ping libuv + obj->Set(String::NewSymbol("uv"), True(node_isolate)); + obj->Set(String::NewSymbol("ipv6"), True(node_isolate)); // TODO ping libuv obj->Set(String::NewSymbol("tls_npn"), Boolean::New(use_npn)); obj->Set(String::NewSymbol("tls_sni"), Boolean::New(use_sni)); obj->Set(String::NewSymbol("tls"), @@ -2252,15 +2255,15 @@ static Handle GetFeatures() { static Handle DebugPortGetter(Local property, const AccessorInfo& info) { - HandleScope scope; - return scope.Close(Integer::NewFromUnsigned(debug_port)); + HandleScope scope(node_isolate); + return scope.Close(Integer::NewFromUnsigned(debug_port, node_isolate)); } static void DebugPortSetter(Local property, Local value, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); debug_port = value->NumberValue(); } @@ -2279,7 +2282,7 @@ Handle NeedImmediateCallbackGetter(Local property, static void NeedImmediateCallbackSetter(Local property, Local value, const AccessorInfo& info) { - HandleScope scope; + HandleScope scope(node_isolate); bool bool_value = value->BooleanValue(); @@ -2299,7 +2302,7 @@ static void NeedImmediateCallbackSetter(Local property, Handle SetupProcessObject(int argc, char *argv[]) { - HandleScope scope; + HandleScope scope(node_isolate); int i, j; @@ -2362,10 +2365,10 @@ Handle SetupProcessObject(int argc, char *argv[]) { // process.argv Local arguments = Array::New(argc - option_end_index + 1); - arguments->Set(Integer::New(0), String::New(argv[0])); + arguments->Set(Integer::New(0, node_isolate), String::New(argv[0])); for (j = 1, i = option_end_index; i < argc; j++, i++) { Local arg = String::New(argv[i]); - arguments->Set(Integer::New(j), arg); + arguments->Set(Integer::New(j, node_isolate), arg); } // assign it process->Set(String::NewSymbol("argv"), arguments); @@ -2373,7 +2376,7 @@ Handle SetupProcessObject(int argc, char *argv[]) { // process.execArgv Local execArgv = Array::New(option_end_index - 1); for (j = 1, i = 0; j < option_end_index; j++, i++) { - execArgv->Set(Integer::New(i), String::New(argv[j])); + execArgv->Set(Integer::New(i, node_isolate), String::New(argv[j])); } // assign it process->Set(String::NewSymbol("execArgv"), execArgv); @@ -2390,7 +2393,7 @@ Handle SetupProcessObject(int argc, char *argv[]) { Local env = envTemplate->NewInstance(); process->Set(String::NewSymbol("env"), env); - process->Set(String::NewSymbol("pid"), Integer::New(getpid())); + process->Set(String::NewSymbol("pid"), Integer::New(getpid(), node_isolate)); process->Set(String::NewSymbol("features"), GetFeatures()); process->SetAccessor(String::New("_needImmediateCallback"), NeedImmediateCallbackGetter, @@ -2403,17 +2406,17 @@ Handle SetupProcessObject(int argc, char *argv[]) { // -p, --print if (print_eval) { - process->Set(String::NewSymbol("_print_eval"), True()); + process->Set(String::NewSymbol("_print_eval"), True(node_isolate)); } // -i, --interactive if (force_repl) { - process->Set(String::NewSymbol("_forceRepl"), True()); + process->Set(String::NewSymbol("_forceRepl"), True(node_isolate)); } // --no-deprecation if (no_deprecation) { - process->Set(String::NewSymbol("noDeprecation"), True()); + process->Set(String::NewSymbol("noDeprecation"), True(node_isolate)); } // --throw-deprecation @@ -2423,7 +2426,7 @@ Handle SetupProcessObject(int argc, char *argv[]) { // --trace-deprecation if (trace_deprecation) { - process->Set(String::NewSymbol("traceDeprecation"), True()); + process->Set(String::NewSymbol("traceDeprecation"), True(node_isolate)); } size_t size = 2*PATH_MAX; @@ -2536,7 +2539,7 @@ void Load(Handle process_l) { // Add a reference to the global object Local global = v8::Context::GetCurrent()->Global(); - Local args[1] = { Local::New(process_l) }; + Local args[1] = { Local::New(node_isolate, process_l) }; #if defined HAVE_DTRACE || defined HAVE_ETW || defined HAVE_SYSTEMTAP InitDTrace(global); @@ -2751,7 +2754,7 @@ static void RegisterSignalHandler(int signal, void (*handler)(int)) { Handle DebugProcess(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() != 1) { return ThrowException(Exception::Error( @@ -2767,7 +2770,7 @@ Handle DebugProcess(const Arguments& args) { return ThrowException(ErrnoException(errno, "kill")); } - return Undefined(); + return Undefined(node_isolate); } #endif // __POSIX__ @@ -2783,7 +2786,7 @@ DWORD WINAPI EnableDebugThreadProc(void* arg) { } } - v8::Debug::DebugBreak(); + v8::Debug::DebugBreak(node_isolate); return 0; } @@ -2839,8 +2842,8 @@ static int RegisterDebugSignalHandler() { static Handle DebugProcess(const Arguments& args) { - HandleScope scope; - Handle rv = Undefined(); + HandleScope scope(node_isolate); + Handle rv = Undefined(node_isolate); DWORD pid; HANDLE process = NULL; HANDLE thread = NULL; @@ -2924,14 +2927,14 @@ static Handle DebugProcess(const Arguments& args) { CloseHandle(mapping); } - return Undefined(); + return Undefined(node_isolate); } #endif // _WIN32 static Handle DebugPause(const Arguments& args) { v8::Debug::DebugBreak(node_isolate); - return Undefined(); + return Undefined(node_isolate); } @@ -2941,7 +2944,7 @@ static Handle DebugEnd(const Arguments& args) { debugger_running = false; } - return Undefined(); + return Undefined(node_isolate); } @@ -3055,11 +3058,11 @@ void AtExit(void (*cb)(void* arg), void* arg) { void EmitExit(v8::Handle process_l) { // process.emit('exit') - process_l->Set(String::NewSymbol("_exiting"), True()); + process_l->Set(String::NewSymbol("_exiting"), True(node_isolate)); Local emit_v = process_l->Get(String::New("emit")); assert(emit_v->IsFunction()); Local emit = Local::Cast(emit_v); - Local args[] = { String::New("exit"), Integer::New(0) }; + Local args[] = { String::New("exit"), Integer::New(0, node_isolate) }; TryCatch try_catch; emit->Call(process_l, 2, args); if (try_catch.HasCaught()) { diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 55cf91d1cb..e629ecd44d 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -92,7 +92,7 @@ static inline size_t base64_decoded_size(const char *src, size_t size) { static size_t ByteLength (Handle string, enum encoding enc) { - HandleScope scope; + HandleScope scope(node_isolate); if (enc == UTF8) { return string->Utf8Length(); @@ -110,7 +110,7 @@ static size_t ByteLength (Handle string, enum encoding enc) { Handle Buffer::New(Handle string) { - HandleScope scope; + HandleScope scope(node_isolate); // get Buffer from global scope. Local global = v8::Context::GetCurrent()->Global(); @@ -118,7 +118,7 @@ Handle Buffer::New(Handle string) { assert(bv->IsFunction()); Local b = Local::Cast(bv); - Local argv[1] = { Local::New(string) }; + Local argv[1] = { Local::New(node_isolate, string) }; Local instance = b->NewInstance(1, argv); return scope.Close(instance); @@ -126,9 +126,9 @@ Handle Buffer::New(Handle string) { Buffer* Buffer::New(size_t length) { - HandleScope scope; + HandleScope scope(node_isolate); - Local arg = Integer::NewFromUnsigned(length); + Local arg = Integer::NewFromUnsigned(length, node_isolate); Local b = constructor_template->GetFunction()->NewInstance(1, &arg); if (b.IsEmpty()) return NULL; @@ -137,9 +137,9 @@ Buffer* Buffer::New(size_t length) { Buffer* Buffer::New(const char* data, size_t length) { - HandleScope scope; + HandleScope scope(node_isolate); - Local arg = Integer::NewFromUnsigned(0); + Local arg = Integer::NewFromUnsigned(0, node_isolate); Local obj = constructor_template->GetFunction()->NewInstance(1, &arg); Buffer *buffer = ObjectWrap::Unwrap(obj); @@ -151,9 +151,9 @@ Buffer* Buffer::New(const char* data, size_t length) { Buffer* Buffer::New(char *data, size_t length, free_callback callback, void *hint) { - HandleScope scope; + HandleScope scope(node_isolate); - Local arg = Integer::NewFromUnsigned(0); + Local arg = Integer::NewFromUnsigned(0, node_isolate); Local obj = constructor_template->GetFunction()->NewInstance(1, &arg); Buffer *buffer = ObjectWrap::Unwrap(obj); @@ -168,7 +168,7 @@ Handle Buffer::New(const Arguments &args) { return FromConstructorTemplate(constructor_template, args); } - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsUint32()) return ThrowTypeError("Bad argument"); @@ -202,7 +202,7 @@ Buffer::~Buffer() { // const_cast in Buffer::New requires this void Buffer::Replace(char *data, size_t length, free_callback callback, void *hint) { - HandleScope scope; + HandleScope scope(node_isolate); if (callback_) { callback_(data_, callback_hint_); @@ -231,12 +231,12 @@ void Buffer::Replace(char *data, size_t length, handle_->SetIndexedPropertiesToExternalArrayData(data_, kExternalUnsignedByteArray, length_); - handle_->Set(length_symbol, Integer::NewFromUnsigned(length_)); + handle_->Set(length_symbol, Integer::NewFromUnsigned(length_, node_isolate)); } Handle Buffer::BinarySlice(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) @@ -352,7 +352,7 @@ static void force_ascii(const char* src, char* dst, size_t len) { Handle Buffer::AsciiSlice(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) @@ -372,7 +372,7 @@ Handle Buffer::AsciiSlice(const Arguments &args) { Handle Buffer::Utf8Slice(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) char *data = parent->data_ + start; @@ -382,7 +382,7 @@ Handle Buffer::Utf8Slice(const Arguments &args) { Handle Buffer::Ucs2Slice(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) uint16_t *data = (uint16_t*)(parent->data_ + start); @@ -392,12 +392,12 @@ Handle Buffer::Ucs2Slice(const Arguments &args) { Handle Buffer::HexSlice(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer* parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) char* src = parent->data_ + start; uint32_t dstlen = (end - start) * 2; - if (dstlen == 0) return scope.Close(String::Empty()); + if (dstlen == 0) return scope.Close(String::Empty(node_isolate)); char* dst = new char[dstlen]; for (uint32_t i = 0, k = 0; k < dstlen; i += 1, k += 2) { static const char hex[] = "0123456789abcdef"; @@ -434,7 +434,7 @@ static const int unbase64_table[] = Handle Buffer::Base64Slice(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *parent = ObjectWrap::Unwrap(args.This()); SLICE_ARGS(args[0], args[1]) @@ -503,7 +503,7 @@ Handle Buffer::Base64Slice(const Arguments &args) { // buffer.fill(value, start, end); Handle Buffer::Fill(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsInt32()) { return ThrowException(Exception::Error(String::New( @@ -518,13 +518,13 @@ Handle Buffer::Fill(const Arguments &args) { value, end - start); - return Undefined(); + return Undefined(node_isolate); } // var bytesCopied = buffer.copy(target, targetStart, sourceStart, sourceEnd); Handle Buffer::Copy(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *source = ObjectWrap::Unwrap(args.This()); @@ -546,7 +546,7 @@ Handle Buffer::Copy(const Arguments &args) { // Copy 0 bytes; we're done if (source_end == source_start) { - return scope.Close(Integer::New(0)); + return scope.Close(Integer::New(0, node_isolate)); } if (target_start >= target_length) { @@ -570,13 +570,13 @@ Handle Buffer::Copy(const Arguments &args) { (const void*)(source->data_ + source_start), to_copy); - return scope.Close(Integer::New(to_copy)); + return scope.Close(Integer::New(to_copy, node_isolate)); } // var charsWritten = buffer.utf8Write(string, offset, [maxLength]); Handle Buffer::Utf8Write(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *buffer = ObjectWrap::Unwrap(args.This()); if (!args[0]->IsString()) { @@ -592,8 +592,8 @@ Handle Buffer::Utf8Write(const Arguments &args) { if (length == 0) { constructor_template->GetFunction()->Set(chars_written_sym, - Integer::New(0)); - return scope.Close(Integer::New(0)); + Integer::New(0, node_isolate)); + return scope.Close(Integer::New(0, node_isolate)); } if (length > 0 && offset >= buffer->length_) { @@ -615,15 +615,16 @@ Handle Buffer::Utf8Write(const Arguments &args) { String::NO_NULL_TERMINATION)); constructor_template->GetFunction()->Set(chars_written_sym, - Integer::New(char_written)); + Integer::New(char_written, + node_isolate)); - return scope.Close(Integer::New(written)); + return scope.Close(Integer::New(written, node_isolate)); } // var charsWritten = buffer.ucs2Write(string, offset, [maxLength]); Handle Buffer::Ucs2Write(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *buffer = ObjectWrap::Unwrap(args.This()); if (!args[0]->IsString()) { @@ -652,9 +653,9 @@ Handle Buffer::Ucs2Write(const Arguments &args) { String::NO_NULL_TERMINATION)); constructor_template->GetFunction()->Set(chars_written_sym, - Integer::New(written)); + Integer::New(written, node_isolate)); - return scope.Close(Integer::New(written * 2)); + return scope.Close(Integer::New(written * 2, node_isolate)); } @@ -667,7 +668,7 @@ inline unsigned hex2bin(char c) { Handle Buffer::HexWrite(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer* parent = ObjectWrap::Unwrap(args.This()); if (args[0]->IsString() == false) { @@ -685,7 +686,7 @@ Handle Buffer::HexWrite(const Arguments& args) { uint32_t end = start + size; if (start >= parent->length_) { - Local val = Integer::New(0); + Local val = Integer::New(0, node_isolate); constructor_template->GetFunction()->Set(chars_written_sym, val); return scope.Close(val); } @@ -696,7 +697,7 @@ Handle Buffer::HexWrite(const Arguments& args) { } if (size == 0) { - Local val = Integer::New(0); + Local val = Integer::New(0, node_isolate); constructor_template->GetFunction()->Set(chars_written_sym, val); return scope.Close(val); } @@ -718,15 +719,15 @@ Handle Buffer::HexWrite(const Arguments& args) { } constructor_template->GetFunction()->Set(chars_written_sym, - Integer::New(max * 2)); + Integer::New(max * 2, node_isolate)); - return scope.Close(Integer::New(max)); + return scope.Close(Integer::New(max, node_isolate)); } // var charsWritten = buffer.asciiWrite(string, offset); Handle Buffer::AsciiWrite(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *buffer = ObjectWrap::Unwrap(args.This()); @@ -755,15 +756,15 @@ Handle Buffer::AsciiWrite(const Arguments &args) { String::NO_NULL_TERMINATION)); constructor_template->GetFunction()->Set(chars_written_sym, - Integer::New(written)); + Integer::New(written, node_isolate)); - return scope.Close(Integer::New(written)); + return scope.Close(Integer::New(written, node_isolate)); } // var bytesWritten = buffer.base64Write(string, offset, [maxLength]); Handle Buffer::Base64Write(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *buffer = ObjectWrap::Unwrap(args.This()); @@ -818,14 +819,15 @@ Handle Buffer::Base64Write(const Arguments &args) { } constructor_template->GetFunction()->Set(chars_written_sym, - Integer::New(dst - start)); + Integer::New(dst - start, + node_isolate)); - return scope.Close(Integer::New(dst - start)); + return scope.Close(Integer::New(dst - start, node_isolate)); } Handle Buffer::BinaryWrite(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); Buffer *buffer = ObjectWrap::Unwrap(args.This()); @@ -850,9 +852,9 @@ Handle Buffer::BinaryWrite(const Arguments &args) { int written = DecodeWrite(p, max_length, s, BINARY); constructor_template->GetFunction()->Set(chars_written_sym, - Integer::New(written)); + Integer::New(written, node_isolate)); - return scope.Close(Integer::New(written)); + return scope.Close(Integer::New(written, node_isolate)); } @@ -949,7 +951,7 @@ Handle WriteFloatGeneric(const Arguments& args) { if (ENDIANNESS != is_big_endian()) swizzle(ptr, sizeof(T)); - return Undefined(); + return Undefined(node_isolate); } @@ -975,7 +977,7 @@ Handle Buffer::WriteDoubleBE(const Arguments& args) { // var nbytes = Buffer.byteLength("string", "utf8") Handle Buffer::ByteLength(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsString()) { return ThrowTypeError("Argument must be a string"); @@ -984,12 +986,12 @@ Handle Buffer::ByteLength(const Arguments &args) { Local s = args[0]->ToString(); enum encoding e = ParseEncoding(args[1], UTF8); - return scope.Close(Integer::New(node::ByteLength(s, e))); + return scope.Close(Integer::New(node::ByteLength(s, e), node_isolate)); } Handle Buffer::MakeFastBuffer(const Arguments &args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!Buffer::HasInstance(args[0])) { return ThrowTypeError("First argument must be a Buffer"); @@ -1017,7 +1019,7 @@ Handle Buffer::MakeFastBuffer(const Arguments &args) { kExternalUnsignedByteArray, length); - return Undefined(); + return Undefined(node_isolate); } @@ -1042,7 +1044,7 @@ Handle SetFastBufferConstructor(const Arguments& args) { assert(args[0]->IsFunction()); fast_buffer_constructor = Persistent::New(node_isolate, args[0].As()); - return Undefined(); + return Undefined(node_isolate); } @@ -1102,7 +1104,7 @@ RetainedObjectInfo* WrapperInfo(uint16_t class_id, Handle wrapper) { void Buffer::Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); // sanity checks assert(unbase64('/') == 63); diff --git a/src/node_counters.cc b/src/node_counters.cc index c5726842a6..289be60186 100644 --- a/src/node_counters.cc +++ b/src/node_counters.cc @@ -44,37 +44,37 @@ static uint64_t counter_gc_end_time; Handle COUNTER_NET_SERVER_CONNECTION(const Arguments& args) { NODE_COUNT_SERVER_CONN_OPEN(); - return Undefined(); + return Undefined(node_isolate); } Handle COUNTER_NET_SERVER_CONNECTION_CLOSE(const Arguments& args) { NODE_COUNT_SERVER_CONN_CLOSE(); - return Undefined(); + return Undefined(node_isolate); } Handle COUNTER_HTTP_SERVER_REQUEST(const Arguments& args) { NODE_COUNT_HTTP_SERVER_REQUEST(); - return Undefined(); + return Undefined(node_isolate); } Handle COUNTER_HTTP_SERVER_RESPONSE(const Arguments& args) { NODE_COUNT_HTTP_SERVER_RESPONSE(); - return Undefined(); + return Undefined(node_isolate); } Handle COUNTER_HTTP_CLIENT_REQUEST(const Arguments& args) { NODE_COUNT_HTTP_CLIENT_REQUEST(); - return Undefined(); + return Undefined(node_isolate); } Handle COUNTER_HTTP_CLIENT_RESPONSE(const Arguments& args) { NODE_COUNT_HTTP_CLIENT_RESPONSE(); - return Undefined(); + return Undefined(node_isolate); } @@ -106,7 +106,7 @@ static void counter_gc_done(GCType type, GCCallbackFlags flags) { #define NODE_PROBE(name) #name, name void InitPerfCounters(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); static struct { const char* name; diff --git a/src/node_crypto.cc b/src/node_crypto.cc index ff5848fac7..c9b3a5164f 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -120,7 +120,7 @@ static void crypto_lock_cb(int mode, int n, const char* file, int line) { Handle ThrowCryptoErrorHelper(unsigned long err, bool is_type_error) { - HandleScope scope; + HandleScope scope(node_isolate); char errmsg[128]; ERR_error_string_n(err, errmsg, sizeof(errmsg)); return is_type_error ? ThrowTypeError(errmsg) : ThrowError(errmsg); @@ -138,7 +138,7 @@ Handle ThrowCryptoTypeError(unsigned long err) { void SecureContext::Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(SecureContext::New); secure_context_constructor = Persistent::New(node_isolate, @@ -165,7 +165,7 @@ void SecureContext::Initialize(Handle target) { Handle SecureContext::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *p = new SecureContext(); p->Wrap(args.Holder()); return args.This(); @@ -173,7 +173,7 @@ Handle SecureContext::New(const Arguments& args) { Handle SecureContext::Init(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -234,7 +234,7 @@ Handle SecureContext::Init(const Arguments& args) { SSL_CTX_sess_set_new_cb(sc->ctx_, NewSessionCallback); sc->ca_store_ = NULL; - return True(); + return True(node_isolate); } @@ -242,7 +242,7 @@ SSL_SESSION* SecureContext::GetSessionCallback(SSL* s, unsigned char* key, int len, int* copy) { - HandleScope scope; + HandleScope scope(node_isolate); Connection* p = static_cast(SSL_get_app_data(s)); @@ -260,7 +260,7 @@ void SessionDataFree(char* data, void* hint) { int SecureContext::NewSessionCallback(SSL* s, SSL_SESSION* sess) { - HandleScope scope; + HandleScope scope(node_isolate); Connection* p = static_cast(SSL_get_app_data(s)); @@ -295,7 +295,7 @@ static BIO* LoadBIO (Handle v) { BIO *bio = BIO_new(BIO_s_mem()); if (!bio) return NULL; - HandleScope scope; + HandleScope scope(node_isolate); int r = -1; @@ -320,7 +320,7 @@ static BIO* LoadBIO (Handle v) { // Takes a string or buffer and loads it into an X509 // Caller responsible for X509_free-ing the returned object. static X509* LoadX509 (Handle v) { - HandleScope scope; // necessary? + HandleScope scope(node_isolate); // necessary? BIO *bio = LoadBIO(v); if (!bio) return NULL; @@ -337,7 +337,7 @@ static X509* LoadX509 (Handle v) { Handle SecureContext::SetKey(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -350,7 +350,7 @@ Handle SecureContext::SetKey(const Arguments& args) { } BIO *bio = LoadBIO(args[0]); - if (!bio) return False(); + if (!bio) return False(node_isolate); String::Utf8Value passphrase(args[1]); @@ -371,7 +371,7 @@ Handle SecureContext::SetKey(const Arguments& args) { EVP_PKEY_free(key); BIO_free_all(bio); - return True(); + return True(node_isolate); } @@ -442,7 +442,7 @@ end: Handle SecureContext::SetCert(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -452,7 +452,7 @@ Handle SecureContext::SetCert(const Arguments& args) { } BIO* bio = LoadBIO(args[0]); - if (!bio) return False(); + if (!bio) return False(node_isolate); int rv = SSL_CTX_use_certificate_chain(sc->ctx_, bio); @@ -467,13 +467,13 @@ Handle SecureContext::SetCert(const Arguments& args) { return ThrowCryptoError(err); } - return True(); + return True(node_isolate); } Handle SecureContext::AddCACert(const Arguments& args) { bool newCAStore = false; - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -487,7 +487,7 @@ Handle SecureContext::AddCACert(const Arguments& args) { } X509* x509 = LoadX509(args[0]); - if (!x509) return False(); + if (!x509) return False(node_isolate); X509_STORE_add_cert(sc->ca_store_, x509); SSL_CTX_add_client_CA(sc->ctx_, x509); @@ -498,12 +498,12 @@ Handle SecureContext::AddCACert(const Arguments& args) { SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); } - return True(); + return True(node_isolate); } Handle SecureContext::AddCRL(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -512,13 +512,13 @@ Handle SecureContext::AddCRL(const Arguments& args) { } BIO *bio = LoadBIO(args[0]); - if (!bio) return False(); + if (!bio) return False(node_isolate); X509_CRL *x509 = PEM_read_bio_X509_CRL(bio, NULL, NULL, NULL); if (x509 == NULL) { BIO_free_all(bio); - return False(); + return False(node_isolate); } X509_STORE_add_crl(sc->ca_store_, x509); @@ -529,13 +529,13 @@ Handle SecureContext::AddCRL(const Arguments& args) { BIO_free_all(bio); X509_CRL_free(x509); - return True(); + return True(node_isolate); } Handle SecureContext::AddRootCerts(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -549,14 +549,14 @@ Handle SecureContext::AddRootCerts(const Arguments& args) { if (!BIO_write(bp, root_certs[i], strlen(root_certs[i]))) { BIO_free_all(bp); - return False(); + return False(node_isolate); } X509 *x509 = PEM_read_bio_X509(bp, NULL, NULL, NULL); if (x509 == NULL) { BIO_free_all(bp); - return False(); + return False(node_isolate); } X509_STORE_add_cert(root_cert_store, x509); @@ -569,12 +569,12 @@ Handle SecureContext::AddRootCerts(const Arguments& args) { sc->ca_store_ = root_cert_store; SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); - return True(); + return True(node_isolate); } Handle SecureContext::SetCiphers(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -585,11 +585,11 @@ Handle SecureContext::SetCiphers(const Arguments& args) { String::Utf8Value ciphers(args[0]); SSL_CTX_set_cipher_list(sc->ctx_, *ciphers); - return True(); + return True(node_isolate); } Handle SecureContext::SetOptions(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -599,11 +599,11 @@ Handle SecureContext::SetOptions(const Arguments& args) { SSL_CTX_set_options(sc->ctx_, args[0]->IntegerValue()); - return True(); + return True(node_isolate); } Handle SecureContext::SetSessionIdContext(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); @@ -631,19 +631,19 @@ Handle SecureContext::SetSessionIdContext(const Arguments& args) { return ThrowException(Exception::TypeError(message)); } - return True(); + return True(node_isolate); } Handle SecureContext::Close(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SecureContext *sc = ObjectWrap::Unwrap(args.Holder()); sc->FreeCTXMem(); - return False(); + return False(node_isolate); } //Takes .pfx or .p12 and password in string or buffer format Handle SecureContext::LoadPKCS12(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); BIO* in = NULL; PKCS12* p12 = NULL; @@ -715,12 +715,12 @@ Handle SecureContext::LoadPKCS12(const Arguments& args) { return ThrowException(Exception::Error(String::New(str))); } - return True(); + return True(node_isolate); } size_t ClientHelloParser::Write(const uint8_t* data, size_t len) { - HandleScope scope; + HandleScope scope(node_isolate); // Just accumulate data, everything will be pushed to BIO later if (state_ == kPaused) return 0; @@ -888,7 +888,7 @@ int Connection::HandleBIOError(BIO *bio, const char* func, int rv) { static char ssl_error_buf[512]; ERR_error_string_n(rv, ssl_error_buf, sizeof(ssl_error_buf)); - HandleScope scope; + HandleScope scope(node_isolate); Local e = Exception::Error(String::New(ssl_error_buf)); handle_->Set(String::New("error"), e); @@ -929,7 +929,7 @@ int Connection::HandleSSLError(const char* func, int rv, ZeroStatus zs) { return 0; } else { - HandleScope scope; + HandleScope scope(node_isolate); BUF_MEM* mem; BIO *bio; @@ -957,7 +957,7 @@ int Connection::HandleSSLError(const char* func, int rv, ZeroStatus zs) { void Connection::ClearError() { #ifndef NDEBUG - HandleScope scope; + HandleScope scope(node_isolate); // We should clear the error in JS-land assert(handle_->Get(String::New("error"))->BooleanValue() == false); @@ -966,22 +966,22 @@ void Connection::ClearError() { void Connection::SetShutdownFlags() { - HandleScope scope; + HandleScope scope(node_isolate); int flags = SSL_get_shutdown(ssl_); if (flags & SSL_SENT_SHUTDOWN) { - handle_->Set(String::New("sentShutdown"), True()); + handle_->Set(String::New("sentShutdown"), True(node_isolate)); } if (flags & SSL_RECEIVED_SHUTDOWN) { - handle_->Set(String::New("receivedShutdown"), True()); + handle_->Set(String::New("receivedShutdown"), True(node_isolate)); } } void Connection::Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(Connection::New); t->InstanceTemplate()->SetInternalFieldCount(1); @@ -1105,7 +1105,8 @@ int Connection::SelectNextProtoCallback_(SSL *s, *outlen = 8; // set status unsupported - p->selectedNPNProto_ = Persistent::New(node_isolate, False()); + p->selectedNPNProto_ = Persistent::New(node_isolate, + False(node_isolate)); return SSL_TLSEXT_ERR_OK; } @@ -1118,7 +1119,8 @@ int Connection::SelectNextProtoCallback_(SSL *s, switch (status) { case OPENSSL_NPN_UNSUPPORTED: - p->selectedNPNProto_ = Persistent::New(node_isolate, Null()); + p->selectedNPNProto_ = Persistent::New(node_isolate, + Null(node_isolate)); break; case OPENSSL_NPN_NEGOTIATED: p->selectedNPNProto_ = Persistent::New(node_isolate, String::New( @@ -1126,7 +1128,8 @@ int Connection::SelectNextProtoCallback_(SSL *s, )); break; case OPENSSL_NPN_NO_OVERLAP: - p->selectedNPNProto_ = Persistent::New(node_isolate, False()); + p->selectedNPNProto_ = Persistent::New(node_isolate, + False(node_isolate)); break; default: break; @@ -1138,7 +1141,7 @@ int Connection::SelectNextProtoCallback_(SSL *s, #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *p = static_cast SSL_get_app_data(s); @@ -1161,7 +1164,8 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) { Local argv[1] = {*p->servername_}; // Call it - Local ret = Local::New(MakeCallback(p->sniObject_, + Local ret = Local::New(node_isolate, + MakeCallback(p->sniObject_, "onselect", ARRAY_SIZE(argv), argv)); @@ -1183,7 +1187,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) { #endif Handle Connection::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *p = new Connection(); p->Wrap(args.Holder()); @@ -1272,7 +1276,7 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) { // a non-const SSL* in OpenSSL <= 0.9.7e. SSL* ssl = const_cast(ssl_); if (where & SSL_CB_HANDSHAKE_START) { - HandleScope scope; + HandleScope scope(node_isolate); Connection* c = static_cast(SSL_get_app_data(ssl)); if (onhandshakestart_sym.IsEmpty()) { onhandshakestart_sym = NODE_PSYMBOL("onhandshakestart"); @@ -1280,7 +1284,7 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) { MakeCallback(c->handle_, onhandshakestart_sym, 0, NULL); } if (where & SSL_CB_HANDSHAKE_DONE) { - HandleScope scope; + HandleScope scope(node_isolate); Connection* c = static_cast(SSL_get_app_data(ssl)); if (onhandshakedone_sym.IsEmpty()) { onhandshakedone_sym = NODE_PSYMBOL("onhandshakedone"); @@ -1291,7 +1295,7 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) { Handle Connection::EncIn(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1332,12 +1336,12 @@ Handle Connection::EncIn(const Arguments& args) { ss->SetShutdownFlags(); } - return scope.Close(Integer::New(bytes_written)); + return scope.Close(Integer::New(bytes_written, node_isolate)); } Handle Connection::ClearOut(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1377,39 +1381,39 @@ Handle Connection::ClearOut(const Arguments& args) { ss->HandleSSLError("SSL_connect:ClearOut", rv, kZeroIsAnError); } - if (rv < 0) return scope.Close(Integer::New(rv)); + if (rv < 0) return scope.Close(Integer::New(rv, node_isolate)); } int bytes_read = SSL_read(ss->ssl_, buffer_data + off, len); ss->HandleSSLError("SSL_read:ClearOut", bytes_read, kZeroIsNotAnError); ss->SetShutdownFlags(); - return scope.Close(Integer::New(bytes_read)); + return scope.Close(Integer::New(bytes_read, node_isolate)); } Handle Connection::ClearPending(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); int bytes_pending = BIO_pending(ss->bio_read_); - return scope.Close(Integer::New(bytes_pending)); + return scope.Close(Integer::New(bytes_pending, node_isolate)); } Handle Connection::EncPending(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); int bytes_pending = BIO_pending(ss->bio_write_); - return scope.Close(Integer::New(bytes_pending)); + return scope.Close(Integer::New(bytes_pending, node_isolate)); } Handle Connection::EncOut(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1443,12 +1447,12 @@ Handle Connection::EncOut(const Arguments& args) { ss->HandleBIOError(ss->bio_write_, "BIO_read:EncOut", bytes_read); ss->SetShutdownFlags(); - return scope.Close(Integer::New(bytes_read)); + return scope.Close(Integer::New(bytes_read, node_isolate)); } Handle Connection::ClearIn(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1487,7 +1491,7 @@ Handle Connection::ClearIn(const Arguments& args) { ss->HandleSSLError("SSL_connect:ClearIn", rv, kZeroIsAnError); } - if (rv < 0) return scope.Close(Integer::New(rv)); + if (rv < 0) return scope.Close(Integer::New(rv, node_isolate)); } int bytes_written = SSL_write(ss->ssl_, buffer_data + off, len); @@ -1495,16 +1499,16 @@ Handle Connection::ClearIn(const Arguments& args) { ss->HandleSSLError("SSL_write:ClearIn", bytes_written, kZeroIsAnError); ss->SetShutdownFlags(); - return scope.Close(Integer::New(bytes_written)); + return scope.Close(Integer::New(bytes_written, node_isolate)); } Handle Connection::GetPeerCertificate(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); - if (ss->ssl_ == NULL) return Undefined(); + if (ss->ssl_ == NULL) return Undefined(node_isolate); Local info = Object::New(); X509* peer_cert = SSL_get_peer_certificate(ss->ssl_); if (peer_cert != NULL) { @@ -1606,7 +1610,7 @@ Handle Connection::GetPeerCertificate(const Arguments& args) { for (int i = 0; i < sk_ASN1_OBJECT_num(eku); i++) { memset(buf, 0, sizeof(buf)); OBJ_obj2txt(buf, sizeof(buf) - 1, sk_ASN1_OBJECT_value(eku, i), 1); - ext_key_usage->Set(Integer::New(i), String::New(buf)); + ext_key_usage->Set(Integer::New(i, node_isolate), String::New(buf)); } sk_ASN1_OBJECT_pop_free(eku, ASN1_OBJECT_free); @@ -1619,14 +1623,14 @@ Handle Connection::GetPeerCertificate(const Arguments& args) { } Handle Connection::GetSession(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); - if (ss->ssl_ == NULL) return Undefined(); + if (ss->ssl_ == NULL) return Undefined(node_isolate); SSL_SESSION* sess = SSL_get_session(ss->ssl_); - if (!sess) return Undefined(); + if (!sess) return Undefined(node_isolate); int slen = i2d_SSL_SESSION(sess, NULL); assert(slen > 0); @@ -1640,11 +1644,11 @@ Handle Connection::GetSession(const Arguments& args) { return scope.Close(s); } - return Null(); + return Null(node_isolate); } Handle Connection::SetSession(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1673,7 +1677,7 @@ Handle Connection::SetSession(const Arguments& args) { delete [] sbuf; if (!sess) - return Undefined(); + return Undefined(node_isolate); int r = SSL_set_session(ss->ssl_, sess); SSL_SESSION_free(sess); @@ -1683,11 +1687,11 @@ Handle Connection::SetSession(const Arguments& args) { return ThrowException(Exception::Error(eStr)); } - return True(); + return True(node_isolate); } Handle Connection::LoadSession(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1707,24 +1711,24 @@ Handle Connection::LoadSession(const Arguments& args) { ss->hello_parser_.Finish(); - return True(); + return True(node_isolate); } Handle Connection::IsSessionReused(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); if (ss->ssl_ == NULL || SSL_session_reused(ss->ssl_) == false) { - return False(); + return False(node_isolate); } - return True(); + return True(node_isolate); } Handle Connection::Start(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1738,60 +1742,60 @@ Handle Connection::Start(const Arguments& args) { ss->HandleSSLError("SSL_connect:Start", rv, kZeroIsAnError); } - return scope.Close(Integer::New(rv)); + return scope.Close(Integer::New(rv, node_isolate)); } - return scope.Close(Integer::New(0)); + return scope.Close(Integer::New(0, node_isolate)); } Handle Connection::Shutdown(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); - if (ss->ssl_ == NULL) return False(); + if (ss->ssl_ == NULL) return False(node_isolate); int rv = SSL_shutdown(ss->ssl_); ss->HandleSSLError("SSL_shutdown", rv, kZeroIsNotAnError); ss->SetShutdownFlags(); - return scope.Close(Integer::New(rv)); + return scope.Close(Integer::New(rv, node_isolate)); } Handle Connection::ReceivedShutdown(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); - if (ss->ssl_ == NULL) return False(); + if (ss->ssl_ == NULL) return False(node_isolate); int r = SSL_get_shutdown(ss->ssl_); - if (r & SSL_RECEIVED_SHUTDOWN) return True(); + if (r & SSL_RECEIVED_SHUTDOWN) return True(node_isolate); - return False(); + return False(node_isolate); } Handle Connection::IsInitFinished(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); if (ss->ssl_ == NULL || SSL_is_init_finished(ss->ssl_) == false) { - return False(); + return False(node_isolate); } - return True(); + return True(node_isolate); } Handle Connection::VerifyError(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); - if (ss->ssl_ == NULL) return Null(); + if (ss->ssl_ == NULL) return Null(node_isolate); // XXX Do this check in JS land? @@ -1812,7 +1816,7 @@ Handle Connection::VerifyError(const Arguments& args) { switch (x509_verify_error) { case X509_V_OK: - return Null(); + return Null(node_isolate); case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT: s = String::New("UNABLE_TO_GET_ISSUER_CERT"); @@ -1932,15 +1936,15 @@ Handle Connection::VerifyError(const Arguments& args) { Handle Connection::GetCurrentCipher(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); OPENSSL_CONST SSL_CIPHER *c; - if ( ss->ssl_ == NULL ) return Undefined(); + if ( ss->ssl_ == NULL ) return Undefined(node_isolate); c = SSL_get_current_cipher(ss->ssl_); - if ( c == NULL ) return Undefined(); + if ( c == NULL ) return Undefined(node_isolate); Local info = Object::New(); const char* cipher_name = SSL_CIPHER_get_name(c); info->Set(name_symbol, String::New(cipher_name)); @@ -1950,7 +1954,7 @@ Handle Connection::GetCurrentCipher(const Arguments& args) { } Handle Connection::Close(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1958,12 +1962,12 @@ Handle Connection::Close(const Arguments& args) { SSL_free(ss->ssl_); ss->ssl_ = NULL; } - return True(); + return True(node_isolate); } #ifdef OPENSSL_NPN_NEGOTIATED Handle Connection::GetNegotiatedProto(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1974,7 +1978,7 @@ Handle Connection::GetNegotiatedProto(const Arguments& args) { SSL_get0_next_proto_negotiated(ss->ssl_, &npn_proto, &npn_proto_len); if (!npn_proto) { - return False(); + return False(node_isolate); } return String::New((const char*) npn_proto, npn_proto_len); @@ -1984,7 +1988,7 @@ Handle Connection::GetNegotiatedProto(const Arguments& args) { } Handle Connection::SetNPNProtocols(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -1999,25 +2003,25 @@ Handle Connection::SetNPNProtocols(const Arguments& args) { } ss->npnProtos_ = Persistent::New(node_isolate, args[0]->ToObject()); - return True(); + return True(node_isolate); }; #endif #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB Handle Connection::GetServername(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); if (ss->is_server_ && !ss->servername_.IsEmpty()) { return ss->servername_; } else { - return False(); + return False(node_isolate); } } Handle Connection::SetSNICallback(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Connection *ss = Connection::Unwrap(args); @@ -2033,13 +2037,13 @@ Handle Connection::SetSNICallback(const Arguments& args) { ss->sniObject_ = Persistent::New(node_isolate, Object::New()); ss->sniObject_->Set(String::New("onselect"), args[0]); - return True(); + return True(node_isolate); } #endif void CipherBase::Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(New); @@ -2056,7 +2060,7 @@ void CipherBase::Initialize(Handle target) { Handle CipherBase::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); CipherBase* cipher = new CipherBase(args[0]->IsTrue() ? kCipher : kDecipher); cipher->Wrap(args.This()); @@ -2067,7 +2071,7 @@ Handle CipherBase::New(const Arguments& args) { Handle CipherBase::Init(char* cipher_type, char* key_buf, int key_buf_len) { - HandleScope scope; + HandleScope scope(node_isolate); assert(cipher_ == NULL); cipher_ = EVP_get_cipherbyname(cipher_type); @@ -2101,12 +2105,12 @@ Handle CipherBase::Init(char* cipher_type, reinterpret_cast(iv), kind_ == kCipher); initialised_ = true; - return Null(); + return Null(node_isolate); } Handle CipherBase::Init(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); CipherBase* cipher = ObjectWrap::Unwrap(args.This()); @@ -2135,7 +2139,7 @@ Handle CipherBase::InitIv(char* cipher_type, int key_len, char* iv, int iv_len) { - HandleScope scope; + HandleScope scope(node_isolate); cipher_ = EVP_get_cipherbyname(cipher_type); if (cipher_ == NULL) { @@ -2162,12 +2166,12 @@ Handle CipherBase::InitIv(char* cipher_type, reinterpret_cast(iv), kind_ == kCipher); initialised_ = true; - return Null(); + return Null(node_isolate); } Handle CipherBase::InitIv(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); CipherBase* cipher = ObjectWrap::Unwrap(args.This()); @@ -2215,7 +2219,7 @@ bool CipherBase::Update(char* data, Handle CipherBase::Update(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); CipherBase* cipher = ObjectWrap::Unwrap(args.This()); @@ -2247,13 +2251,13 @@ bool CipherBase::SetAutoPadding(bool auto_padding) { Handle CipherBase::SetAutoPadding(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); CipherBase* cipher = ObjectWrap::Unwrap(args.This()); cipher->SetAutoPadding(args.Length() < 1 || args[0]->BooleanValue()); - return Undefined(); + return Undefined(node_isolate); } @@ -2270,7 +2274,7 @@ bool CipherBase::Final(unsigned char** out, int *out_len) { Handle CipherBase::Final(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); CipherBase* cipher = ObjectWrap::Unwrap(args.This()); @@ -2294,7 +2298,7 @@ Handle CipherBase::Final(const Arguments& args) { void Hmac::Initialize(v8::Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(New); @@ -2309,7 +2313,7 @@ void Hmac::Initialize(v8::Handle target) { Handle Hmac::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Hmac* hmac = new Hmac(); hmac->Wrap(args.This()); @@ -2318,7 +2322,7 @@ Handle Hmac::New(const Arguments& args) { Handle Hmac::HmacInit(char* hashType, char* key, int key_len) { - HandleScope scope; + HandleScope scope(node_isolate); assert(md_ == NULL); md_ = EVP_get_digestbyname(hashType); @@ -2333,12 +2337,12 @@ Handle Hmac::HmacInit(char* hashType, char* key, int key_len) { } initialised_ = true; - return Null(); + return Null(node_isolate); } Handle Hmac::HmacInit(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Hmac* hmac = ObjectWrap::Unwrap(args.This()); @@ -2372,7 +2376,7 @@ bool Hmac::HmacUpdate(char* data, int len) { Handle Hmac::HmacUpdate(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Hmac* hmac = ObjectWrap::Unwrap(args.This()); @@ -2404,7 +2408,7 @@ bool Hmac::HmacDigest(unsigned char** md_value, unsigned int* md_len) { Handle Hmac::HmacDigest(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Hmac* hmac = ObjectWrap::Unwrap(args.This()); @@ -2425,7 +2429,7 @@ Handle Hmac::HmacDigest(const Arguments& args) { void Hash::Initialize(v8::Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(New); @@ -2439,7 +2443,7 @@ void Hash::Initialize(v8::Handle target) { Handle Hash::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() == 0 || !args[0]->IsString()) { return ThrowError("Must give hashtype string as argument"); @@ -2477,7 +2481,7 @@ bool Hash::HashUpdate(char* data, int len) { Handle Hash::HashUpdate(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Hash* hash = ObjectWrap::Unwrap(args.This()); @@ -2498,7 +2502,7 @@ Handle Hash::HashUpdate(const Arguments& args) { Handle Hash::HashDigest(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Hash* hash = ObjectWrap::Unwrap(args.This()); @@ -2520,7 +2524,7 @@ Handle Hash::HashDigest(const Arguments& args) { void Sign::Initialize(v8::Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(New); @@ -2535,7 +2539,7 @@ void Sign::Initialize(v8::Handle target) { Handle Sign::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Sign* sign = new Sign(); sign->Wrap(args.This()); @@ -2545,7 +2549,7 @@ Handle Sign::New(const Arguments& args) { Handle Sign::SignInit(const char* sign_type) { - HandleScope scope; + HandleScope scope(node_isolate); assert(md_ == NULL); md_ = EVP_get_digestbyname(sign_type); @@ -2555,12 +2559,12 @@ Handle Sign::SignInit(const char* sign_type) { EVP_MD_CTX_init(&mdctx_); EVP_SignInit_ex(&mdctx_, md_, NULL); initialised_ = true; - return Null(); + return Null(node_isolate); } Handle Sign::SignInit(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Sign* sign = ObjectWrap::Unwrap(args.This()); @@ -2589,7 +2593,7 @@ bool Sign::SignUpdate(char* data, int len) { Handle Sign::SignUpdate(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Sign* sign = ObjectWrap::Unwrap(args.This()); @@ -2634,7 +2638,7 @@ bool Sign::SignFinal(unsigned char** md_value, Handle Sign::SignFinal(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Sign* sign = ObjectWrap::Unwrap(args.This()); @@ -2664,7 +2668,7 @@ Handle Sign::SignFinal(const Arguments& args) { void Verify::Initialize(v8::Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(New); @@ -2679,7 +2683,7 @@ void Verify::Initialize(v8::Handle target) { Handle Verify::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Verify* verify = new Verify(); verify->Wrap(args.This()); @@ -2689,7 +2693,7 @@ Handle Verify::New(const Arguments& args) { Handle Verify::VerifyInit(const char* verify_type) { - HandleScope scope; + HandleScope scope(node_isolate); assert(md_ == NULL); md_ = EVP_get_digestbyname(verify_type); @@ -2701,12 +2705,12 @@ Handle Verify::VerifyInit(const char* verify_type) { EVP_VerifyInit_ex(&mdctx_, md_, NULL); initialised_ = true; - return Null(); + return Null(node_isolate); } Handle Verify::VerifyInit(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Verify* verify = ObjectWrap::Unwrap(args.This()); @@ -2735,7 +2739,7 @@ bool Verify::VerifyUpdate(char* data, int len) { Handle Verify::VerifyUpdate(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Verify* verify = ObjectWrap::Unwrap(args.This()); @@ -2760,7 +2764,7 @@ Handle Verify::VerifyFinal(char* key_pem, int key_pem_len, unsigned char* sig, int siglen) { - HandleScope scope; + HandleScope scope(node_isolate); if (!initialised_) { return ThrowError("Verify not initalised"); @@ -2825,12 +2829,12 @@ exit: return ThrowCryptoError(err); } - return scope.Close(r ? True() : False()); + return scope.Close(r ? True() : False(node_isolate)); } Handle Verify::VerifyFinal(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Verify* verify = ObjectWrap::Unwrap(args.This()); @@ -2847,7 +2851,7 @@ Handle Verify::VerifyFinal(const Arguments& args) { void DiffieHellman::Initialize(v8::Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(New); @@ -2913,7 +2917,7 @@ bool DiffieHellman::Init(unsigned char* p, Handle DiffieHellman::DiffieHellmanGroup(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = new DiffieHellman(); @@ -2947,7 +2951,7 @@ Handle DiffieHellman::DiffieHellmanGroup(const Arguments& args) { Handle DiffieHellman::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = new DiffieHellman(); bool initialized = false; @@ -2973,7 +2977,7 @@ Handle DiffieHellman::New(const Arguments& args) { Handle DiffieHellman::GenerateKeys(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3001,7 +3005,7 @@ Handle DiffieHellman::GenerateKeys(const Arguments& args) { Handle DiffieHellman::GetPrime(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3025,7 +3029,7 @@ Handle DiffieHellman::GetPrime(const Arguments& args) { Handle DiffieHellman::GetGenerator(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3049,7 +3053,7 @@ Handle DiffieHellman::GetGenerator(const Arguments& args) { Handle DiffieHellman::GetPublicKey(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3078,7 +3082,7 @@ Handle DiffieHellman::GetPublicKey(const Arguments& args) { Handle DiffieHellman::GetPrivateKey(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3107,7 +3111,7 @@ Handle DiffieHellman::GetPrivateKey(const Arguments& args) { Handle DiffieHellman::ComputeSecret(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3180,7 +3184,7 @@ Handle DiffieHellman::ComputeSecret(const Arguments& args) { Handle DiffieHellman::SetPublicKey(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3203,7 +3207,7 @@ Handle DiffieHellman::SetPublicKey(const Arguments& args) { Handle DiffieHellman::SetPrivateKey(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); DiffieHellman* diffieHellman = ObjectWrap::Unwrap(args.This()); @@ -3273,12 +3277,12 @@ void EIO_PBKDF2(uv_work_t* work_req) { void EIO_PBKDF2After(pbkdf2_req* req, Local argv[2]) { if (req->err) { - argv[0] = Local::New(Undefined()); + argv[0] = Local::New(node_isolate, Undefined(node_isolate)); argv[1] = Encode(req->key, req->keylen, BUFFER); memset(req->key, 0, req->keylen); } else { argv[0] = Exception::Error(String::New("PBKDF2 error")); - argv[1] = Local::New(Undefined()); + argv[1] = Local::New(node_isolate, Undefined(node_isolate)); } delete[] req->pass; @@ -3291,7 +3295,7 @@ void EIO_PBKDF2After(pbkdf2_req* req, Local argv[2]) { void EIO_PBKDF2After(uv_work_t* work_req, int status) { assert(status == 0); pbkdf2_req* req = container_of(work_req, pbkdf2_req, work_req); - HandleScope scope; + HandleScope scope(node_isolate); Local argv[2]; Persistent obj = req->obj; EIO_PBKDF2After(req, argv); @@ -3301,7 +3305,7 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) { Handle PBKDF2(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); const char* type_error = NULL; char* pass = NULL; @@ -3380,7 +3384,7 @@ Handle PBKDF2(const Arguments& args) { &req->work_req, EIO_PBKDF2, EIO_PBKDF2After); - return Undefined(); + return Undefined(node_isolate); } else { Local argv[2]; EIO_PBKDF2(req); @@ -3451,13 +3455,13 @@ void RandomBytesCheck(RandomBytesRequest* req, Local argv[2]) { ERR_error_string_n(req->error_, errmsg, sizeof errmsg); argv[0] = Exception::Error(String::New(errmsg)); - argv[1] = Local::New(Null()); + argv[1] = Local::New(node_isolate, Null(node_isolate)); } else { // avoids the malloc + memcpy Buffer* buffer = Buffer::New(req->data_, req->size_, RandomBytesFree, NULL); - argv[0] = Local::New(Null()); - argv[1] = Local::New(buffer->handle_); + argv[0] = Local::New(node_isolate, Null(node_isolate)); + argv[1] = Local::New(node_isolate, buffer->handle_); } } @@ -3467,7 +3471,7 @@ void RandomBytesAfter(uv_work_t* work_req, int status) { RandomBytesRequest* req = container_of(work_req, RandomBytesRequest, work_req_); - HandleScope scope; + HandleScope scope(node_isolate); Local argv[2]; RandomBytesCheck(req, argv); MakeCallback(req->obj_, "ondone", ARRAY_SIZE(argv), argv); @@ -3477,7 +3481,7 @@ void RandomBytesAfter(uv_work_t* work_req, int status) { template Handle RandomBytes(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); // maybe allow a buffer to write to? cuts down on object creation // when generating random data in a loop @@ -3519,7 +3523,7 @@ Handle RandomBytes(const Arguments& args) { Handle GetCiphers(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); SSL_CTX* ctx = SSL_CTX_new(TLSv1_server_method()); if (ctx == NULL) { @@ -3557,7 +3561,7 @@ static void add_hash_to_array(const EVP_MD* md, Handle GetHashes(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Local arr = Array::New(); EVP_MD_do_all_sorted(add_hash_to_array, &arr); return scope.Close(arr); @@ -3565,7 +3569,7 @@ Handle GetHashes(const Arguments& args) { void InitCrypto(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); SSL_library_init(); OpenSSL_add_all_algorithms(); diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc index 534b3b9670..99bc3002d7 100644 --- a/src/node_dtrace.cc +++ b/src/node_dtrace.cc @@ -129,10 +129,10 @@ using namespace v8; Handle DTRACE_NET_SERVER_CONNECTION(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_NET_SERVER_CONNECTION_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); SLURP_CONNECTION(args[0], conn); #ifdef HAVE_SYSTEMTAP @@ -142,16 +142,16 @@ Handle DTRACE_NET_SERVER_CONNECTION(const Arguments& args) { NODE_NET_SERVER_CONNECTION(&conn); #endif - return Undefined(); + return Undefined(node_isolate); } Handle DTRACE_NET_STREAM_END(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_NET_STREAM_END_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); SLURP_CONNECTION(args[0], conn); #ifdef HAVE_SYSTEMTAP @@ -160,16 +160,16 @@ Handle DTRACE_NET_STREAM_END(const Arguments& args) { NODE_NET_STREAM_END(&conn); #endif - return Undefined(); + return Undefined(node_isolate); } Handle DTRACE_NET_SOCKET_READ(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_NET_SOCKET_READ_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); SLURP_CONNECTION(args[0], conn); @@ -184,16 +184,16 @@ Handle DTRACE_NET_SOCKET_READ(const Arguments& args) { NODE_NET_SOCKET_READ(&conn, nbytes); #endif - return Undefined(); + return Undefined(node_isolate); } Handle DTRACE_NET_SOCKET_WRITE(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_NET_SOCKET_WRITE_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); SLURP_CONNECTION(args[0], conn); @@ -208,7 +208,7 @@ Handle DTRACE_NET_SOCKET_WRITE(const Arguments& args) { NODE_NET_SOCKET_WRITE(&conn, nbytes); #endif - return Undefined(); + return Undefined(node_isolate); } Handle DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) { @@ -216,10 +216,10 @@ Handle DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_HTTP_SERVER_REQUEST_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); Local arg0 = Local::Cast(args[0]); Local headers; @@ -249,16 +249,16 @@ Handle DTRACE_HTTP_SERVER_REQUEST(const Arguments& args) { #else NODE_HTTP_SERVER_REQUEST(&req, &conn); #endif - return Undefined(); + return Undefined(node_isolate); } Handle DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_HTTP_SERVER_RESPONSE_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); SLURP_CONNECTION(args[0], conn); #ifdef HAVE_SYSTEMTAP @@ -267,7 +267,7 @@ Handle DTRACE_HTTP_SERVER_RESPONSE(const Arguments& args) { NODE_HTTP_SERVER_RESPONSE(&conn); #endif - return Undefined(); + return Undefined(node_isolate); } Handle DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) { @@ -276,10 +276,10 @@ Handle DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_HTTP_CLIENT_REQUEST_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); /* * For the method and URL, we're going to dig them out of the header. This @@ -312,15 +312,15 @@ Handle DTRACE_HTTP_CLIENT_REQUEST(const Arguments& args) { #else NODE_HTTP_CLIENT_REQUEST(&req, &conn); #endif - return Undefined(); + return Undefined(node_isolate); } Handle DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) { #ifndef HAVE_SYSTEMTAP if (!NODE_HTTP_CLIENT_RESPONSE_ENABLED()) - return Undefined(); + return Undefined(node_isolate); #endif - HandleScope scope; + HandleScope scope(node_isolate); SLURP_CONNECTION_HTTP_CLIENT_RESPONSE(args[0], args[1], conn); #ifdef HAVE_SYSTEMTAP @@ -329,7 +329,7 @@ Handle DTRACE_HTTP_CLIENT_RESPONSE(const Arguments& args) { NODE_HTTP_CLIENT_RESPONSE(&conn); #endif - return Undefined(); + return Undefined(node_isolate); } #define NODE_PROBE(name) #name, name, Persistent() diff --git a/src/node_file.cc b/src/node_file.cc index 52a300a18c..684044401d 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -81,7 +81,7 @@ static inline int IsInt64(double x) { static void After(uv_fs_t *req) { - HandleScope scope; + HandleScope scope(node_isolate); FSReqWrap* req_wrap = (FSReqWrap*) req->data; assert(&req_wrap->req_ == req); @@ -110,7 +110,7 @@ static void After(uv_fs_t *req) { } } else { // error value is empty or null for non-error. - argv[0] = Local::New(Null()); + argv[0] = Local::New(node_isolate, Null(node_isolate)); // All have at least two args now. argc = 2; @@ -141,11 +141,11 @@ static void After(uv_fs_t *req) { break; case UV_FS_OPEN: - argv[1] = Integer::New(req->result); + argv[1] = Integer::New(req->result, node_isolate); break; case UV_FS_WRITE: - argv[1] = Integer::New(req->result); + argv[1] = Integer::New(req->result, node_isolate); break; case UV_FS_STAT: @@ -160,7 +160,7 @@ static void After(uv_fs_t *req) { case UV_FS_READ: // Buffer interface - argv[1] = Integer::New(req->result); + argv[1] = Integer::New(req->result, node_isolate); break; case UV_FS_READDIR: @@ -172,7 +172,7 @@ static void After(uv_fs_t *req) { for (int i = 0; i < nnames; i++) { Local name = String::New(namebuf); - names->Set(Integer::New(i), name); + names->Set(Integer::New(i, node_isolate), name); #ifndef NDEBUG namebuf += strlen(namebuf); assert(*namebuf == '\0'); @@ -241,7 +241,7 @@ struct fs_req_wrap { static Handle Close(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -253,7 +253,7 @@ static Handle Close(const Arguments& args) { ASYNC_CALL(close, args[1], fd) } else { SYNC_CALL(close, 0, fd) - return Undefined(); + return Undefined(node_isolate); } } @@ -275,7 +275,7 @@ static Persistent mtime_symbol; static Persistent ctime_symbol; Local BuildStatsObject(const uv_statbuf_t* s) { - HandleScope scope; + HandleScope scope(node_isolate); if (dev_symbol.IsEmpty()) { dev_symbol = NODE_PSYMBOL("dev"); @@ -311,7 +311,7 @@ Local BuildStatsObject(const uv_statbuf_t* s) { // and make sure that we bail out when V8 returns an empty handle. #define X(name) \ { \ - Local val = Integer::New(s->st_##name); \ + Local val = Integer::New(s->st_##name, node_isolate); \ if (val.IsEmpty()) return Local(); \ stats->Set(name##_symbol, val); \ } @@ -354,7 +354,7 @@ Local BuildStatsObject(const uv_statbuf_t* s) { } static Handle Stat(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1) return TYPE_ERROR("path required"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); @@ -371,7 +371,7 @@ static Handle Stat(const Arguments& args) { } static Handle LStat(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1) return TYPE_ERROR("path required"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); @@ -388,7 +388,7 @@ static Handle LStat(const Arguments& args) { } static Handle FStat(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -406,7 +406,7 @@ static Handle FStat(const Arguments& args) { } static Handle Symlink(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("dest path required"); @@ -434,12 +434,12 @@ static Handle Symlink(const Arguments& args) { ASYNC_CALL(symlink, args[3], *dest, *path, flags) } else { SYNC_CALL(symlink, *path, *dest, *path, flags) - return Undefined(); + return Undefined(node_isolate); } } static Handle Link(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("dest path required"); @@ -454,12 +454,12 @@ static Handle Link(const Arguments& args) { ASYNC_CALL(link, args[2], *orig_path, *new_path) } else { SYNC_CALL(link, *orig_path, *orig_path, *new_path) - return Undefined(); + return Undefined(node_isolate); } } static Handle ReadLink(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1) return TYPE_ERROR("path required"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); @@ -475,7 +475,7 @@ static Handle ReadLink(const Arguments& args) { } static Handle Rename(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("old path required"); @@ -490,12 +490,12 @@ static Handle Rename(const Arguments& args) { ASYNC_CALL(rename, args[2], *old_path, *new_path) } else { SYNC_CALL(rename, *old_path, *old_path, *new_path) - return Undefined(); + return Undefined(node_isolate); } } static Handle FTruncate(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 2 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -510,12 +510,12 @@ static Handle FTruncate(const Arguments& args) { ASYNC_CALL(ftruncate, args[2], fd, len) } else { SYNC_CALL(ftruncate, 0, fd, len) - return Undefined(); + return Undefined(node_isolate); } } static Handle Fdatasync(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -527,12 +527,12 @@ static Handle Fdatasync(const Arguments& args) { ASYNC_CALL(fdatasync, args[1], fd) } else { SYNC_CALL(fdatasync, 0, fd) - return Undefined(); + return Undefined(node_isolate); } } static Handle Fsync(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -544,12 +544,12 @@ static Handle Fsync(const Arguments& args) { ASYNC_CALL(fsync, args[1], fd) } else { SYNC_CALL(fsync, 0, fd) - return Undefined(); + return Undefined(node_isolate); } } static Handle Unlink(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1) return TYPE_ERROR("path required"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); @@ -560,12 +560,12 @@ static Handle Unlink(const Arguments& args) { ASYNC_CALL(unlink, args[1], *path) } else { SYNC_CALL(unlink, *path, *path) - return Undefined(); + return Undefined(node_isolate); } } static Handle RMDir(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1) return TYPE_ERROR("path required"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); @@ -576,12 +576,12 @@ static Handle RMDir(const Arguments& args) { ASYNC_CALL(rmdir, args[1], *path) } else { SYNC_CALL(rmdir, *path, *path) - return Undefined(); + return Undefined(node_isolate); } } static Handle MKDir(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { return THROW_BAD_ARGS; @@ -594,12 +594,12 @@ static Handle MKDir(const Arguments& args) { ASYNC_CALL(mkdir, args[2], *path, mode) } else { SYNC_CALL(mkdir, *path, *path, mode) - return Undefined(); + return Undefined(node_isolate); } } static Handle ReadDir(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 1) return TYPE_ERROR("path required"); if (!args[0]->IsString()) return TYPE_ERROR("path must be a string"); @@ -617,7 +617,7 @@ static Handle ReadDir(const Arguments& args) { for (int i = 0; i < nnames; i++) { Local name = String::New(namebuf); - names->Set(Integer::New(i), name); + names->Set(Integer::New(i, node_isolate), name); #ifndef NDEBUG namebuf += strlen(namebuf); assert(*namebuf == '\0'); @@ -632,7 +632,7 @@ static Handle ReadDir(const Arguments& args) { } static Handle Open(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("path required"); @@ -651,7 +651,7 @@ static Handle Open(const Arguments& args) { } else { SYNC_CALL(open, *path, *path, flags, mode) int fd = SYNC_RESULT; - return scope.Close(Integer::New(fd)); + return scope.Close(Integer::New(fd, node_isolate)); } } @@ -665,7 +665,7 @@ static Handle Open(const Arguments& args) { // 4 position if integer, position to write at in the file. // if null, write from the current position static Handle Write(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (!args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -704,7 +704,7 @@ static Handle Write(const Arguments& args) { ASYNC_CALL(write, cb, fd, buf, len, pos) } else { SYNC_CALL(write, 0, fd, buf, len, pos) - return scope.Close(Integer::New(SYNC_RESULT)); + return scope.Close(Integer::New(SYNC_RESULT, node_isolate)); } } @@ -721,7 +721,7 @@ static Handle Write(const Arguments& args) { * */ static Handle Read(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (args.Length() < 2 || !args[0]->IsInt32()) { return THROW_BAD_ARGS; @@ -767,7 +767,7 @@ static Handle Read(const Arguments& args) { ASYNC_CALL(read, cb, fd, buf, len, pos); } else { SYNC_CALL(read, 0, fd, buf, len, pos) - Local bytesRead = Integer::New(SYNC_RESULT); + Local bytesRead = Integer::New(SYNC_RESULT, node_isolate); return scope.Close(bytesRead); } } @@ -777,7 +777,7 @@ static Handle Read(const Arguments& args) { * Wrapper for chmod(1) / EIO_CHMOD */ static Handle Chmod(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if(args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { return THROW_BAD_ARGS; @@ -789,7 +789,7 @@ static Handle Chmod(const Arguments& args) { ASYNC_CALL(chmod, args[2], *path, mode); } else { SYNC_CALL(chmod, *path, *path, mode); - return Undefined(); + return Undefined(node_isolate); } } @@ -798,7 +798,7 @@ static Handle Chmod(const Arguments& args) { * Wrapper for fchmod(1) / EIO_FCHMOD */ static Handle FChmod(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if(args.Length() < 2 || !args[0]->IsInt32() || !args[1]->IsInt32()) { return THROW_BAD_ARGS; @@ -810,7 +810,7 @@ static Handle FChmod(const Arguments& args) { ASYNC_CALL(fchmod, args[2], fd, mode); } else { SYNC_CALL(fchmod, 0, fd, mode); - return Undefined(); + return Undefined(node_isolate); } } @@ -819,7 +819,7 @@ static Handle FChmod(const Arguments& args) { * Wrapper for chown(1) / EIO_CHOWN */ static Handle Chown(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("path required"); @@ -837,7 +837,7 @@ static Handle Chown(const Arguments& args) { ASYNC_CALL(chown, args[3], *path, uid, gid); } else { SYNC_CALL(chown, *path, *path, uid, gid); - return Undefined(); + return Undefined(node_isolate); } } @@ -846,7 +846,7 @@ static Handle Chown(const Arguments& args) { * Wrapper for fchown(1) / EIO_FCHOWN */ static Handle FChown(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("fd required"); @@ -864,13 +864,13 @@ static Handle FChown(const Arguments& args) { ASYNC_CALL(fchown, args[3], fd, uid, gid); } else { SYNC_CALL(fchown, 0, fd, uid, gid); - return Undefined(); + return Undefined(node_isolate); } } static Handle UTimes(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("path required"); @@ -888,12 +888,12 @@ static Handle UTimes(const Arguments& args) { ASYNC_CALL(utime, args[3], *path, atime, mtime); } else { SYNC_CALL(utime, *path, *path, atime, mtime); - return Undefined(); + return Undefined(node_isolate); } } static Handle FUTimes(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int len = args.Length(); if (len < 1) return TYPE_ERROR("fd required"); @@ -911,13 +911,13 @@ static Handle FUTimes(const Arguments& args) { ASYNC_CALL(futime, args[3], fd, atime, mtime); } else { SYNC_CALL(futime, 0, fd, atime, mtime); - return Undefined(); + return Undefined(node_isolate); } } void File::Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); NODE_SET_METHOD(target, "close", Close); NODE_SET_METHOD(target, "open", Open); @@ -951,7 +951,7 @@ void File::Initialize(Handle target) { } void InitFs(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); // Initialize the stats object Local stat_templ = FunctionTemplate::New(); stats_constructor_template = Persistent::New(node_isolate, diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 493f1e065e..782bdf9bc9 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -170,7 +170,7 @@ struct StringPtr { if (str_) return String::New(str_, size_); else - return String::Empty(); + return String::Empty(node_isolate); } @@ -270,22 +270,22 @@ public: // STATUS if (parser_.type == HTTP_RESPONSE) { message_info->Set(status_code_sym, - Integer::New(parser_.status_code)); + Integer::New(parser_.status_code, node_isolate)); } // VERSION message_info->Set(version_major_sym, - Integer::New(parser_.http_major)); + Integer::New(parser_.http_major, node_isolate)); message_info->Set(version_minor_sym, - Integer::New(parser_.http_minor)); + Integer::New(parser_.http_minor, node_isolate)); message_info->Set(should_keep_alive_sym, - http_should_keep_alive(&parser_) ? True() - : False()); + http_should_keep_alive(&parser_) ? True(node_isolate) + : False(node_isolate)); message_info->Set(upgrade_sym, - parser_.upgrade ? True() - : False()); + parser_.upgrade ? True(node_isolate) + : False(node_isolate)); Local argv[1] = { message_info }; @@ -302,7 +302,7 @@ public: HTTP_DATA_CB(on_body) { - HandleScope scope; + HandleScope scope(node_isolate); Local cb = handle_->Get(on_body_sym); if (!cb->IsFunction()) @@ -310,8 +310,8 @@ public: Local argv[3] = { *current_buffer, - Integer::New(at - current_buffer_data), - Integer::New(length) + Integer::New(at - current_buffer_data, node_isolate), + Integer::New(length, node_isolate) }; Local r = Local::Cast(cb)->Call(handle_, 3, argv); @@ -326,7 +326,7 @@ public: HTTP_CB(on_message_complete) { - HandleScope scope; + HandleScope scope(node_isolate); if (num_fields_) Flush(); // Flush trailing HTTP headers. @@ -348,7 +348,7 @@ public: static Handle New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); http_parser_type type = static_cast(args[0]->Int32Value()); @@ -380,7 +380,7 @@ public: // var bytesParsed = parser->execute(buffer, off, len); static Handle Execute(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Parser* parser = ObjectWrap::Unwrap(args.This()); @@ -434,7 +434,7 @@ public: // If there was an exception in one of the callbacks if (parser->got_exception_) return Local(); - Local nparsed_obj = Integer::New(nparsed); + Local nparsed_obj = Integer::New(nparsed, node_isolate); // If there was a parse error in one of the callbacks // TODO What if there is an error on EOF? if (!parser->parser_.upgrade && nparsed != len) { @@ -452,7 +452,7 @@ public: static Handle Finish(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Parser* parser = ObjectWrap::Unwrap(args.This()); @@ -468,17 +468,17 @@ public: Local e = Exception::Error(String::NewSymbol("Parse Error")); Local obj = e->ToObject(); - obj->Set(String::NewSymbol("bytesParsed"), Integer::New(0)); + obj->Set(String::NewSymbol("bytesParsed"), Integer::New(0, node_isolate)); obj->Set(String::NewSymbol("code"), String::New(http_errno_name(err))); return scope.Close(e); } - return Undefined(); + return Undefined(node_isolate); } static Handle Reinitialize(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); http_parser_type type = static_cast(args[0]->Int32Value()); @@ -491,7 +491,7 @@ public: Parser* parser = ObjectWrap::Unwrap(args.This()); parser->Init(type); - return Undefined(); + return Undefined(node_isolate); } @@ -513,7 +513,7 @@ private: // spill headers and request path to JS land void Flush() { - HandleScope scope; + HandleScope scope(node_isolate); Local cb = handle_->Get(on_headers_sym); @@ -557,7 +557,7 @@ private: void InitHttpParser(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(Parser::New); t->InstanceTemplate()->SetInternalFieldCount(1); @@ -565,10 +565,10 @@ void InitHttpParser(Handle target) { PropertyAttribute attrib = (PropertyAttribute) (ReadOnly | DontDelete); t->Set(String::NewSymbol("REQUEST"), - Integer::New(HTTP_REQUEST), + Integer::New(HTTP_REQUEST, node_isolate), attrib); t->Set(String::NewSymbol("RESPONSE"), - Integer::New(HTTP_RESPONSE), + Integer::New(HTTP_RESPONSE, node_isolate), attrib); NODE_SET_PROTOTYPE_METHOD(t, "execute", Parser::Execute); diff --git a/src/node_javascript.cc b/src/node_javascript.cc index 49695c0824..5b5a2bea7b 100644 --- a/src/node_javascript.cc +++ b/src/node_javascript.cc @@ -37,7 +37,7 @@ Handle MainSource() { } void DefineJavaScript(v8::Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); for (int i = 0; natives[i].name; i++) { if (natives[i].source != node_native) { diff --git a/src/node_os.cc b/src/node_os.cc index d9712b8bf4..614a10c96f 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -42,7 +42,7 @@ namespace node { using namespace v8; static Handle GetEndianness(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); int i = 1; bool big = (*(char *)&i) == 0; Local endianness = String::New(big ? "BE" : "LE"); @@ -50,7 +50,7 @@ static Handle GetEndianness(const Arguments& args) { } static Handle GetHostname(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); char s[255]; int r = gethostname(s, 255); @@ -66,7 +66,7 @@ static Handle GetHostname(const Arguments& args) { } static Handle GetOSType(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); #ifdef __POSIX__ char type[256]; @@ -83,7 +83,7 @@ static Handle GetOSType(const Arguments& args) { } static Handle GetOSRelease(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); char release[256]; #ifdef __POSIX__ @@ -98,7 +98,7 @@ static Handle GetOSRelease(const Arguments& args) { info.dwOSVersionInfoSize = sizeof(info); if (GetVersionEx(&info) == 0) { - return Undefined(); + return Undefined(node_isolate); } sprintf(release, "%d.%d.%d", static_cast(info.dwMajorVersion), @@ -109,14 +109,14 @@ static Handle GetOSRelease(const Arguments& args) { } static Handle GetCPUInfo(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); uv_cpu_info_t* cpu_infos; int count, i; uv_err_t err = uv_cpu_info(&cpu_infos, &count); if (err.code != UV_OK) { - return Undefined(); + return Undefined(node_isolate); } Local cpus = Array::New(); @@ -124,20 +124,20 @@ static Handle GetCPUInfo(const Arguments& args) { for (i = 0; i < count; i++) { Local times_info = Object::New(); times_info->Set(String::New("user"), - Integer::New(cpu_infos[i].cpu_times.user)); + Integer::New(cpu_infos[i].cpu_times.user, node_isolate)); times_info->Set(String::New("nice"), - Integer::New(cpu_infos[i].cpu_times.nice)); + Integer::New(cpu_infos[i].cpu_times.nice, node_isolate)); times_info->Set(String::New("sys"), - Integer::New(cpu_infos[i].cpu_times.sys)); + Integer::New(cpu_infos[i].cpu_times.sys, node_isolate)); times_info->Set(String::New("idle"), - Integer::New(cpu_infos[i].cpu_times.idle)); + Integer::New(cpu_infos[i].cpu_times.idle, node_isolate)); times_info->Set(String::New("irq"), - Integer::New(cpu_infos[i].cpu_times.irq)); + Integer::New(cpu_infos[i].cpu_times.irq, node_isolate)); Local cpu_info = Object::New(); cpu_info->Set(String::New("model"), String::New(cpu_infos[i].model)); cpu_info->Set(String::New("speed"), - Integer::New(cpu_infos[i].speed)); + Integer::New(cpu_infos[i].speed, node_isolate)); cpu_info->Set(String::New("times"), times_info); (*cpus)->Set(i,cpu_info); } @@ -148,42 +148,42 @@ static Handle GetCPUInfo(const Arguments& args) { } static Handle GetFreeMemory(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); double amount = uv_get_free_memory(); if (amount < 0) { - return Undefined(); + return Undefined(node_isolate); } return scope.Close(Number::New(amount)); } static Handle GetTotalMemory(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); double amount = uv_get_total_memory(); if (amount < 0) { - return Undefined(); + return Undefined(node_isolate); } return scope.Close(Number::New(amount)); } static Handle GetUptime(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); double uptime; uv_err_t err = uv_uptime(&uptime); if (err.code != UV_OK) { - return Undefined(); + return Undefined(node_isolate); } return scope.Close(Number::New(uptime)); } static Handle GetLoadAvg(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); double loadavg[3]; uv_loadavg(loadavg); @@ -197,7 +197,7 @@ static Handle GetLoadAvg(const Arguments& args) { static Handle GetInterfaceAddresses(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); uv_interface_address_t* interfaces; int count, i; char ip[INET6_ADDRSTRLEN]; @@ -238,7 +238,7 @@ static Handle GetInterfaceAddresses(const Arguments& args) { const bool internal = interfaces[i].is_internal; o->Set(String::New("internal"), - internal ? True() : False()); + internal ? True(node_isolate) : False(node_isolate)); ifarr->Set(ifarr->Length(), o); } @@ -250,7 +250,7 @@ static Handle GetInterfaceAddresses(const Arguments& args) { void OS::Initialize(v8::Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); NODE_SET_METHOD(target, "getEndianness", GetEndianness); NODE_SET_METHOD(target, "getHostname", GetHostname); diff --git a/src/node_script.cc b/src/node_script.cc index ca7b9404a7..6f279bc640 100644 --- a/src/node_script.cc +++ b/src/node_script.cc @@ -103,7 +103,7 @@ Persistent cloneObjectMethod; void CloneObject(Handle recv, Handle source, Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Handle args[] = {source, target}; @@ -133,7 +133,7 @@ void CloneObject(Handle recv, void WrappedContext::Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(WrappedContext::New); constructor_template = Persistent::New(node_isolate, t); @@ -151,7 +151,7 @@ bool WrappedContext::InstanceOf(Handle value) { Handle WrappedContext::New(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); WrappedContext *t = new WrappedContext(); t->Wrap(args.This()); @@ -185,7 +185,7 @@ Persistent WrappedScript::constructor_template; void WrappedScript::Initialize(Handle target) { - HandleScope scope; + HandleScope scope(node_isolate); Local t = FunctionTemplate::New(WrappedScript::New); constructor_template = Persistent::New(node_isolate, t); @@ -237,7 +237,7 @@ Handle WrappedScript::New(const Arguments& args) { return FromConstructorTemplate(constructor_template, args); } - HandleScope scope; + HandleScope scope(node_isolate); WrappedScript *t = new WrappedScript(); t->Wrap(args.Holder()); @@ -253,7 +253,7 @@ WrappedScript::~WrappedScript() { Handle WrappedScript::CreateContext(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); Local context = WrappedContext::NewInstance(); @@ -313,7 +313,7 @@ template Handle WrappedScript::EvalMachine(const Arguments& args) { - HandleScope scope; + HandleScope scope(node_isolate); if (input_flag == compileCode && args.Length() < 1) { return ThrowException(Exception::TypeError( @@ -364,7 +364,7 @@ Handle WrappedScript::EvalMachine(const Arguments& args) { // to a local handle, and then dispose the persistent handle. This ensures // that when this function exits the context will be disposed. Persistent tmp = Context::New(); - context = Local::New(tmp); + context = Local::New(node_isolate, tmp); tmp.Dispose(node_isolate); } else if (context_flag == userContext) { @@ -427,7 +427,7 @@ Handle WrappedScript::EvalMachine(const Arguments& args) { return ThrowException(Exception::Error( String::New("Must be called as a method of Script."))); } - n_script->script_ = Persistent