Ignore:
Timestamp:
Dec 17, 2012, 10:54:52 PM (13 years ago)
Author:
[email protected]
Message:

Constant fold !{number} in the parser
https://bugs.webkit.org/show_bug.cgi?id=105232

Reviewed by Filip Pizlo.

Typically, we wait for hot execution and constant fold in the DFG.
However, !0 and !1 are common enough in minifiers that it can be good
to get them out of the way early, for faster/smaller parsing and startup.

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createLogicalNot): !{literal} is super simple, especially
since there's no literal form of NaN or Inf.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r136863 r137988  
    146146    ExpressionNode* makeURightShiftNode(const JSTokenLocation&, ExpressionNode* left, ExpressionNode* right, bool rightHasAssignments);
    147147
    148     ExpressionNode* createLogicalNot(const JSTokenLocation& location, ExpressionNode* expr) { return new (m_globalData) LogicalNotNode(location, expr); }
     148    ExpressionNode* createLogicalNot(const JSTokenLocation& location, ExpressionNode* expr)
     149    {
     150        if (expr->isNumber())
     151            return createBoolean(location, !static_cast<NumberNode*>(expr)->value());
     152
     153        return new (m_globalData) LogicalNotNode(location, expr);
     154    }
    149155    ExpressionNode* createUnaryPlus(const JSTokenLocation& location, ExpressionNode* expr) { return new (m_globalData) UnaryPlusNode(location, expr); }
    150156    ExpressionNode* createVoid(const JSTokenLocation& location, ExpressionNode* expr)
Note: See TracChangeset for help on using the changeset viewer.