Changeset 36036 in webkit for trunk/JavaScriptCore/kjs


Ignore:
Timestamp:
Sep 2, 2008, 7:58:14 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-02 Geoffrey Garen <[email protected]>

Reviewed by Anders Carlsson.


Added optimized paths for comparing to null.


SunSpider says 0.5% faster.

Location:
trunk/JavaScriptCore/kjs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/JSCell.h

    r36016 r36036  
    7878        virtual JSObject* toObject(ExecState*) const = 0;
    7979
     80        // WebCore uses this to make document.all and style.filter undetectable
     81        virtual bool masqueradeAsUndefined() const { return false; }
     82
    8083        // Garbage collection.
    8184        void* operator new(size_t, ExecState*);
  • trunk/JavaScriptCore/kjs/JSObject.h

    r36032 r36036  
    115115        virtual bool getPropertyAttributes(ExecState*, const Identifier& propertyName, unsigned& attributes) const;
    116116
    117         // WebCore uses this to make document.all and style.filter undetectable
    118         virtual bool masqueradeAsUndefined() const { return false; }
    119 
    120117        // This get function only looks at the property map.
    121118        JSValue* getDirect(const Identifier& propertyName) const { return m_propertyMap.get(propertyName); }
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r36016 r36036  
    744744RegisterID* BinaryOpNode::emitCode(CodeGenerator& generator, RegisterID* dst)
    745745{
     746    OpcodeID opcode = this->opcode();
     747    if (opcode == op_eq || opcode == op_neq) {
     748        if (m_expr1->isNull() || m_expr2->isNull()) {
     749            RefPtr<RegisterID> src = generator.emitNode(dst, m_expr1->isNull() ? m_expr2.get() : m_expr1.get());
     750            return generator.emitUnaryOp(opcode == op_eq ? op_eq_null : op_neq_null, generator.finalDestination(dst, src.get()), src.get());
     751        }
     752    }
     753
    746754    RefPtr<RegisterID> src1 = generator.emitNodeForLeftHandSide(m_expr1.get(), m_rightHasAssignments, m_expr2->isPure(generator));
    747755    RegisterID* src2 = generator.emitNode(m_expr2.get());
    748     return generator.emitBinaryOp(opcode(), generator.finalDestination(dst, src1.get()), src1.get(), src2);
     756    return generator.emitBinaryOp(opcode, generator.finalDestination(dst, src1.get()), src1.get(), src2);
    749757}
    750758
     
    18111819    proto->putDirect(exec->propertyNames().constructor, func, DontEnum);
    18121820    func->putDirect(exec->propertyNames().prototype, proto, DontDelete);
    1813     func->putDirect(exec->propertyNames().length, jsNumber(exec, m_body->parameters().size()), ReadOnly | DontDelete | DontEnum);
    18141821    return func;
    18151822}
  • trunk/JavaScriptCore/kjs/nodes.h

    r35986 r36036  
    209209        virtual bool isNumber() const KJS_FAST_CALL { return false; }
    210210        virtual bool isString() const KJS_FAST_CALL { return false; }
     211        virtual bool isNull() const KJS_FAST_CALL { return false; }
    211212        virtual bool isPure(CodeGenerator&) const KJS_FAST_CALL { return false; }       
    212213        virtual bool isLocation() const KJS_FAST_CALL { return false; }
     
    245246        {
    246247        }
     248
     249        virtual bool isNull() const KJS_FAST_CALL { return true; }
    247250
    248251        virtual RegisterID* emitCode(CodeGenerator&, RegisterID* = 0) KJS_FAST_CALL;
Note: See TracChangeset for help on using the changeset viewer.