Ignore:
Timestamp:
Feb 3, 2009, 6:02:32 PM (16 years ago)
Author:
[email protected]
Message:

2009-02-03 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

https://bugs.webkit.org/show_bug.cgi?id=23715

Simplify MacroAssembler interface, by combining comparison methods.
Seprate operations are combined as follows:

jz32/jnz32/jzPtr/jnzPtr -> branchTest32/branchTestPtr,
j*(Add|Mul|Sub)32/j*(Add|Mul|Sub)Ptr -> branch(Add|Mul|Sub)32/branch(Add|Mul|Sub)Ptr
j*32/j*Ptr (all other two op combparisons) -> branch32/brnachPtr
set*32 -> set32

Also, represent the Scale of BaseIndex addresses as a plain enum (0,1,2,3),
instead of as multiplicands (1,2,4,8).

This patch singificantly reduces replication of code, and increases functionality supported
by the MacroAssembler. No performance impact.

  • assembler/MacroAssembler.h: (JSC::MacroAssembler::): (JSC::MacroAssembler::branchPtr): (JSC::MacroAssembler::branchPtrWithPatch): (JSC::MacroAssembler::branch32): (JSC::MacroAssembler::branch16): (JSC::MacroAssembler::branchTestPtr): (JSC::MacroAssembler::branchTest32): (JSC::MacroAssembler::branchAddPtr): (JSC::MacroAssembler::branchAdd32): (JSC::MacroAssembler::branchMul32): (JSC::MacroAssembler::branchSubPtr): (JSC::MacroAssembler::branchSub32): (JSC::MacroAssembler::set32): (JSC::MacroAssembler::setTest32):
  • assembler/X86Assembler.h: (JSC::X86Assembler::): (JSC::X86Assembler::jccRel32): (JSC::X86Assembler::setccOpcode): (JSC::X86Assembler::cmpq_mr): (JSC::X86Assembler::setcc_r): (JSC::X86Assembler::sete_r): (JSC::X86Assembler::setne_r): (JSC::X86Assembler::jne): (JSC::X86Assembler::je): (JSC::X86Assembler::jl): (JSC::X86Assembler::jb): (JSC::X86Assembler::jle): (JSC::X86Assembler::jbe): (JSC::X86Assembler::jge): (JSC::X86Assembler::jg): (JSC::X86Assembler::ja): (JSC::X86Assembler::jae): (JSC::X86Assembler::jo): (JSC::X86Assembler::jp): (JSC::X86Assembler::js): (JSC::X86Assembler::jcc): (JSC::X86Assembler::X86InstructionFormatter::putModRmSib):
  • jit/JIT.cpp: (JSC::JIT::compileOpStrictEq): (JSC::JIT::emitSlowScriptCheck): (JSC::JIT::privateCompileMainPass): (JSC::JIT::privateCompileSlowCases): (JSC::JIT::privateCompile): (JSC::JIT::privateCompileCTIMachineTrampolines):
  • jit/JITArithmetic.cpp: (JSC::JIT::compileFastArith_op_lshift): (JSC::JIT::compileFastArith_op_mod): (JSC::JIT::compileFastArith_op_post_inc): (JSC::JIT::compileFastArith_op_post_dec): (JSC::JIT::compileFastArith_op_pre_inc): (JSC::JIT::compileFastArith_op_pre_dec): (JSC::JIT::compileBinaryArithOp): (JSC::JIT::compileFastArith_op_add): (JSC::JIT::compileFastArith_op_mul):
  • jit/JITCall.cpp: (JSC::JIT::compileOpCall): (JSC::JIT::compileOpCallSlowCase):
  • jit/JITInlineMethods.h: (JSC::JIT::checkStructure): (JSC::JIT::emitJumpIfJSCell): (JSC::JIT::emitJumpIfNotJSCell): (JSC::JIT::emitJumpIfImmediateNumber): (JSC::JIT::emitJumpIfNotImmediateNumber): (JSC::JIT::emitJumpIfImmediateInteger): (JSC::JIT::emitJumpIfNotImmediateInteger): (JSC::JIT::emitFastArithDeTagImmediateJumpIfZero):
  • jit/JITPropertyAccess.cpp: (JSC::JIT::compileGetByIdHotPath): (JSC::JIT::compilePutByIdHotPath): (JSC::JIT::privateCompilePutByIdTransition): (JSC::JIT::privateCompilePatchGetArrayLength): (JSC::JIT::privateCompileGetByIdProto): (JSC::JIT::privateCompileGetByIdProtoList): (JSC::JIT::privateCompileGetByIdChainList): (JSC::JIT::privateCompileGetByIdChain):
  • runtime/RegExp.cpp: (JSC::RegExp::match):
  • wrec/WRECGenerator.cpp: (JSC::WREC::Generator::generateEnter): (JSC::WREC::Generator::generateIncrementIndex): (JSC::WREC::Generator::generateLoadCharacter): (JSC::WREC::Generator::generateJumpIfNotEndOfInput): (JSC::WREC::Generator::generateBackreferenceQuantifier): (JSC::WREC::Generator::generateNonGreedyQuantifier): (JSC::WREC::Generator::generateGreedyQuantifier): (JSC::WREC::Generator::generatePatternCharacterPair): (JSC::WREC::Generator::generatePatternCharacter): (JSC::WREC::Generator::generateCharacterClassInvertedRange): (JSC::WREC::Generator::generateCharacterClassInverted): (JSC::WREC::Generator::generateAssertionBOL): (JSC::WREC::Generator::generateAssertionEOL): (JSC::WREC::Generator::generateAssertionWordBoundary): (JSC::WREC::Generator::generateBackreference):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wrec/WRECGenerator.cpp

    r40522 r40562  
    6868#endif
    6969#endif
    70 
    71 #ifndef NDEBUG
    72     // ASSERT that the output register is not null.
    73     Jump outputNotNull = jnzPtr(output);
    74     breakpoint();
    75     outputNotNull.link(this);
    76 #endif
    7770}
    7871
     
    10194    peek(index);
    10295    if (failure)
    103         *failure = je32(length, index);
     96        *failure = branch32(Equal, length, index);
    10497    add32(Imm32(1), index);
    10598    poke(index);
     
    108101void Generator::generateLoadCharacter(JumpList& failures)
    109102{
    110     failures.append(je32(length, index));
     103    failures.append(branch32(Equal, length, index));
    111104    load16(BaseIndex(input, index, TimesTwo), character);
    112105}
     
    116109void Generator::generateJumpIfNotEndOfInput(Label target)
    117110{
    118     jle32(index, length, target);
     111    branch32(LessThanOrEqual, index, length, target);
    119112}
    120113
     
    146139
    147140    load32(Address(output, (2 * subpatternId) * sizeof(int)), character);
    148     Jump skipIfEmpty = je32(Address(output, ((2 * subpatternId) + 1) * sizeof(int)), character);
     141    Jump skipIfEmpty = branch32(Equal, Address(output, ((2 * subpatternId) + 1) * sizeof(int)), character);
    149142
    150143    ASSERT(quantifierType == Quantifier::Greedy || quantifierType == Quantifier::NonGreedy);
     
    176169    pop(index);
    177170    if (max != Quantifier::Infinity)
    178         je32(repeatCount, Imm32(max), quantifierFailed);
     171        branch32(Equal, repeatCount, Imm32(max), quantifierFailed);
    179172
    180173    // (1) Read an atom.
     
    188181    // (2) Keep reading if we're under the minimum.
    189182    if (min > 1)
    190         jl32(repeatCount, Imm32(min), readAtom);
     183        branch32(LessThan, repeatCount, Imm32(min), readAtom);
    191184
    192185    // (3) Test the rest of the alternative.
     
    222215        doneReadingAtomsList.append(jump());
    223216    else {
    224         jne32(repeatCount, Imm32(max), readAtom);
     217        branch32(NotEqual, repeatCount, Imm32(max), readAtom);
    225218        doneReadingAtomsList.append(jump());
    226219    }
     
    239232    // (2) Verify that we have enough atoms.
    240233    doneReadingAtomsList.link(this);
    241     jl32(repeatCount, Imm32(min), quantifierFailed);
     234    branch32(LessThan, repeatCount, Imm32(min), quantifierFailed);
    242235
    243236    // (3) Test the rest of the alternative.
     
    278271    // Optimistically consume 2 characters.
    279272    add32(Imm32(2), index);
    280     failures.append(jg32(index, length));
     273    failures.append(branch32(GreaterThan, index, length));
    281274
    282275    // Load the characters we just consumed, offset -2 characters from index.
     
    307300    int pair = ch1 | (ch2 << 16);
    308301
    309     failures.append(jne32(character, Imm32(pair)));
     302    failures.append(branch32(NotEqual, character, Imm32(pair)));
    310303    return true;
    311304}
     
    329322        } else if (!isASCII(ch) && ((lower = Unicode::toLower(ch)) != (upper = Unicode::toUpper(ch)))) {
    330323            // handle unicode case sentitive characters - branch to success on upper
    331             isUpper = je32(character, Imm32(upper));
     324            isUpper = branch32(Equal, character, Imm32(upper));
    332325            hasUpper = true;
    333326            ch = lower;
     
    336329   
    337330    // checks for ch, or lower case version of ch, if insensitive
    338     failures.append(jne32(character, Imm32((unsigned short)ch)));
     331    failures.append(branch32(NotEqual, character, Imm32((unsigned short)ch)));
    339332
    340333    if (m_parser.ignoreCase() && hasUpper) {
     
    358351        // if there is anything else to check, check that first, if it falls through jmp to failure.
    359352        if ((*matchIndex < matchCount) && (matches[*matchIndex] < lo)) {
    360             Jump loOrAbove = jge32(character, Imm32((unsigned short)lo));
     353            Jump loOrAbove = branch32(GreaterThanOrEqual, character, Imm32((unsigned short)lo));
    361354           
    362355            // generate code for all ranges before this one
     
    365358           
    366359            while ((*matchIndex < matchCount) && (matches[*matchIndex] < lo)) {
    367                 matchDest.append(je32(character, Imm32((unsigned short)matches[*matchIndex])));
     360                matchDest.append(branch32(Equal, character, Imm32((unsigned short)matches[*matchIndex])));
    368361                ++*matchIndex;
    369362            }
     
    372365            loOrAbove.link(this);
    373366        } else if (which) {
    374             Jump loOrAbove = jge32(character, Imm32((unsigned short)lo));
     367            Jump loOrAbove = branch32(GreaterThanOrEqual, character, Imm32((unsigned short)lo));
    375368
    376369            generateCharacterClassInvertedRange(failures, matchDest, ranges, which, matchIndex, matches, matchCount);
     
    379372            loOrAbove.link(this);
    380373        } else
    381             failures.append(jl32(character, Imm32((unsigned short)lo)));
     374            failures.append(branch32(LessThan, character, Imm32((unsigned short)lo)));
    382375
    383376        while ((*matchIndex < matchCount) && (matches[*matchIndex] <= hi))
    384377            ++*matchIndex;
    385378
    386         matchDest.append(jle32(character, Imm32((unsigned short)hi)));
     379        matchDest.append(branch32(LessThanOrEqual, character, Imm32((unsigned short)hi)));
    387380        // fall through to here, the value is above hi.
    388381
     
    398391    Jump unicodeFail;
    399392    if (charClass.numMatchesUnicode || charClass.numRangesUnicode) {
    400         Jump isAscii = jle32(character, Imm32(0x7f));
     393        Jump isAscii = branch32(LessThanOrEqual, character, Imm32(0x7f));
    401394   
    402395        if (charClass.numMatchesUnicode) {
    403396            for (unsigned i = 0; i < charClass.numMatchesUnicode; ++i) {
    404397                UChar ch = charClass.matchesUnicode[i];
    405                 matchDest.append(je32(character, Imm32(ch)));
     398                matchDest.append(branch32(Equal, character, Imm32(ch)));
    406399            }
    407400        }
     
    412405                UChar hi = charClass.rangesUnicode[i].end;
    413406               
    414                 Jump below = jl32(character, Imm32(lo));
    415                 matchDest.append(jle32(character, Imm32(hi)));
     407                Jump below = branch32(LessThan, character, Imm32(lo));
     408                matchDest.append(branch32(LessThanOrEqual, character, Imm32(hi)));
    416409                below.link(this);
    417410            }
     
    427420        generateCharacterClassInvertedRange(failures, matchDest, charClass.ranges, charClass.numRanges, &matchIndex, charClass.matches, charClass.numMatches);
    428421        while (matchIndex < charClass.numMatches)
    429             matchDest.append(je32(character, Imm32((unsigned short)charClass.matches[matchIndex++])));
     422            matchDest.append(branch32(Equal, character, Imm32((unsigned short)charClass.matches[matchIndex++])));
    430423
    431424        failures.link(this);
     
    444437                    continue;
    445438            }
    446             matchDest.append(je32(character, Imm32((unsigned short)ch)));
     439            matchDest.append(branch32(Equal, character, Imm32((unsigned short)ch)));
    447440        }
    448441
     
    450443            or32(Imm32(32), character);
    451444            for (unsigned i = 0; i < countAZaz; ++i)
    452                 matchDest.append(je32(character, Imm32(matchesAZaz[i])));
     445                matchDest.append(branch32(Equal, character, Imm32(matchesAZaz[i])));
    453446        }
    454447    }
     
    534527
    535528        // begin of input == success
    536         previousIsNewline.append(je32(index, Imm32(0)));
     529        previousIsNewline.append(branch32(Equal, index, Imm32(0)));
    537530
    538531        // now check prev char against newline characters.
     
    544537        previousIsNewline.link(this);
    545538    } else
    546         failures.append(jne32(index, Imm32(0)));
     539        failures.append(branch32(NotEqual, index, Imm32(0)));
    547540}
    548541
     
    557550        nextIsNewline.link(this);
    558551    } else {
    559         failures.append(jne32(length, index));
     552        failures.append(branch32(NotEqual, length, index));
    560553    }
    561554}
     
    569562
    570563    // (1.1) check for begin of input
    571     Jump atBegin = je32(index, Imm32(0));
     564    Jump atBegin = branch32(Equal, index, Imm32(0));
    572565    // (1.2) load the last char, and chck if is word character
    573566    load16(BaseIndex(input, index, TimesTwo, -2), character);
     
    626619
    627620    // check if we're at the end of backref (if we are, success!)
    628     Jump endOfBackRef = je32(Address(output, ((2 * subpatternId) + 1) * sizeof(int)), repeatCount);
     621    Jump endOfBackRef = branch32(Equal, Address(output, ((2 * subpatternId) + 1) * sizeof(int)), repeatCount);
    629622
    630623    load16(BaseIndex(input, repeatCount, MacroAssembler::TimesTwo), character);
    631624
    632625    // check if we've run out of input (this would be a can o'fail)
    633     Jump endOfInput = je32(length, index);
    634 
    635     je16(character, BaseIndex(input, index, TimesTwo), topOfLoop);
     626    Jump endOfInput = branch32(Equal, length, index);
     627
     628    branch16(Equal, BaseIndex(input, index, TimesTwo), character, topOfLoop);
    636629
    637630    endOfInput.link(this);
Note: See TracChangeset for help on using the changeset viewer.