This reverts commit 3c44100558.
Reverted for breaking node-heapdump[0].
AsyncWrap assigns a class id but does not set a v8::RetainedObjectInfo
provider callback with v8::HeapProfiler::SetWrapperClassInfoProvider().
The result is a null pointer dereference when taking a heap snapshot.
It can probably be solved by setting a generic provider callback inside
the AsyncWrap constructor but that may have performance ramifications
that need to be investigated first. I move to revert it for now.
[0] https://github.com/bnoordhuis/node-heapdump
PR-URL: https://github.com/nodejs/io.js/pull/1827
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
66 lines
1.3 KiB
C++
66 lines
1.3 KiB
C++
#ifndef SRC_BASE_OBJECT_INL_H_
|
|
#define SRC_BASE_OBJECT_INL_H_
|
|
|
|
#include "base-object.h"
|
|
#include "env.h"
|
|
#include "env-inl.h"
|
|
#include "util.h"
|
|
#include "util-inl.h"
|
|
#include "v8.h"
|
|
|
|
namespace node {
|
|
|
|
inline BaseObject::BaseObject(Environment* env, v8::Local<v8::Object> handle)
|
|
: handle_(env->isolate(), handle),
|
|
env_(env) {
|
|
CHECK_EQ(false, handle.IsEmpty());
|
|
}
|
|
|
|
|
|
inline BaseObject::~BaseObject() {
|
|
CHECK(handle_.IsEmpty());
|
|
}
|
|
|
|
|
|
inline v8::Persistent<v8::Object>& BaseObject::persistent() {
|
|
return handle_;
|
|
}
|
|
|
|
|
|
inline v8::Local<v8::Object> BaseObject::object() {
|
|
return PersistentToLocal(env_->isolate(), handle_);
|
|
}
|
|
|
|
|
|
inline Environment* BaseObject::env() const {
|
|
return env_;
|
|
}
|
|
|
|
|
|
template <typename Type>
|
|
inline void BaseObject::WeakCallback(
|
|
const v8::WeakCallbackData<v8::Object, Type>& data) {
|
|
Type* self = data.GetParameter();
|
|
self->persistent().Reset();
|
|
delete self;
|
|
}
|
|
|
|
|
|
template <typename Type>
|
|
inline void BaseObject::MakeWeak(Type* ptr) {
|
|
v8::HandleScope scope(env_->isolate());
|
|
v8::Local<v8::Object> handle = object();
|
|
CHECK_GT(handle->InternalFieldCount(), 0);
|
|
Wrap(handle, ptr);
|
|
handle_.MarkIndependent();
|
|
handle_.SetWeak<Type>(ptr, WeakCallback<Type>);
|
|
}
|
|
|
|
|
|
inline void BaseObject::ClearWeak() {
|
|
handle_.ClearWeak();
|
|
}
|
|
|
|
} // namespace node
|
|
|
|
#endif // SRC_BASE_OBJECT_INL_H_
|