WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 139416
Removed some allocation and cruft from the parser
https://bugs.webkit.org/show_bug.cgi?id=139416
Summary
Removed some allocation and cruft from the parser
Geoffrey Garen
Reported
2014-12-08 14:55:33 PST
Removed some allocation and cruft from the parser
Attachments
Patch
(36.49 KB, patch)
2014-12-08 15:51 PST
,
Geoffrey Garen
mark.lam
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Geoffrey Garen
Comment 1
2014-12-08 15:51:57 PST
Created
attachment 242857
[details]
Patch
Mark Lam
Comment 2
2014-12-08 16:51:17 PST
Comment on
attachment 242857
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=242857&action=review
r=me with one suggestion.
> Source/JavaScriptCore/parser/SyntaxChecker.h:133 > + ExpressionType appendToCommaExpr(const JSTokenLocation&, ExpressionType& tail, ExpressionType next) { tail = next; return next; }
I suggest changing this prototype to match the one in ASTBuilder (tail can be just ExpressionType). Also, you no longer need to assign "tail = next;" here since you've changed the parser to do the assign using the return value. Hence, this "tail" assignment is redundant.
Geoffrey Garen
Comment 3
2014-12-08 17:13:25 PST
> > Source/JavaScriptCore/parser/SyntaxChecker.h:133 > > + ExpressionType appendToCommaExpr(const JSTokenLocation&, ExpressionType& tail, ExpressionType next) { tail = next; return next; } > > I suggest changing this prototype to match the one in ASTBuilder (tail can > be just ExpressionType). Also, you no longer need to assign "tail = next;" > here since you've changed the parser to do the assign using the return > value. Hence, this "tail" assignment is redundant.
You're right that I wrote this redundantly with its caller; I'll fix that. But the code will continue to need a distinct signature. This code is a bit evil. The ASTBuilder builds a valid linked list of comma nodes. But the SyntaxChecker actually builds an invalid list that constantly overwrites its head with its tail. The reason it does this is so that the parent expression of the comma list can statically check for errors caused by the value of the last node (which is the node that produces the comma expression's value). By overwriting the head with the tail, the syntax checker presents only the tail node of the comma list to its parent expression for checking.
Geoffrey Garen
Comment 4
2014-12-08 17:14:27 PST
For example, the program 'use strict'; ++(1, 2, 3, eval) is a syntax error.
Mark Lam
Comment 5
2014-12-08 17:31:24 PST
(In reply to
comment #3
)
> By overwriting the head with the tail, the syntax checker presents only the > tail node of the comma list to its parent expression for checking.
Interesting. So tricky.
Geoffrey Garen
Comment 6
2014-12-08 17:53:16 PST
Committed
r177001
: <
http://trac.webkit.org/changeset/177001
>
Gyuyoung Kim
Comment 7
2014-12-08 21:24:02 PST
EFL port has broken since
r177001
. Because EFL port treats build warning as error. This patch generated a below warning. ../../Source/JavaScriptCore/parser/Nodes.h:1104:11: error: direct base ‘JSC::ParserArenaFreeable’ inaccessible in ‘JSC::CommaNode’ due to ambiguity [-Werror] class CommaNode final : public ExpressionNode, public ParserArenaFreeable { ^
Gyuyoung Kim
Comment 8
2014-12-08 21:43:29 PST
(In reply to
comment #7
)
> EFL port has broken since
r177001
. Because EFL port treats build warning as > error. This patch generated a below warning. > > > ../../Source/JavaScriptCore/parser/Nodes.h:1104:11: error: direct base > ‘JSC::ParserArenaFreeable’ inaccessible in ‘JSC::CommaNode’ due to ambiguity > [-Werror] > class CommaNode final : public ExpressionNode, public > ParserArenaFreeable { > ^
I upload a fix to
Bug 139428
.
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