| Index: include/v8.h
|
| diff --git a/include/v8.h b/include/v8.h
|
| index 7b954983af19a451f4a6d26710e81dca89c3d246..1e018cb832d068fe98933c868d960fabe1dd52ea 100644
|
| --- a/include/v8.h
|
| +++ b/include/v8.h
|
| @@ -437,6 +437,7 @@ class V8EXPORT HandleScope {
|
| * Creates a new handle with the given value.
|
| */
|
| static internal::Object** CreateHandle(internal::Object* value);
|
| + static internal::Object** CreateHandleFromHeapObject(internal::Object* value);
|
|
|
| private:
|
| // Make it impossible to create heap-allocated or illegal handle
|
| @@ -3483,6 +3484,9 @@ class Internals {
|
| uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset - kHeapObjectTag;
|
| return *reinterpret_cast<T*>(addr);
|
| }
|
| +
|
| + static inline bool IsHeapObject(void*) { return false; }
|
| + static inline bool IsHeapObject(Date*) { return true; }
|
| };
|
|
|
| } // namespace internal
|
| @@ -3499,7 +3503,12 @@ Local<T>::Local() : Handle<T>() { }
|
| template <class T>
|
| Local<T> Local<T>::New(Handle<T> that) {
|
| if (that.IsEmpty()) return Local<T>();
|
| - internal::Object** p = reinterpret_cast<internal::Object**>(*that);
|
| + T* that_ptr = *that;
|
| + internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
|
| + if (internal::Internals::IsHeapObject(that_ptr)) {
|
| + return Local<T>(
|
| + reinterpret_cast<T*>(HandleScope::CreateHandleFromHeapObject(*p)));
|
| + }
|
| return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
|
| }
|
|
|
|
|