-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PRO-901] Add DG adoptedPromise
edge
#264
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5470,6 +5470,10 @@ void JSPromise::set_async_task_id(int id) { | |
set_flags(AsyncTaskIdBits::update(flags(), id)); | ||
} | ||
|
||
|
||
extern bool RecordReplayShouldCallOnPromiseHook(); | ||
void AddPromiseDependencyGraphAdoption(Isolate* isolate, Handle<Object> promise, Handle<Object> adoption); | ||
|
||
// static | ||
Handle<Object> JSPromise::Fulfill(Handle<JSPromise> promise, | ||
Handle<Object> value) { | ||
|
@@ -5550,6 +5554,10 @@ Handle<Object> JSPromise::Reject(Handle<JSPromise> promise, | |
kPromiseRejectWithNoHandler); | ||
} | ||
|
||
if (RecordReplayShouldCallOnPromiseHook() && reason->IsJSReceiver()) { | ||
AddPromiseDependencyGraphAdoption(isolate, Handle<Object>::cast(promise), reason); | ||
} | ||
Comment on lines
+5557
to
+5559
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this needed? I'm not sure if my initial conclusion that it would be holds true 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Its not. Rejections indeed cannot nest promises. I somehow thought they could, but I'm definitely wrong. var p = Promise.resolve().then(() => new Promise(r => setTimeout(r,100))).then(() => console.log("A"));
Promise.reject(p).finally(() => console.log("B")) |
||
|
||
// 8. Return TriggerPromiseReactions(reactions, reason). | ||
return TriggerPromiseReactions(isolate, reactions, reason, | ||
PromiseReaction::kReject); | ||
|
@@ -5625,6 +5633,10 @@ MaybeHandle<Object> JSPromise::Resolve(Handle<JSPromise> promise, | |
return Fulfill(promise, resolution); | ||
} | ||
|
||
if (RecordReplayShouldCallOnPromiseHook()) { | ||
AddPromiseDependencyGraphAdoption(isolate, Handle<Object>::cast(promise), resolution); | ||
} | ||
|
||
// 13. Let job be NewPromiseResolveThenableJob(promise, resolution, | ||
// thenAction). | ||
Handle<NativeContext> then_context; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might, slightly, dilute what
GetOrCreatePromiseDependencyGraphData
is about. By reading this code I'd think it would contain only promise IDs but that's not quite true as other objects could potentially be "registered" in it, right?I also wonder if this whole thing can now generate a sensible graph when thenables are involved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with these concerns, GetOrCreatePromiseDependencyGraphData should only be used with promises. Things won't break if it's used with other objects, but the edges being created here seem fairly meaningless. I'd like a more detailed explanation of how this PR helps to be able to review it.