Browse Source

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.
v0.11.0-release
Trevor Norris 12 years ago
committed by Ben Noordhuis
parent
commit
0bba590283
  1. 3
      lib/fs.js
  2. 4
      src/cares_wrap.cc
  3. 5
      src/fs_event_wrap.cc
  4. 10
      src/handle_wrap.cc
  5. 2
      src/handle_wrap.h
  6. 27
      src/node.cc
  7. 8
      src/node.h
  8. 12
      src/node_buffer.cc
  9. 2
      src/node_counters.cc
  10. 38
      src/node_crypto.cc
  11. 10
      src/node_crypto.h
  12. 2
      src/node_dtrace.cc
  13. 3
      src/node_file.cc
  14. 2
      src/node_internals.h
  15. 28
      src/node_object_wrap.h
  16. 13
      src/node_script.cc
  17. 2
      src/node_stat_watcher.cc
  18. 10
      src/node_zlib.cc
  19. 6
      src/pipe_wrap.cc
  20. 4
      src/req_wrap.h
  21. 10
      src/slab_allocator.cc
  22. 4
      src/stream_wrap.cc
  23. 6
      src/tcp_wrap.cc
  24. 2
      src/tty_wrap.cc
  25. 6
      src/udp_wrap.cc
  26. 32
      src/v8_typed_array.cc
  27. 2
      test/message/error_exit.out
  28. 2
      test/message/stack_overflow.js
  29. 2
      test/message/stack_overflow.out

3
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;
}

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();
}

5
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) {

10
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;

2
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:

27
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
}

8
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;
}

12
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"));

2
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());
}

38
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(),

10
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
}

2
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());
}

3
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);

2
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__); \

28
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;
}
};

13
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

2
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"));

10
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?");

6
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;

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();
}

10
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;
}

4
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

6
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;

2
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));
}

6
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));
}

32
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();

2
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:*:*)

2
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

2
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

Loading…
Cancel
Save