Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Norris <trev.norris@gmail.com>2013-03-19 00:54:00 +0400
committerBen Noordhuis <info@bnoordhuis.nl>2013-03-20 04:11:01 +0400
commit0bba59028381c146b90411d43425a18415d85f98 (patch)
tree173ffbc09c11ed471c17b6f7609cc89fb26e2755
parent06bec0e08737ee6c3e165ec6dd16b54ffe1b4c91 (diff)
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.
-rw-r--r--lib/fs.js3
-rw-r--r--src/cares_wrap.cc4
-rw-r--r--src/fs_event_wrap.cc5
-rw-r--r--src/handle_wrap.cc10
-rw-r--r--src/handle_wrap.h2
-rw-r--r--src/node.cc27
-rw-r--r--src/node.h8
-rw-r--r--src/node_buffer.cc12
-rw-r--r--src/node_counters.cc2
-rw-r--r--src/node_crypto.cc38
-rw-r--r--src/node_crypto.h10
-rw-r--r--src/node_dtrace.cc2
-rw-r--r--src/node_file.cc3
-rw-r--r--src/node_internals.h2
-rw-r--r--src/node_object_wrap.h28
-rw-r--r--src/node_script.cc13
-rw-r--r--src/node_stat_watcher.cc2
-rw-r--r--src/node_zlib.cc10
-rw-r--r--src/pipe_wrap.cc6
-rw-r--r--src/req_wrap.h4
-rw-r--r--src/slab_allocator.cc10
-rw-r--r--src/stream_wrap.cc4
-rw-r--r--src/tcp_wrap.cc6
-rw-r--r--src/tty_wrap.cc2
-rw-r--r--src/udp_wrap.cc6
-rw-r--r--src/v8_typed_array.cc32
-rw-r--r--test/message/error_exit.out2
-rw-r--r--test/message/stack_overflow.js2
-rw-r--r--test/message/stack_overflow.out2
29 files changed, 139 insertions, 118 deletions
diff --git a/lib/fs.js b/lib/fs.js
index 3d37a648a7a..e637e03f6df 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -63,7 +63,8 @@ function rethrow() {
var backtrace = new Error;
return function(err) {
if (err) {
- backtrace.message = err.message;
+ backtrace.stack = err.name + ': ' + err.message +
+ backtrace.stack.substr(backtrace.name.length);
err = backtrace;
throw err;
}
diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc
index b7ba82870f5..fa6302b1b2b 100644
--- a/src/cares_wrap.cc
+++ b/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();
}
diff --git a/src/fs_event_wrap.cc b/src/fs_event_wrap.cc
index 7e3eb8c5297..f85f12c8127 100644
--- a/src/fs_event_wrap.cc
+++ b/src/fs_event_wrap.cc
@@ -74,7 +74,8 @@ void FSEventWrap::Initialize(Handle<Object> target) {
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 Arguments& args) {
// 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) {
diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc
index 3f05c7d81b5..99fb6bf853b 100644
--- a/src/handle_wrap.cc
+++ b/src/handle_wrap.cc
@@ -84,7 +84,7 @@ Handle<Value> HandleWrap::Close(const Arguments& args) {
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> object, uv_handle_t* h) {
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* handle) {
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;
diff --git a/src/handle_wrap.h b/src/handle_wrap.h
index dbefc2a1140..7c88a61d87a 100644
--- a/src/handle_wrap.h
+++ b/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:
diff --git a/src/node.cc b/src/node.cc
index e17baec825e..a8587deb5a3 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -195,7 +195,7 @@ static void Spin(uv_idle_t* handle, int status) {
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;
@@ -912,7 +912,7 @@ MakeDomainCallback(const Handle<Object> object,
abort();
}
Local<Function> cb = cb_v.As<Function>();
- process_tickDomainCallback = Persistent<Function>::New(cb);
+ process_tickDomainCallback = Persistent<Function>::New(node_isolate, cb);
}
// lazy load domain specific symbols
@@ -1002,7 +1002,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;
@@ -1802,7 +1802,7 @@ v8::Handle<v8::Value> MemoryUsage(const v8::Arguments& args) {
// 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,
@@ -2021,7 +2021,7 @@ static Handle<Value> Binding(const Arguments& args) {
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;
@@ -2307,7 +2307,8 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
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,
@@ -2317,7 +2318,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
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
@@ -2984,6 +2985,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);
@@ -2999,10 +3004,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);
@@ -3111,7 +3112,7 @@ int Start(int argc, char *argv[]) {
V8::Initialize();
{
- Locker locker;
+ Locker locker(node_isolate);
HandleScope handle_scope;
// Create the one and only Context.
@@ -3137,7 +3138,7 @@ int Start(int argc, char *argv[]) {
RunAtExit();
#ifndef NDEBUG
- context.Dispose();
+ context.Dispose(node_isolate);
#endif
}
diff --git a/src/node.h b/src/node.h
index 5769a7b9ceb..d01dc40adc4 100644
--- a/src/node.h
+++ b/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(const uv_statbuf_t* s);
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::Function>* cb_unwrap(void *data) {
}
static inline void cb_destroy(v8::Persistent<v8::Function> * cb) {
- cb->Dispose();
+ cb->Dispose(node_isolate);
delete cb;
}
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index 21960f88528..55cf91d1cba 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -187,7 +187,7 @@ Buffer::Buffer(Handle<Object> wrapper, size_t length) : ObjectWrap() {
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 length,
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 length,
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> val) {
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> target) {
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"));
diff --git a/src/node_counters.cc b/src/node_counters.cc
index 3c8d49c00b4..c5726842a66 100644
--- a/src/node_counters.cc
+++ b/src/node_counters.cc
@@ -122,7 +122,7 @@ void InitPerfCounters(Handle<Object> target) {
};
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());
}
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index bc8d6db3b23..ff5848fac73 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -141,7 +141,8 @@ void SecureContext::Initialize(Handle<Object> target) {
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"));
@@ -1094,7 +1095,7 @@ int Connection::SelectNextProtoCallback_(SSL *s,
// Release old protocol handler if present
if (!p->selectedNPNProto_.IsEmpty()) {
- p->selectedNPNProto_.Dispose();
+ p->selectedNPNProto_.Dispose(node_isolate);
}
if (p->npnProtos_.IsEmpty()) {
@@ -1104,7 +1105,7 @@ int Connection::SelectNextProtoCallback_(SSL *s,
*outlen = 8;
// set status unsupported
- p->selectedNPNProto_ = Persistent<Value>::New(False());
+ p->selectedNPNProto_ = Persistent<Value>::New(node_isolate, False());
return SSL_TLSEXT_ERR_OK;
}
@@ -1117,15 +1118,15 @@ int Connection::SelectNextProtoCallback_(SSL *s,
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;
@@ -1145,14 +1146,15 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
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
@@ -1166,7 +1168,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
// 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_);
@@ -1993,9 +1995,9 @@ Handle<Value> Connection::SetNPNProtocols(const Arguments& args) {
// 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();
};
@@ -2026,9 +2028,9 @@ Handle<Value> Connection::SetSNICallback(const Arguments& args) {
// 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();
@@ -3294,7 +3296,7 @@ void EIO_PBKDF2After(uv_work_t* work_req, int status) {
Persistent<Object> obj = req->obj;
EIO_PBKDF2After(req, argv);
MakeCallback(obj, "ondone", ARRAY_SIZE(argv), argv);
- obj.Dispose();
+ obj.Dispose(node_isolate);
}
@@ -3372,7 +3374,7 @@ Handle<Value> PBKDF2(const Arguments& args) {
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,
@@ -3406,7 +3408,7 @@ struct RandomBytesRequest {
RandomBytesRequest::~RandomBytesRequest() {
if (obj_.IsEmpty()) return;
- obj_.Dispose();
+ obj_.Dispose(node_isolate);
obj_.Clear();
}
@@ -3492,7 +3494,7 @@ Handle<Value> RandomBytes(const Arguments& args) {
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(),
diff --git a/src/node_crypto.h b/src/node_crypto.h
index 825823e854c..0ceb1f69c97 100644
--- a/src/node_crypto.h
+++ b/src/node_crypto.h
@@ -249,14 +249,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
}
diff --git a/src/node_dtrace.cc b/src/node_dtrace.cc
index df42af2a977..534b3b9670b 100644
--- a/src/node_dtrace.cc
+++ b/src/node_dtrace.cc
@@ -373,7 +373,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());
}
diff --git a/src/node_file.cc b/src/node_file.cc
index c4441bd1255..52a300a18cf 100644
--- a/src/node_file.cc
+++ b/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);
diff --git a/src/node_internals.h b/src/node_internals.h
index 10b1742fb54..794770874ee 100644
--- a/src/node_internals.h
+++ b/src/node_internals.h
@@ -99,7 +99,7 @@ inline static v8::Handle<v8::Value> ThrowRangeError(const char* errmsg) {
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__); \
diff --git a/src/node_object_wrap.h b/src/node_object_wrap.h
index c7fa3eb9ba5..4f86da3f3af 100644
--- a/src/node_object_wrap.h
+++ b/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();
+ assert(handle_.IsNearDeath(node_isolate));
+ handle_.ClearWeak(node_isolate);
handle_->SetInternalField(0, v8::Undefined());
- handle_.Dispose();
+ 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;
}
};
diff --git a/src/node_script.cc b/src/node_script.cc
index 15c56122c7d..ca7b9404a70 100644
--- a/src/node_script.cc
+++ b/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<Object> target) {
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() : ObjectWrap() {
WrappedContext::~WrappedContext() {
- context_.Dispose();
+ context_.Dispose(node_isolate);
}
@@ -187,7 +188,7 @@ void WrappedScript::Initialize(Handle<Object> target) {
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 Arguments& args) {
WrappedScript::~WrappedScript() {
- script_.Dispose();
+ script_.Dispose(node_isolate);
}
@@ -364,7 +365,7 @@ Handle<Value> WrappedScript::EvalMachine(const Arguments& args) {
// 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
diff --git a/src/node_stat_watcher.cc b/src/node_stat_watcher.cc
index c3f668c086f..4eaad499de3 100644
--- a/src/node_stat_watcher.cc
+++ b/src/node_stat_watcher.cc
@@ -38,7 +38,7 @@ void StatWatcher::Initialize(Handle<Object> target) {
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"));
diff --git a/src/node_zlib.cc b/src/node_zlib.cc
index ebaba6bb114..d15f371b54b 100644
--- a/src/node_zlib.cc
+++ b/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?");
diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc
index 3952a0799c4..6d651b88207 100644
--- a/src/pipe_wrap.cc
+++ b/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> target) {
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* handle, int status) {
// 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;
diff --git a/src/req_wrap.h b/src/req_wrap.h
index ba56821bbef..1251cea6db9 100644
--- a/src/req_wrap.h
+++ b/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();
}
diff --git a/src/slab_allocator.cc b/src/slab_allocator.cc
index e0d7b131321..6af7215302f 100644
--- a/src/slab_allocator.cc
+++ b/src/slab_allocator.cc
@@ -51,9 +51,9 @@ SlabAllocator::SlabAllocator(unsigned int size) {
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<Object> obj, unsigned int size) {
}
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;
}
diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc
index fb6edbc3a39..50497140b03 100644
--- a/src/stream_wrap.cc
+++ b/src/stream_wrap.cc
@@ -199,7 +199,7 @@ static Local<Object> AcceptHandle(uv_stream_t* pipe) {
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::WriteStringImpl(const Arguments& args) {
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
diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc
index 4c55f2eff50..34ee8a06383 100644
--- a/src/tcp_wrap.cc
+++ b/src/tcp_wrap.cc
@@ -118,7 +118,7 @@ void TCPWrap::Initialize(Handle<Object> target) {
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");
@@ -130,7 +130,7 @@ void TCPWrap::Initialize(Handle<Object> target) {
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));
}
@@ -327,7 +327,7 @@ void TCPWrap::OnConnection(uv_stream_t* handle, int status) {
// 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;
diff --git a/src/tty_wrap.cc b/src/tty_wrap.cc
index 4be53c8e7b1..5ad6106c095 100644
--- a/src/tty_wrap.cc
+++ b/src/tty_wrap.cc
@@ -88,7 +88,7 @@ void TTYWrap::Initialize(Handle<Object> target) {
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));
}
diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc
index 73b722f6759..d3e49e0e2e5 100644
--- a/src/udp_wrap.cc
+++ b/src/udp_wrap.cc
@@ -123,8 +123,8 @@ void UDPWrap::Initialize(Handle<Object> target) {
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));
}
diff --git a/src/v8_typed_array.cc b/src/v8_typed_array.cc
index 012fb706c15..3eaf19dca82 100644
--- a/src/v8_typed_array.cc
+++ b/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();
diff --git a/test/message/error_exit.out b/test/message/error_exit.out
index 11ea76fd72d..bef1586e08c 100644
--- a/test/message/error_exit.out
+++ b/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:*:*)
diff --git a/test/message/stack_overflow.js b/test/message/stack_overflow.js
index 91974bee1e4..00663130841 100644
--- a/test/message/stack_overflow.js
+++ b/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
diff --git a/test/message/stack_overflow.out b/test/message/stack_overflow.out
index 72dc019ff1a..4f7b8b132fc 100644
--- a/test/message/stack_overflow.out
+++ b/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