Bug 157307 - DOMPromise should only restrict the resolution type
Summary: DOMPromise should only restrict the resolution type
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords:
Depends on: 157623
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-03 02:19 PDT by youenn fablet
Modified: 2016-05-17 03:19 PDT (History)
3 users (show)

See Also:


Attachments
Patch (32.30 KB, patch)
2016-05-10 06:41 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (32.78 KB, patch)
2016-05-12 02:06 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing - updating Ref/RefPtr detection (36.02 KB, patch)
2016-05-13 02:00 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (36.10 KB, patch)
2016-05-13 03:23 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (36.10 KB, patch)
2016-05-13 03:31 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (31.43 KB, patch)
2016-05-17 02:48 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2016-05-03 02:19:42 PDT
Restricting the error type is not efficient as some promises may reject with exception codes (int) or some dedicated errors.
Comment 1 youenn fablet 2016-05-10 06:41:41 PDT
Created attachment 278488 [details]
Patch
Comment 2 youenn fablet 2016-05-10 06:45:14 PDT
(In reply to comment #1)
> Created attachment 278488 [details]
> Patch

Patch is removing the DOMPromise rejection type restriction.

It also tries to remove some limitations of the resolve/reject methods.
Currently these methods take const references as parameter.
For DOM objects, it may be better to pass either plain references or Ref/RefPtr rvalues.
Comment 3 WebKit Commit Bot 2016-05-11 00:51:09 PDT
Comment on attachment 278488 [details]
Patch

Rejecting attachment 278488 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'build', '--no-clean', '--no-update', '--build-style=release', '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
Volumes/Data/EWS/WebKit/Source/WebCore/loader/archive/ArchiveFactory.cpp -o /Volumes/Data/EWS/WebKit/WebKitBuild/WebCore.build/Release/WebCore.build/Objects-normal/x86_64/ArchiveFactory.o

** BUILD FAILED **


The following build commands failed:
	CompileC /Volumes/Data/EWS/WebKit/WebKitBuild/WebCore.build/Release/WebCore.build/Objects-normal/x86_64/AccessibilityMediaControls.o accessibility/AccessibilityMediaControls.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Full output: http://webkit-queues.webkit.org/results/1302453
Comment 4 youenn fablet 2016-05-12 02:06:25 PDT
Created attachment 278719 [details]
Patch for landing
Comment 5 youenn fablet 2016-05-12 02:09:40 PDT
Comment on attachment 278719 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=278719&action=review

> Source/WebCore/bindings/js/JSDOMBinding.h:544
> +template<typename T> inline JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, RefPtr<T>& ptr)

I hesitated on adding this one.
Ref<T> defines its cast to T&, but RefPtr<T> is not doing that for T*.
Is there a reason for that?
Comment 6 WebKit Commit Bot 2016-05-12 02:35:11 PDT
Comment on attachment 278719 [details]
Patch for landing

Clearing flags on attachment: 278719

Committed r200766: <http://trac.webkit.org/changeset/200766>
Comment 7 WebKit Commit Bot 2016-05-12 02:35:14 PDT
All reviewed patches have been landed.  Closing bug.
Comment 8 WebKit Commit Bot 2016-05-12 05:22:35 PDT
Re-opened since this is blocked by bug 157623
Comment 9 youenn fablet 2016-05-13 02:00:31 PDT
Created attachment 278824 [details]
Patch for landing - updating Ref/RefPtr detection
Comment 10 youenn fablet 2016-05-13 03:23:07 PDT
Created attachment 278828 [details]
Patch for landing
Comment 11 WebKit Commit Bot 2016-05-13 03:25:17 PDT
Comment on attachment 278828 [details]
Patch for landing

Rejecting attachment 278828 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'validate-changelog', '--check-oops', '--non-interactive', 278828, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

ChangeLog entry in Source/WTF/ChangeLog contains OOPS!.

Full output: http://webkit-queues.webkit.org/results/1314216
Comment 12 youenn fablet 2016-05-13 03:31:42 PDT
Created attachment 278829 [details]
Patch for landing
Comment 13 WebKit Commit Bot 2016-05-13 04:02:09 PDT
Comment on attachment 278829 [details]
Patch for landing

Clearing flags on attachment: 278829

Committed r200837: <http://trac.webkit.org/changeset/200837>
Comment 14 WebKit Commit Bot 2016-05-13 04:02:13 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 youenn fablet 2016-05-13 07:21:02 PDT
Last patch updated the way to detect Ref and RefPtr.
To make Yosemite build happy, I added Ref::isRef and RefPtr::isRefPtr constexpr.
The test is split in two tests (one for Ref and one for RefPtr) to make win bot happy.

I am not sure why Ref has a cast to T&, but RefPtr does not have for T*.
Comment 16 Darin Adler 2016-05-13 08:39:42 PDT
(In reply to comment #15)
> I am not sure why Ref has a cast to T&, but RefPtr does not have for T*.

Both are dangerous. Silently converting a smart pointer or reference to a raw one can be dangerous because the lifetime of the object is not extended and can lead to use after free. This primary comes into play when assigning to a local variable.

Both are convenient. Silently converting without a call to get() or ptr() can be much more elegant when passing an argument to a function, and in that case the lifetime works out just fine.
Comment 17 Chris Dumez 2016-05-13 12:09:36 PDT
I am still working on confirming but the bots showed a 3% regression on Speedometer / iOS when this patch landed.
Comment 18 Chris Dumez 2016-05-13 12:13:48 PDT
Comment on attachment 278829 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=278829&action=review

> Source/WebCore/bindings/js/JSDOMBinding.h:-255
> -template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const Ref<T>&);

To more overloads for Ref<>? Isn't it so now that if someone passes a Ref<>&& we're going to use the RefPtr<>&& overload and therefore do null checks?
This may have disabled my optimization from yesterday, which would explain why the benchmarks are back to their old scores.
Comment 19 Chris Dumez 2016-05-13 12:18:12 PDT
Reverted r200837 for reason:

Seems to have regressed Speedometer and JetStream on iOS

Committed r200875: <http://trac.webkit.org/changeset/200875>
Comment 20 youenn fablet 2016-05-13 12:35:57 PDT
(In reply to comment #17)
> I am still working on confirming but the bots showed a 3% regression on
> Speedometer / iOS when this patch landed.

Is it possible to have access to monitor these results?

> > Source/WebCore/bindings/js/JSDOMBinding.h:-255
> > -template<typename T> JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, const Ref<T>&);
> 
> To more overloads for Ref<>? Isn't it so now that if someone passes a
> Ref<>&& we're going to use the RefPtr<>&& overload and therefore do null
> checks?
> This may have disabled my optimization from yesterday, which would explain
> why the benchmarks are back to their old scores.

I guess we could add an additional toJS(... Ref<T>&&).
Comment 21 Chris Dumez 2016-05-13 13:11:06 PDT
(In reply to comment #20)
> (In reply to comment #17)
> > I am still working on confirming but the bots showed a 3% regression on
> > Speedometer / iOS when this patch landed.
> 
> Is it possible to have access to monitor these results?

Not at the moment unfortunately. I am monitoring to make sure the scores go back up after the roll out.
Comment 22 Chris Dumez 2016-05-13 13:33:18 PDT
(In reply to comment #19)
> Reverted r200837 for reason:
> 
> Seems to have regressed Speedometer and JetStream on iOS
> 
> Committed r200875: <http://trac.webkit.org/changeset/200875>

FYI, this patch was also a 2% regression on Kraken / iOS even though my original toJS() change did not progress Kraken at all. So it seems this did more than just disabling my optimization.
Comment 23 youenn fablet 2016-05-14 05:14:24 PDT
(In reply to comment #22)
> (In reply to comment #19)
> > Reverted r200837 for reason:
> > 
> > Seems to have regressed Speedometer and JetStream on iOS
> > 
> > Committed r200875: <http://trac.webkit.org/changeset/200875>
> 
> FYI, this patch was also a 2% regression on Kraken / iOS even though my
> original toJS() change did not progress Kraken at all. So it seems this did
> more than just disabling my optimization.

That seems like a lot to me.
I was thinking Kraken was solely targetting JSC. 
I am surprised toJS() changes have such a big effect on Kraken results.
Comment 24 youenn fablet 2016-05-17 02:48:33 PDT
Created attachment 279107 [details]
Patch for landing
Comment 25 youenn fablet 2016-05-17 02:49:24 PDT
(In reply to comment #24)
> Created attachment 279107 [details]
> Patch for landing

I removed the toJS changes.
Comment 26 WebKit Commit Bot 2016-05-17 03:19:15 PDT
Comment on attachment 279107 [details]
Patch for landing

Clearing flags on attachment: 279107

Committed r201013: <http://trac.webkit.org/changeset/201013>
Comment 27 WebKit Commit Bot 2016-05-17 03:19:21 PDT
All reviewed patches have been landed.  Closing bug.