Closed
Bug 1130785
Opened 9 years ago
Closed 9 years ago
JS_HAS_EXPR_CLOSURES macro is used in wrong places.
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla38
Tracking | Status | |
---|---|---|
firefox38 | --- | fixed |
People
(Reporter: arai, Unassigned)
Details
Attachments
(1 file)
2.52 KB,
patch
|
shu
:
review+
|
Details | Diff | Splinter Review |
in frontend/Parser.cpp, code in `#if JS_HAS_EXPR_CLOSURES` is also used by arrow function, and turning JS_HAS_EXPR_CLOSURES off breaks it. https://hg.mozilla.org/mozilla-central/file/193c4c5c7ec2/js/src/frontend/Parser.cpp#l1043 > if (type == StatementListBody) { > pn = statements(); > if (!pn) > return null(); > } else { > MOZ_ASSERT(type == ExpressionBody); > MOZ_ASSERT(JS_HAS_EXPR_CLOSURES); and https://hg.mozilla.org/mozilla-central/file/193c4c5c7ec2/js/src/frontend/Parser.cpp#l2571 > #if JS_HAS_EXPR_CLOSURES > if (bodyType == StatementListBody) { > #endif > bool matched; > if (!tokenStream.matchToken(&matched, TOK_RC)) > return false; > if (!matched) { > report(ParseError, false, null(), JSMSG_CURLY_AFTER_BODY); > return false; > } > funbox->bufEnd = pos().begin + 1; > #if JS_HAS_EXPR_CLOSURES > } else { > if (tokenStream.hadError()) > return false; > funbox->bufEnd = pos().end; > if (kind == Statement && !MatchOrInsertSemicolon(tokenStream)) > return false; > } > #endif
Reporter | ||
Comment 1•9 years ago
|
||
With this patch, we can run tests with expression closure disabled build :) No change for expression closure enabled build.
Attachment #8561023 -
Flags: review?(shu)
Comment 2•9 years ago
|
||
Comment on attachment 8561023 [details] [diff] [review] Fix JS_HAS_EXPR_CLOSURES macro conditions. Review of attachment 8561023 [details] [diff] [review]: ----------------------------------------------------------------- Seems okay to me. I'd like clarification on fun->setIsExprClosure(). Will that be removed and will JSFunction::setArrow be used at some point? ::: js/src/frontend/Parser.cpp @@ +2563,4 @@ > > tokenStream.ungetToken(); > bodyType = ExpressionBody; > fun->setIsExprClosure(); So right now, arrow functions are marked as expression closures, regardless of JS_HAS_EXPR_CLOSURES? @@ +2585,1 @@ > } else { This else clause can only be hit in the case of kind == Arrow, right? Could we assert this in the case of #ifndef JS_HAS_EXPR_CLOSURES?
Attachment #8561023 -
Flags: review?(shu) → review+
Reporter | ||
Comment 3•9 years ago
|
||
Thank you for reviewing :D (In reply to Shu-yu Guo [:shu] from comment #2) > Comment on attachment 8561023 [details] [diff] [review] > Fix JS_HAS_EXPR_CLOSURES macro conditions. > > Review of attachment 8561023 [details] [diff] [review]: > ----------------------------------------------------------------- > > Seems okay to me. I'd like clarification on fun->setIsExprClosure(). Will > that be removed and will JSFunction::setArrow be used at some point? > > ::: js/src/frontend/Parser.cpp > @@ +2563,4 @@ > > > > tokenStream.ungetToken(); > > bodyType = ExpressionBody; > > fun->setIsExprClosure(); > > So right now, arrow functions are marked as expression closures, regardless > of JS_HAS_EXPR_CLOSURES? Oops, it should also be inside `#if JS_HAS_EXPR_CLOSURES`, since there is only one consumer for arrow function's case in jsreflect.cpp, and it's also inside `#if`. https://hg.mozilla.org/mozilla-central/file/3436787a82d0/js/src/jsreflect.cpp#l3284 > bool isExpression = > #if JS_HAS_EXPR_CLOSURES > func->isExprClosure(); > #else > false; > #endif Also, I guess `setArrow` shouldn't be called there, it's already specified here: https://hg.mozilla.org/mozilla-central/file/2cb22c058add/js/src/frontend/Parser.cpp#l1249 > JSFunction::Flags flags = (kind == Expression) > ? JSFunction::INTERPRETED_LAMBDA > : (kind == Arrow) > ? JSFunction::INTERPRETED_LAMBDA_ARROW > : JSFunction::INTERPRETED; > @@ +2585,1 @@ > > } else { > > This else clause can only be hit in the case of kind == Arrow, right? Could > we assert this in the case of #ifndef JS_HAS_EXPR_CLOSURES? Yeah, should have it :) I guess it would be better to use `#if not JS_HAS_EXPR_CLOSURES`, since JS_HAS_EXPR_CLOSURES is defined as a number, and 0 means false for `#if JS_HAS_EXPR_CLOSURES`.
Reporter | ||
Comment 4•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/f13b5763c5ce
Comment 5•9 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/f13b5763c5ce
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox38:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla38
You need to log in
before you can comment on or make changes to this bug.
Description
•