Merge pull request #16 from brenca/mark-independent-high-only
Only use MarkIndependent if high_memory_ flag is set
This commit is contained in:
commit
88fa343387
2 changed files with 11 additions and 3 deletions
|
@ -17,7 +17,7 @@ WrappableBase::WrappableBase()
|
|||
WrappableBase::~WrappableBase() {
|
||||
if (wrapper_.IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
GetWrapper()->SetAlignedPointerInInternalField(0, nullptr);
|
||||
wrapper_.ClearWeak();
|
||||
wrapper_.Reset();
|
||||
|
@ -38,7 +38,9 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
|
|||
wrapper->SetAlignedPointerInInternalField(0, this);
|
||||
wrapper_.Reset(isolate, wrapper);
|
||||
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
|
||||
wrapper_.MarkIndependent();
|
||||
|
||||
if (high_memory_)
|
||||
wrapper_.MarkIndependent();
|
||||
|
||||
// Call object._init if we have one.
|
||||
v8::Local<v8::Function> init;
|
||||
|
@ -48,6 +50,12 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
|
|||
AfterInit(isolate);
|
||||
}
|
||||
|
||||
void WrappableBase::MarkHighMemoryUsage() {
|
||||
high_memory_ = true;
|
||||
if (!wrapper_.IsEmpty())
|
||||
wrapper_.MarkIndependent();
|
||||
}
|
||||
|
||||
// static
|
||||
void WrappableBase::FirstWeakCallback(
|
||||
const v8::WeakCallbackInfo<WrappableBase>& data) {
|
||||
|
|
|
@ -46,7 +46,7 @@ class WrappableBase {
|
|||
|
||||
// Marks wrapped object as high memory usage
|
||||
// Deletes the wrapped object on the first round of GC callbacks
|
||||
void MarkHighMemoryUsage() { high_memory_ = true; }
|
||||
virtual void MarkHighMemoryUsage();
|
||||
|
||||
private:
|
||||
friend struct internal::Destroyable;
|
||||
|
|
Loading…
Reference in a new issue