Bug 149518 - [Streams API] Add support for private WebCore JS builtins functions
Summary: [Streams API] Add support for private WebCore JS builtins functions
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:
Blocks: 147092
  Show dependency treegraph
 
Reported: 2015-09-24 01:52 PDT by youenn fablet
Modified: 2015-11-14 01:22 PST (History)
5 users (show)

See Also:


Attachments
Patch (36.10 KB, patch)
2015-09-24 02:36 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (32.58 KB, patch)
2015-10-01 00:37 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Rebasing for landing (32.80 KB, patch)
2015-10-01 00:45 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (32.92 KB, patch)
2015-10-01 04:36 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 2015-09-24 01:52:21 PDT
Private JS builtin functions are needed for ReadableStream JS builtin implementation.
Comment 1 youenn fablet 2015-09-24 02:36:40 PDT
Created attachment 261864 [details]
Patch
Comment 2 WebKit Commit Bot 2015-09-24 02:39:29 PDT
Attachment 261864 [details] did not pass style-queue:


ERROR: Source/WebCore/bindings/js/JSDOMWindowBase.cpp:91:  Missing space after ,  [whitespace/comma] [3]
Total errors found: 1 in 21 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 youenn fablet 2015-09-25 06:43:43 PDT
Comment on attachment 261864 [details]
Patch

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

> Source/JavaScriptCore/builtins/BuiltinNames.h:115
> +    m_privateToPublicMap.add(privateName.impl(), &publicName);

Might be good to add an ASSERT above to ensure name collision does not happen.
Comment 4 Xabier Rodríguez Calvar 2015-09-28 02:10:46 PDT
(In reply to comment #3)
> Might be good to add an ASSERT above to ensure name collision does not
> happen.

Yep, definitely needed. Actually I remember trying to figure out a crash because of a collision so it is very needed.

The rest of the shallow review looks good. Only one comment you knew I was going to make, that is why don't you separate into the generation and the actual tee skeleton.
Comment 5 youenn fablet 2015-09-28 02:22:38 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > Might be good to add an ASSERT above to ensure name collision does not
> > happen.
> 
> Yep, definitely needed. Actually I remember trying to figure out a crash
> because of a collision so it is very needed.
> 
> The rest of the shallow review looks good. Only one comment you knew I was
> going to make, that is why don't you separate into the generation and the
> actual tee skeleton.

Thanks.
As of tee skeleton, you are right, I could have split it.
It feels a bit safer to validate everything works fine on all bots at the time the binding generator is updated.
Comment 6 youenn fablet 2015-09-30 06:51:46 PDT
Ping review, this is the last patch messing with JSC before being able to do pure JS Builtins DOM classes.
Comment 7 Darin Adler 2015-09-30 08:45:51 PDT
Comment on attachment 261864 [details]
Patch

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

> Source/JavaScriptCore/runtime/CommonIdentifiers.cpp:86
> +}
> +
>  

Extra blank line here.

> Source/JavaScriptCore/runtime/CommonIdentifiers.h:362
> +        JS_EXPORT_PRIVATE void appendExternalName(const Identifier& publicName, const Identifier& privateName);

This API is a bit dangerous and difficult to use correctly. These maps hold pointers to Identifier objects. That means the Identifier itself has to survive, not just the reference counted object the Identifier holds. That might not be clear to the caller. Probably even needs a comment.

> Source/WebCore/bindings/js/JSDOMWindowBase.h:88
> +#if ENABLE(STREAMS_API)
> +        ReadableStreamInternalsBuiltinFunctions m_readableStreamFunctions;
> +#endif

Does this really need to be done like this? It’s not good that we’re going to need to add one of these every time we add another class that uses built-ins. Can we minimize the number of separate places that we have to list ReadableStream explicitly? Instead we could simply have something that is for all built-in functions from all enabled WebCore features and have the #if be done as part of the table generation code instead of at each call site.

I count 10 different places that each had to list this explicitly. That’s not good for the future.

If JSDOMWindowBase and WebCoreJSClientData are going to need to include all of them, then what’s the value of generating each class’s list of names in a separate file?

> Source/WebCore/generate-js-builtins:140
> +class ${Filename}BuiltinFunctions
> +{

We’d normally put the brace on the line before.
Comment 8 youenn fablet 2015-10-01 00:21:23 PDT
Thanks for the review!

(In reply to comment #7)
> Comment on attachment 261864 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=261864&action=review
> 
> > Source/JavaScriptCore/runtime/CommonIdentifiers.cpp:86
> > +}
> > +
> >  
> 
> Extra blank line here.

OK

> 
> > Source/JavaScriptCore/runtime/CommonIdentifiers.h:362
> > +        JS_EXPORT_PRIVATE void appendExternalName(const Identifier& publicName, const Identifier& privateName);
> 
> This API is a bit dangerous and difficult to use correctly. These maps hold
> pointers to Identifier objects. That means the Identifier itself has to
> survive, not just the reference counted object the Identifier holds. That
> might not be clear to the caller. Probably even needs a comment.

Agreed.
I will add a comment.

> > Source/WebCore/bindings/js/JSDOMWindowBase.h:88
> > +#if ENABLE(STREAMS_API)
> > +        ReadableStreamInternalsBuiltinFunctions m_readableStreamFunctions;
> > +#endif
> 
> Does this really need to be done like this? It’s not good that we’re going
> to need to add one of these every time we add another class that uses
> built-ins. Can we minimize the number of separate places that we have to
> list ReadableStream explicitly? Instead we could simply have something that
> is for all built-in functions from all enabled WebCore features and have the
> #if be done as part of the table generation code instead of at each call
> site.
> I count 10 different places that each had to list this explicitly. That’s
> not good for the future.
> 
> If JSDOMWindowBase and WebCoreJSClientData are going to need to include all
> of them, then what’s the value of generating each class’s list of names in a
> separate file?

There are two parameters that need to be handled:
- whether a given js file should be #if ENABLE(...)
- whether a given js file contains functions mapped to WebIDL (owned by JSXXPrototype) or internal functions (owned by the global object).

The first one might be handled by the js generator by including this information as a comment in the js file.
For the second, the same could be done. Or this could be done as part of the build system. Or it could be done by hand since this might happen less often.
Let's do that after ReadableStream is shipped as a refactoring step.

> 
> > Source/WebCore/generate-js-builtins:140
> > +class ${Filename}BuiltinFunctions
> > +{
> 
> We’d normally put the brace on the line before.

OK
Comment 9 youenn fablet 2015-10-01 00:37:16 PDT
Created attachment 262239 [details]
Patch for landing
Comment 10 WebKit Commit Bot 2015-10-01 00:40:30 PDT
Comment on attachment 262239 [details]
Patch for landing

Rejecting attachment 262239 [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-01', 'apply-attachment', '--no-update', '--non-interactive', 262239, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
ore/generate-js-builtins
patching file LayoutTests/ChangeLog
Hunk #1 succeeded at 1 with fuzz 3.
patching file LayoutTests/streams/reference-implementation/readable-stream-expected.txt
patching file LayoutTests/streams/reference-implementation/readable-stream-tee-expected.txt
patching file LayoutTests/streams/reference-implementation/readable-stream-templated-expected.txt

Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Full output: http://webkit-queues.webkit.org/results/231568
Comment 11 youenn fablet 2015-10-01 00:45:11 PDT
Created attachment 262240 [details]
Rebasing for landing
Comment 12 WebKit Commit Bot 2015-10-01 00:48:14 PDT
Attachment 262240 [details] did not pass style-queue:


ERROR: Source/WebCore/bindings/js/JSDOMWindowBase.cpp:93:  Missing space after ,  [whitespace/comma] [3]
Total errors found: 1 in 21 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 youenn fablet 2015-10-01 04:36:06 PDT
Created attachment 262246 [details]
Patch
Comment 14 WebKit Commit Bot 2015-10-01 05:31:09 PDT
Comment on attachment 262246 [details]
Patch

Clearing flags on attachment: 262246

Committed r190401: <http://trac.webkit.org/changeset/190401>
Comment 15 WebKit Commit Bot 2015-10-01 05:31:14 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 youenn fablet 2015-10-02 09:26:04 PDT
> I count 10 different places that each had to list this explicitly. That’s
> not good for the future.
> 
> If JSDOMWindowBase and WebCoreJSClientData are going to need to include all
> of them, then what’s the value of generating each class’s list of names in a
> separate file?

Filed bug 149751 to keep track of it.