Skip to content

Commit

Permalink
fixup! src: use symbol to store AsyncWrap resource
Browse files Browse the repository at this point in the history
  • Loading branch information
addaleax committed May 19, 2020
1 parent dd44bb9 commit a6b337d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/async_wrap.cc
Expand Up @@ -534,12 +534,12 @@ void AsyncWrap::GetProviderType(const FunctionCallbackInfo<Value>& args) {
}


void AsyncWrap::EmitDestroy() {
void AsyncWrap::EmitDestroy(bool from_gc) {
AsyncWrap::EmitDestroy(env(), async_id_);
// Ensure no double destroy is emitted via AsyncReset().
async_id_ = kInvalidAsyncId;

if (!persistent().IsEmpty()) {
if (!persistent().IsEmpty() && !from_gc) {
HandleScope handle_scope(env()->isolate());
USE(object()->Set(env()->context(), env()->resource_symbol(), object()));
}
Expand Down Expand Up @@ -727,7 +727,7 @@ bool AsyncWrap::IsDoneInitializing() const {

AsyncWrap::~AsyncWrap() {
EmitTraceEventDestroy();
EmitDestroy();
EmitDestroy(true /* from gc */);
}

void AsyncWrap::EmitTraceEventDestroy() {
Expand Down Expand Up @@ -853,7 +853,7 @@ MaybeLocal<Value> AsyncWrap::MakeCallback(const Local<Function> cb,
ProviderType provider = provider_type();
async_context context { get_async_id(), get_trigger_async_id() };
MaybeLocal<Value> ret = InternalMakeCallback(
env(), GetResource(), object(), cb, argc, argv, context);
env(), object(), object(), cb, argc, argv, context);

// This is a static call with cached values because the `this` object may
// no longer be alive at this point.
Expand Down
2 changes: 1 addition & 1 deletion src/async_wrap.h
Expand Up @@ -152,7 +152,7 @@ class AsyncWrap : public BaseObject {
static void EmitAfter(Environment* env, double async_id);
static void EmitPromiseResolve(Environment* env, double async_id);

void EmitDestroy();
void EmitDestroy(bool from_gc = false);

void EmitTraceEventBefore();
static void EmitTraceEventAfter(ProviderType type, double async_id);
Expand Down

0 comments on commit a6b337d

Please sign in to comment.