Bug 201158

Summary: [JSC] JSPromise should work with object-allocation-sinking
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: JavaScriptCoreAssignee: Yusuke Suzuki <ysuzuki>
Status: NEW ---    
Severity: Normal CC: saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Yusuke Suzuki 2019-08-26 16:08:10 PDT
...
Comment 1 Radar WebKit Bug Importer 2019-08-26 16:08:32 PDT
<rdar://problem/54726575>
Comment 2 Saam Barati 2019-08-30 15:29:27 PDT
won't inlining the constructor which will be written in JS now sink the executor function?
Comment 3 Yusuke Suzuki 2019-08-30 15:37:03 PDT
(In reply to Saam Barati from comment #2)
> won't inlining the constructor which will be written in JS now sink the
> executor function?

I would like to sink JSPromise object itself too when it can be done.
Comment 4 Yusuke Suzuki 2019-08-30 15:38:23 PDT
One possible thing (I'm not talking about whether it is possible in our implementation) is, 

Promise.resolve(42).then(function (value) {
    //
});

Promise.resolve's returning promise is essentially unnecessary.
Comment 5 Saam Barati 2019-08-30 16:28:52 PDT
(In reply to Yusuke Suzuki from comment #4)
> One possible thing (I'm not talking about whether it is possible in our
> implementation) is, 
> 
> Promise.resolve(42).then(function (value) {
>     //
> });
> 
> Promise.resolve's returning promise is essentially unnecessary.

Yeah it would be nice too. But is this common?

Maybe through inlining it might become common. That said, don't we need the intermediate promise because "function (value)" isn't called until next run loop tick?
Comment 6 Yusuke Suzuki 2019-08-30 16:59:23 PDT
(In reply to Saam Barati from comment #5)
> (In reply to Yusuke Suzuki from comment #4)
> > One possible thing (I'm not talking about whether it is possible in our
> > implementation) is, 
> > 
> > Promise.resolve(42).then(function (value) {
> >     //
> > });
> > 
> > Promise.resolve's returning promise is essentially unnecessary.
> 
> Yeah it would be nice too. But is this common?
> 
> Maybe through inlining it might become common. That said, don't we need the
> intermediate promise because "function (value)" isn't called until next run
> loop tick?

In the above example, Promise.resolve's promise is unnecessary. It is already resolved. Microtask only contains reactions of Promises, and value for resolution, so Promise object itself is not necessary.