RESOLVED FIXED Bug 170844
[JSC] use ExpressionErrorClassifier for AwaitExpression operand
https://bugs.webkit.org/show_bug.cgi?id=170844
Summary [JSC] use ExpressionErrorClassifier for AwaitExpression operand
Caitlin Potter (:caitp)
Reported 2017-04-13 20:56:41 PDT
[JSC] use ExpressionErrorClassifier for AwaitExpression operand
Attachments
Patch (2.54 KB, patch)
2017-04-13 20:57 PDT, Caitlin Potter (:caitp)
no flags
Patch (2.91 KB, patch)
2017-04-14 07:12 PDT, Caitlin Potter (:caitp)
no flags
Patch (2.80 KB, patch)
2017-04-14 08:08 PDT, Caitlin Potter (:caitp)
no flags
Patch (3.05 KB, patch)
2017-04-14 12:02 PDT, Caitlin Potter (:caitp)
no flags
Patch for landing (3.05 KB, patch)
2017-04-14 12:02 PDT, Caitlin Potter (:caitp)
no flags
Patch for landing (3.05 KB, patch)
2017-04-14 12:06 PDT, Caitlin Potter (:caitp)
no flags
Caitlin Potter (:caitp)
Comment 1 2017-04-13 20:57:09 PDT
Sam Weinig
Comment 2 2017-04-14 00:08:38 PDT
Comment on attachment 307087 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307087&action=review > Source/JavaScriptCore/ChangeLog:9 > + * parser/Parser.cpp: > + (JSC::Parser<LexerType>::parseAwaitExpression): The changelog should ideally include information about why this change is being made. Just from the patch and the test, it isn't immediately clear what is being fixed.
Caitlin Potter (:caitp)
Comment 3 2017-04-14 07:12:25 PDT
Caitlin Potter (:caitp)
Comment 4 2017-04-14 08:08:07 PDT
Saam Barati
Comment 5 2017-04-14 08:29:54 PDT
Comment on attachment 307114 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307114&action=review > Source/JavaScriptCore/parser/Parser.cpp:3558 > + ExpressionErrorClassifier classifier(this); Does this change the error message that's produced?
Caitlin Potter (:caitp)
Comment 6 2017-04-14 09:10:36 PDT
Comment on attachment 307114 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307114&action=review >> Source/JavaScriptCore/parser/Parser.cpp:3558 >> + ExpressionErrorClassifier classifier(this); > > Does this change the error message that's produced? No, it still produces "Unexpected token '=>'"
Saam Barati
Comment 7 2017-04-14 09:47:06 PDT
Comment on attachment 307114 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307114&action=review >>> Source/JavaScriptCore/parser/Parser.cpp:3558 >>> + ExpressionErrorClassifier classifier(this); >> >> Does this change the error message that's produced? > > No, it still produces "Unexpected token '=>'" I'm confused then what the point of this is? What does ExpressionErrorClassifier do?
Caitlin Potter (:caitp)
Comment 8 2017-04-14 09:59:25 PDT
(In reply to Saam Barati from comment #7) > Comment on attachment 307114 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=307114&action=review > > >>> Source/JavaScriptCore/parser/Parser.cpp:3558 > >>> + ExpressionErrorClassifier classifier(this); > >> > >> Does this change the error message that's produced? > > > > No, it still produces "Unexpected token '=>'" > > I'm confused then what the point of this is? What does > ExpressionErrorClassifier do? The classifier records hints that indicate which cover grammar productions to try. It allows the parser to skip cover grammars in some cases.
Saam Barati
Comment 9 2017-04-14 10:08:21 PDT
Comment on attachment 307114 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=307114&action=review >>>>> Source/JavaScriptCore/parser/Parser.cpp:3558 >>>>> + ExpressionErrorClassifier classifier(this); >>>> >>>> Does this change the error message that's produced? >>> >>> No, it still produces "Unexpected token '=>'" >> >> I'm confused then what the point of this is? What does ExpressionErrorClassifier do? > > The classifier records hints that indicate which cover grammar productions to try. It allows the parser to skip cover grammars in some cases. Ok, I just read the code to see what this does. I'm still a bit confused why this is needed for correctness. Can you explain that a bit more? What's the issue you're fixing?
Caitlin Potter (:caitp)
Comment 10 2017-04-14 10:21:24 PDT
(In reply to Saam Barati from comment #9) > Comment on attachment 307114 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=307114&action=review > > >>>>> Source/JavaScriptCore/parser/Parser.cpp:3558 > >>>>> + ExpressionErrorClassifier classifier(this); > >>>> > >>>> Does this change the error message that's produced? > >>> > >>> No, it still produces "Unexpected token '=>'" > >> > >> I'm confused then what the point of this is? What does ExpressionErrorClassifier do? > > > > The classifier records hints that indicate which cover grammar productions to try. It allows the parser to skip cover grammars in some cases. > > Ok, I just read the code to see what this does. I'm still a bit confused why > this is needed for correctness. Can you explain that a bit more? What's the > issue you're fixing? Inside parseUnaryExpression, we eventually reach parseMemberExpression(), and see `async()` followed by a `=>` token. In an AssignmentExpression context rather than a UnaryExpression context, this would mean "parse the async arrow function cover grammar", so it records a hint to do that. But the AssignmentExpression started with `await` rather than `async`, so restoring the save point to parse the cover grammar fails this assertion and crashes. The goal is to prevent the branch that leads to that assertion from being parsed at all. This is done by adding another hint recording scope, which allows the hint to be discarded properly. parseAssignmentExpression uses the hint to determine which arrow function cover grammar to parse, rather than trying both.
Saam Barati
Comment 11 2017-04-14 10:23:32 PDT
(In reply to Caitlin Potter (:caitp) from comment #10) > (In reply to Saam Barati from comment #9) > > Comment on attachment 307114 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=307114&action=review > > > > >>>>> Source/JavaScriptCore/parser/Parser.cpp:3558 > > >>>>> + ExpressionErrorClassifier classifier(this); > > >>>> > > >>>> Does this change the error message that's produced? > > >>> > > >>> No, it still produces "Unexpected token '=>'" > > >> > > >> I'm confused then what the point of this is? What does ExpressionErrorClassifier do? > > > > > > The classifier records hints that indicate which cover grammar productions to try. It allows the parser to skip cover grammars in some cases. > > > > Ok, I just read the code to see what this does. I'm still a bit confused why > > this is needed for correctness. Can you explain that a bit more? What's the > > issue you're fixing? > > Inside parseUnaryExpression, we eventually reach parseMemberExpression(), > and see `async()` followed by a `=>` token. > > In an AssignmentExpression context rather than a UnaryExpression context, > this would mean "parse the async arrow function cover grammar", so it > records a hint to do that. But the AssignmentExpression started with `await` > rather than `async`, so restoring the save point to parse the cover grammar > fails this assertion and crashes. > > The goal is to prevent the branch that leads to that assertion from being > parsed at all. This is done by adding another hint recording scope, which > allows the hint to be discarded properly. > > parseAssignmentExpression uses the hint to determine which arrow function > cover grammar to parse, rather than trying both. Gotcha. Can you add this explanation to the changelog?
Saam Barati
Comment 12 2017-04-14 10:23:41 PDT
Comment on attachment 307114 [details] Patch r=me
Caitlin Potter (:caitp)
Comment 13 2017-04-14 10:36:23 PDT
(In reply to Saam Barati from comment #11) > (In reply to Caitlin Potter (:caitp) from comment #10) > > (In reply to Saam Barati from comment #9) > > > Comment on attachment 307114 [details] > > > Patch > > > > > > View in context: > > > https://bugs.webkit.org/attachment.cgi?id=307114&action=review > > > > > > >>>>> Source/JavaScriptCore/parser/Parser.cpp:3558 > > > >>>>> + ExpressionErrorClassifier classifier(this); > > > >>>> > > > >>>> Does this change the error message that's produced? > > > >>> > > > >>> No, it still produces "Unexpected token '=>'" > > > >> > > > >> I'm confused then what the point of this is? What does ExpressionErrorClassifier do? > > > > > > > > The classifier records hints that indicate which cover grammar productions to try. It allows the parser to skip cover grammars in some cases. > > > > > > Ok, I just read the code to see what this does. I'm still a bit confused why > > > this is needed for correctness. Can you explain that a bit more? What's the > > > issue you're fixing? > > > > Inside parseUnaryExpression, we eventually reach parseMemberExpression(), > > and see `async()` followed by a `=>` token. > > > > In an AssignmentExpression context rather than a UnaryExpression context, > > this would mean "parse the async arrow function cover grammar", so it > > records a hint to do that. But the AssignmentExpression started with `await` > > rather than `async`, so restoring the save point to parse the cover grammar > > fails this assertion and crashes. > > > > The goal is to prevent the branch that leads to that assertion from being > > parsed at all. This is done by adding another hint recording scope, which > > allows the hint to be discarded properly. > > > > parseAssignmentExpression uses the hint to determine which arrow function > > cover grammar to parse, rather than trying both. > > Gotcha. Can you add this explanation to the changelog? Sure. Hows this, does this seem clear/understandable? ``` In parseAssignmentExpression(), several cover grammars are handled, and use ExpressionErrorClassifier to record hints about which grammars to try. In parseAwaitExpression(), the hints recorded during parsing of the operand need to be discarded, because if they propagate to the outer parseAssignmentExpression(), the hints will lead the parser down invalid branches that should be skipped, but are not. This change adds an additional ExpressionErrorClassifier to parseAwaitExpression(), in order to discard hints recorded by the operand. ```
Caitlin Potter (:caitp)
Comment 14 2017-04-14 12:02:18 PDT
Caitlin Potter (:caitp)
Comment 15 2017-04-14 12:02:32 PDT
Created attachment 307130 [details] Patch for landing
WebKit Commit Bot
Comment 16 2017-04-14 12:03:17 PDT
Comment on attachment 307130 [details] Patch for landing Rejecting attachment 307130 [details] from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'validate-changelog', '--check-oops', '--non-interactive', 307130, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit ChangeLog entry in JSTests/ChangeLog contains OOPS!. Full output: http://webkit-queues.webkit.org/results/3535149
Caitlin Potter (:caitp)
Comment 17 2017-04-14 12:06:11 PDT
Created attachment 307131 [details] Patch for landing
Caitlin Potter (:caitp)
Comment 18 2017-04-14 12:06:48 PDT
(In reply to WebKit Commit Bot from comment #16) > Comment on attachment 307130 [details] > Patch for landing > > Rejecting attachment 307130 [details] from commit-queue. > > Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', > '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', > 'validate-changelog', '--check-oops', '--non-interactive', 307130, > '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit > > ChangeLog entry in JSTests/ChangeLog contains OOPS!. > > Full output: http://webkit-queues.webkit.org/results/3535149 webkit-patch workflow remains very confusing T_T
WebKit Commit Bot
Comment 19 2017-04-14 12:50:27 PDT
Comment on attachment 307131 [details] Patch for landing Clearing flags on attachment: 307131 Committed r215370: <http://trac.webkit.org/changeset/215370>
WebKit Commit Bot
Comment 20 2017-04-14 12:50:29 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.