Remove usage of MarkIndependent api
https://bugs.chromium.org/p/chromium/issues/detail?id=780749 Use Active/Not Active as indicator whether the Scavenger can drop wrappers
This commit is contained in:
parent
6a3d238b7e
commit
894c96f39f
2 changed files with 2 additions and 22 deletions
|
@ -10,9 +10,7 @@
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
|
|
||||||
WrappableBase::WrappableBase()
|
WrappableBase::WrappableBase() : isolate_(nullptr) {}
|
||||||
: isolate_(nullptr), high_memory_(false) {
|
|
||||||
}
|
|
||||||
|
|
||||||
WrappableBase::~WrappableBase() {
|
WrappableBase::~WrappableBase() {
|
||||||
if (wrapper_.IsEmpty())
|
if (wrapper_.IsEmpty())
|
||||||
|
@ -38,9 +36,6 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
|
||||||
wrapper_.Reset(isolate, wrapper);
|
wrapper_.Reset(isolate, wrapper);
|
||||||
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
|
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
|
||||||
|
|
||||||
if (high_memory_)
|
|
||||||
wrapper_.MarkIndependent();
|
|
||||||
|
|
||||||
// Call object._init if we have one.
|
// Call object._init if we have one.
|
||||||
v8::Local<v8::Function> init;
|
v8::Local<v8::Function> init;
|
||||||
if (Dictionary(isolate, wrapper).Get("_init", &init))
|
if (Dictionary(isolate, wrapper).Get("_init", &init))
|
||||||
|
@ -49,23 +44,13 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
|
||||||
AfterInit(isolate);
|
AfterInit(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WrappableBase::MarkHighMemoryUsage() {
|
|
||||||
high_memory_ = true;
|
|
||||||
if (!wrapper_.IsEmpty())
|
|
||||||
wrapper_.MarkIndependent();
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void WrappableBase::FirstWeakCallback(
|
void WrappableBase::FirstWeakCallback(
|
||||||
const v8::WeakCallbackInfo<WrappableBase>& data) {
|
const v8::WeakCallbackInfo<WrappableBase>& data) {
|
||||||
WrappableBase* wrappable = data.GetParameter();
|
WrappableBase* wrappable = data.GetParameter();
|
||||||
wrappable->wrapper_.Reset();
|
wrappable->wrapper_.Reset();
|
||||||
if (wrappable->high_memory_) {
|
|
||||||
delete wrappable;
|
|
||||||
} else {
|
|
||||||
data.SetSecondPassCallback(SecondWeakCallback);
|
data.SetSecondPassCallback(SecondWeakCallback);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void WrappableBase::SecondWeakCallback(
|
void WrappableBase::SecondWeakCallback(
|
||||||
|
|
|
@ -44,10 +44,6 @@ class WrappableBase {
|
||||||
// This method should only be called by classes using Constructor.
|
// This method should only be called by classes using Constructor.
|
||||||
virtual void InitWith(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
|
virtual void InitWith(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
|
||||||
|
|
||||||
// Marks wrapped object as high memory usage
|
|
||||||
// Deletes the wrapped object on the first round of GC callbacks
|
|
||||||
virtual void MarkHighMemoryUsage();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct internal::Destroyable;
|
friend struct internal::Destroyable;
|
||||||
|
|
||||||
|
@ -58,7 +54,6 @@ class WrappableBase {
|
||||||
|
|
||||||
v8::Isolate* isolate_;
|
v8::Isolate* isolate_;
|
||||||
v8::Global<v8::Object> wrapper_; // Weak
|
v8::Global<v8::Object> wrapper_; // Weak
|
||||||
bool high_memory_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WrappableBase);
|
DISALLOW_COPY_AND_ASSIGN(WrappableBase);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue