OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2653 // Any other flat string must be a flat ascii string. | 2653 // Any other flat string must be a flat ascii string. |
2654 __ andb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask)); | 2654 __ andb(rbx, Immediate(kIsNotStringMask | kStringRepresentationMask)); |
2655 __ j(zero, &seq_ascii_string, Label::kNear); | 2655 __ j(zero, &seq_ascii_string, Label::kNear); |
2656 | 2656 |
2657 // Check for flat cons string or sliced string. | 2657 // Check for flat cons string or sliced string. |
2658 // A flat cons string is a cons string where the second part is the empty | 2658 // A flat cons string is a cons string where the second part is the empty |
2659 // string. In that case the subject string is just the first part of the cons | 2659 // string. In that case the subject string is just the first part of the cons |
2660 // string. Also in this case the first part of the cons string is known to be | 2660 // string. Also in this case the first part of the cons string is known to be |
2661 // a sequential string or an external string. | 2661 // a sequential string or an external string. |
2662 // In the case of a sliced string its offset has to be taken into account. | 2662 // In the case of a sliced string its offset has to be taken into account. |
2663 Label cons_string, check_encoding; | 2663 Label cons_string, external_string, check_encoding; |
2664 STATIC_ASSERT(kConsStringTag < kExternalStringTag); | 2664 STATIC_ASSERT(kConsStringTag < kExternalStringTag); |
2665 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); | 2665 STATIC_ASSERT(kSlicedStringTag > kExternalStringTag); |
2666 __ cmpq(rbx, Immediate(kExternalStringTag)); | 2666 __ cmpq(rbx, Immediate(kExternalStringTag)); |
2667 __ j(less, &cons_string, Label::kNear); | 2667 __ j(less, &cons_string, Label::kNear); |
2668 __ j(equal, &runtime); | 2668 __ j(equal, &external_string); |
2669 | 2669 |
2670 // String is sliced. | 2670 // String is sliced. |
2671 __ SmiToInteger32(r14, FieldOperand(rdi, SlicedString::kOffsetOffset)); | 2671 __ SmiToInteger32(r14, FieldOperand(rdi, SlicedString::kOffsetOffset)); |
2672 __ movq(rdi, FieldOperand(rdi, SlicedString::kParentOffset)); | 2672 __ movq(rdi, FieldOperand(rdi, SlicedString::kParentOffset)); |
2673 // r14: slice offset | 2673 // r14: slice offset |
2674 // r15: original subject string | 2674 // r15: original subject string |
2675 // rdi: parent string | 2675 // rdi: parent string |
2676 __ jmp(&check_encoding, Label::kNear); | 2676 __ jmp(&check_encoding, Label::kNear); |
2677 // String is a cons string, check whether it is flat. | 2677 // String is a cons string, check whether it is flat. |
2678 __ bind(&cons_string); | 2678 __ bind(&cons_string); |
2679 __ CompareRoot(FieldOperand(rdi, ConsString::kSecondOffset), | 2679 __ CompareRoot(FieldOperand(rdi, ConsString::kSecondOffset), |
2680 Heap::kEmptyStringRootIndex); | 2680 Heap::kEmptyStringRootIndex); |
2681 __ j(not_equal, &runtime); | 2681 __ j(not_equal, &runtime); |
2682 __ movq(rdi, FieldOperand(rdi, ConsString::kFirstOffset)); | 2682 __ movq(rdi, FieldOperand(rdi, ConsString::kFirstOffset)); |
2683 // rdi: first part of cons string or parent of sliced string. | 2683 // rdi: first part of cons string or parent of sliced string. |
2684 // rbx: map of first part of cons string or map of parent of sliced string. | 2684 // rbx: map of first part of cons string or map of parent of sliced string. |
2685 // Is first part of cons or parent of slice a flat two byte string? | 2685 // Is first part of cons or parent of slice a flat two byte string? |
2686 __ bind(&check_encoding); | 2686 __ bind(&check_encoding); |
2687 __ movq(rbx, FieldOperand(rdi, HeapObject::kMapOffset)); | 2687 __ movq(rbx, FieldOperand(rdi, HeapObject::kMapOffset)); |
2688 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), | 2688 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), |
2689 Immediate(kStringRepresentationMask | kStringEncodingMask)); | 2689 Immediate(kStringRepresentationMask | kStringEncodingMask)); |
2690 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); | 2690 STATIC_ASSERT((kSeqStringTag | kTwoByteStringTag) == 0); |
2691 __ j(zero, &seq_two_byte_string, Label::kNear); | 2691 __ j(zero, &seq_two_byte_string, Label::kNear); |
2692 // Any other flat string must be ascii. | 2692 // Any other flat string must be sequential ascii or external. |
2693 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), | 2693 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), |
2694 Immediate(kStringRepresentationMask)); | 2694 Immediate(kStringRepresentationMask)); |
2695 __ j(not_zero, &runtime); | 2695 __ j(not_zero, &external_string); |
2696 | 2696 |
2697 __ bind(&seq_ascii_string); | 2697 __ bind(&seq_ascii_string); |
2698 // rdi: subject string (sequential ascii) | 2698 // rdi: subject string (sequential ascii) |
2699 // rax: RegExp data (FixedArray) | 2699 // rax: RegExp data (FixedArray) |
2700 __ movq(r11, FieldOperand(rax, JSRegExp::kDataAsciiCodeOffset)); | 2700 __ movq(r11, FieldOperand(rax, JSRegExp::kDataAsciiCodeOffset)); |
2701 __ Set(rcx, 1); // Type is ascii. | 2701 __ Set(rcx, 1); // Type is ascii. |
2702 __ jmp(&check_code, Label::kNear); | 2702 __ jmp(&check_code, Label::kNear); |
2703 | 2703 |
2704 __ bind(&seq_two_byte_string); | 2704 __ bind(&seq_two_byte_string); |
2705 // rdi: subject string (flat two-byte) | 2705 // rdi: subject string (flat two-byte) |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2919 __ movq(pending_exception_operand, rdx); | 2919 __ movq(pending_exception_operand, rdx); |
2920 | 2920 |
2921 __ CompareRoot(rax, Heap::kTerminationExceptionRootIndex); | 2921 __ CompareRoot(rax, Heap::kTerminationExceptionRootIndex); |
2922 Label termination_exception; | 2922 Label termination_exception; |
2923 __ j(equal, &termination_exception, Label::kNear); | 2923 __ j(equal, &termination_exception, Label::kNear); |
2924 __ Throw(rax); | 2924 __ Throw(rax); |
2925 | 2925 |
2926 __ bind(&termination_exception); | 2926 __ bind(&termination_exception); |
2927 __ ThrowUncatchable(TERMINATION, rax); | 2927 __ ThrowUncatchable(TERMINATION, rax); |
2928 | 2928 |
| 2929 // String is external. |
| 2930 // rdi: subject string (expected to be external) |
| 2931 // rbx: scratch |
| 2932 __ bind(&external_string); |
| 2933 if (FLAG_debug_code) { |
| 2934 // Assert that we do not have a cons or slice (indirect strings) here. |
| 2935 // Sequential strings have already been ruled out. |
| 2936 __ movq(rbx, FieldOperand(rdi, HeapObject::kMapOffset)); |
| 2937 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), |
| 2938 Immediate(kIsIndirectStringMask)); |
| 2939 __ Assert(zero, "unexpected indirect string encountered"); |
| 2940 } |
| 2941 __ movq(rbx, FieldOperand(rdi, HeapObject::kMapOffset)); |
| 2942 __ movq(rdi, FieldOperand(rdi, ExternalString::kResourceDataOffset)); |
| 2943 // Assert that the data pointer cache is valid. |
| 2944 __ testq(rdi, rdi); |
| 2945 __ j(zero, &runtime, Label::kNear); |
| 2946 // Move the pointer so that offset-wise, it looks like a sequential string. |
| 2947 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqAsciiString::kHeaderSize); |
| 2948 __ subq(rdi, Immediate(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 2949 STATIC_ASSERT(kTwoByteStringTag == 0); |
| 2950 __ testb(FieldOperand(rbx, Map::kInstanceTypeOffset), |
| 2951 Immediate(kStringEncodingMask)); |
| 2952 __ j(not_zero, &seq_ascii_string); |
| 2953 __ jmp(&seq_two_byte_string); |
| 2954 |
2929 // Do the runtime call to execute the regexp. | 2955 // Do the runtime call to execute the regexp. |
2930 __ bind(&runtime); | 2956 __ bind(&runtime); |
2931 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); | 2957 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); |
2932 #endif // V8_INTERPRETED_REGEXP | 2958 #endif // V8_INTERPRETED_REGEXP |
2933 } | 2959 } |
2934 | 2960 |
2935 | 2961 |
2936 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { | 2962 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { |
2937 const int kMaxInlineLength = 100; | 2963 const int kMaxInlineLength = 100; |
2938 Label slowcase; | 2964 Label slowcase; |
(...skipping 3165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6104 xmm0, | 6130 xmm0, |
6105 &slow_elements); | 6131 &slow_elements); |
6106 __ ret(0); | 6132 __ ret(0); |
6107 } | 6133 } |
6108 | 6134 |
6109 #undef __ | 6135 #undef __ |
6110 | 6136 |
6111 } } // namespace v8::internal | 6137 } } // namespace v8::internal |
6112 | 6138 |
6113 #endif // V8_TARGET_ARCH_X64 | 6139 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |