mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Backed out changeset 3e660b56c502 (bug 1169171) for easily backing out bug 1141865
--HG-- extra : amend_source : 5e071bcb2a6dce6ed5ec9035c48d9407d5dc3a47
This commit is contained in:
parent
dd6d17a95b
commit
93b34f209b
@ -1998,26 +1998,31 @@ BytecodeEmitter::checkSideEffects(ParseNode* pn, bool* answer)
|
||||
|
||||
case PN_UNARY:
|
||||
switch (pn->getKind()) {
|
||||
case PNK_DELETENAME: {
|
||||
ParseNode* nameExpr = pn->pn_kid;
|
||||
MOZ_ASSERT(nameExpr->isKind(PNK_NAME));
|
||||
if (!bindNameToSlot(nameExpr))
|
||||
return false;
|
||||
*answer = !nameExpr->isConst();
|
||||
return true;
|
||||
case PNK_DELETE:
|
||||
{
|
||||
ParseNode* pn2 = pn->pn_kid;
|
||||
switch (pn2->getKind()) {
|
||||
case PNK_NAME:
|
||||
if (!bindNameToSlot(pn2))
|
||||
return false;
|
||||
if (pn2->isConst()) {
|
||||
MOZ_ASSERT(*answer == false);
|
||||
return true;
|
||||
}
|
||||
/* FALL THROUGH */
|
||||
case PNK_DOT:
|
||||
case PNK_CALL:
|
||||
case PNK_ELEM:
|
||||
case PNK_SUPERELEM:
|
||||
/* All these delete addressing modes have effects too. */
|
||||
*answer = true;
|
||||
return true;
|
||||
default:
|
||||
return checkSideEffects(pn2, answer);
|
||||
}
|
||||
MOZ_CRASH("We have a returning default case");
|
||||
}
|
||||
|
||||
case PNK_DELETEPROP:
|
||||
case PNK_DELETESUPERPROP:
|
||||
case PNK_DELETEELEM:
|
||||
case PNK_DELETESUPERELEM:
|
||||
// All these delete addressing modes have effects, too.
|
||||
*answer = true;
|
||||
return true;
|
||||
|
||||
case PNK_DELETEEXPR:
|
||||
return checkSideEffects(pn->pn_kid, answer);
|
||||
|
||||
case PNK_TYPEOF:
|
||||
case PNK_VOID:
|
||||
case PNK_NOT:
|
||||
@ -6176,110 +6181,82 @@ BytecodeEmitter::emitStatement(ParseNode* pn)
|
||||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitDeleteName(ParseNode* node)
|
||||
BytecodeEmitter::emitDelete(ParseNode* pn)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_DELETENAME));
|
||||
MOZ_ASSERT(node->isArity(PN_UNARY));
|
||||
|
||||
ParseNode* nameExpr = node->pn_kid;
|
||||
MOZ_ASSERT(nameExpr->isKind(PNK_NAME));
|
||||
|
||||
if (!bindNameToSlot(nameExpr))
|
||||
return false;
|
||||
|
||||
MOZ_ASSERT(nameExpr->isOp(JSOP_DELNAME));
|
||||
return emitAtomOp(nameExpr, JSOP_DELNAME);
|
||||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitDeleteProperty(ParseNode* node)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_DELETEPROP));
|
||||
MOZ_ASSERT(node->isArity(PN_UNARY));
|
||||
|
||||
ParseNode* propExpr = node->pn_kid;
|
||||
MOZ_ASSERT(propExpr->isKind(PNK_DOT));
|
||||
|
||||
JSOp delOp = sc->strict() ? JSOP_STRICTDELPROP : JSOP_DELPROP;
|
||||
return emitPropOp(propExpr, delOp);
|
||||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitDeleteSuperProperty(ParseNode* node)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_DELETESUPERPROP));
|
||||
MOZ_ASSERT(node->isArity(PN_UNARY));
|
||||
MOZ_ASSERT(node->pn_kid->isKind(PNK_SUPERPROP));
|
||||
|
||||
// Still have to calculate the base, even though we are are going
|
||||
// to throw unconditionally, as calculating the base could also
|
||||
// throw.
|
||||
if (!emit1(JSOP_SUPERBASE))
|
||||
return false;
|
||||
|
||||
return emitUint16Operand(JSOP_THROWMSG, JSMSG_CANT_DELETE_SUPER);
|
||||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitDeleteElement(ParseNode* node)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_DELETEELEM));
|
||||
MOZ_ASSERT(node->isArity(PN_UNARY));
|
||||
|
||||
ParseNode* elemExpr = node->pn_kid;
|
||||
MOZ_ASSERT(elemExpr->isKind(PNK_ELEM));
|
||||
|
||||
JSOp delOp = sc->strict() ? JSOP_STRICTDELELEM : JSOP_DELELEM;
|
||||
return emitElemOp(elemExpr, delOp);
|
||||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitDeleteSuperElement(ParseNode* node)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_DELETESUPERELEM));
|
||||
MOZ_ASSERT(node->isArity(PN_UNARY));
|
||||
|
||||
ParseNode* superElemExpr = node->pn_kid;
|
||||
MOZ_ASSERT(superElemExpr->isKind(PNK_SUPERELEM));
|
||||
|
||||
// Still have to calculate everything, even though we're gonna throw
|
||||
// since it may have side effects
|
||||
MOZ_ASSERT(superElemExpr->isArity(PN_UNARY));
|
||||
if (!emitTree(superElemExpr->pn_kid))
|
||||
return false;
|
||||
if (!emit1(JSOP_SUPERBASE))
|
||||
return false;
|
||||
if (!emitUint16Operand(JSOP_THROWMSG, JSMSG_CANT_DELETE_SUPER))
|
||||
return false;
|
||||
|
||||
// Another wrinkle: Balance the stack from the emitter's point of view.
|
||||
// Execution will not reach here, as the last bytecode threw.
|
||||
return emit1(JSOP_POP);
|
||||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitDeleteExpression(ParseNode* node)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_DELETEEXPR));
|
||||
MOZ_ASSERT(node->isArity(PN_UNARY));
|
||||
|
||||
ParseNode* expression = node->pn_kid;
|
||||
|
||||
// If useless, just emit JSOP_TRUE; otherwise convert |delete <expr>| to
|
||||
// effectively |<expr>, true|.
|
||||
bool useful = false;
|
||||
if (!checkSideEffects(expression, &useful))
|
||||
return false;
|
||||
|
||||
if (useful) {
|
||||
MOZ_ASSERT_IF(expression->isKind(PNK_CALL), !(expression->pn_xflags & PNX_SETCALL));
|
||||
if (!emitTree(expression))
|
||||
/*
|
||||
* Under ECMA 3, deleting a non-reference returns true -- but alas we
|
||||
* must evaluate the operand if it appears it might have side effects.
|
||||
*/
|
||||
ParseNode* pn2 = pn->pn_kid;
|
||||
switch (pn2->getKind()) {
|
||||
case PNK_NAME:
|
||||
if (!bindNameToSlot(pn2))
|
||||
return false;
|
||||
if (!emitAtomOp(pn2, pn2->getOp()))
|
||||
return false;
|
||||
break;
|
||||
case PNK_DOT:
|
||||
{
|
||||
JSOp delOp = sc->strict() ? JSOP_STRICTDELPROP : JSOP_DELPROP;
|
||||
if (!emitPropOp(pn2, delOp))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case PNK_SUPERPROP:
|
||||
// Still have to calculate the base, even though we are are going
|
||||
// to throw unconditionally, as calculating the base could also
|
||||
// throw.
|
||||
if (!emit1(JSOP_SUPERBASE))
|
||||
return false;
|
||||
if (!emitUint16Operand(JSOP_THROWMSG, JSMSG_CANT_DELETE_SUPER))
|
||||
return false;
|
||||
break;
|
||||
case PNK_ELEM:
|
||||
{
|
||||
JSOp delOp = sc->strict() ? JSOP_STRICTDELELEM : JSOP_DELELEM;
|
||||
if (!emitElemOp(pn2, delOp))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case PNK_SUPERELEM:
|
||||
// Still have to calculate everything, even though we're gonna throw
|
||||
// since it may have side effects
|
||||
if (!emitTree(pn2->pn_kid))
|
||||
return false;
|
||||
if (!emit1(JSOP_SUPERBASE))
|
||||
return false;
|
||||
if (!emitUint16Operand(JSOP_THROWMSG, JSMSG_CANT_DELETE_SUPER))
|
||||
return false;
|
||||
|
||||
// Another wrinkle: Balance the stack from the emitter's point of view.
|
||||
// Execution will not reach here, as the last bytecode threw.
|
||||
if (!emit1(JSOP_POP))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
{
|
||||
/*
|
||||
* If useless, just emit JSOP_TRUE; otherwise convert delete foo()
|
||||
* to foo(), true (a comma expression).
|
||||
*/
|
||||
bool useful = false;
|
||||
if (!checkSideEffects(pn2, &useful))
|
||||
return false;
|
||||
|
||||
if (useful) {
|
||||
MOZ_ASSERT_IF(pn2->isKind(PNK_CALL), !(pn2->pn_xflags & PNX_SETCALL));
|
||||
if (!emitTree(pn2))
|
||||
return false;
|
||||
if (!emit1(JSOP_POP))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!emit1(JSOP_TRUE))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return emit1(JSOP_TRUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -7521,28 +7498,8 @@ BytecodeEmitter::emitTree(ParseNode* pn)
|
||||
ok = emitIncOrDec(pn);
|
||||
break;
|
||||
|
||||
case PNK_DELETENAME:
|
||||
ok = emitDeleteName(pn);
|
||||
break;
|
||||
|
||||
case PNK_DELETEPROP:
|
||||
ok = emitDeleteProperty(pn);
|
||||
break;
|
||||
|
||||
case PNK_DELETESUPERPROP:
|
||||
ok = emitDeleteSuperProperty(pn);
|
||||
break;
|
||||
|
||||
case PNK_DELETEELEM:
|
||||
ok = emitDeleteElement(pn);
|
||||
break;
|
||||
|
||||
case PNK_DELETESUPERELEM:
|
||||
ok = emitDeleteSuperElement(pn);
|
||||
break;
|
||||
|
||||
case PNK_DELETEEXPR:
|
||||
ok = emitDeleteExpression(pn);
|
||||
case PNK_DELETE:
|
||||
ok = emitDelete(pn);
|
||||
break;
|
||||
|
||||
case PNK_DOT:
|
||||
|
@ -546,13 +546,7 @@ struct BytecodeEmitter
|
||||
bool emitStatement(ParseNode* pn);
|
||||
bool emitStatementList(ParseNode* pn, ptrdiff_t top);
|
||||
|
||||
bool emitDeleteName(ParseNode* pn);
|
||||
bool emitDeleteProperty(ParseNode* pn);
|
||||
bool emitDeleteSuperProperty(ParseNode* pn);
|
||||
bool emitDeleteElement(ParseNode* pn);
|
||||
bool emitDeleteSuperElement(ParseNode* pn);
|
||||
bool emitDeleteExpression(ParseNode* pn);
|
||||
|
||||
bool emitDelete(ParseNode* pn);
|
||||
bool emitLogical(ParseNode* pn);
|
||||
bool emitUnary(ParseNode* pn);
|
||||
|
||||
|
@ -325,12 +325,7 @@ ContainsHoistedDeclaration(ExclusiveContext* cx, ParseNode* node, bool* result)
|
||||
case PNK_VOID:
|
||||
case PNK_NOT:
|
||||
case PNK_BITNOT:
|
||||
case PNK_DELETENAME:
|
||||
case PNK_DELETEPROP:
|
||||
case PNK_DELETESUPERPROP:
|
||||
case PNK_DELETEELEM:
|
||||
case PNK_DELETESUPERELEM:
|
||||
case PNK_DELETEEXPR:
|
||||
case PNK_DELETE:
|
||||
case PNK_POS:
|
||||
case PNK_NEG:
|
||||
case PNK_PREINCREMENT:
|
||||
@ -722,7 +717,7 @@ Fold(ExclusiveContext* cx, ParseNode** pnp,
|
||||
SyntacticContext kidsc =
|
||||
pn->isKind(PNK_NOT)
|
||||
? SyntacticContext::Condition
|
||||
: IsDeleteKind(pn->getKind())
|
||||
: pn->isKind(PNK_DELETE)
|
||||
? SyntacticContext::Delete
|
||||
: SyntacticContext::Other;
|
||||
if (!Fold(cx, &pn->pn_kid, handler, options, inGenexpLambda, kidsc))
|
||||
@ -752,7 +747,7 @@ Fold(ExclusiveContext* cx, ParseNode** pnp,
|
||||
break;
|
||||
}
|
||||
|
||||
// The immediate child of a PNK_DELETE* node should not be replaced
|
||||
// The immediate child of a PNK_DELETE node should not be replaced
|
||||
// with node indicating a different syntactic form; |delete x| is not
|
||||
// the same as |delete (true && x)|. See bug 888002.
|
||||
//
|
||||
|
@ -187,23 +187,11 @@ class FullParseHandler
|
||||
}
|
||||
|
||||
ParseNode* newDelete(uint32_t begin, ParseNode* expr) {
|
||||
if (expr->isKind(PNK_NAME)) {
|
||||
if (expr->getKind() == PNK_NAME) {
|
||||
expr->pn_dflags |= PND_DEOPTIMIZED;
|
||||
expr->setOp(JSOP_DELNAME);
|
||||
return newUnary(PNK_DELETENAME, JSOP_NOP, begin, expr);
|
||||
}
|
||||
|
||||
if (expr->isKind(PNK_DOT))
|
||||
return newUnary(PNK_DELETEPROP, JSOP_NOP, begin, expr);
|
||||
if (expr->isKind(PNK_SUPERPROP))
|
||||
return newUnary(PNK_DELETESUPERPROP, JSOP_NOP, begin, expr);
|
||||
|
||||
if (expr->isKind(PNK_ELEM))
|
||||
return newUnary(PNK_DELETEELEM, JSOP_NOP, begin, expr);
|
||||
if (expr->isKind(PNK_SUPERELEM))
|
||||
return newUnary(PNK_DELETESUPERELEM, JSOP_NOP, begin, expr);
|
||||
|
||||
return newUnary(PNK_DELETEEXPR, JSOP_NOP, begin, expr);
|
||||
return newUnary(PNK_DELETE, JSOP_NOP, begin, expr);
|
||||
}
|
||||
|
||||
ParseNode* newNullary(ParseNodeKind kind, JSOp op, const TokenPos& pos) {
|
||||
|
@ -384,12 +384,7 @@ class NameResolver
|
||||
case PNK_NOT:
|
||||
case PNK_BITNOT:
|
||||
case PNK_THROW:
|
||||
case PNK_DELETENAME:
|
||||
case PNK_DELETEPROP:
|
||||
case PNK_DELETESUPERPROP:
|
||||
case PNK_DELETEELEM:
|
||||
case PNK_DELETESUPERELEM:
|
||||
case PNK_DELETEEXPR:
|
||||
case PNK_DELETE:
|
||||
case PNK_NEG:
|
||||
case PNK_POS:
|
||||
case PNK_PREINCREMENT:
|
||||
|
@ -227,12 +227,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
|
||||
case PNK_NOT:
|
||||
case PNK_BITNOT:
|
||||
case PNK_THROW:
|
||||
case PNK_DELETENAME:
|
||||
case PNK_DELETEPROP:
|
||||
case PNK_DELETESUPERPROP:
|
||||
case PNK_DELETEELEM:
|
||||
case PNK_DELETESUPERELEM:
|
||||
case PNK_DELETEEXPR:
|
||||
case PNK_DELETE:
|
||||
case PNK_POS:
|
||||
case PNK_NEG:
|
||||
case PNK_PREINCREMENT:
|
||||
|
@ -118,13 +118,7 @@ class UpvarCookie
|
||||
F(WITH) \
|
||||
F(RETURN) \
|
||||
F(NEW) \
|
||||
/* Delete operations. These must be sequential. */ \
|
||||
F(DELETENAME) \
|
||||
F(DELETEPROP) \
|
||||
F(DELETESUPERPROP) \
|
||||
F(DELETEELEM) \
|
||||
F(DELETESUPERELEM) \
|
||||
F(DELETEEXPR) \
|
||||
F(DELETE) \
|
||||
F(TRY) \
|
||||
F(CATCH) \
|
||||
F(CATCHLIST) \
|
||||
@ -234,12 +228,6 @@ enum ParseNodeKind
|
||||
PNK_ASSIGNMENT_LAST = PNK_MODASSIGN
|
||||
};
|
||||
|
||||
inline bool
|
||||
IsDeleteKind(ParseNodeKind kind)
|
||||
{
|
||||
return PNK_DELETENAME <= kind && kind <= PNK_DELETEEXPR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Label Variant Members
|
||||
* ----- ------- -------
|
||||
@ -406,16 +394,7 @@ IsDeleteKind(ParseNodeKind kind)
|
||||
* PNK_NEW list pn_head: list of ctor, arg1, arg2, ... argN
|
||||
* pn_count: 1 + N (where N is number of args)
|
||||
* ctor is a MEMBER expr
|
||||
* PNK_DELETENAME unary pn_kid: PNK_NAME expr
|
||||
* PNK_DELETEPROP unary pn_kid: PNK_DOT expr
|
||||
* PNK_DELETESUPERPROP unary pn_kid: PNK_SUPERPROP expr
|
||||
* PNK_DELETEELEM unary pn_kid: PNK_ELEM expr
|
||||
* PNK_DELETESUPERELEM unary pn_kid: PNK_SUPERELEM expr
|
||||
* PNK_DELETEEXPR unary pn_kid: MEMBER expr that's evaluated, then the
|
||||
* overall delete evaluates to true; can't be a kind
|
||||
* for a more-specific PNK_DELETE* unless constant
|
||||
* folding (or a similar parse tree manipulation) has
|
||||
* occurred
|
||||
* PNK_DELETE unary pn_kid: MEMBER expr
|
||||
* PNK_DOT name pn_expr: MEMBER expr to left of .
|
||||
* pn_atom: name to right of .
|
||||
* PNK_ELEM binary pn_left: MEMBER expr to left of [
|
||||
|
@ -159,9 +159,7 @@ class SyntaxParseHandler
|
||||
|
||||
Node newElision() { return NodeGeneric; }
|
||||
|
||||
Node newDelete(uint32_t begin, Node expr) {
|
||||
return NodeGeneric;
|
||||
}
|
||||
Node newDelete(uint32_t begin, Node expr) { return NodeGeneric; }
|
||||
|
||||
Node newUnary(ParseNodeKind kind, JSOp op, uint32_t begin, Node kid) {
|
||||
return NodeGeneric;
|
||||
|
@ -1922,7 +1922,7 @@ ASTSerializer::aop(JSOp op)
|
||||
UnaryOperator
|
||||
ASTSerializer::unop(ParseNodeKind kind, JSOp op)
|
||||
{
|
||||
if (IsDeleteKind(kind))
|
||||
if (kind == PNK_DELETE)
|
||||
return UNOP_DELETE;
|
||||
|
||||
switch (op) {
|
||||
@ -2938,12 +2938,7 @@ ASTSerializer::expression(ParseNode* pn, MutableHandleValue dst)
|
||||
case PNK_INSTANCEOF:
|
||||
return leftAssociate(pn, dst);
|
||||
|
||||
case PNK_DELETENAME:
|
||||
case PNK_DELETEPROP:
|
||||
case PNK_DELETESUPERPROP:
|
||||
case PNK_DELETEELEM:
|
||||
case PNK_DELETESUPERELEM:
|
||||
case PNK_DELETEEXPR:
|
||||
case PNK_DELETE:
|
||||
case PNK_TYPEOF:
|
||||
case PNK_VOID:
|
||||
case PNK_NOT:
|
||||
|
Loading…
Reference in New Issue
Block a user