Closed Bug 775391 Opened 14 years ago Closed 10 years ago

Fix potential erroneous comment in DefineArg

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: ejpbruel, Unassigned)

Details

(Whiteboard: [js:t])

Attachments

(1 file)

The comment in http://mxr.mozilla.org/mozilla-central/source/js/src/frontend/Parser.cpp#900 doesn't make sense. We assert that pnarg->op == JSOP_NOP before calling Define (causing pnarg to be added to tc->decls.), and before appending pnarg to pn->pn_body. Neither of those operations check the opcode of pnarg, nor do they perform a clone of pnarg. Yet immediately after we set pnarg->pn_op to JSOP_GETARG. It seems to me that that comment is wrong, and we should be able to just set pnarg->op to JSOP_GETARG from the start.
I've tested this patch with jit-tests and jstests and didn't find any regressions.
Attachment #643704 - Flags: review?(n.nethercote)
Comment on attachment 643704 [details] [diff] [review] Patch to be reviewed Review of attachment 643704 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/frontend/Parser.cpp @@ +919,5 @@ > ParseNode *argpn = NameNode::create(PNK_NAME, atom, parser, parser->tc); > if (!argpn) > return false; > + argpn->setOp(JSOP_GETARG); > + JS_ASSERT(argpn->isKind(PNK_NAME) && argpn->isOp(JSOP_GETARG)); In the same way we don't write this: int x = 3; JS_ASSERT(x == 3); I think this assertion can now be removed :)
Attachment #643704 - Flags: review?(n.nethercote) → review+
Whiteboard: [js:t]
Assignee: ejpbruel → general
Assignee: general → nobody
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: