Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1197)

Issue 2581503003: [promisehook] Store promise in PromiseReactionJob (Closed)

Created:
4 years ago by gsathya
Modified:
4 years ago
Reviewers:
kozy, Dan Ehrenberg, adamk
CC:
v8-reviews_googlegroups.com
Target Ref:
refs/pending/heads/master
Project:
v8
Visibility:
Public.

Description

[promisehook] Store promise in PromiseReactionJob This will be used in PromiseHook. BUG=v8:4643 Review-Url: https://codereview.chromium.org/2581503003 Cr-Commit-Position: refs/heads/master@{#41730} Committed: https://chromium.googlesource.com/v8/v8/+/b4aadaec1e46a98f2c2ee273c99aa808e19c770f

Patch Set 1 #

Patch Set 2 : thread it through to promisehandle #

Patch Set 3 : remove unused var #

Total comments: 1

Patch Set 4 : update debug and print #

Patch Set 5 : add promise to AllocatePromiseReactionJobInfo #

Patch Set 6 : rebase #

Patch Set 7 : rebase correctly #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+55 lines, -43 lines) Patch
M src/bootstrapper.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M src/builtins/builtins.h View 1 1 chunk +1 line, -1 line 0 comments Download
M src/builtins/builtins-promise.cc View 1 2 3 4 5 6 chunks +12 lines, -12 lines 1 comment Download
M src/code-stub-assembler.h View 1 2 3 4 5 1 chunk +2 lines, -2 lines 0 comments Download
M src/code-stub-assembler.cc View 1 2 3 4 5 1 chunk +4 lines, -4 lines 0 comments Download
M src/factory.h View 1 chunk +3 lines, -3 lines 0 comments Download
M src/factory.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M src/isolate.cc View 1 3 chunks +3 lines, -2 lines 0 comments Download
M src/objects.h View 2 chunks +5 lines, -1 line 0 comments Download
M src/objects-debug.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M src/objects-inl.h View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/objects-printer.cc View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M src/runtime/runtime-promise.cc View 4 chunks +14 lines, -13 lines 0 comments Download
M test/cctest/test-code-stub-assembler.cc View 1 2 3 4 5 6 2 chunks +4 lines, -2 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 42 (29 generated)
gsathya
4 years ago (2016-12-15 01:53:17 UTC) #11
adamk
lgtm % comment below (haven't actually looked at the PromiseHook CL yet, but assuming this ...
4 years ago (2016-12-15 07:00:37 UTC) #12
gsathya
On 2016/12/15 07:00:37, adamk wrote: > lgtm % comment below > > (haven't actually looked ...
4 years ago (2016-12-15 14:38:44 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2581503003/110001
4 years ago (2016-12-15 15:48:53 UTC) #30
commit-bot: I haz the power
Committed patchset #7 (id:110001) as https://chromium.googlesource.com/v8/v8/+/b4aadaec1e46a98f2c2ee273c99aa808e19c770f
4 years ago (2016-12-15 15:51:00 UTC) #33
kozy
https://codereview.chromium.org/2581503003/diff/110001/src/builtins/builtins-promise.cc File src/builtins/builtins-promise.cc (right): https://codereview.chromium.org/2581503003/diff/110001/src/builtins/builtins-promise.cc#newcode503 src/builtins/builtins-promise.cc:503: a->CallRuntime(Runtime::kEnqueuePromiseReactionJob, context, promise, Does it mean that before promise ...
4 years ago (2016-12-15 16:07:59 UTC) #35
gsathya
On 2016/12/15 16:07:59, kozyatinskiy wrote: > https://codereview.chromium.org/2581503003/diff/110001/src/builtins/builtins-promise.cc > File src/builtins/builtins-promise.cc (right): > > https://codereview.chromium.org/2581503003/diff/110001/src/builtins/builtins-promise.cc#newcode503 > ...
4 years ago (2016-12-15 16:10:43 UTC) #36
adamk
On 2016/12/15 16:10:43, gsathya wrote: > On 2016/12/15 16:07:59, kozyatinskiy wrote: > > > https://codereview.chromium.org/2581503003/diff/110001/src/builtins/builtins-promise.cc ...
4 years ago (2016-12-15 17:15:17 UTC) #37
kozy
On 2016/12/15 17:15:17, adamk wrote: > On 2016/12/15 16:10:43, gsathya wrote: > > On 2016/12/15 ...
4 years ago (2016-12-15 18:03:08 UTC) #38
adamk
On 2016/12/15 18:03:08, kozyatinskiy wrote: > On 2016/12/15 17:15:17, adamk wrote: > > On 2016/12/15 ...
4 years ago (2016-12-15 18:08:06 UTC) #39
kozy
On 2016/12/15 18:08:06, adamk wrote: > On 2016/12/15 18:03:08, kozyatinskiy wrote: > > I'm working ...
4 years ago (2016-12-15 18:18:35 UTC) #40
kozy
On 2016/12/15 18:08:06, adamk wrote: > > Hmm. Would it make sense to only store ...
4 years ago (2016-12-15 18:19:55 UTC) #41
gsathya
4 years ago (2016-12-15 18:28:47 UTC) #42
Message was sent while issue was closed.
On 2016/12/15 18:03:08, kozyatinskiy wrote:
> On 2016/12/15 17:15:17, adamk wrote:
> > On 2016/12/15 16:10:43, gsathya wrote:
> > > On 2016/12/15 16:07:59, kozyatinskiy wrote:
> > > >
> > >
> >
>
https://codereview.chromium.org/2581503003/diff/110001/src/builtins/builtins-...
> > > > File src/builtins/builtins-promise.cc (right):
> > > > 
> > > >
> > >
> >
>
https://codereview.chromium.org/2581503003/diff/110001/src/builtins/builtins-...
> > > > src/builtins/builtins-promise.cc:503:
> > > > a->CallRuntime(Runtime::kEnqueuePromiseReactionJob, context, promise,
> > > > Does it mean that before promise can be collected when microtask is
> already
> > > > scheduled but not executed yet and now it's not a true?
> > > > 
> > > > var resolve;
> > > > var p = new Promise(resolveCb => resolve = resolveCb);
> > > > p.then(foo);
> > > > p = null;
> > > > resolve(); <- promise can be collected after this function call.
> > > > 
> > > > function foo() {
> > > > } <- now, promise will be collected after this function finished.
> > > 
> > > Yes, you're correct.
> > 
> > kozyatinskiy, Is there a reason this causes concern?
> 
> I'm working on better async task instrumentation for inspector and with
holding
> promise I can simplify some logic, will upload CL soon.
> And I'm just worried about two use cases:
> 1. for (var i = 0; i < N; ++i) Promise.resolve().then(foo) - we'll hold N
> additional promises.
> 2. and it can hard to detect this additional memory in code that aggressively
> use thenable jobs:
> function fib(i) {
>   if (i == 0) return Promise.resolve(1);
>   if (i == 1) return Promise.resolve(1);
>   return Promise.all([fib(i-1), fib(i-2)]).then((r) => r[0] + r[1]);
> }

The first example is valid, but I don't know if waiting until the next microtask
is a regression.

In the second example, we would hold all the promises anyway because the parent
promise isn't resolved until each child one is and they all hold references.
Similar to https://bugs.chromium.org/p/v8/issues/detail?id=5002

Powered by Google App Engine
This is Rietveld 408576698