| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 6444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6455 FieldOperand(right, length, times_1, SeqAsciiString::kHeaderSize)); | 6455 FieldOperand(right, length, times_1, SeqAsciiString::kHeaderSize)); |
| 6456 __ neg(length); | 6456 __ neg(length); |
| 6457 Register index = length; // index = -length; | 6457 Register index = length; // index = -length; |
| 6458 | 6458 |
| 6459 // Compare loop. | 6459 // Compare loop. |
| 6460 Label loop; | 6460 Label loop; |
| 6461 __ bind(&loop); | 6461 __ bind(&loop); |
| 6462 __ mov_b(scratch, Operand(left, index, times_1, 0)); | 6462 __ mov_b(scratch, Operand(left, index, times_1, 0)); |
| 6463 __ cmpb(scratch, Operand(right, index, times_1, 0)); | 6463 __ cmpb(scratch, Operand(right, index, times_1, 0)); |
| 6464 __ j(not_equal, chars_not_equal, chars_not_equal_near); | 6464 __ j(not_equal, chars_not_equal, chars_not_equal_near); |
| 6465 __ add(index, Immediate(1)); | 6465 __ inc(index); |
| 6466 __ j(not_zero, &loop); | 6466 __ j(not_zero, &loop); |
| 6467 } | 6467 } |
| 6468 | 6468 |
| 6469 | 6469 |
| 6470 void StringCompareStub::Generate(MacroAssembler* masm) { | 6470 void StringCompareStub::Generate(MacroAssembler* masm) { |
| 6471 Label runtime; | 6471 Label runtime; |
| 6472 | 6472 |
| 6473 // Stack frame on entry. | 6473 // Stack frame on entry. |
| 6474 // esp[0]: return address | 6474 // esp[0]: return address |
| 6475 // esp[4]: right string | 6475 // esp[4]: right string |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6638 __ bind(&done); | 6638 __ bind(&done); |
| 6639 __ ret(0); | 6639 __ ret(0); |
| 6640 | 6640 |
| 6641 __ bind(&miss); | 6641 __ bind(&miss); |
| 6642 GenerateMiss(masm); | 6642 GenerateMiss(masm); |
| 6643 } | 6643 } |
| 6644 | 6644 |
| 6645 | 6645 |
| 6646 void ICCompareStub::GenerateStrings(MacroAssembler* masm) { | 6646 void ICCompareStub::GenerateStrings(MacroAssembler* masm) { |
| 6647 ASSERT(state_ == CompareIC::STRINGS); | 6647 ASSERT(state_ == CompareIC::STRINGS); |
| 6648 ASSERT(GetCondition() == equal); | |
| 6649 Label miss; | 6648 Label miss; |
| 6650 | 6649 |
| 6650 bool equality = Token::IsEqualityOp(op_); |
| 6651 |
| 6651 // Registers containing left and right operands respectively. | 6652 // Registers containing left and right operands respectively. |
| 6652 Register left = edx; | 6653 Register left = edx; |
| 6653 Register right = eax; | 6654 Register right = eax; |
| 6654 Register tmp1 = ecx; | 6655 Register tmp1 = ecx; |
| 6655 Register tmp2 = ebx; | 6656 Register tmp2 = ebx; |
| 6656 Register tmp3 = edi; | 6657 Register tmp3 = edi; |
| 6657 | 6658 |
| 6658 // Check that both operands are heap objects. | 6659 // Check that both operands are heap objects. |
| 6659 __ mov(tmp1, left); | 6660 __ mov(tmp1, left); |
| 6660 STATIC_ASSERT(kSmiTag == 0); | 6661 STATIC_ASSERT(kSmiTag == 0); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6679 __ j(not_equal, ¬_same, Label::kNear); | 6680 __ j(not_equal, ¬_same, Label::kNear); |
| 6680 STATIC_ASSERT(EQUAL == 0); | 6681 STATIC_ASSERT(EQUAL == 0); |
| 6681 STATIC_ASSERT(kSmiTag == 0); | 6682 STATIC_ASSERT(kSmiTag == 0); |
| 6682 __ Set(eax, Immediate(Smi::FromInt(EQUAL))); | 6683 __ Set(eax, Immediate(Smi::FromInt(EQUAL))); |
| 6683 __ ret(0); | 6684 __ ret(0); |
| 6684 | 6685 |
| 6685 // Handle not identical strings. | 6686 // Handle not identical strings. |
| 6686 __ bind(¬_same); | 6687 __ bind(¬_same); |
| 6687 | 6688 |
| 6688 // Check that both strings are symbols. If they are, we're done | 6689 // Check that both strings are symbols. If they are, we're done |
| 6689 // because we already know they are not identical. | 6690 // because we already know they are not identical. But in the case of |
| 6690 Label do_compare; | 6691 // non-equality compare, we still need to determine the order. |
| 6691 STATIC_ASSERT(kSymbolTag != 0); | 6692 if (equality) { |
| 6692 __ and_(tmp1, tmp2); | 6693 Label do_compare; |
| 6693 __ test(tmp1, Immediate(kIsSymbolMask)); | 6694 STATIC_ASSERT(kSymbolTag != 0); |
| 6694 __ j(zero, &do_compare, Label::kNear); | 6695 __ and_(tmp1, tmp2); |
| 6695 // Make sure eax is non-zero. At this point input operands are | 6696 __ test(tmp1, Immediate(kIsSymbolMask)); |
| 6696 // guaranteed to be non-zero. | 6697 __ j(zero, &do_compare, Label::kNear); |
| 6697 ASSERT(right.is(eax)); | 6698 // Make sure eax is non-zero. At this point input operands are |
| 6698 __ ret(0); | 6699 // guaranteed to be non-zero. |
| 6700 ASSERT(right.is(eax)); |
| 6701 __ ret(0); |
| 6702 __ bind(&do_compare); |
| 6703 } |
| 6699 | 6704 |
| 6700 // Check that both strings are sequential ASCII. | 6705 // Check that both strings are sequential ASCII. |
| 6701 Label runtime; | 6706 Label runtime; |
| 6702 __ bind(&do_compare); | |
| 6703 __ JumpIfNotBothSequentialAsciiStrings(left, right, tmp1, tmp2, &runtime); | 6707 __ JumpIfNotBothSequentialAsciiStrings(left, right, tmp1, tmp2, &runtime); |
| 6704 | 6708 |
| 6705 // Compare flat ASCII strings. Returns when done. | 6709 // Compare flat ASCII strings. Returns when done. |
| 6706 StringCompareStub::GenerateFlatAsciiStringEquals( | 6710 if (equality) { |
| 6707 masm, left, right, tmp1, tmp2); | 6711 StringCompareStub::GenerateFlatAsciiStringEquals( |
| 6712 masm, left, right, tmp1, tmp2); |
| 6713 } else { |
| 6714 StringCompareStub::GenerateCompareFlatAsciiStrings( |
| 6715 masm, left, right, tmp1, tmp2, tmp3); |
| 6716 } |
| 6708 | 6717 |
| 6709 // Handle more complex cases in runtime. | 6718 // Handle more complex cases in runtime. |
| 6710 __ bind(&runtime); | 6719 __ bind(&runtime); |
| 6711 __ pop(tmp1); // Return address. | 6720 __ pop(tmp1); // Return address. |
| 6712 __ push(left); | 6721 __ push(left); |
| 6713 __ push(right); | 6722 __ push(right); |
| 6714 __ push(tmp1); | 6723 __ push(tmp1); |
| 6715 __ TailCallRuntime(Runtime::kStringEquals, 2, 1); | 6724 if (equality) { |
| 6725 __ TailCallRuntime(Runtime::kStringEquals, 2, 1); |
| 6726 } else { |
| 6727 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
| 6728 } |
| 6716 | 6729 |
| 6717 __ bind(&miss); | 6730 __ bind(&miss); |
| 6718 GenerateMiss(masm); | 6731 GenerateMiss(masm); |
| 6719 } | 6732 } |
| 6720 | 6733 |
| 6721 | 6734 |
| 6722 void ICCompareStub::GenerateObjects(MacroAssembler* masm) { | 6735 void ICCompareStub::GenerateObjects(MacroAssembler* masm) { |
| 6723 ASSERT(state_ == CompareIC::OBJECTS); | 6736 ASSERT(state_ == CompareIC::OBJECTS); |
| 6724 Label miss; | 6737 Label miss; |
| 6725 __ mov(ecx, edx); | 6738 __ mov(ecx, edx); |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7363 false); | 7376 false); |
| 7364 __ pop(edx); | 7377 __ pop(edx); |
| 7365 __ ret(0); | 7378 __ ret(0); |
| 7366 } | 7379 } |
| 7367 | 7380 |
| 7368 #undef __ | 7381 #undef __ |
| 7369 | 7382 |
| 7370 } } // namespace v8::internal | 7383 } } // namespace v8::internal |
| 7371 | 7384 |
| 7372 #endif // V8_TARGET_ARCH_IA32 | 7385 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |