Changeset 63244 in webkit for trunk/JavaScriptCore/parser/Nodes.h


Ignore:
Timestamp:
Jul 13, 2010, 1:34:11 PM (15 years ago)
Author:
[email protected]
Message:

Bug 42182 - Change how numeric compare functions are detected

Reviewed by Oliver Hunt.

JavaScriptCore:

There are three problems with the current mechanism:

  • It requires that a function executable be bytecode compiled without being JIT generated (in order to copy the bytecode from the numeric compare function). This is a problem since we have an invariant when running with the JIT that functions are never bytecode compiled without also being JIT generated (after checking the codeblock we assume the function has JIT code). To help maintain this invariant
  • This implementation will prevent us from experimenting with alternate compilation paths which do not compile via bytecode.
  • It doesn't work. Functions passing more than two arguments will match if they are comparing their last two arguments, not the first two. Generally the mapping back from bytecode to semantics may be more complex then initially expected.
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::generate):
(JSC::BytecodeGenerator::setIsNumericCompareFunction):
(JSC::BytecodeGenerator::argumentNumberFor):

  • bytecompiler/BytecodeGenerator.h:
  • bytecompiler/NodesCodegen.cpp:

(JSC::BlockNode::singleStatement):
(JSC::FunctionBodyNode::emitBytecode):

  • parser/Nodes.h:

(JSC::ExpressionNode::isSubtract):
(JSC::BinaryOpNode::lhs):
(JSC::BinaryOpNode::rhs):
(JSC::SubNode::isSubtract):
(JSC::ReturnNode::value):

  • runtime/JSGlobalData.cpp:

(JSC::JSGlobalData::JSGlobalData):

  • runtime/JSGlobalData.h:

LayoutTests:

Test case.

  • fast/js/array-sort-numericCompare-expected.txt: Added.
  • fast/js/array-sort-numericCompare.html: Added.
  • fast/js/script-tests/array-sort-numericCompare.js: Added.

(doSort):
(dontSort):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/Nodes.h

    r62848 r63244  
    153153        virtual bool isSimpleArray() const { return false; }
    154154        virtual bool isAdd() const { return false; }
     155        virtual bool isSubtract() const { return false; }
    155156        virtual bool hasConditionContextCodegen() const { return false; }
    156157
     
    807808        RegisterID* emitStrcat(BytecodeGenerator& generator, RegisterID* destination, RegisterID* lhs = 0, ReadModifyResolveNode* emitExpressionInfoForMe = 0);
    808809
     810        ExpressionNode* lhs() { return m_expr1; };
     811        ExpressionNode* rhs() { return m_expr2; };
     812
    809813    private:
    810814        virtual RegisterID* emitBytecode(BytecodeGenerator&, RegisterID* = 0);
     
    855859    public:
    856860        SubNode(JSGlobalData*, ExpressionNode* expr1, ExpressionNode* expr2, bool rightHasAssignments);
     861
     862        virtual bool isSubtract() const { return true; }
    857863    };
    858864
     
    11441150        BlockNode(JSGlobalData*, SourceElements* = 0);
    11451151
     1152        StatementNode* singleStatement() const;
    11461153        StatementNode* lastStatement() const;
    11471154
     
    12941301    public:
    12951302        ReturnNode(JSGlobalData*, ExpressionNode* value);
     1303
     1304        ExpressionNode* value() { return m_value; }
    12961305
    12971306    private:
Note: See TracChangeset for help on using the changeset viewer.