Bug 192294 - [WHLSL] Add a handwritten lexer
Summary: [WHLSL] Add a handwritten lexer
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: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on:
Blocks: 192355 192991
  Show dependency treegraph
 
Reported: 2018-12-02 20:33 PST by Myles C. Maxfield
Modified: 2019-01-10 08:45 PST (History)
11 users (show)

See Also:


Attachments
WIP (32.09 KB, patch)
2018-12-02 20:38 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (42.73 KB, patch)
2018-12-18 14:55 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2018-12-02 20:33:11 PST
[WHLSL] Add a handwritten lexer
Comment 1 Myles C. Maxfield 2018-12-02 20:38:41 PST
Created attachment 356353 [details]
WIP
Comment 2 EWS Watchlist 2018-12-02 20:39:52 PST
Attachment 356353 [details] did not pass style-queue:


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: 1 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Myles C. Maxfield 2018-12-18 14:55:38 PST
Created attachment 357617 [details]
Patch
Comment 4 Jon Lee 2018-12-19 01:36:58 PST
Comment on attachment 357617 [details]
Patch

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

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp:556
> +    for ( ; m_offset < m_stringView.length() && !isNewline(m_stringView[m_offset]); ++m_offset) { }

Nit: consistent style of empty block.
Comment 5 Myles C. Maxfield 2018-12-19 15:01:55 PST
Comment on attachment 357617 [details]
Patch

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

>> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp:556
>> +    for ( ; m_offset < m_stringView.length() && !isNewline(m_stringView[m_offset]); ++m_offset) { }
> 
> Nit: consistent style of empty block.

ERROR: Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp:558:  One line control clauses should not use braces.  [whitespace/braces] [4]

and if i use a semicolon

ERROR: Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp:556:  Semicolon defining empty statement for this loop. Use { } instead.  [whitespace/semicolon] [5]
Comment 6 WebKit Commit Bot 2018-12-19 15:27:54 PST
Comment on attachment 357617 [details]
Patch

Clearing flags on attachment: 357617

Committed r239398: <https://trac.webkit.org/changeset/239398>
Comment 7 WebKit Commit Bot 2018-12-19 15:27:56 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Radar WebKit Bug Importer 2018-12-19 15:28:23 PST
<rdar://problem/46854789>
Comment 9 Saam Barati 2019-01-10 01:17:51 PST
Comment on attachment 357617 [details]
Patch

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

> Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp:255
> +auto Lexer::recognizeKeyword(unsigned end) -> std::optional<Token::Type>

Is this slow? Do you know what code LLVM emits for this? Is it actually a bunch of string compares? It might be worth doing what JSC’s lexer does. IIRC, we have a compile step that essentially compiles a function that does this.
Comment 10 Myles C. Maxfield 2019-01-10 08:45:39 PST
Yeah I thought about making a trie at compiler time but I didn’t want to add the complexity in the first patch. I’ll measure how bad the current code is to see if it’s worth it.