Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 8680010: Add external strings support to regexp in generated code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fixing small mistakes Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 __ movq(rbx, FieldOperand(rdi, HeapObject::kMapOffset));
2934 __ movzxbl(rbx, FieldOperand(rbx, Map::kInstanceTypeOffset));
2935 if (FLAG_debug_code) {
2936 // Assert that we do not have a cons or slice (indirect strings) here.
2937 // Sequential strings have already been ruled out.
2938 __ testb(rbx, Immediate(kIsIndirectStringMask));
2939 __ Assert(zero, "external string expected, but not found");
2940 }
2941 // Rule out short external strings.
2942 STATIC_CHECK(kShortExternalStringTag != 0);
2943 __ testb(rbx, Immediate(kShortExternalStringMask));
2944 __ j(not_zero, &runtime);
2945 __ movq(rdi, FieldOperand(rdi, ExternalString::kResourceDataOffset));
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(rbx, Immediate(kStringEncodingMask));
2951 __ j(not_zero, &seq_ascii_string);
2952 __ jmp(&seq_two_byte_string);
2953
2929 // Do the runtime call to execute the regexp. 2954 // Do the runtime call to execute the regexp.
2930 __ bind(&runtime); 2955 __ bind(&runtime);
2931 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); 2956 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1);
2932 #endif // V8_INTERPRETED_REGEXP 2957 #endif // V8_INTERPRETED_REGEXP
2933 } 2958 }
2934 2959
2935 2960
2936 void RegExpConstructResultStub::Generate(MacroAssembler* masm) { 2961 void RegExpConstructResultStub::Generate(MacroAssembler* masm) {
2937 const int kMaxInlineLength = 100; 2962 const int kMaxInlineLength = 100;
2938 Label slowcase; 2963 Label slowcase;
(...skipping 3165 matching lines...) Expand 10 before | Expand all | Expand 10 after
6104 xmm0, 6129 xmm0,
6105 &slow_elements); 6130 &slow_elements);
6106 __ ret(0); 6131 __ ret(0);
6107 } 6132 }
6108 6133
6109 #undef __ 6134 #undef __
6110 6135
6111 } } // namespace v8::internal 6136 } } // namespace v8::internal
6112 6137
6113 #endif // V8_TARGET_ARCH_X64 6138 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698