WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
238911
Reduce number of StringView to String conversions in JSC
https://bugs.webkit.org/show_bug.cgi?id=238911
Summary
Reduce number of StringView to String conversions in JSC
Chris Dumez
Reported
2022-04-06 16:50:39 PDT
Reduce number of StringView to String conversions in JSC.
Attachments
Patch
(36.55 KB, patch)
2022-04-06 17:05 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(36.57 KB, patch)
2022-04-06 18:15 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(38.44 KB, patch)
2022-04-07 14:26 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Patch
(38.42 KB, patch)
2022-04-07 19:49 PDT
,
Chris Dumez
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Chris Dumez
Comment 1
2022-04-06 17:05:47 PDT
Created
attachment 456878
[details]
Patch
Chris Dumez
Comment 2
2022-04-06 18:15:23 PDT
Created
attachment 456880
[details]
Patch
Darin Adler
Comment 3
2022-04-07 12:36:55 PDT
Comment on
attachment 456880
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=456880&action=review
> Source/JavaScriptCore/dfg/DFGLazyJSValue.cpp:54 > + return jsString(vm, String { u.stringImpl });
While this resolves ambiguity, it misses the chance to reduce reference count churn, since there’s no need for a temporary String here. I suppose we can fix that by adding an overload of jsString that takes an rvalue reference? Or one that takes a StringImpl*.
> Source/JavaScriptCore/dfg/DFGLazyJSValue.cpp:56 > return jsString(vm, AtomStringImpl::add(u.stringImpl));
Same issue/opportunity here?
> Source/JavaScriptCore/jsc.cpp:1099 > + return FileSystem::pathByAppendingComponent(cachePath, makeString(StringViewHashTranslator::hash(source()), '-', filename, ".bytecode-cache"));
Does this really need to be in the StringViewHashTranslator namespace? I know the hash translator has to use it, but is that the best way to call it?
> Source/JavaScriptCore/runtime/ExceptionHelpers.cpp:211 > + String rightHandSide = sourceText.substring(inIndex + inLength).toStringWithoutCopying().simplifyWhiteSpace();
What a waste creating a String here at all. Does this really need "simplifyWhitespace"? Maybe we can write a version that doesn’t allocate memory in the super-common case where there is no whitespace that needs to be simplified. Some day.
> Source/JavaScriptCore/runtime/ExceptionHelpers.cpp:230 > + String rightHandSide = sourceText.substring(instanceofIndex + instanceofLength).toStringWithoutCopying().simplifyWhiteSpace();
Ditto.
> Source/JavaScriptCore/runtime/IdentifierInlines.h:132 > + return jsString(vm, String { identifier.impl() });
Same reference count churn thought as above.
> Source/JavaScriptCore/runtime/IdentifierInlines.h:139 > + return jsString(vm, String { identifier.impl() });
Ditto.
> Source/JavaScriptCore/runtime/JSModuleLoader.cpp:235 > + arguments.append(jsString(vm, String { moduleKey.impl() }));
Same reference count churn thing.
> Source/JavaScriptCore/runtime/JSModuleLoader.cpp:401 > + result->putDirectIndex(globalObject, i++, jsString(vm, String { key.get() }));
Again.
> Source/JavaScriptCore/runtime/JSString.h:891 > + auto impl = s.is8Bit() ? StringImpl::create(s.characters8(), s.length()) : StringImpl::create(s.characters16(), s.length());
Truly unfortunate if the StringView came from an existing String; I guess overloading decreases the chance that will occur.
> Source/JavaScriptCore/runtime/SymbolConstructor.cpp:128 > + return JSValue::encode(jsString(vm, String { uid }));
Yet another chance to avoid reference count churn.
Chris Dumez
Comment 4
2022-04-07 14:26:14 PDT
Created
attachment 456968
[details]
Patch
Chris Dumez
Comment 5
2022-04-07 19:49:00 PDT
Created
attachment 457005
[details]
Patch
EWS
Comment 6
2022-04-08 10:56:03 PDT
Committed
r292619
(
249443@main
): <
https://commits.webkit.org/249443@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 457005
[details]
.
Radar WebKit Bug Importer
Comment 7
2022-04-08 10:57:18 PDT
<
rdar://problem/91492071
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug