WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
194419
[JSC] Shrink sizeof(CodeBlock) more
https://bugs.webkit.org/show_bug.cgi?id=194419
Summary
[JSC] Shrink sizeof(CodeBlock) more
Yusuke Suzuki
Reported
2019-02-07 16:28:51 PST
[JSC] Shrink sizeof(CodeBlock) more
Attachments
Patch
(84.86 KB, patch)
2019-02-07 16:35 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(84.85 KB, patch)
2019-02-07 17:47 PST
,
Yusuke Suzuki
no flags
Details
Formatted Diff
Diff
Patch
(86.22 KB, patch)
2019-02-07 18:08 PST
,
Yusuke Suzuki
mark.lam
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Yusuke Suzuki
Comment 1
2019-02-07 16:35:53 PST
Created
attachment 361469
[details]
Patch
EWS Watchlist
Comment 2
2019-02-07 16:41:38 PST
Attachment 361469
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/ChangeLog:94: Please consider whether the use of security-sensitive phrasing could help someone exploit WebKit: fuzzing [changelog/unwantedsecurityterms] [3] Total errors found: 1 in 37 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 3
2019-02-07 17:47:40 PST
Created
attachment 361477
[details]
Patch
EWS Watchlist
Comment 4
2019-02-07 17:49:25 PST
Attachment 361477
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/ChangeLog:94: Please consider whether the use of security-sensitive phrasing could help someone exploit WebKit: fuzzing [changelog/unwantedsecurityterms] [3] Total errors found: 1 in 37 files If any of these errors are false positives, please file a bug against check-webkit-style.
Yusuke Suzuki
Comment 5
2019-02-07 18:08:25 PST
Created
attachment 361482
[details]
Patch
EWS Watchlist
Comment 6
2019-02-07 18:10:27 PST
Attachment 361482
[details]
did not pass style-queue: ERROR: Source/JavaScriptCore/ChangeLog:94: Please consider whether the use of security-sensitive phrasing could help someone exploit WebKit: fuzzing [changelog/unwantedsecurityterms] [3] ERROR: Source/WebCore/ChangeLog:8: You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible. [changelog/nonewtests] [5] Total errors found: 2 in 39 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Lam
Comment 7
2019-02-08 15:34:22 PST
Comment on
attachment 361482
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=361482&action=review
Very nice. r=me with suggestions.
> Source/JavaScriptCore/bytecode/CodeBlock.cpp:526 > - for (const auto& instruction : *m_instructions) { > + for (const auto& instruction : instructions()) {
Pre-cache instructions() in a local before the loop so that the compiler knows that it won't change on each iteration.
> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1074 > + auto instruction = instructions().at(propertyAccessInstructions[i]);
Precache instructions in a local before loop.
> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1204 > + const auto curInstruction = instructions().at(propertyAccessInstructions[i]);
Precache instructions in a local before loop.
> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1711 > + auto instruction = instructions().at(bytecodeOffset);
Use auto& to make is explicit at a glance that this is a reference.
> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1816 > + for (const auto& it : instructions()) {
Precache instructions in a local before loop.
> Source/JavaScriptCore/bytecode/CodeBlock.cpp:2755 > + for (const auto& instruction : instructions()) {
Precache instructions in a local before loop.
> Source/JavaScriptCore/bytecode/CodeBlock.cpp:2944 > + for (const auto& instruction : instructions()) {
Precache instructions in a local before loop.
Yusuke Suzuki
Comment 8
2019-02-08 16:18:31 PST
Comment on
attachment 361482
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=361482&action=review
Thank you!
>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:526 >> + for (const auto& instruction : instructions()) { > > Pre-cache instructions() in a local before the loop so that the compiler knows that it won't change on each iteration.
Fixed.
>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1074 >> + auto instruction = instructions().at(propertyAccessInstructions[i]); > > Precache instructions in a local before loop.
Fixed.
>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1204 >> + const auto curInstruction = instructions().at(propertyAccessInstructions[i]); > > Precache instructions in a local before loop.
Fixed.
>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1711 >> + auto instruction = instructions().at(bytecodeOffset); > > Use auto& to make is explicit at a glance that this is a reference.
Fixed.
>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:1816 >> + for (const auto& it : instructions()) { > > Precache instructions in a local before loop.
Fixed.
>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:2755 >> + for (const auto& instruction : instructions()) { > > Precache instructions in a local before loop.
Fixed.
>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:2944 >> + for (const auto& instruction : instructions()) { > > Precache instructions in a local before loop.
Fixed.
Yusuke Suzuki
Comment 9
2019-02-08 16:29:31 PST
Committed
r241222
: <
https://trac.webkit.org/changeset/241222
>
Radar WebKit Bug Importer
Comment 10
2019-02-08 16:30:38 PST
<
rdar://problem/47934328
>
Darin Adler
Comment 11
2019-02-09 12:13:18 PST
Comment on
attachment 361482
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=361482&action=review
>>> Source/JavaScriptCore/bytecode/CodeBlock.cpp:526 >>> + for (const auto& instruction : instructions()) { >> >> Pre-cache instructions() in a local before the loop so that the compiler knows that it won't change on each iteration. > > Fixed.
While it’s OK to do this if you prefer it from a stylistic point of view, there is no need to change it for correct behavior. The way a range for loop is defined, the compiler will not and must not call instructions() more than once. An example of an on-line reference that makes this clear is <
https://en.cppreference.com/w/cpp/language/range-for
>.
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