Skip to content

Commit 4bb4f73

Browse files
committed
src: unexport node_isolate
Commit 0bba590 accidentally (or maybe erroneously) added node_isolate to src/node.h and src/node_object_wrap.h. Undo that, said variable is not for public consumption. Add-on authors should use v8::Isolate::GetCurrent() instead. I missed that while reviewing. Mea culpa. Fixes nodejs#5639.
1 parent 0882a75 commit 4bb4f73

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

src/node.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@
8686

8787
namespace node {
8888

89-
extern v8::Isolate* node_isolate;
90-
9189
NODE_EXTERN extern bool no_deprecation;
9290

9391
NODE_EXTERN int Start(int argc, char *argv[]);
@@ -97,8 +95,9 @@ v8::Handle<v8::Object> SetupProcessObject(int argc, char *argv[]);
9795
void Load(v8::Handle<v8::Object> process);
9896
void EmitExit(v8::Handle<v8::Object> process);
9997

100-
#define NODE_PSYMBOL(s) \
101-
v8::Persistent<v8::String>::New(node_isolate, v8::String::NewSymbol(s))
98+
#define NODE_PSYMBOL(s) \
99+
v8::Persistent<v8::String>::New(v8::Isolate::GetCurrent(), \
100+
v8::String::NewSymbol(s))
102101

103102
/* Converts a unixtime to V8 Date */
104103
#define NODE_UNIXTIME_V8(t) v8::Date::New(1000*static_cast<double>(t))
@@ -152,10 +151,10 @@ NODE_EXTERN ssize_t DecodeWrite(char *buf,
152151
v8::Local<v8::Object> BuildStatsObject(const uv_stat_t* s);
153152

154153

155-
static inline v8::Persistent<v8::Function>* cb_persist(
156-
const v8::Local<v8::Value> &v) {
157-
v8::Persistent<v8::Function> *fn = new v8::Persistent<v8::Function>();
158-
*fn = v8::Persistent<v8::Function>::New(node_isolate, v8::Local<v8::Function>::Cast(v));
154+
static inline v8::Persistent<v8::Function>* cb_persist(v8::Local<v8::Value> v) {
155+
v8::Persistent<v8::Function>* fn = new v8::Persistent<v8::Function>();
156+
*fn = v8::Persistent<v8::Function>::New(v8::Isolate::GetCurrent(),
157+
v.As<v8::Function>());
159158
return fn;
160159
}
161160

@@ -167,7 +166,7 @@ static inline v8::Persistent<v8::Function>* cb_unwrap(void *data) {
167166
}
168167

169168
static inline void cb_destroy(v8::Persistent<v8::Function> * cb) {
170-
cb->Dispose(node_isolate);
169+
cb->Dispose(v8::Isolate::GetCurrent());
171170
delete cb;
172171
}
173172

src/node_object_wrap.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737

3838
namespace node {
3939

40-
extern v8::Isolate* node_isolate;
41-
4240
class NODE_EXTERN ObjectWrap {
4341
public:
4442
ObjectWrap ( ) {
@@ -48,10 +46,11 @@ class NODE_EXTERN ObjectWrap {
4846

4947
virtual ~ObjectWrap ( ) {
5048
if (!handle_.IsEmpty()) {
51-
assert(handle_.IsNearDeath(node_isolate));
52-
handle_.ClearWeak(node_isolate);
49+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
50+
assert(handle_.IsNearDeath(isolate));
51+
handle_.ClearWeak(isolate);
5352
handle_->SetAlignedPointerInInternalField(0, 0);
54-
handle_.Dispose(node_isolate);
53+
handle_.Dispose(isolate);
5554
handle_.Clear();
5655
}
5756
}
@@ -71,15 +70,17 @@ class NODE_EXTERN ObjectWrap {
7170
inline void Wrap (v8::Handle<v8::Object> handle) {
7271
assert(handle_.IsEmpty());
7372
assert(handle->InternalFieldCount() > 0);
74-
handle_ = v8::Persistent<v8::Object>::New(node_isolate, handle);
73+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
74+
handle_ = v8::Persistent<v8::Object>::New(isolate, handle);
7575
handle_->SetAlignedPointerInInternalField(0, this);
7676
MakeWeak();
7777
}
7878

7979

8080
inline void MakeWeak (void) {
81-
handle_.MakeWeak(node_isolate, this, WeakCallback);
82-
handle_.MarkIndependent(node_isolate);
81+
v8::Isolate* isolate = v8::Isolate::GetCurrent();
82+
handle_.MakeWeak(isolate, this, WeakCallback);
83+
handle_.MarkIndependent(isolate);
8384
}
8485

8586
/* Ref() marks the object as being attached to an event loop.
@@ -89,7 +90,7 @@ class NODE_EXTERN ObjectWrap {
8990
virtual void Ref() {
9091
assert(!handle_.IsEmpty());
9192
refs_++;
92-
handle_.ClearWeak(node_isolate);
93+
handle_.ClearWeak(v8::Isolate::GetCurrent());
9394
}
9495

9596
/* Unref() marks an object as detached from the event loop. This is its
@@ -103,7 +104,7 @@ class NODE_EXTERN ObjectWrap {
103104
*/
104105
virtual void Unref() {
105106
assert(!handle_.IsEmpty());
106-
assert(!handle_.IsWeak(node_isolate));
107+
assert(!handle_.IsWeak(v8::Isolate::GetCurrent()));
107108
assert(refs_ > 0);
108109
if (--refs_ == 0) { MakeWeak(); }
109110
}
@@ -113,18 +114,18 @@ class NODE_EXTERN ObjectWrap {
113114

114115

115116
private:
116-
static void WeakCallback(v8::Isolate* env,
117+
static void WeakCallback(v8::Isolate* isolate,
117118
v8::Persistent<v8::Value> value,
118119
void* data) {
119-
v8::HandleScope scope(node_isolate);
120-
120+
v8::HandleScope scope(isolate);
121121
ObjectWrap *obj = static_cast<ObjectWrap*>(data);
122122
assert(value == obj->handle_);
123123
assert(!obj->refs_);
124-
assert(value.IsNearDeath(env));
124+
assert(value.IsNearDeath(isolate));
125125
delete obj;
126126
}
127127
};
128128

129129
} // namespace node
130+
130131
#endif // object_wrap_h

0 commit comments

Comments
 (0)