Bug 238264 - Prepare JSC for making the String(const char*) constructor explicit
Summary: Prepare JSC for making the String(const char*) constructor explicit
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 238693
  Show dependency treegraph
 
Reported: 2022-03-23 09:28 PDT by Chris Dumez
Modified: 2022-04-01 19:56 PDT (History)
27 users (show)

See Also:


Attachments
Patch (651.97 KB, patch)
2022-03-23 10:50 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (652.23 KB, patch)
2022-03-23 11:30 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (652.25 KB, patch)
2022-03-23 11:36 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (651.99 KB, patch)
2022-03-23 11:51 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (651.99 KB, patch)
2022-03-23 12:29 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (651.18 KB, patch)
2022-03-23 16:04 PDT, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2022-03-23 09:28:34 PDT
Prepare JSC for making the String(const char*) constructor explicit.
Making this constructor explicit helps catch at compile time cases where the ""_s prefix is missing on String literals.
Comment 1 Chris Dumez 2022-03-23 10:50:01 PDT
Created attachment 455518 [details]
Patch
Comment 2 Chris Dumez 2022-03-23 11:30:42 PDT
Created attachment 455530 [details]
Patch
Comment 3 Chris Dumez 2022-03-23 11:36:46 PDT
Created attachment 455533 [details]
Patch
Comment 4 Chris Dumez 2022-03-23 11:51:25 PDT
Created attachment 455534 [details]
Patch
Comment 5 Darin Adler 2022-03-23 12:17:27 PDT
Comment on attachment 455518 [details]
Patch

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

I love how this reveals the idioms used. Some comments about the less-great ones here.

Another thing this points out is cases where Latin-1 may not be the right way to interpret non-ASCII characters and we might want UTF-8 instead.

I like the idea of landing the obviously 100% correct _s cases first, so the biggest patch is the most obviously right. Like all the ClassInfo.

> Source/JavaScriptCore/API/JSAPIGlobalObject.mm:93
> +        absoluteURL = URL(URL({ }, "file://"_s), specifier);

This isn’t taking advantage of our new simpler URL constructor!

> Source/JavaScriptCore/API/JSValue.mm:1182
> +        StructHandlers::iterator iter = structHandlers->find(String { type.get() });

Seems like an unfortunate situation where we have to make a String just to search for something. Probably fixable.

> Source/JavaScriptCore/API/JSValue.mm:1220
> +    StructHandlers::iterator iter = structHandlers->find(String { encodedType });

Ditto.

> Source/JavaScriptCore/API/JSWrapperMap.mm:454
> +            auto iter = initTable.find(String { name });

Ditto.

> Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.cpp:95
> +    auto functionString = makeString("(function(WebInspectorAudit) { \"use strict\"; return eval(`(", String { test }.replace('`', "\\`"_s), ")`)(WebInspectorAudit); })");

Ah, make a String just to pass it to replace, yuck.

> Source/JavaScriptCore/jsc.cpp:1099
> +        return FileSystem::pathByAppendingComponent(String { cachePath }, makeString(source().toString().hash(), '-', filename, ".bytecode-cache"));

Maybe this FileSystem function should be changed to take StringView.
Comment 6 Chris Dumez 2022-03-23 12:19:38 PDT
(In reply to Darin Adler from comment #5)
> Comment on attachment 455518 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=455518&action=review
> 
> I love how this reveals the idioms used. Some comments about the less-great
> ones here.
> 
> Another thing this points out is cases where Latin-1 may not be the right
> way to interpret non-ASCII characters and we might want UTF-8 instead.
> 
> I like the idea of landing the obviously 100% correct _s cases first, so the
> biggest patch is the most obviously right. Like all the ClassInfo.
> 
> > Source/JavaScriptCore/API/JSAPIGlobalObject.mm:93
> > +        absoluteURL = URL(URL({ }, "file://"_s), specifier);
> 
> This isn’t taking advantage of our new simpler URL constructor!
> 
> > Source/JavaScriptCore/API/JSValue.mm:1182
> > +        StructHandlers::iterator iter = structHandlers->find(String { type.get() });
> 
> Seems like an unfortunate situation where we have to make a String just to
> search for something. Probably fixable.
> 
> > Source/JavaScriptCore/API/JSValue.mm:1220
> > +    StructHandlers::iterator iter = structHandlers->find(String { encodedType });
> 
> Ditto.
> 
> > Source/JavaScriptCore/API/JSWrapperMap.mm:454
> > +            auto iter = initTable.find(String { name });
> 
> Ditto.
> 
> > Source/JavaScriptCore/inspector/agents/InspectorAuditAgent.cpp:95
> > +    auto functionString = makeString("(function(WebInspectorAudit) { \"use strict\"; return eval(`(", String { test }.replace('`', "\\`"_s), ")`)(WebInspectorAudit); })");
> 
> Ah, make a String just to pass it to replace, yuck.

Yes, I am working on adding an overload that takes a StringView separately.

> 
> > Source/JavaScriptCore/jsc.cpp:1099
> > +        return FileSystem::pathByAppendingComponent(String { cachePath }, makeString(source().toString().hash(), '-', filename, ".bytecode-cache"));
> 
> Maybe this FileSystem function should be changed to take StringView.
Comment 7 Chris Dumez 2022-03-23 12:29:11 PDT
Created attachment 455538 [details]
Patch
Comment 8 Geoffrey Garen 2022-03-23 15:58:53 PDT
Comment on attachment 455538 [details]
Patch

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

r=me

> Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:214
> -            className = thisObject->className(vm);
> +            className =  thisObject->className(vm);

oops?
Comment 9 Chris Dumez 2022-03-23 16:04:23 PDT
Created attachment 455574 [details]
Patch
Comment 10 Chris Dumez 2022-03-23 18:40:50 PDT
Committed r291779 (248807@trunk): <https://commits.webkit.org/248807@trunk>
Comment 11 Radar WebKit Bug Importer 2022-03-23 18:41:47 PDT
<rdar://problem/90738742>
Comment 12 EWS 2022-03-23 20:40:57 PDT
Found 1 new test failure: imported/w3c/web-platform-tests/webstorage/event_case_sensitive.html