2010-05-06  Oliver Hunt  <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        Improve performance of single character string compares
        https://bugs.webkit.org/show_bug.cgi?id=38659

        Add logic to the jit to identify comparisons to single character string literals
        and then just perform the comparison inline, rather than ignoring the evidence
        and attempting to perform an integer comparison.

        Multiple changes required -- add jnlesseq opcode, add helper function to identify
        single character string constants, add a helper to load single character strings.
        Then add the 32_64 and normal codepaths to the JIT.

        * assembler/MacroAssemblerX86Common.h:
        (JSC::MacroAssemblerX86Common::load16):
        * bytecode/CodeBlock.cpp:
        (JSC::CodeBlock::dump):
        * bytecode/Opcode.h:
        * bytecompiler/BytecodeGenerator.cpp:
        (JSC::BytecodeGenerator::emitJumpIfTrue):
        * interpreter/Interpreter.cpp:
        (JSC::Interpreter::privateExecute):
        * jit/JIT.cpp:
        (JSC::JIT::privateCompileMainPass):
        (JSC::JIT::privateCompileSlowCases):
        * jit/JIT.h:
        * jit/JITArithmetic.cpp:
        (JSC::JIT::emit_op_jnless):
        (JSC::JIT::emitSlow_op_jnless):
        (JSC::JIT::emit_op_jless):
        (JSC::JIT::emitSlow_op_jless):
        (JSC::JIT::emit_op_jlesseq):
        (JSC::JIT::emit_op_jnlesseq):
        (JSC::JIT::emitSlow_op_jlesseq):
        (JSC::JIT::emitSlow_op_jnlesseq):
        * jit/JITArithmetic32_64.cpp:
        (JSC::JIT::emit_op_jnless):
        (JSC::JIT::emitSlow_op_jnless):
        (JSC::JIT::emit_op_jless):
        (JSC::JIT::emitSlow_op_jless):
        (JSC::JIT::emit_op_jlesseq):
        (JSC::JIT::emit_op_jnlesseq):
        (JSC::JIT::emitSlow_op_jlesseq):
        (JSC::JIT::emitSlow_op_jnlesseq):
        (JSC::JIT::emitBinaryDoubleOp):
        * jit/JITInlineMethods.h:
        (JSC::JIT::emitLoadCharacterString):
        (JSC::JIT::isOperandConstantImmediateChar):
        * jit/JSInterfaceJIT.h:
        (JSC::ThunkHelpers::stringImplDataOffset):
        (JSC::ThunkHelpers::jsStringLengthOffset):
        (JSC::ThunkHelpers::jsStringValueOffset):
         Moved from ThunkGenerators to make it possible to share.
        * jit/ThunkGenerators.cpp:
2010-05-06  Oliver Hunt  <oliver@apple.com>

        Reviewed by Geoffrey Garen.

        Improve performance of single character string compares
        https://bugs.webkit.org/show_bug.cgi?id=38659

        Add many tests of <, >, <=, >=, ==, ===, !=, !== as the existing
        tests were woefully inadequate.

        * fast/js/comparison-operators-expected.txt: Added.
        * fast/js/comparison-operators-greater-expected.txt: Added.
        * fast/js/comparison-operators-greater.html: Added.
        * fast/js/comparison-operators-less-expected.txt: Added.
        * fast/js/comparison-operators-less.html: Added.
        * fast/js/comparison-operators.html: Added.
        * fast/js/script-tests/comparison-operators-greater.js: Added.
        (description.makeTest.func.f.toString):
        (description.makeTest):
        (doTest):
        * fast/js/script-tests/comparison-operators-less.js: Added.
        (description.makeTest.func.f.toString):
        (description.makeTest):
        (doTest):
        * fast/js/script-tests/comparison-operators.js: Added.
        (description.makeTest.func.f.toString):
        (description.makeTest):
        (doTest):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58902 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/jit/JIT.h b/JavaScriptCore/jit/JIT.h
index dbd311b..a7e8890 100644
--- a/JavaScriptCore/jit/JIT.h
+++ b/JavaScriptCore/jit/JIT.h
@@ -672,6 +672,7 @@
         void emit_op_jneq_ptr(Instruction*);
         void emit_op_jnless(Instruction*);
         void emit_op_jless(Instruction*);
+        void emit_op_jlesseq(Instruction*, bool invert = false);
         void emit_op_jnlesseq(Instruction*);
         void emit_op_jsr(Instruction*);
         void emit_op_jtrue(Instruction*);
@@ -759,6 +760,7 @@
         void emitSlow_op_jfalse(Instruction*, Vector<SlowCaseEntry>::iterator&);
         void emitSlow_op_jnless(Instruction*, Vector<SlowCaseEntry>::iterator&);
         void emitSlow_op_jless(Instruction*, Vector<SlowCaseEntry>::iterator&);
+        void emitSlow_op_jlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&, bool invert = false);
         void emitSlow_op_jnlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
         void emitSlow_op_jtrue(Instruction*, Vector<SlowCaseEntry>::iterator&);
         void emitSlow_op_loop_if_less(Instruction*, Vector<SlowCaseEntry>::iterator&);
@@ -812,6 +814,7 @@
 
         JSValue getConstantOperand(unsigned src);
         bool isOperandConstantImmediateInt(unsigned src);
+        bool isOperandConstantImmediateChar(unsigned src);
 
         Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
         {
@@ -835,6 +838,9 @@
         void restoreReturnAddressBeforeReturn(RegisterID);
         void restoreReturnAddressBeforeReturn(Address);
 
+        // Loads the character value of a single character string into dst.
+        void emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures);
+        
         void emitTimeoutCheck();
 #ifndef NDEBUG
         void printBytecodeOperandTypes(unsigned src1, unsigned src2);