LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File nodejs-v8-3.18.0.patch of Package nodejs (Project devel:languages:nodejs)

From 0bba59028381c146b90411d43425a18415d85f98 Mon Sep 17 00:00:00 2001
From: Trevor Norris <trev.norris@gmail.com>
Date: Mon, 18 Mar 2013 13:54:00 -0700
Subject: [PATCH] bindings: update api

All compile time warnings about using deprecated APIs have been
suppressed by updating node's API. Though there are still many function
calls that can accept Isolate, and still need to be updated.

node_isolate had to be added as an extern variable in node.h and
node_object_wrap.h

Also a couple small fixes for Error handling.

Before v8 3.16.6 the error stack message was lazily written when it was
needed, which allowed you to change the message after instantiation.
Then the stack would be written with the new message the first time it
was accessed. Though that has changed. Now it creates the stack message
on instantiation. So setting a different message afterwards won't be
displayed.

This is not a complete fix for the problem. Getting error without any
message isn't very useful.
---
 lib/fs.js                       |  3 ++-
 src/cares_wrap.cc               |  4 ++--
 src/fs_event_wrap.cc            |  5 +++--
 src/handle_wrap.cc              | 10 +++++-----
 src/handle_wrap.h               |  2 +-
 src/node.cc                     | 27 ++++++++++++++-------------
 src/node.h                      |  8 +++++---
 src/node_buffer.cc              | 12 +++++++-----
 src/node_counters.cc            |  2 +-
 src/node_crypto.cc              | 38 ++++++++++++++++++++------------------
 src/node_crypto.h               | 10 +++++-----
 src/node_dtrace.cc              |  2 +-
 src/node_file.cc                |  3 ++-
 src/node_internals.h            |  2 +-
 src/node_object_wrap.h          | 28 ++++++++++++++++------------
 src/node_script.cc              | 13 +++++++------
 src/node_stat_watcher.cc        |  2 +-
 src/node_zlib.cc                | 10 ++++++----
 src/pipe_wrap.cc                |  6 +++---
 src/req_wrap.h                  |  4 ++--
 src/slab_allocator.cc           | 10 +++++-----
 src/stream_wrap.cc              |  4 ++--
 src/tcp_wrap.cc                 |  6 +++---
 src/tty_wrap.cc                 |  2 +-
 src/udp_wrap.cc                 |  6 +++---
 src/v8_typed_array.cc           | 32 +++++++++++++++++---------------
 test/message/error_exit.out     |  2 +-
 test/message/stack_overflow.js  |  2 ++
 test/message/stack_overflow.out |  2 +-
 29 files changed, 139 insertions(+), 118 deletions(-)

Index: node-v0.10.4/src/cares_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/cares_wrap.cc
+++ node-v0.10.4/src/cares_wrap.cc
@@ -272,7 +272,7 @@ class QueryWrap {
   QueryWrap() {
     HandleScope scope;
 
-    object_ = Persistent<Object>::New(Object::New());
+    object_ = Persistent<Object>::New(node_isolate, Object::New());
   }
 
   virtual ~QueryWrap() {
@@ -280,7 +280,7 @@ class QueryWrap {
 
     object_->Delete(oncomplete_sym);
 
-    object_.Dispose();
+    object_.Dispose(node_isolate);
     object_.Clear();
   }
 
Index: node-v0.10.4/src/fs_event_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/fs_event_wrap.cc
+++ node-v0.10.4/src/fs_event_wrap.cc
@@ -74,7 +74,8 @@ void FSEventWrap::Initialize(Handle<Obje
   NODE_SET_PROTOTYPE_METHOD(t, "close", Close);
 
   target->Set(String::NewSymbol("FSEvent"),
-              Persistent<FunctionTemplate>::New(t)->GetFunction());
+              Persistent<FunctionTemplate>::New(node_isolate,
+                                                t)->GetFunction());
 }
 
 
@@ -172,7 +173,7 @@ Handle<Value> FSEventWrap::Close(const A
   // and legal, HandleWrap::Close() deals with them the same way.
   assert(!args.Holder().IsEmpty());
   assert(args.Holder()->InternalFieldCount() > 0);
-  void* ptr = args.Holder()->GetPointerFromInternalField(0);
+  void* ptr = args.Holder()->GetAlignedPointerFromInternalField(0);
   FSEventWrap* wrap = static_cast<FSEventWrap*>(ptr);
 
   if (wrap == NULL || wrap->initialized_ == false) {
Index: node-v0.10.4/src/handle_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/handle_wrap.cc
+++ node-v0.10.4/src/handle_wrap.cc
@@ -84,7 +84,7 @@ Handle<Value> HandleWrap::Close(const Ar
   HandleScope scope;
 
   HandleWrap *wrap = static_cast<HandleWrap*>(
-      args.Holder()->GetPointerFromInternalField(0));
+      args.Holder()->GetAlignedPointerFromInternalField(0));
 
   // guard against uninitialized handle or double close
   if (wrap == NULL || wrap->handle__ == NULL) {
@@ -115,8 +115,8 @@ HandleWrap::HandleWrap(Handle<Object> ob
   HandleScope scope;
   assert(object_.IsEmpty());
   assert(object->InternalFieldCount() > 0);
-  object_ = v8::Persistent<v8::Object>::New(object);
-  object_->SetPointerInInternalField(0, this);
+  object_ = v8::Persistent<v8::Object>::New(node_isolate, object);
+  object_->SetAlignedPointerInInternalField(0, this);
   ngx_queue_insert_tail(&handle_wrap_queue, &handle_wrap_queue_);
 }
 
@@ -147,8 +147,8 @@ void HandleWrap::OnClose(uv_handle_t* ha
     MakeCallback(wrap->object_, close_sym, 0, NULL);
   }
 
-  wrap->object_->SetPointerInInternalField(0, NULL);
-  wrap->object_.Dispose();
+  wrap->object_->SetAlignedPointerInInternalField(0, NULL);
+  wrap->object_.Dispose(node_isolate);
   wrap->object_.Clear();
 
   delete wrap;
Index: node-v0.10.4/src/handle_wrap.h
===================================================================
--- node-v0.10.4.orig/src/handle_wrap.h
+++ node-v0.10.4/src/handle_wrap.h
@@ -50,7 +50,7 @@ namespace node {
   assert(!args.Holder().IsEmpty());                                         \
   assert(args.Holder()->InternalFieldCount() > 0);                          \
   type* wrap = static_cast<type*>(                                          \
-      args.Holder()->GetPointerFromInternalField(0));
+      args.Holder()->GetAlignedPointerFromInternalField(0));
 
 class HandleWrap {
   public:
Index: node-v0.10.4/src/node.cc
===================================================================
--- node-v0.10.4.orig/src/node.cc
+++ node-v0.10.4/src/node.cc
@@ -195,7 +195,7 @@ static void Spin(uv_idle_t* handle, int
       abort();
     }
     Local<Function> cb = cb_v.As<Function>();
-    process_tickFromSpinner = Persistent<Function>::New(cb);
+    process_tickFromSpinner = Persistent<Function>::New(node_isolate, cb);
   }
 
   TryCatch try_catch;
@@ -918,7 +918,7 @@ Handle<Value> UsingDomains(const Argumen
   Local<Function> ndt = ndt_v.As<Function>();
   process->Set(String::New("_tickCallback"), tdc);
   process->Set(String::New("nextTick"), ndt);
-  process_tickCallback = Persistent<Function>::New(tdc);
+  process_tickCallback = Persistent<Function>::New(node_isolate, tdc);
   return Undefined();
 }
 
@@ -1013,7 +1013,7 @@ MakeCallback(const Handle<Object> object
       abort();
     }
     Local<Function> cb = cb_v.As<Function>();
-    process_tickCallback = Persistent<Function>::New(cb);
+    process_tickCallback = Persistent<Function>::New(node_isolate, cb);
   }
 
   TryCatch try_catch;
@@ -1826,7 +1826,7 @@ v8::Handle<v8::Value> MemoryUsage(const
 
   // V8 memory usage
   HeapStatistics v8_heap_stats;
-  V8::GetHeapStatistics(&v8_heap_stats);
+  node_isolate->GetHeapStatistics(&v8_heap_stats);
   info->Set(heap_total_symbol,
             Integer::NewFromUnsigned(v8_heap_stats.total_heap_size()));
   info->Set(heap_used_symbol,
@@ -2045,7 +2045,7 @@ static Handle<Value> Binding(const Argum
   node_module_struct* modp;
 
   if (binding_cache.IsEmpty()) {
-    binding_cache = Persistent<Object>::New(Object::New());
+    binding_cache = Persistent<Object>::New(node_isolate, Object::New());
   }
 
   Local<Object> exports;
@@ -2331,7 +2331,8 @@ Handle<Object> SetupProcessObject(int ar
 
   process_template->SetClassName(String::NewSymbol("process"));
 
-  process = Persistent<Object>::New(process_template->GetFunction()->NewInstance());
+  process = Persistent<Object>::New(node_isolate,
+                                process_template->GetFunction()->NewInstance());
 
   process->SetAccessor(String::New("title"),
                        ProcessTitleGetter,
@@ -2341,7 +2342,7 @@ Handle<Object> SetupProcessObject(int ar
   process->Set(String::NewSymbol("version"), String::New(NODE_VERSION));
 
   // process.moduleLoadList
-  module_load_list = Persistent<Array>::New(Array::New());
+  module_load_list = Persistent<Array>::New(node_isolate, Array::New());
   process->Set(String::NewSymbol("moduleLoadList"), module_load_list);
 
   // process.versions
@@ -3010,6 +3011,10 @@ char** Init(int argc, char *argv[]) {
   }
   V8::SetFlagsFromCommandLine(&v8argc, v8argv, false);
 
+  // Fetch a reference to the main isolate, so we have a reference to it
+  // even when we need it to access it from another (debugger) thread.
+  node_isolate = Isolate::GetCurrent();
+
 #ifdef __POSIX__
   // Ignore SIGPIPE
   RegisterSignalHandler(SIGPIPE, SIG_IGN);
@@ -3025,10 +3030,6 @@ char** Init(int argc, char *argv[]) {
 
   V8::SetFatalErrorHandler(node::OnFatalError);
 
-  // Fetch a reference to the main isolate, so we have a reference to it
-  // even when we need it to access it from another (debugger) thread.
-  node_isolate = Isolate::GetCurrent();
-
   // If the --debug flag was specified then initialize the debug thread.
   if (use_debug_agent) {
     EnableDebug(debug_wait_connect);
@@ -3137,7 +3138,7 @@ int Start(int argc, char *argv[]) {
 
   V8::Initialize();
   {
-    Locker locker;
+    Locker locker(node_isolate);
     HandleScope handle_scope;
 
     // Create the one and only Context.
@@ -3163,7 +3164,7 @@ int Start(int argc, char *argv[]) {
     RunAtExit();
 
 #ifndef NDEBUG
-    context.Dispose();
+    context.Dispose(node_isolate);
 #endif
   }
 
Index: node-v0.10.4/src/node.h
===================================================================
--- node-v0.10.4.orig/src/node.h
+++ node-v0.10.4/src/node.h
@@ -86,6 +86,8 @@
 
 namespace node {
 
+extern v8::Isolate* node_isolate;
+
 NODE_EXTERN extern bool no_deprecation;
 
 NODE_EXTERN int Start(int argc, char *argv[]);
@@ -96,7 +98,7 @@ void Load(v8::Handle<v8::Object> process
 void EmitExit(v8::Handle<v8::Object> process);
 
 #define NODE_PSYMBOL(s) \
-  v8::Persistent<v8::String>::New(v8::String::NewSymbol(s))
+  v8::Persistent<v8::String>::New(node_isolate, v8::String::NewSymbol(s))
 
 /* Converts a unixtime to V8 Date */
 #define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t))
@@ -153,7 +155,7 @@ v8::Local<v8::Object> BuildStatsObject(c
 static inline v8::Persistent<v8::Function>* cb_persist(
     const v8::Local<v8::Value> &v) {
   v8::Persistent<v8::Function> *fn = new v8::Persistent<v8::Function>();
-  *fn = v8::Persistent<v8::Function>::New(v8::Local<v8::Function>::Cast(v));
+  *fn = v8::Persistent<v8::Function>::New(node_isolate, v8::Local<v8::Function>::Cast(v));
   return fn;
 }
 
@@ -165,7 +167,7 @@ static inline v8::Persistent<v8::Functio
 }
 
 static inline void cb_destroy(v8::Persistent<v8::Function> * cb) {
-  cb->Dispose();
+  cb->Dispose(node_isolate);
   delete cb;
 }
 
Index: node-v0.10.4/src/node_buffer.cc
===================================================================
--- node-v0.10.4.orig/src/node_buffer.cc
+++ node-v0.10.4/src/node_buffer.cc
@@ -187,7 +187,7 @@ Buffer::Buffer(Handle<Object> wrapper, s
 
   length_ = 0;
   callback_ = NULL;
-  handle_.SetWrapperClassId(BUFFER_CLASS_ID);
+  handle_.SetWrapperClassId(node_isolate, BUFFER_CLASS_ID);
 
   Replace(NULL, length, NULL, NULL);
 }
@@ -208,7 +208,7 @@ void Buffer::Replace(char *data, size_t
     callback_(data_, callback_hint_);
   } else if (length_) {
     delete [] data_;
-    V8::AdjustAmountOfExternalAllocatedMemory(
+    node_isolate->AdjustAmountOfExternalAllocatedMemory(
         -static_cast<intptr_t>(sizeof(Buffer) + length_));
   }
 
@@ -222,7 +222,8 @@ void Buffer::Replace(char *data, size_t
     data_ = new char[length_];
     if (data)
       memcpy(data_, data, length_);
-    V8::AdjustAmountOfExternalAllocatedMemory(sizeof(Buffer) + length_);
+    node_isolate->AdjustAmountOfExternalAllocatedMemory(sizeof(Buffer) +
+                                                        length_);
   } else {
     data_ = NULL;
   }
@@ -1039,7 +1040,8 @@ bool Buffer::HasInstance(Handle<Value> v
 
 Handle<Value> SetFastBufferConstructor(const Arguments& args) {
   assert(args[0]->IsFunction());
-  fast_buffer_constructor = Persistent<Function>::New(args[0].As<Function>());
+  fast_buffer_constructor = Persistent<Function>::New(node_isolate,
+                                                      args[0].As<Function>());
   return Undefined();
 }
 
@@ -1117,7 +1119,7 @@ void Buffer::Initialize(Handle<Object> t
   chars_written_sym = NODE_PSYMBOL("_charsWritten");
 
   Local<FunctionTemplate> t = FunctionTemplate::New(Buffer::New);
-  constructor_template = Persistent<FunctionTemplate>::New(t);
+  constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t);
   constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
   constructor_template->SetClassName(String::NewSymbol("SlowBuffer"));
 
Index: node-v0.10.4/src/node_counters.cc
===================================================================
--- node-v0.10.4.orig/src/node_counters.cc
+++ node-v0.10.4/src/node_counters.cc
@@ -122,7 +122,7 @@ void InitPerfCounters(Handle<Object> tar
   };
 
   for (int i = 0; i < ARRAY_SIZE(tab); i++) {
-    tab[i].templ = Persistent<FunctionTemplate>::New(
+    tab[i].templ = Persistent<FunctionTemplate>::New(node_isolate,
         FunctionTemplate::New(tab[i].func));
     target->Set(String::NewSymbol(tab[i].name), tab[i].templ->GetFunction());
   }
Index: node-v0.10.4/src/node_crypto.cc
===================================================================
--- node-v0.10.4.orig/src/node_crypto.cc
+++ node-v0.10.4/src/node_crypto.cc
@@ -141,7 +141,8 @@ void SecureContext::Initialize(Handle<Ob
   HandleScope scope;
 
   Local<FunctionTemplate> t = FunctionTemplate::New(SecureContext::New);
-  secure_context_constructor = Persistent<FunctionTemplate>::New(t);
+  secure_context_constructor = Persistent<FunctionTemplate>::New(node_isolate,
+                                                                 t);
 
   t->InstanceTemplate()->SetInternalFieldCount(1);
   t->SetClassName(String::NewSymbol("SecureContext"));
@@ -1099,7 +1100,7 @@ int Connection::SelectNextProtoCallback_
 
   // Release old protocol handler if present
   if (!p->selectedNPNProto_.IsEmpty()) {
-    p->selectedNPNProto_.Dispose();
+    p->selectedNPNProto_.Dispose(node_isolate);
   }
 
   if (p->npnProtos_.IsEmpty()) {
@@ -1109,7 +1110,7 @@ int Connection::SelectNextProtoCallback_
     *outlen = 8;
 
     // set status unsupported
-    p->selectedNPNProto_ = Persistent<Value>::New(False());
+    p->selectedNPNProto_ = Persistent<Value>::New(node_isolate, False());
 
     return SSL_TLSEXT_ERR_OK;
   }
@@ -1122,15 +1123,15 @@ int Connection::SelectNextProtoCallback_
 
   switch (status) {
     case OPENSSL_NPN_UNSUPPORTED:
-      p->selectedNPNProto_ = Persistent<Value>::New(Null());
+      p->selectedNPNProto_ = Persistent<Value>::New(node_isolate, Null());
       break;
     case OPENSSL_NPN_NEGOTIATED:
-      p->selectedNPNProto_ = Persistent<Value>::New(String::New(
+      p->selectedNPNProto_ = Persistent<Value>::New(node_isolate, String::New(
                                  reinterpret_cast<const char*>(*out), *outlen
                              ));
       break;
     case OPENSSL_NPN_NO_OVERLAP:
-      p->selectedNPNProto_ = Persistent<Value>::New(False());
+      p->selectedNPNProto_ = Persistent<Value>::New(node_isolate, False());
       break;
     default:
       break;
@@ -1150,14 +1151,15 @@ int Connection::SelectSNIContextCallback
 
   if (servername) {
     if (!p->servername_.IsEmpty()) {
-      p->servername_.Dispose();
+      p->servername_.Dispose(node_isolate);
     }
-    p->servername_ = Persistent<String>::New(String::New(servername));
+    p->servername_ = Persistent<String>::New(node_isolate,
+                                             String::New(servername));
 
     // Call the SNI callback and use its return value as context
     if (!p->sniObject_.IsEmpty()) {
       if (!p->sniContext_.IsEmpty()) {
-        p->sniContext_.Dispose();
+        p->sniContext_.Dispose(node_isolate);
       }
 
       // Get callback init args
@@ -1171,7 +1173,7 @@ int Connection::SelectSNIContextCallback
 
       // If ret is SecureContext
       if (secure_context_constructor->HasInstance(ret)) {
-        p->sniContext_ = Persistent<Value>::New(ret);
+        p->sniContext_ = Persistent<Value>::New(node_isolate, ret);
         SecureContext *sc = ObjectWrap::Unwrap<SecureContext>(
                                 Local<Object>::Cast(ret));
         SSL_set_SSL_CTX(s, sc->ctx_);
@@ -1980,9 +1982,9 @@ Handle<Value> Connection::SetNPNProtocol
 
   // Release old handle
   if (!ss->npnProtos_.IsEmpty()) {
-    ss->npnProtos_.Dispose();
+    ss->npnProtos_.Dispose(node_isolate);
   }
-  ss->npnProtos_ = Persistent<Object>::New(args[0]->ToObject());
+  ss->npnProtos_ = Persistent<Object>::New(node_isolate, args[0]->ToObject());
 
   return True();
 };
@@ -2013,9 +2015,9 @@ Handle<Value> Connection::SetSNICallback
 
   // Release old handle
   if (!ss->sniObject_.IsEmpty()) {
-    ss->sniObject_.Dispose();
+    ss->sniObject_.Dispose(node_isolate);
   }
-  ss->sniObject_ = Persistent<Object>::New(Object::New());
+  ss->sniObject_ = Persistent<Object>::New(node_isolate, Object::New());
   ss->sniObject_->Set(String::New("onselect"), args[0]);
 
   return True();
@@ -3732,7 +3734,7 @@ void EIO_PBKDF2After(uv_work_t* work_req
   Persistent<Object> obj = req->obj;
   EIO_PBKDF2After(req, argv);
   MakeCallback(obj, "ondone", ARRAY_SIZE(argv), argv);
-  obj.Dispose();
+  obj.Dispose(node_isolate);
 }
 
 
@@ -3810,7 +3812,7 @@ Handle<Value> PBKDF2(const Arguments& ar
   req->keylen = keylen;
 
   if (args[4]->IsFunction()) {
-    req->obj = Persistent<Object>::New(Object::New());
+    req->obj = Persistent<Object>::New(node_isolate, Object::New());
     req->obj->Set(String::New("ondone"), args[4]);
     uv_queue_work(uv_default_loop(),
                   &req->work_req,
@@ -3844,7 +3846,7 @@ struct RandomBytesRequest {
 
 RandomBytesRequest::~RandomBytesRequest() {
   if (obj_.IsEmpty()) return;
-  obj_.Dispose();
+  obj_.Dispose(node_isolate);
   obj_.Clear();
 }
 
@@ -3932,7 +3934,7 @@ Handle<Value> RandomBytes(const Argument
   req->size_ = size;
 
   if (args[1]->IsFunction()) {
-    req->obj_ = Persistent<Object>::New(Object::New());
+    req->obj_ = Persistent<Object>::New(node_isolate, Object::New());
     req->obj_->Set(String::New("ondone"), args[1]);
 
     uv_queue_work(uv_default_loop(),
Index: node-v0.10.4/src/node_crypto.h
===================================================================
--- node-v0.10.4.orig/src/node_crypto.h
+++ node-v0.10.4/src/node_crypto.h
@@ -247,14 +247,14 @@ class Connection : ObjectWrap {
     }
 
 #ifdef OPENSSL_NPN_NEGOTIATED
-    if (!npnProtos_.IsEmpty()) npnProtos_.Dispose();
-    if (!selectedNPNProto_.IsEmpty()) selectedNPNProto_.Dispose();
+    if (!npnProtos_.IsEmpty()) npnProtos_.Dispose(node_isolate);
+    if (!selectedNPNProto_.IsEmpty()) selectedNPNProto_.Dispose(node_isolate);
 #endif
 
 #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
-   if (!sniObject_.IsEmpty()) sniObject_.Dispose();
-   if (!sniContext_.IsEmpty()) sniContext_.Dispose();
-   if (!servername_.IsEmpty()) servername_.Dispose();
+   if (!sniObject_.IsEmpty()) sniObject_.Dispose(node_isolate);
+   if (!sniContext_.IsEmpty()) sniContext_.Dispose(node_isolate);
+   if (!servername_.IsEmpty()) servername_.Dispose(node_isolate);
 #endif
   }
 
Index: node-v0.10.4/src/node_dtrace.cc
===================================================================
--- node-v0.10.4.orig/src/node_dtrace.cc
+++ node-v0.10.4/src/node_dtrace.cc
@@ -380,7 +380,7 @@ void InitDTrace(Handle<Object> target) {
   };
 
   for (unsigned int i = 0; i < ARRAY_SIZE(tab); i++) {
-    tab[i].templ = Persistent<FunctionTemplate>::New(
+    tab[i].templ = Persistent<FunctionTemplate>::New(node_isolate,
         FunctionTemplate::New(tab[i].func));
     target->Set(String::NewSymbol(tab[i].name), tab[i].templ->GetFunction());
   }
Index: node-v0.10.4/src/node_file.cc
===================================================================
--- node-v0.10.4.orig/src/node_file.cc
+++ node-v0.10.4/src/node_file.cc
@@ -954,7 +954,8 @@ void InitFs(Handle<Object> target) {
   HandleScope scope;
   // Initialize the stats object
   Local<FunctionTemplate> stat_templ = FunctionTemplate::New();
-  stats_constructor_template = Persistent<FunctionTemplate>::New(stat_templ);
+  stats_constructor_template = Persistent<FunctionTemplate>::New(node_isolate,
+                                                                 stat_templ);
   target->Set(String::NewSymbol("Stats"),
                stats_constructor_template->GetFunction());
   File::Initialize(target);
Index: node-v0.10.4/src/node_internals.h
===================================================================
--- node-v0.10.4.orig/src/node_internals.h
+++ node-v0.10.4/src/node_internals.h
@@ -99,7 +99,7 @@ inline static v8::Handle<v8::Value> Thro
   assert(!args.Holder().IsEmpty());                                         \
   assert(args.Holder()->InternalFieldCount() > 0);                          \
   type* wrap = static_cast<type*>(                                          \
-      args.Holder()->GetPointerFromInternalField(0));                \
+      args.Holder()->GetAlignedPointerFromInternalField(0));                \
   if (!wrap) {                                                              \
     fprintf(stderr, #type ": Aborting due to unwrap failure at %s:%d\n",    \
             __FILE__, __LINE__);                                            \
Index: node-v0.10.4/src/node_object_wrap.h
===================================================================
--- node-v0.10.4.orig/src/node_object_wrap.h
+++ node-v0.10.4/src/node_object_wrap.h
@@ -37,6 +37,8 @@
 
 namespace node {
 
+extern v8::Isolate* node_isolate;
+
 class NODE_EXTERN ObjectWrap {
  public:
   ObjectWrap ( ) {
@@ -46,10 +48,10 @@ class NODE_EXTERN ObjectWrap {
 
   virtual ~ObjectWrap ( ) {
     if (!handle_.IsEmpty()) {
-      assert(handle_.IsNearDeath());
-      handle_.ClearWeak();
-      handle_->SetPointerInInternalField(0, 0);
-      handle_.Dispose();
+      assert(handle_.IsNearDeath(node_isolate));
+      handle_.ClearWeak(node_isolate);
+      handle_->SetAlignedPointerInInternalField(0, 0);
+      handle_.Dispose(node_isolate);
       handle_.Clear();
     }
   }
@@ -59,7 +61,7 @@ class NODE_EXTERN ObjectWrap {
   static inline T* Unwrap (v8::Handle<v8::Object> handle) {
     assert(!handle.IsEmpty());
     assert(handle->InternalFieldCount() > 0);
-    return static_cast<T*>(handle->GetPointerFromInternalField(0));
+    return static_cast<T*>(handle->GetAlignedPointerFromInternalField(0));
   }
 
 
@@ -69,15 +71,15 @@ class NODE_EXTERN ObjectWrap {
   inline void Wrap (v8::Handle<v8::Object> handle) {
     assert(handle_.IsEmpty());
     assert(handle->InternalFieldCount() > 0);
-    handle_ = v8::Persistent<v8::Object>::New(handle);
-    handle_->SetPointerInInternalField(0, this);
+    handle_ = v8::Persistent<v8::Object>::New(node_isolate, handle);
+    handle_->SetAlignedPointerInInternalField(0, this);
     MakeWeak();
   }
 
 
   inline void MakeWeak (void) {
-    handle_.MakeWeak(this, WeakCallback);
-    handle_.MarkIndependent();
+    handle_.MakeWeak(node_isolate, this, WeakCallback);
+    handle_.MarkIndependent(node_isolate);
   }
 
   /* Ref() marks the object as being attached to an event loop.
@@ -87,7 +89,7 @@ class NODE_EXTERN ObjectWrap {
   virtual void Ref() {
     assert(!handle_.IsEmpty());
     refs_++;
-    handle_.ClearWeak();
+    handle_.ClearWeak(node_isolate);
   }
 
   /* Unref() marks an object as detached from the event loop.  This is its
@@ -101,7 +103,7 @@ class NODE_EXTERN ObjectWrap {
    */
   virtual void Unref() {
     assert(!handle_.IsEmpty());
-    assert(!handle_.IsWeak());
+    assert(!handle_.IsWeak(node_isolate));
     assert(refs_ > 0);
     if (--refs_ == 0) { MakeWeak(); }
   }
@@ -111,13 +113,15 @@ class NODE_EXTERN ObjectWrap {
 
 
  private:
-  static void WeakCallback (v8::Persistent<v8::Value> value, void *data) {
+  static void WeakCallback(v8::Isolate* env,
+                           v8::Persistent<v8::Value> value,
+                           void* data) {
     v8::HandleScope scope;
 
     ObjectWrap *obj = static_cast<ObjectWrap*>(data);
     assert(value == obj->handle_);
     assert(!obj->refs_);
-    assert(value.IsNearDeath());
+    assert(value.IsNearDeath(env));
     delete obj;
   }
 };
Index: node-v0.10.4/src/node_script.cc
===================================================================
--- node-v0.10.4.orig/src/node_script.cc
+++ node-v0.10.4/src/node_script.cc
@@ -124,7 +124,8 @@ void CloneObject(Handle<Object> recv,
         })"
       ), String::New("binding:script"))->Run()
     );
-    cloneObjectMethod = Persistent<Function>::New(cloneObjectMethod_);
+    cloneObjectMethod = Persistent<Function>::New(node_isolate,
+                                                  cloneObjectMethod_);
   }
 
   cloneObjectMethod->Call(recv, 2, args);
@@ -135,7 +136,7 @@ void WrappedContext::Initialize(Handle<O
   HandleScope scope;
 
   Local<FunctionTemplate> t = FunctionTemplate::New(WrappedContext::New);
-  constructor_template = Persistent<FunctionTemplate>::New(t);
+  constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t);
   constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
   constructor_template->SetClassName(String::NewSymbol("Context"));
 
@@ -165,7 +166,7 @@ WrappedContext::WrappedContext() : Objec
 
 
 WrappedContext::~WrappedContext() {
-  context_.Dispose();
+  context_.Dispose(node_isolate);
 }
 
 
@@ -187,7 +188,7 @@ void WrappedScript::Initialize(Handle<Ob
   HandleScope scope;
 
   Local<FunctionTemplate> t = FunctionTemplate::New(WrappedScript::New);
-  constructor_template = Persistent<FunctionTemplate>::New(t);
+  constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t);
   constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
   // Note: We use 'NodeScript' instead of 'Script' so that we do not
   // conflict with V8's Script class defined in v8/src/messages.js
@@ -247,7 +248,7 @@ Handle<Value> WrappedScript::New(const A
 
 
 WrappedScript::~WrappedScript() {
-  script_.Dispose();
+  script_.Dispose(node_isolate);
 }
 
 
@@ -364,7 +365,7 @@ Handle<Value> WrappedScript::EvalMachine
     // that when this function exits the context will be disposed.
     Persistent<Context> tmp = Context::New();
     context = Local<Context>::New(tmp);
-    tmp.Dispose();
+    tmp.Dispose(node_isolate);
 
   } else if (context_flag == userContext) {
     // Use the passed in context
Index: node-v0.10.4/src/node_stat_watcher.cc
===================================================================
--- node-v0.10.4.orig/src/node_stat_watcher.cc
+++ node-v0.10.4/src/node_stat_watcher.cc
@@ -38,7 +38,7 @@ void StatWatcher::Initialize(Handle<Obje
   HandleScope scope;
 
   Local<FunctionTemplate> t = FunctionTemplate::New(StatWatcher::New);
-  constructor_template = Persistent<FunctionTemplate>::New(t);
+  constructor_template = Persistent<FunctionTemplate>::New(node_isolate, t);
   constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
   constructor_template->SetClassName(String::NewSymbol("StatWatcher"));
 
Index: node-v0.10.4/src/node_zlib.cc
===================================================================
--- node-v0.10.4.orig/src/node_zlib.cc
+++ node-v0.10.4/src/node_zlib.cc
@@ -89,11 +89,11 @@ class ZCtx : public ObjectWrap {
 
     if (mode_ == DEFLATE || mode_ == GZIP || mode_ == DEFLATERAW) {
       (void)deflateEnd(&strm_);
-      V8::AdjustAmountOfExternalAllocatedMemory(-kDeflateContextSize);
+      node_isolate->AdjustAmountOfExternalAllocatedMemory(-kDeflateContextSize);
     } else if (mode_ == INFLATE || mode_ == GUNZIP || mode_ == INFLATERAW ||
                mode_ == UNZIP) {
       (void)inflateEnd(&strm_);
-      V8::AdjustAmountOfExternalAllocatedMemory(-kInflateContextSize);
+      node_isolate->AdjustAmountOfExternalAllocatedMemory(-kInflateContextSize);
     }
     mode_ = NONE;
 
@@ -406,14 +406,16 @@ class ZCtx : public ObjectWrap {
                                  ctx->windowBits_,
                                  ctx->memLevel_,
                                  ctx->strategy_);
-        V8::AdjustAmountOfExternalAllocatedMemory(kDeflateContextSize);
+        node_isolate->
+                    AdjustAmountOfExternalAllocatedMemory(kDeflateContextSize);
         break;
       case INFLATE:
       case GUNZIP:
       case INFLATERAW:
       case UNZIP:
         ctx->err_ = inflateInit2(&ctx->strm_, ctx->windowBits_);
-        V8::AdjustAmountOfExternalAllocatedMemory(kInflateContextSize);
+        node_isolate->
+                    AdjustAmountOfExternalAllocatedMemory(kInflateContextSize);
         break;
       default:
         assert(0 && "wtf?");
Index: node-v0.10.4/src/pipe_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/pipe_wrap.cc
+++ node-v0.10.4/src/pipe_wrap.cc
@@ -69,7 +69,7 @@ Local<Object> PipeWrap::Instantiate() {
 PipeWrap* PipeWrap::Unwrap(Local<Object> obj) {
   assert(!obj.IsEmpty());
   assert(obj->InternalFieldCount() > 0);
-  return static_cast<PipeWrap*>(obj->GetPointerFromInternalField(0));
+  return static_cast<PipeWrap*>(obj->GetAlignedPointerFromInternalField(0));
 }
 
 
@@ -114,7 +114,7 @@ void PipeWrap::Initialize(Handle<Object>
   NODE_SET_PROTOTYPE_METHOD(t, "setPendingInstances", SetPendingInstances);
 #endif
 
-  pipeConstructor = Persistent<Function>::New(t->GetFunction());
+  pipeConstructor = Persistent<Function>::New(node_isolate, t->GetFunction());
 
   target->Set(String::NewSymbol("Pipe"), pipeConstructor);
 }
@@ -214,7 +214,7 @@ void PipeWrap::OnConnection(uv_stream_t*
   // Unwrap the client javascript object.
   assert(client_obj->InternalFieldCount() > 0);
   PipeWrap* client_wrap =
-      static_cast<PipeWrap*>(client_obj->GetPointerFromInternalField(0));
+      static_cast<PipeWrap*>(client_obj->GetAlignedPointerFromInternalField(0));
 
   if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;
 
Index: node-v0.10.4/src/req_wrap.h
===================================================================
--- node-v0.10.4.orig/src/req_wrap.h
+++ node-v0.10.4/src/req_wrap.h
@@ -36,7 +36,7 @@ class ReqWrap {
  public:
   ReqWrap() {
     v8::HandleScope scope;
-    object_ = v8::Persistent<v8::Object>::New(v8::Object::New());
+    object_ = v8::Persistent<v8::Object>::New(node_isolate, v8::Object::New());
 
     v8::Local<v8::Value> domain = v8::Context::GetCurrent()
                                   ->Global()
@@ -58,7 +58,7 @@ class ReqWrap {
     // Assert that someone has called Dispatched()
     assert(req_.data == this);
     assert(!object_.IsEmpty());
-    object_.Dispose();
+    object_.Dispose(node_isolate);
     object_.Clear();
   }
 
Index: node-v0.10.4/src/slab_allocator.cc
===================================================================
--- node-v0.10.4.orig/src/slab_allocator.cc
+++ node-v0.10.4/src/slab_allocator.cc
@@ -51,9 +51,9 @@ SlabAllocator::SlabAllocator(unsigned in
 SlabAllocator::~SlabAllocator() {
   if (!initialized_) return;
   if (V8::IsDead()) return;
-  slab_sym_.Dispose();
+  slab_sym_.Dispose(node_isolate);
   slab_sym_.Clear();
-  slab_.Dispose();
+  slab_.Dispose(node_isolate);
   slab_.Clear();
 }
 
@@ -65,7 +65,7 @@ void SlabAllocator::Initialize() {
   offset_ = 0;
   last_ptr_ = NULL;
   initialized_ = true;
-  slab_sym_ = Persistent<String>::New(String::New(sym));
+  slab_sym_ = Persistent<String>::New(node_isolate, String::New(sym));
 }
 
 
@@ -94,9 +94,9 @@ char* SlabAllocator::Allocate(Handle<Obj
   }
 
   if (slab_.IsEmpty() || offset_ + size > size_) {
-    slab_.Dispose();
+    slab_.Dispose(node_isolate);
     slab_.Clear();
-    slab_ = Persistent<Object>::New(NewSlab(size_));
+    slab_ = Persistent<Object>::New(node_isolate, NewSlab(size_));
     offset_ = 0;
     last_ptr_ = NULL;
   }
Index: node-v0.10.4/src/stream_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/stream_wrap.cc
+++ node-v0.10.4/src/stream_wrap.cc
@@ -199,7 +199,7 @@ static Local<Object> AcceptHandle(uv_str
     return Local<Object>();
 
   wrap = static_cast<WrapType*>(
-      wrap_obj->GetPointerFromInternalField(0));
+      wrap_obj->GetAlignedPointerFromInternalField(0));
   handle = wrap->UVHandle();
 
   if (uv_accept(pipe, reinterpret_cast<uv_stream_t*>(handle)))
@@ -436,7 +436,7 @@ Handle<Value> StreamWrap::WriteStringImp
       Local<Object> send_handle_obj = args[1]->ToObject();
       assert(send_handle_obj->InternalFieldCount() > 0);
       HandleWrap* send_handle_wrap = static_cast<HandleWrap*>(
-          send_handle_obj->GetPointerFromInternalField(0));
+          send_handle_obj->GetAlignedPointerFromInternalField(0));
       send_handle = send_handle_wrap->GetHandle();
 
       // Reference StreamWrap instance to prevent it from being garbage
Index: node-v0.10.4/src/tcp_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/tcp_wrap.cc
+++ node-v0.10.4/src/tcp_wrap.cc
@@ -119,7 +119,7 @@ void TCPWrap::Initialize(Handle<Object>
   NODE_SET_PROTOTYPE_METHOD(t, "setSimultaneousAccepts", SetSimultaneousAccepts);
 #endif
 
-  tcpConstructor = Persistent<Function>::New(t->GetFunction());
+  tcpConstructor = Persistent<Function>::New(node_isolate, t->GetFunction());
 
   onconnection_sym = NODE_PSYMBOL("onconnection");
   oncomplete_sym = NODE_PSYMBOL("oncomplete");
@@ -131,7 +131,7 @@ void TCPWrap::Initialize(Handle<Object>
 TCPWrap* TCPWrap::Unwrap(Local<Object> obj) {
   assert(!obj.IsEmpty());
   assert(obj->InternalFieldCount() > 0);
-  return static_cast<TCPWrap*>(obj->GetPointerFromInternalField(0));
+  return static_cast<TCPWrap*>(obj->GetAlignedPointerFromInternalField(0));
 }
 
 
@@ -337,7 +337,7 @@ void TCPWrap::OnConnection(uv_stream_t*
     // Unwrap the client javascript object.
     assert(client_obj->InternalFieldCount() > 0);
     TCPWrap* client_wrap = static_cast<TCPWrap*>(
-        client_obj->GetPointerFromInternalField(0));
+        client_obj->GetAlignedPointerFromInternalField(0));
 
     if (uv_accept(handle, (uv_stream_t*)&client_wrap->handle_)) return;
 
Index: node-v0.10.4/src/tty_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/tty_wrap.cc
+++ node-v0.10.4/src/tty_wrap.cc
@@ -88,7 +88,7 @@ void TTYWrap::Initialize(Handle<Object>
 TTYWrap* TTYWrap::Unwrap(Local<Object> obj) {
   assert(!obj.IsEmpty());
   assert(obj->InternalFieldCount() > 0);
-  return static_cast<TTYWrap*>(obj->GetPointerFromInternalField(0));
+  return static_cast<TTYWrap*>(obj->GetAlignedPointerFromInternalField(0));
 }
 
 
Index: node-v0.10.4/src/udp_wrap.cc
===================================================================
--- node-v0.10.4.orig/src/udp_wrap.cc
+++ node-v0.10.4/src/udp_wrap.cc
@@ -123,8 +123,8 @@ void UDPWrap::Initialize(Handle<Object>
   NODE_SET_PROTOTYPE_METHOD(t, "ref", HandleWrap::Ref);
   NODE_SET_PROTOTYPE_METHOD(t, "unref", HandleWrap::Unref);
 
-  constructor = Persistent<Function>::New(
-      Persistent<FunctionTemplate>::New(t)->GetFunction());
+  constructor = Persistent<Function>::New(node_isolate,
+      Persistent<FunctionTemplate>::New(node_isolate, t)->GetFunction());
   target->Set(String::NewSymbol("UDP"), constructor);
 }
 
@@ -427,7 +427,7 @@ void UDPWrap::OnRecv(uv_udp_t* handle,
 UDPWrap* UDPWrap::Unwrap(Local<Object> obj) {
   assert(!obj.IsEmpty());
   assert(obj->InternalFieldCount() > 0);
-  return static_cast<UDPWrap*>(obj->GetPointerFromInternalField(0));
+  return static_cast<UDPWrap*>(obj->GetAlignedPointerFromInternalField(0));
 }
 
 
Index: node-v0.10.4/src/v8_typed_array.cc
===================================================================
--- node-v0.10.4.orig/src/v8_typed_array.cc
+++ node-v0.10.4/src/v8_typed_array.cc
@@ -48,7 +48,7 @@ class ArrayBuffer {
       return ft_cache;
 
     v8::HandleScope scope;
-    ft_cache = v8::Persistent<v8::FunctionTemplate>::New(
+    ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate,
         v8::FunctionTemplate::New(&ArrayBuffer::V8New));
     ft_cache->SetClassName(v8::String::New("ArrayBuffer"));
     v8::Local<v8::ObjectTemplate> instance = ft_cache->InstanceTemplate();
@@ -69,7 +69,9 @@ class ArrayBuffer {
   }
 
  private:
-  static void WeakCallback(v8::Persistent<v8::Value> value, void* data) {
+  static void WeakCallback(v8::Isolate* env,
+                           v8::Persistent<v8::Value> value,
+                           void* data) {
     v8::Object* obj = v8::Object::Cast(*value);
 
     void* ptr = obj->GetIndexedPropertiesExternalArrayData();
@@ -78,10 +80,10 @@ class ArrayBuffer {
     int size =
         obj->GetIndexedPropertiesExternalArrayDataLength() * element_size;
 
-    v8::V8::AdjustAmountOfExternalAllocatedMemory(-size);
+    node::node_isolate->AdjustAmountOfExternalAllocatedMemory(-size);
 
-    value.ClearWeak();
-    value.Dispose();
+    value.ClearWeak(env);
+    value.Dispose(env);
 
     free(ptr);
   }
@@ -108,7 +110,7 @@ class ArrayBuffer {
     if (!buf)
       return ThrowError("Unable to allocate ArrayBuffer.");
 
-    args.This()->SetPointerInInternalField(0, buf);
+    args.This()->SetAlignedPointerInInternalField(0, buf);
 
     args.This()->Set(v8::String::New("byteLength"),
                      v8::Integer::NewFromUnsigned(num_bytes),
@@ -121,11 +123,11 @@ class ArrayBuffer {
     args.This()->SetIndexedPropertiesToExternalArrayData(
         buf, v8::kExternalUnsignedByteArray, num_bytes);
 
-    v8::V8::AdjustAmountOfExternalAllocatedMemory(num_bytes);
+    node::node_isolate->AdjustAmountOfExternalAllocatedMemory(num_bytes);
 
     v8::Persistent<v8::Object> persistent =
-        v8::Persistent<v8::Object>::New(args.This());
-    persistent.MakeWeak(NULL, &ArrayBuffer::WeakCallback);
+        v8::Persistent<v8::Object>::New(node::node_isolate, args.This());
+    persistent.MakeWeak(node::node_isolate, NULL, &ArrayBuffer::WeakCallback);
 
     return args.This();
   }
@@ -159,8 +161,8 @@ class ArrayBuffer {
 
     if (buffer.IsEmpty()) return v8::Undefined();  // constructor failed
 
-    void* src = args.This()->GetPointerFromInternalField(0);
-    void* dest = buffer->GetPointerFromInternalField(0);
+    void* src = args.This()->GetAlignedPointerFromInternalField(0);
+    void* dest = buffer->GetAlignedPointerFromInternalField(0);
     memcpy(dest, static_cast<char*>(src) + begin, slice_length);
 
     return buffer;
@@ -204,7 +206,7 @@ class TypedArray {
       return ft_cache;
 
     v8::HandleScope scope;
-    ft_cache = v8::Persistent<v8::FunctionTemplate>::New(
+    ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate,
         v8::FunctionTemplate::New(&TypedArray<TBytes, TEAType>::V8New));
     ft_cache->SetClassName(v8::String::New(TEANameTrait<TEAType>::name));
     v8::Local<v8::ObjectTemplate> instance = ft_cache->InstanceTemplate();
@@ -298,7 +300,7 @@ class TypedArray {
                  GetFunction()->NewInstance(1, argv);
       if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed
 
-      void* buf = buffer->GetPointerFromInternalField(0);
+      void* buf = buffer->GetAlignedPointerFromInternalField(0);
       args.This()->SetIndexedPropertiesToExternalArrayData(
           buf, TEAType, length);
       // TODO(deanm): check for failure.
@@ -327,7 +329,7 @@ class TypedArray {
                  GetFunction()->NewInstance(1, argv);
       if (buffer.IsEmpty()) return v8::Undefined(); // constructor failed
 
-      void* buf = buffer->GetPointerFromInternalField(0);
+      void* buf = buffer->GetAlignedPointerFromInternalField(0);
       args.This()->SetIndexedPropertiesToExternalArrayData(
           buf, TEAType, length);
       // TODO(deanm): check for failure.
@@ -569,7 +571,7 @@ class DataView {
       return ft_cache;
 
     v8::HandleScope scope;
-    ft_cache = v8::Persistent<v8::FunctionTemplate>::New(
+    ft_cache = v8::Persistent<v8::FunctionTemplate>::New(node::node_isolate,
         v8::FunctionTemplate::New(&DataView::V8New));
     ft_cache->SetClassName(v8::String::New("DataView"));
     v8::Local<v8::ObjectTemplate> instance = ft_cache->InstanceTemplate();
Index: node-v0.10.4/test/message/error_exit.out
===================================================================
--- node-v0.10.4.orig/test/message/error_exit.out
+++ node-v0.10.4/test/message/error_exit.out
@@ -3,7 +3,7 @@ Exiting with code=1
 assert.js:*
   throw new assert.AssertionError({
         ^
-AssertionError: 1 == 2
+AssertionError
     at Object.<anonymous> (*test*message*error_exit.js:*:*)
     at Module._compile (module.js:*:*)
     at Object.Module._extensions..js (module.js:*:*)
Index: node-v0.10.4/test/message/stack_overflow.js
===================================================================
--- node-v0.10.4.orig/test/message/stack_overflow.js
+++ node-v0.10.4/test/message/stack_overflow.js
@@ -25,6 +25,8 @@
 var common = require('../common');
 var assert = require('assert');
 
+Error.stackTraceLimit = 0;
+
 common.error('before');
 
 // stack overflow
Index: node-v0.10.4/test/message/stack_overflow.out
===================================================================
--- node-v0.10.4.orig/test/message/stack_overflow.out
+++ node-v0.10.4/test/message/stack_overflow.out
@@ -1,6 +1,6 @@
 before
 
-*test*message*stack_overflow.js:31
+*test*message*stack_overflow.js:*
 function stackOverflow() {
                       ^
 RangeError: Maximum call stack size exceeded