Skip to content

Commit 7a631a0

Browse files
committed
Support larger addresses in AddressToJS
1 parent 888b1a7 commit 7a631a0

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/node_io_watcher.cc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ Persistent<String> callback_symbol;
1919
Persistent<String> on_io_symbol;
2020

2121

22-
static inline Local<Integer> AddressToJS(void* address) {
22+
static inline Local<Value> AddressToJS(void* address) {
2323
intptr_t diff = (intptr_t)address - (intptr_t)&etext;
24-
assert(diff > 0 && diff < 0x7FFFFFFF);
25-
return Integer::New(diff);
24+
if (diff < 0x7FFFFFFF && diff > 0) {
25+
return Integer::New(diff);
26+
} else {
27+
return External::New(address);
28+
}
2629
}
2730

2831

2932
template <class T>
3033
static inline T* JSToAddress(Local<Value> v) {
31-
return static_cast<T*>((void*)(v->IntegerValue() + &etext));
34+
if (v->IsExternal()) {
35+
return static_cast<T*>(External::Unwrap(v));
36+
} else {
37+
assert(v->IsInt32());
38+
return static_cast<T*>((void*)(v->IntegerValue() + &etext));
39+
}
3240
}
3341

3442

0 commit comments

Comments
 (0)