Merge pull request #24 from electron/remove_independent_lifetime

Remove usage of MarkIndependent api
This commit is contained in:
Cheng Zhao 2018-03-31 21:42:13 +09:00 committed by GitHub
commit 02693839ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 22 deletions

View file

@ -10,9 +10,7 @@
namespace mate {
WrappableBase::WrappableBase()
: isolate_(nullptr), high_memory_(false) {
}
WrappableBase::WrappableBase() : isolate_(nullptr) {}
WrappableBase::~WrappableBase() {
if (wrapper_.IsEmpty())
@ -38,9 +36,6 @@ void WrappableBase::InitWith(v8::Isolate* isolate,
wrapper_.Reset(isolate, wrapper);
wrapper_.SetWeak(this, FirstWeakCallback, v8::WeakCallbackType::kParameter);
if (high_memory_)
wrapper_.MarkIndependent();
// Call object._init if we have one.
v8::Local<v8::Function> init;
if (Dictionary(isolate, wrapper).Get("_init", &init))
@ -49,22 +44,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) {
WrappableBase* wrappable = data.GetParameter();
wrappable->wrapper_.Reset();
if (wrappable->high_memory_) {
delete wrappable;
} else {
data.SetSecondPassCallback(SecondWeakCallback);
}
data.SetSecondPassCallback(SecondWeakCallback);
}
// static

View file

@ -44,10 +44,6 @@ class WrappableBase {
// This method should only be called by classes using Constructor.
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:
friend struct internal::Destroyable;
@ -58,7 +54,6 @@ class WrappableBase {
v8::Isolate* isolate_;
v8::Global<v8::Object> wrapper_; // Weak
bool high_memory_;
DISALLOW_COPY_AND_ASSIGN(WrappableBase);
};