Bug 171737 - Move trivial String prototype functions to JS builtins
Summary: Move trivial String prototype functions to JS builtins
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Oliver Hunt
URL:
Keywords: InRadar
Depends on: 171786
Blocks:
  Show dependency treegraph
 
Reported: 2017-05-05 10:48 PDT by Oliver Hunt
Modified: 2017-05-08 09:28 PDT (History)
14 users (show)

See Also:


Attachments
Patch (16.79 KB, patch)
2017-05-05 10:51 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff
Patch (16.85 KB, patch)
2017-05-05 11:07 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff
Patch (17.65 KB, patch)
2017-05-05 12:04 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff
Patch (17.64 KB, patch)
2017-05-05 13:01 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-elcapitan (975.98 KB, application/zip)
2017-05-05 14:08 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-elcapitan-wk2 (914.47 KB, application/zip)
2017-05-05 14:13 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews124 for ios-simulator-wk2 (20.27 MB, application/zip)
2017-05-05 14:19 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews116 for mac-elcapitan (1.75 MB, application/zip)
2017-05-05 14:25 PDT, Build Bot
no flags Details
Patch (21.43 KB, patch)
2017-05-05 14:30 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-elcapitan (1.17 MB, application/zip)
2017-05-05 15:12 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (1.30 MB, application/zip)
2017-05-05 15:17 PDT, Build Bot
no flags Details
Patch (26.71 KB, patch)
2017-05-05 15:27 PDT, Oliver Hunt
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2017-05-05 10:48:09 PDT
Move trivial String prototype functions to JS builtins
Comment 1 Oliver Hunt 2017-05-05 10:51:25 PDT
Created attachment 309182 [details]
Patch
Comment 2 Oliver Hunt 2017-05-05 10:52:46 PDT
Still waiting on my build completing, but obviously it will work right?
Comment 3 Oliver Hunt 2017-05-05 10:54:50 PDT
<rdar://problem/32005106>
Comment 4 Geoffrey Garen 2017-05-05 10:55:39 PDT
Comment on attachment 309182 [details]
Patch

r=me

Shiny
Comment 5 Yusuke Suzuki 2017-05-05 11:00:00 PDT
Comment on attachment 309182 [details]
Patch

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

a bit comments.

> Source/JavaScriptCore/builtins/StringPrototype.js:318
> +        let escapedV = V.replace('"', '&quot;');

String.prototype.replace can be altered by user code. I suggest exposing @replace in StringPrototype and using it.

> Source/JavaScriptCore/builtins/StringPrototype.js:330
> +    return createHTML("String.prototype.link", this, "a", "name", url)

Need to use `@createHTML`.

> Source/JavaScriptCore/runtime/StringPrototype.cpp:90
>  EncodedJSValue JSC_HOST_CALL stringProtoFuncAnchor(ExecState*);

We can drop other function declarations.
Comment 6 Oliver Hunt 2017-05-05 11:07:11 PDT
Created attachment 309187 [details]
Patch
Comment 7 Oliver Hunt 2017-05-05 11:11:06 PDT
Just pushing some fixes because apparently blindly assuming my code would be correct before waiting for the compile to finish wasn't correct :D

Who would have thunk it?

No meaningful changes (forgot @, and accidentally dropped blink() :D )
Comment 8 Oliver Hunt 2017-05-05 11:11:35 PDT
(In reply to Yusuke Suzuki from comment #5)
> Comment on attachment 309182 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=309182&action=review
> 
> a bit comments.
> 
> > Source/JavaScriptCore/builtins/StringPrototype.js:318
> > +        let escapedV = V.replace('"', '&quot;');
> 
Zomg, i'm an idiot, will definitely do that :D

Such unsafe code :D
Comment 9 Oliver Hunt 2017-05-05 11:12:06 PDT
Comment on attachment 309187 [details]
Patch

Yusuke's spotted a horrifying issue (String.replace can be dropped)
Comment 10 Oliver Hunt 2017-05-05 12:04:26 PDT
Created attachment 309195 [details]
Patch
Comment 11 Oliver Hunt 2017-05-05 12:07:04 PDT
Comment on attachment 309195 [details]
Patch

Correct the .replace issue yusuke saw tests passed locally
Comment 12 Saam Barati 2017-05-05 12:37:06 PDT
Comment on attachment 309195 [details]
Patch

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

> Source/JavaScriptCore/builtins/StringPrototype.js:324
> +    return p4;

Maybe use a template literal for these last 3 concatenations?
Comment 13 Saam Barati 2017-05-05 12:37:50 PDT
Comment on attachment 309195 [details]
Patch

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

> Source/JavaScriptCore/builtins/StringPrototype.js:319
> +        p1 = p1 + " " + @toString(attribute) + '="' + escapedV + '"'

Maybe same here?
Comment 14 Oliver Hunt 2017-05-05 12:38:41 PDT
Comment on attachment 309195 [details]
Patch

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

>> Source/JavaScriptCore/builtins/StringPrototype.js:324
>> +    return p4;
> 
> Maybe use a template literal for these last 3 concatenations?

I pondered doing that (I initially had template literals) but i decided it would be better to just match the spec text.
Comment 15 Build Bot 2017-05-05 12:46:34 PDT
Comment on attachment 309195 [details]
Patch

Attachment 309195 [details] did not pass jsc-ews (mac):
Output: http://webkit-queues.webkit.org/results/3680420

New failing tests:
ChakraCore.yaml/ChakraCore/test/Strings/StringTagFunctions.js.default
ChakraCore.yaml/ChakraCore/test/Strings/HTMLHelpers.js.default
Comment 16 Oliver Hunt 2017-05-05 13:01:28 PDT
Created attachment 309200 [details]
Patch
Comment 17 Build Bot 2017-05-05 14:08:05 PDT
Comment on attachment 309200 [details]
Patch

Attachment 309200 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3680795

New failing tests:
js/dom/string-fontcolor.html
js/dom/string-anchor.html
js/dom/string-fontsize.html
js/dom/string-link.html
Comment 18 Build Bot 2017-05-05 14:08:07 PDT
Created attachment 309203 [details]
Archive of layout-test-results from ews101 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 19 Build Bot 2017-05-05 14:13:05 PDT
Comment on attachment 309200 [details]
Patch

Attachment 309200 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3680801

New failing tests:
js/dom/string-fontcolor.html
js/dom/string-anchor.html
js/dom/string-fontsize.html
js/dom/string-link.html
Comment 20 Build Bot 2017-05-05 14:13:07 PDT
Created attachment 309205 [details]
Archive of layout-test-results from ews106 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 21 Build Bot 2017-05-05 14:19:05 PDT
Comment on attachment 309200 [details]
Patch

Attachment 309200 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3680753

New failing tests:
js/dom/string-fontcolor.html
js/dom/string-anchor.html
js/dom/string-fontsize.html
js/dom/string-link.html
Comment 22 Build Bot 2017-05-05 14:19:07 PDT
Created attachment 309208 [details]
Archive of layout-test-results from ews124 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews124  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 23 Build Bot 2017-05-05 14:25:09 PDT
Comment on attachment 309200 [details]
Patch

Attachment 309200 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3680812

New failing tests:
js/dom/string-fontcolor.html
js/dom/string-anchor.html
js/dom/string-fontsize.html
js/dom/string-link.html
Comment 24 Build Bot 2017-05-05 14:25:11 PDT
Created attachment 309211 [details]
Archive of layout-test-results from ews116 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 25 Oliver Hunt 2017-05-05 14:30:27 PDT
Created attachment 309212 [details]
Patch
Comment 26 Oliver Hunt 2017-05-05 14:31:09 PDT
Getting build bots to give me expected outputs.
Comment 27 Build Bot 2017-05-05 15:12:33 PDT
Comment on attachment 309212 [details]
Patch

Attachment 309212 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3681157

New failing tests:
js/dom/string-fontcolor.html
js/dom/string-anchor.html
js/dom/string-fontsize.html
js/dom/string-link.html
Comment 28 Build Bot 2017-05-05 15:12:35 PDT
Created attachment 309218 [details]
Archive of layout-test-results from ews101 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 29 Build Bot 2017-05-05 15:17:04 PDT
Comment on attachment 309212 [details]
Patch

Attachment 309212 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3681163

New failing tests:
js/dom/string-fontcolor.html
js/dom/string-anchor.html
js/dom/string-fontsize.html
js/dom/string-link.html
Comment 30 Build Bot 2017-05-05 15:17:06 PDT
Created attachment 309219 [details]
Archive of layout-test-results from ews105 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews105  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 31 Oliver Hunt 2017-05-05 15:27:20 PDT
Created attachment 309223 [details]
Patch
Comment 32 Oliver Hunt 2017-05-05 15:27:53 PDT
Comment on attachment 309223 [details]
Patch

Finally should pass everything
Comment 33 Saam Barati 2017-05-05 16:46:50 PDT
Comment on attachment 309223 [details]
Patch

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

> Source/JavaScriptCore/builtins/StringPrototype.js:312
> +    if (string == null)

Do we care about document.all here counting as undefined?
Comment 34 Oliver Hunt 2017-05-05 16:49:13 PDT
Comment on attachment 309223 [details]
Patch

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

>> Source/JavaScriptCore/builtins/StringPrototype.js:312
>> +    if (string == null)
> 
> Do we care about document.all here counting as undefined?

I believe not -- this matches the impl of all the other string functions
Comment 35 WebKit Commit Bot 2017-05-05 17:33:23 PDT
Comment on attachment 309223 [details]
Patch

Clearing flags on attachment: 309223

Committed r216301: <http://trac.webkit.org/changeset/216301>
Comment 36 WebKit Commit Bot 2017-05-05 17:33:25 PDT
All reviewed patches have been landed.  Closing bug.
Comment 37 Myles C. Maxfield 2017-05-05 18:16:16 PDT
Reopening to attach new patch.
Comment 38 Joseph Pecoraro 2017-05-05 18:52:49 PDT
Comment on attachment 309223 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:11
> +        Core implementation is basically a 1-for-1 match to the spec.

Indeed it does! Would be nice to link to it:
https://tc39.github.io/ecma262/#sec-createhtml

> Source/JavaScriptCore/builtins/StringPrototype.js:319
> +        p1 = p1 + " " + @toString(attribute) + '="' + escapedV + '"'

Nit: Semicolon

> Source/JavaScriptCore/builtins/StringPrototype.js:321
> +    let p2 = p1 + ">"

Nit: Semicolon

> Source/JavaScriptCore/builtins/StringPrototype.js:330
> +    return @createHTML("String.prototype.link", this, "a", "name", url)

Nit: Semicolon
Comment 39 Oliver Hunt 2017-05-05 21:14:50 PDT
(In reply to Myles C. Maxfield from comment #37)
> Reopening to attach new patch.

Wait did this get rolled out?
Comment 40 David Kilzer (:ddkilzer) 2017-05-07 14:46:27 PDT
(In reply to Oliver Hunt from comment #39)
> (In reply to Myles C. Maxfield from comment #37)
> > Reopening to attach new patch.
> 
> Wait did this get rolled out?

No, it didn't get rolled out.  Myles re-opened the wrong bug.

Moving back to RESOLVED/FIXED.
Comment 41 Mark Lam 2017-05-08 09:21:21 PDT
FYI, this patch caused a regression: https://bugs.webkit.org/show_bug.cgi?id=171786