Bug 206321 - Pass JSToken by const reference
Summary: Pass JSToken by const reference
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jonathan Bedard
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-01-15 15:42 PST by Jonathan Bedard
Modified: 2020-01-16 10:15 PST (History)
9 users (show)

See Also:


Attachments
Patch (3.54 KB, patch)
2020-01-15 15:44 PST, Jonathan Bedard
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Bedard 2020-01-15 15:42:52 PST
Simon shared shared a lgtm link, this was one of issues identified.

The JSToken object is larger than the word size, so we should really be passing it by const reference, not by value.

https://lgtm.com/projects/g/WebKit/webkit/?tag=&lang=cpp&mode=tree&ruleFocus=2163210742
Comment 1 Jonathan Bedard 2020-01-15 15:44:40 PST
Created attachment 387859 [details]
Patch
Comment 2 Saam Barati 2020-01-15 17:11:18 PST
Comment on attachment 387859 [details]
Patch

This call site concerns me since m_token is a field that's updated as we parse more things

    pattern = createBindingPattern(context, kind, exportType, *m_token.m_data.ident, m_token, bindingContext, duplicateIdentifier);
Comment 3 Saam Barati 2020-01-16 00:20:03 PST
Comment on attachment 387859 [details]
Patch

Actually it looks like this function doesn’t lex, so we’re ok. Passing it by reference is ok since m_token won’t be updated

Can you verify also that it doesn’t end up lexing?

r=me
Comment 4 Jonathan Bedard 2020-01-16 07:54:06 PST
(In reply to Saam Barati from comment #3)
> Comment on attachment 387859 [details]
> Patch
> 
> Actually it looks like this function doesn’t lex, so we’re ok. Passing it by
> reference is ok since m_token won’t be updated
> 
> Can you verify also that it doesn’t end up lexing?
> 
> r=me

It does not lex. And reading through what the function is doing, seems like it shouldn't be lexing in the future either, although this change would sort of force that on us.
Comment 5 WebKit Commit Bot 2020-01-16 10:14:17 PST
Comment on attachment 387859 [details]
Patch

Clearing flags on attachment: 387859

Committed r254689: <https://trac.webkit.org/changeset/254689>
Comment 6 WebKit Commit Bot 2020-01-16 10:14:19 PST
All reviewed patches have been landed.  Closing bug.
Comment 7 Radar WebKit Bug Importer 2020-01-16 10:15:13 PST
<rdar://problem/58648149>