Bug 42182 - Change how numeric compare functions are detected
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jul 2010 20:34:11 +0000 (20:34 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Jul 2010 20:34:11 +0000 (20:34 +0000)
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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63244 268f45cc-cd09-0410-ab3c-d52691b4dbfc


No differences found