зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1481247: Don't compare pointers twice in MacroAssembler::compareStrings. r=tcampbell
This commit is contained in:
Родитель
454fcd01bd
Коммит
73eb837842
|
@ -1429,26 +1429,28 @@ MacroAssembler::compareStrings(JSOp op, Register left, Register right, Register
|
|||
|
||||
Label done;
|
||||
Label notPointerEqual;
|
||||
// Fast path for identical strings.
|
||||
// If operands point to the same instance, the strings are trivially equal.
|
||||
branchPtr(Assembler::NotEqual, left, right, ¬PointerEqual);
|
||||
move32(Imm32(op == JSOP_EQ || op == JSOP_STRICTEQ), result);
|
||||
jump(&done);
|
||||
|
||||
bind(¬PointerEqual);
|
||||
|
||||
Label notAtom;
|
||||
// Optimize the equality operation to a pointer compare for two atoms.
|
||||
Label leftIsNotAtom;
|
||||
Label setNotEqualResult;
|
||||
// Atoms cannot be equal to each other if they point to different strings.
|
||||
Imm32 nonAtomBit(JSString::NON_ATOM_BIT);
|
||||
branchTest32(Assembler::NonZero, Address(left, JSString::offsetOfFlags()), nonAtomBit, ¬Atom);
|
||||
branchTest32(Assembler::NonZero, Address(right, JSString::offsetOfFlags()), nonAtomBit, ¬Atom);
|
||||
branchTest32(Assembler::NonZero, Address(left, JSString::offsetOfFlags()), nonAtomBit,
|
||||
&leftIsNotAtom);
|
||||
branchTest32(Assembler::Zero, Address(right, JSString::offsetOfFlags()), nonAtomBit,
|
||||
&setNotEqualResult);
|
||||
|
||||
cmpPtrSet(JSOpToCondition(MCompare::Compare_String, op), left, right, result);
|
||||
jump(&done);
|
||||
|
||||
bind(¬Atom);
|
||||
bind(&leftIsNotAtom);
|
||||
// Strings of different length can never be equal.
|
||||
loadStringLength(left, result);
|
||||
branch32(Assembler::Equal, Address(right, JSString::offsetOfLength()), result, fail);
|
||||
|
||||
bind(&setNotEqualResult);
|
||||
move32(Imm32(op == JSOP_NE || op == JSOP_STRICTNE), result);
|
||||
|
||||
bind(&done);
|
||||
|
|
Загрузка…
Ссылка в новой задаче