| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/api-arguments.h" | 8 #include "src/api-arguments.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); | 470 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); |
| 471 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); | 471 STATIC_ASSERT(Isolate::kJSRegexpStaticOffsetsVectorSize >= 2); |
| 472 __ cmp(edx, Isolate::kJSRegexpStaticOffsetsVectorSize - 2); | 472 __ cmp(edx, Isolate::kJSRegexpStaticOffsetsVectorSize - 2); |
| 473 __ j(above, &runtime); | 473 __ j(above, &runtime); |
| 474 | 474 |
| 475 // Reset offset for possibly sliced string. | 475 // Reset offset for possibly sliced string. |
| 476 __ Move(edi, Immediate(0)); | 476 __ Move(edi, Immediate(0)); |
| 477 __ mov(eax, Operand(esp, kSubjectOffset)); | 477 __ mov(eax, Operand(esp, kSubjectOffset)); |
| 478 __ JumpIfSmi(eax, &runtime); | 478 __ JumpIfSmi(eax, &runtime); |
| 479 __ mov(edx, eax); // Make a copy of the original subject string. | 479 __ mov(edx, eax); // Make a copy of the original subject string. |
| 480 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 481 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 482 | 480 |
| 483 // eax: subject string | 481 // eax: subject string |
| 484 // edx: subject string | 482 // edx: subject string |
| 485 // ebx: subject string instance type | |
| 486 // ecx: RegExp data (FixedArray) | 483 // ecx: RegExp data (FixedArray) |
| 487 // Handle subject string according to its encoding and representation: | 484 // Handle subject string according to its encoding and representation: |
| 488 // (1) Sequential two byte? If yes, go to (9). | 485 // (1) Sequential two byte? If yes, go to (9). |
| 489 // (2) Sequential one byte? If yes, go to (6). | 486 // (2) Sequential one byte? If yes, go to (5). |
| 490 // (3) Anything but sequential or cons? If yes, go to (7). | 487 // (3) Sequential or cons? If not, go to (6). |
| 491 // (4) Cons string. If the string is flat, replace subject with first string. | 488 // (4) Cons string. If the string is flat, replace subject with first string |
| 492 // Otherwise bailout. | 489 // and go to (1). Otherwise bail out to runtime. |
| 493 // (5a) Is subject sequential two byte? If yes, go to (9). | 490 // (5) One byte sequential. Load regexp code for one byte. |
| 494 // (5b) Is subject external? If yes, go to (8). | |
| 495 // (6) One byte sequential. Load regexp code for one byte. | |
| 496 // (E) Carry on. | 491 // (E) Carry on. |
| 497 /// [...] | 492 /// [...] |
| 498 | 493 |
| 499 // Deferred code at the end of the stub: | 494 // Deferred code at the end of the stub: |
| 500 // (7) Not a long external string? If yes, go to (10). | 495 // (6) Long external string? If not, go to (10). |
| 501 // (8) External string. Make it, offset-wise, look like a sequential string. | 496 // (7) External string. Make it, offset-wise, look like a sequential string. |
| 502 // (8a) Is the external string one byte? If yes, go to (6). | 497 // (8) Is the external string one byte? If yes, go to (5). |
| 503 // (9) Two byte sequential. Load regexp code for one byte. Go to (E). | 498 // (9) Two byte sequential. Load regexp code for two byte. Go to (E). |
| 504 // (10) Short external string or not a string? If yes, bail out to runtime. | 499 // (10) Short external string or not a string? If yes, bail out to runtime. |
| 505 // (11) Sliced string. Replace subject with parent. Go to (5a). | 500 // (11) Sliced string. Replace subject with parent. Go to (1). |
| 506 | 501 |
| 507 Label seq_one_byte_string /* 6 */, seq_two_byte_string /* 9 */, | 502 Label seq_one_byte_string /* 5 */, seq_two_byte_string /* 9 */, |
| 508 external_string /* 8 */, check_underlying /* 5a */, | 503 external_string /* 7 */, check_underlying /* 1 */, |
| 509 not_seq_nor_cons /* 7 */, check_code /* E */, | 504 not_seq_nor_cons /* 6 */, check_code /* E */, not_long_external /* 10 */; |
| 510 not_long_external /* 10 */; | |
| 511 | 505 |
| 506 __ bind(&check_underlying); |
| 512 // (1) Sequential two byte? If yes, go to (9). | 507 // (1) Sequential two byte? If yes, go to (9). |
| 508 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 509 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 510 |
| 513 __ and_(ebx, kIsNotStringMask | | 511 __ and_(ebx, kIsNotStringMask | |
| 514 kStringRepresentationMask | | 512 kStringRepresentationMask | |
| 515 kStringEncodingMask | | 513 kStringEncodingMask | |
| 516 kShortExternalStringMask); | 514 kShortExternalStringMask); |
| 517 STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0); | 515 STATIC_ASSERT((kStringTag | kSeqStringTag | kTwoByteStringTag) == 0); |
| 518 __ j(zero, &seq_two_byte_string); // Go to (9). | 516 __ j(zero, &seq_two_byte_string); // Go to (9). |
| 519 | 517 |
| 520 // (2) Sequential one byte? If yes, go to (6). | 518 // (2) Sequential one byte? If yes, go to (5). |
| 521 // Any other sequential string must be one byte. | 519 // Any other sequential string must be one byte. |
| 522 __ and_(ebx, Immediate(kIsNotStringMask | | 520 __ and_(ebx, Immediate(kIsNotStringMask | |
| 523 kStringRepresentationMask | | 521 kStringRepresentationMask | |
| 524 kShortExternalStringMask)); | 522 kShortExternalStringMask)); |
| 525 __ j(zero, &seq_one_byte_string, Label::kNear); // Go to (6). | 523 __ j(zero, &seq_one_byte_string, Label::kNear); // Go to (5). |
| 526 | 524 |
| 527 // (3) Anything but sequential or cons? If yes, go to (7). | 525 // (3) Sequential or cons? If not, go to (6). |
| 528 // We check whether the subject string is a cons, since sequential strings | 526 // We check whether the subject string is a cons, since sequential strings |
| 529 // have already been covered. | 527 // have already been covered. |
| 530 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 528 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
| 531 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 529 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
| 532 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); | 530 STATIC_ASSERT(kIsNotStringMask > kExternalStringTag); |
| 533 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); | 531 STATIC_ASSERT(kShortExternalStringTag > kExternalStringTag); |
| 534 __ cmp(ebx, Immediate(kExternalStringTag)); | 532 __ cmp(ebx, Immediate(kExternalStringTag)); |
| 535 __ j(greater_equal, ¬_seq_nor_cons); // Go to (7). | 533 __ j(greater_equal, ¬_seq_nor_cons); // Go to (6). |
| 536 | 534 |
| 537 // (4) Cons string. Check that it's flat. | 535 // (4) Cons string. Check that it's flat. |
| 538 // Replace subject with first string and reload instance type. | 536 // Replace subject with first string and reload instance type. |
| 539 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string()); | 537 __ cmp(FieldOperand(eax, ConsString::kSecondOffset), factory->empty_string()); |
| 540 __ j(not_equal, &runtime); | 538 __ j(not_equal, &runtime); |
| 541 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); | 539 __ mov(eax, FieldOperand(eax, ConsString::kFirstOffset)); |
| 542 __ bind(&check_underlying); | 540 __ jmp(&check_underlying); |
| 543 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | |
| 544 __ mov(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 545 | |
| 546 // (5a) Is subject sequential two byte? If yes, go to (9). | |
| 547 __ test_b(ebx, Immediate(kStringRepresentationMask | kStringEncodingMask)); | |
| 548 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); | |
| 549 __ j(zero, &seq_two_byte_string); // Go to (9). | |
| 550 // (5b) Is subject external? If yes, go to (8). | |
| 551 __ test_b(ebx, Immediate(kStringRepresentationMask)); | |
| 552 // The underlying external string is never a short external string. | |
| 553 STATIC_ASSERT(ExternalString::kMaxShortLength < ConsString::kMinLength); | |
| 554 STATIC_ASSERT(ExternalString::kMaxShortLength < SlicedString::kMinLength); | |
| 555 __ j(not_zero, &external_string); // Go to (8). | |
| 556 | 541 |
| 557 // eax: sequential subject string (or look-alike, external string) | 542 // eax: sequential subject string (or look-alike, external string) |
| 558 // edx: original subject string | 543 // edx: original subject string |
| 559 // ecx: RegExp data (FixedArray) | 544 // ecx: RegExp data (FixedArray) |
| 560 // (6) One byte sequential. Load regexp code for one byte. | 545 // (5) One byte sequential. Load regexp code for one byte. |
| 561 __ bind(&seq_one_byte_string); | 546 __ bind(&seq_one_byte_string); |
| 562 // Load previous index and check range before edx is overwritten. We have | 547 // Load previous index and check range before edx is overwritten. We have |
| 563 // to use edx instead of eax here because it might have been only made to | 548 // to use edx instead of eax here because it might have been only made to |
| 564 // look like a sequential string when it actually is an external string. | 549 // look like a sequential string when it actually is an external string. |
| 565 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); | 550 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); |
| 566 __ JumpIfNotSmi(ebx, &runtime); | 551 __ JumpIfNotSmi(ebx, &runtime); |
| 567 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); | 552 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); |
| 568 __ j(above_equal, &runtime); | 553 __ j(above_equal, &runtime); |
| 569 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataOneByteCodeOffset)); | 554 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataOneByteCodeOffset)); |
| 570 __ Move(ecx, Immediate(1)); // Type is one byte. | 555 __ Move(ecx, Immediate(1)); // Type is one byte. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 | 756 |
| 772 // Return last match info. | 757 // Return last match info. |
| 773 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); | 758 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); |
| 774 __ ret(4 * kPointerSize); | 759 __ ret(4 * kPointerSize); |
| 775 | 760 |
| 776 // Do the runtime call to execute the regexp. | 761 // Do the runtime call to execute the regexp. |
| 777 __ bind(&runtime); | 762 __ bind(&runtime); |
| 778 __ TailCallRuntime(Runtime::kRegExpExec); | 763 __ TailCallRuntime(Runtime::kRegExpExec); |
| 779 | 764 |
| 780 // Deferred code for string handling. | 765 // Deferred code for string handling. |
| 781 // (7) Not a long external string? If yes, go to (10). | 766 // (6) Long external string? If not, go to (10). |
| 782 __ bind(¬_seq_nor_cons); | 767 __ bind(¬_seq_nor_cons); |
| 783 // Compare flags are still set from (3). | 768 // Compare flags are still set from (3). |
| 784 __ j(greater, ¬_long_external, Label::kNear); // Go to (10). | 769 __ j(greater, ¬_long_external, Label::kNear); // Go to (10). |
| 785 | 770 |
| 786 // (8) External string. Short external strings have been ruled out. | 771 // (7) External string. Short external strings have been ruled out. |
| 787 __ bind(&external_string); | 772 __ bind(&external_string); |
| 788 // Reload instance type. | 773 // Reload instance type. |
| 789 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); | 774 __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset)); |
| 790 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 775 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
| 791 if (FLAG_debug_code) { | 776 if (FLAG_debug_code) { |
| 792 // Assert that we do not have a cons or slice (indirect strings) here. | 777 // Assert that we do not have a cons or slice (indirect strings) here. |
| 793 // Sequential strings have already been ruled out. | 778 // Sequential strings have already been ruled out. |
| 794 __ test_b(ebx, Immediate(kIsIndirectStringMask)); | 779 __ test_b(ebx, Immediate(kIsIndirectStringMask)); |
| 795 __ Assert(zero, kExternalStringExpectedButNotFound); | 780 __ Assert(zero, kExternalStringExpectedButNotFound); |
| 796 } | 781 } |
| 797 __ mov(eax, FieldOperand(eax, ExternalString::kResourceDataOffset)); | 782 __ mov(eax, FieldOperand(eax, ExternalString::kResourceDataOffset)); |
| 798 // Move the pointer so that offset-wise, it looks like a sequential string. | 783 // Move the pointer so that offset-wise, it looks like a sequential string. |
| 799 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); | 784 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
| 800 __ sub(eax, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); | 785 __ sub(eax, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 801 STATIC_ASSERT(kTwoByteStringTag == 0); | 786 STATIC_ASSERT(kTwoByteStringTag == 0); |
| 802 // (8a) Is the external string one byte? If yes, go to (6). | 787 // (8) Is the external string one byte? If yes, go to (5). |
| 803 __ test_b(ebx, Immediate(kStringEncodingMask)); | 788 __ test_b(ebx, Immediate(kStringEncodingMask)); |
| 804 __ j(not_zero, &seq_one_byte_string); // Goto (6). | 789 __ j(not_zero, &seq_one_byte_string); // Go to (5). |
| 805 | 790 |
| 806 // eax: sequential subject string (or look-alike, external string) | 791 // eax: sequential subject string (or look-alike, external string) |
| 807 // edx: original subject string | 792 // edx: original subject string |
| 808 // ecx: RegExp data (FixedArray) | 793 // ecx: RegExp data (FixedArray) |
| 809 // (9) Two byte sequential. Load regexp code for one byte. Go to (E). | 794 // (9) Two byte sequential. Load regexp code for two byte. Go to (E). |
| 810 __ bind(&seq_two_byte_string); | 795 __ bind(&seq_two_byte_string); |
| 811 // Load previous index and check range before edx is overwritten. We have | 796 // Load previous index and check range before edx is overwritten. We have |
| 812 // to use edx instead of eax here because it might have been only made to | 797 // to use edx instead of eax here because it might have been only made to |
| 813 // look like a sequential string when it actually is an external string. | 798 // look like a sequential string when it actually is an external string. |
| 814 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); | 799 __ mov(ebx, Operand(esp, kPreviousIndexOffset)); |
| 815 __ JumpIfNotSmi(ebx, &runtime); | 800 __ JumpIfNotSmi(ebx, &runtime); |
| 816 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); | 801 __ cmp(ebx, FieldOperand(edx, String::kLengthOffset)); |
| 817 __ j(above_equal, &runtime); | 802 __ j(above_equal, &runtime); |
| 818 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset)); | 803 __ mov(edx, FieldOperand(ecx, JSRegExp::kDataUC16CodeOffset)); |
| 819 __ Move(ecx, Immediate(0)); // Type is two byte. | 804 __ Move(ecx, Immediate(0)); // Type is two byte. |
| 820 __ jmp(&check_code); // Go to (E). | 805 __ jmp(&check_code); // Go to (E). |
| 821 | 806 |
| 822 // (10) Not a string or a short external string? If yes, bail out to runtime. | 807 // (10) Not a string or a short external string? If yes, bail out to runtime. |
| 823 __ bind(¬_long_external); | 808 __ bind(¬_long_external); |
| 824 // Catch non-string subject or short external string. | 809 // Catch non-string subject or short external string. |
| 825 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); | 810 STATIC_ASSERT(kNotStringTag != 0 && kShortExternalStringTag !=0); |
| 826 __ test(ebx, Immediate(kIsNotStringMask | kShortExternalStringTag)); | 811 __ test(ebx, Immediate(kIsNotStringMask | kShortExternalStringTag)); |
| 827 __ j(not_zero, &runtime); | 812 __ j(not_zero, &runtime); |
| 828 | 813 |
| 829 // (11) Sliced string. Replace subject with parent. Go to (5a). | 814 // (11) Sliced string. Replace subject with parent. Go to (1). |
| 830 // Load offset into edi and replace subject string with parent. | 815 // Load offset into edi and replace subject string with parent. |
| 831 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset)); | 816 __ mov(edi, FieldOperand(eax, SlicedString::kOffsetOffset)); |
| 832 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset)); | 817 __ mov(eax, FieldOperand(eax, SlicedString::kParentOffset)); |
| 833 __ jmp(&check_underlying); // Go to (5a). | 818 __ jmp(&check_underlying); // Go to (1). |
| 834 #endif // V8_INTERPRETED_REGEXP | 819 #endif // V8_INTERPRETED_REGEXP |
| 835 } | 820 } |
| 836 | 821 |
| 837 | 822 |
| 838 static int NegativeComparisonResult(Condition cc) { | 823 static int NegativeComparisonResult(Condition cc) { |
| 839 DCHECK(cc != equal); | 824 DCHECK(cc != equal); |
| 840 DCHECK((cc == less) || (cc == less_equal) | 825 DCHECK((cc == less) || (cc == less_equal) |
| 841 || (cc == greater) || (cc == greater_equal)); | 826 || (cc == greater) || (cc == greater_equal)); |
| 842 return (cc == greater || cc == greater_equal) ? LESS : GREATER; | 827 return (cc == greater || cc == greater_equal) ? LESS : GREATER; |
| 843 } | 828 } |
| (...skipping 4685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5529 kStackUnwindSpace, nullptr, return_value_operand, | 5514 kStackUnwindSpace, nullptr, return_value_operand, |
| 5530 NULL); | 5515 NULL); |
| 5531 } | 5516 } |
| 5532 | 5517 |
| 5533 #undef __ | 5518 #undef __ |
| 5534 | 5519 |
| 5535 } // namespace internal | 5520 } // namespace internal |
| 5536 } // namespace v8 | 5521 } // namespace v8 |
| 5537 | 5522 |
| 5538 #endif // V8_TARGET_ARCH_X87 | 5523 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |