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

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

Issue 2415103002: [regexp] Turn last match info into a simple FixedArray (Closed)
Patch Set: Don't check instance type before map check Created 4 years, 2 months 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
OLDNEW
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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 __ bind(&success); 624 __ bind(&success);
625 __ mov(eax, Operand(esp, kJSRegExpOffset)); 625 __ mov(eax, Operand(esp, kJSRegExpOffset));
626 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset)); 626 __ mov(ecx, FieldOperand(eax, JSRegExp::kDataOffset));
627 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset)); 627 __ mov(edx, FieldOperand(ecx, JSRegExp::kIrregexpCaptureCountOffset));
628 // Calculate number of capture registers (number_of_captures + 1) * 2. 628 // Calculate number of capture registers (number_of_captures + 1) * 2.
629 STATIC_ASSERT(kSmiTag == 0); 629 STATIC_ASSERT(kSmiTag == 0);
630 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); 630 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1);
631 __ add(edx, Immediate(2)); // edx was a smi. 631 __ add(edx, Immediate(2)); // edx was a smi.
632 632
633 // edx: Number of capture registers 633 // edx: Number of capture registers
634 // Load last_match_info which is still known to be a fast-elements JSObject. 634 // Check that the last match info is a FixedArray.
635 // Check that the fourth object is a JSObject. 635 __ mov(ebx, Operand(esp, kLastMatchInfoOffset));
636 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); 636 __ JumpIfSmi(ebx, &runtime);
637 __ JumpIfSmi(eax, &runtime);
638 __ CmpObjectType(eax, JS_OBJECT_TYPE, ebx);
639 __ j(not_equal, &runtime);
640 // Check that the object has fast elements. 637 // Check that the object has fast elements.
641 __ mov(ebx, FieldOperand(eax, JSArray::kElementsOffset));
642 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset)); 638 __ mov(eax, FieldOperand(ebx, HeapObject::kMapOffset));
643 __ cmp(eax, factory->fixed_array_map()); 639 __ cmp(eax, factory->fixed_array_map());
644 __ j(not_equal, &runtime); 640 __ j(not_equal, &runtime);
645 // Check that the last match info has space for the capture registers and the 641 // Check that the last match info has space for the capture registers and the
646 // additional information. 642 // additional information.
647 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset)); 643 __ mov(eax, FieldOperand(ebx, FixedArray::kLengthOffset));
648 __ SmiUntag(eax); 644 __ SmiUntag(eax);
649 __ sub(eax, Immediate(RegExpImpl::kLastMatchOverhead)); 645 __ sub(eax, Immediate(RegExpMatchInfo::kLastMatchOverhead));
650 __ cmp(edx, eax); 646 __ cmp(edx, eax);
651 __ j(greater, &runtime); 647 __ j(greater, &runtime);
652 648
653 // ebx: last_match_info backing store (FixedArray) 649 // ebx: last_match_info backing store (FixedArray)
654 // edx: number of capture registers 650 // edx: number of capture registers
655 // Store the capture count. 651 // Store the capture count.
656 __ SmiTag(edx); // Number of capture registers to smi. 652 __ SmiTag(edx); // Number of capture registers to smi.
657 __ mov(FieldOperand(ebx, RegExpImpl::kLastCaptureCountOffset), edx); 653 __ mov(FieldOperand(ebx, RegExpMatchInfo::kNumberOfCapturesOffset), edx);
658 __ SmiUntag(edx); // Number of capture registers back from smi. 654 __ SmiUntag(edx); // Number of capture registers back from smi.
659 // Store last subject and last input. 655 // Store last subject and last input.
660 __ mov(eax, Operand(esp, kSubjectOffset)); 656 __ mov(eax, Operand(esp, kSubjectOffset));
661 __ mov(ecx, eax); 657 __ mov(ecx, eax);
662 __ mov(FieldOperand(ebx, RegExpImpl::kLastSubjectOffset), eax); 658 __ mov(FieldOperand(ebx, RegExpMatchInfo::kLastSubjectOffset), eax);
663 __ RecordWriteField(ebx, RegExpImpl::kLastSubjectOffset, eax, edi, 659 __ RecordWriteField(ebx, RegExpMatchInfo::kLastSubjectOffset, eax, edi,
664 kDontSaveFPRegs); 660 kDontSaveFPRegs);
665 __ mov(eax, ecx); 661 __ mov(eax, ecx);
666 __ mov(FieldOperand(ebx, RegExpImpl::kLastInputOffset), eax); 662 __ mov(FieldOperand(ebx, RegExpMatchInfo::kLastInputOffset), eax);
667 __ RecordWriteField(ebx, RegExpImpl::kLastInputOffset, eax, edi, 663 __ RecordWriteField(ebx, RegExpMatchInfo::kLastInputOffset, eax, edi,
668 kDontSaveFPRegs); 664 kDontSaveFPRegs);
669 665
670 // Get the static offsets vector filled by the native regexp code. 666 // Get the static offsets vector filled by the native regexp code.
671 ExternalReference address_of_static_offsets_vector = 667 ExternalReference address_of_static_offsets_vector =
672 ExternalReference::address_of_static_offsets_vector(isolate()); 668 ExternalReference::address_of_static_offsets_vector(isolate());
673 __ mov(ecx, Immediate(address_of_static_offsets_vector)); 669 __ mov(ecx, Immediate(address_of_static_offsets_vector));
674 670
675 // ebx: last_match_info backing store (FixedArray) 671 // ebx: last_match_info backing store (FixedArray)
676 // ecx: offsets vector 672 // ecx: offsets vector
677 // edx: number of capture registers 673 // edx: number of capture registers
678 Label next_capture, done; 674 Label next_capture, done;
679 // Capture register counter starts from number of capture registers and 675 // Capture register counter starts from number of capture registers and
680 // counts down until wraping after zero. 676 // counts down until wrapping after zero.
681 __ bind(&next_capture); 677 __ bind(&next_capture);
682 __ sub(edx, Immediate(1)); 678 __ sub(edx, Immediate(1));
683 __ j(negative, &done, Label::kNear); 679 __ j(negative, &done, Label::kNear);
684 // Read the value from the static offsets vector buffer. 680 // Read the value from the static offsets vector buffer.
685 __ mov(edi, Operand(ecx, edx, times_int_size, 0)); 681 __ mov(edi, Operand(ecx, edx, times_int_size, 0));
686 __ SmiTag(edi); 682 __ SmiTag(edi);
687 // Store the smi value in the last match info. 683 // Store the smi value in the last match info.
688 __ mov(FieldOperand(ebx, 684 __ mov(FieldOperand(ebx, edx, times_pointer_size,
689 edx, 685 RegExpMatchInfo::kFirstCaptureOffset),
690 times_pointer_size, 686 edi);
691 RegExpImpl::kFirstCaptureOffset),
692 edi);
693 __ jmp(&next_capture); 687 __ jmp(&next_capture);
694 __ bind(&done); 688 __ bind(&done);
695 689
696 // Return last match info. 690 // Return last match info.
697 __ mov(eax, Operand(esp, kLastMatchInfoOffset)); 691 __ mov(eax, ebx);
698 __ ret(4 * kPointerSize); 692 __ ret(4 * kPointerSize);
699 693
700 // Do the runtime call to execute the regexp. 694 // Do the runtime call to execute the regexp.
701 __ bind(&runtime); 695 __ bind(&runtime);
702 __ TailCallRuntime(Runtime::kRegExpExec); 696 __ TailCallRuntime(Runtime::kRegExpExec);
703 697
704 // Deferred code for string handling. 698 // Deferred code for string handling.
705 // (6) Long external string? If not, go to (10). 699 // (6) Long external string? If not, go to (10).
706 __ bind(&not_seq_nor_cons); 700 __ bind(&not_seq_nor_cons);
707 // Compare flags are still set from (3). 701 // Compare flags are still set from (3).
(...skipping 4027 matching lines...) Expand 10 before | Expand all | Expand 10 after
4735 kStackUnwindSpace, nullptr, return_value_operand, 4729 kStackUnwindSpace, nullptr, return_value_operand,
4736 NULL); 4730 NULL);
4737 } 4731 }
4738 4732
4739 #undef __ 4733 #undef __
4740 4734
4741 } // namespace internal 4735 } // namespace internal
4742 } // namespace v8 4736 } // namespace v8
4743 4737
4744 #endif // V8_TARGET_ARCH_X87 4738 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/x64/code-stubs-x64.cc ('k') | test/cctest/interpreter/bytecode_expectations/CallRuntime.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698