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

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

Issue 2415103002: [regexp] Turn last match info into a simple FixedArray (Closed)
Patch Set: Port architectures and move internal match info to context 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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_PPC 5 #if V8_TARGET_ARCH_PPC
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 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 // Process the result from the native regexp code. 1569 // Process the result from the native regexp code.
1570 __ bind(&success); 1570 __ bind(&success);
1571 __ LoadP(r4, 1571 __ LoadP(r4,
1572 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); 1572 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset));
1573 // Calculate number of capture registers (number_of_captures + 1) * 2. 1573 // Calculate number of capture registers (number_of_captures + 1) * 2.
1574 // SmiToShortArrayOffset accomplishes the multiplication by 2 and 1574 // SmiToShortArrayOffset accomplishes the multiplication by 2 and
1575 // SmiUntag (which is a nop for 32-bit). 1575 // SmiUntag (which is a nop for 32-bit).
1576 __ SmiToShortArrayOffset(r4, r4); 1576 __ SmiToShortArrayOffset(r4, r4);
1577 __ addi(r4, r4, Operand(2)); 1577 __ addi(r4, r4, Operand(2));
1578 1578
1579 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); 1579 // Check that the last match info is a FixedArray.
1580 __ JumpIfSmi(r3, &runtime); 1580 __ LoadP(last_match_info_elements, MemOperand(sp, kLastMatchInfoOffset));
1581 __ CompareObjectType(r3, r5, r5, JS_OBJECT_TYPE); 1581 __ JumpIfSmi(last_match_info_elements, &runtime);
1582 __ CompareObjectType(last_match_info_elements, r5, r5, FIXED_ARRAY_TYPE);
1582 __ bne(&runtime); 1583 __ bne(&runtime);
1583 // Check that the object has fast elements. 1584 // Check that the object has fast elements.
1584 __ LoadP(last_match_info_elements,
1585 FieldMemOperand(r3, JSArray::kElementsOffset));
1586 __ LoadP(r3, 1585 __ LoadP(r3,
1587 FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); 1586 FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset));
1588 __ CompareRoot(r3, Heap::kFixedArrayMapRootIndex); 1587 __ CompareRoot(r3, Heap::kFixedArrayMapRootIndex);
1589 __ bne(&runtime); 1588 __ bne(&runtime);
1590 // Check that the last match info has space for the capture registers and the 1589 // Check that the last match info has space for the capture registers and the
1591 // additional information. 1590 // additional information.
1592 __ LoadP( 1591 __ LoadP(
1593 r3, FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); 1592 r3, FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset));
1594 __ addi(r5, r4, Operand(RegExpImpl::kLastMatchOverhead)); 1593 __ addi(r5, r4, Operand(RegExpMatchInfo::kLastMatchOverhead));
1595 __ SmiUntag(r0, r3); 1594 __ SmiUntag(r0, r3);
1596 __ cmp(r5, r0); 1595 __ cmp(r5, r0);
1597 __ bgt(&runtime); 1596 __ bgt(&runtime);
1598 1597
1599 // r4: number of capture registers 1598 // r4: number of capture registers
1600 // subject: subject string 1599 // subject: subject string
1601 // Store the capture count. 1600 // Store the capture count.
1602 __ SmiTag(r5, r4); 1601 __ SmiTag(r5, r4);
1603 __ StoreP(r5, FieldMemOperand(last_match_info_elements, 1602 __ StoreP(r5, FieldMemOperand(last_match_info_elements,
1604 RegExpImpl::kLastCaptureCountOffset), 1603 RegExpMatchInfo::kNumberOfCapturesOffset),
1605 r0); 1604 r0);
1606 // Store last subject and last input. 1605 // Store last subject and last input.
1607 __ StoreP(subject, FieldMemOperand(last_match_info_elements, 1606 __ StoreP(subject, FieldMemOperand(last_match_info_elements,
1608 RegExpImpl::kLastSubjectOffset), 1607 RegExpMatchInfo::kLastSubjectOffset),
1609 r0); 1608 r0);
1610 __ mr(r5, subject); 1609 __ mr(r5, subject);
1611 __ RecordWriteField(last_match_info_elements, RegExpImpl::kLastSubjectOffset, 1610 __ RecordWriteField(last_match_info_elements,
1612 subject, r10, kLRHasNotBeenSaved, kDontSaveFPRegs); 1611 RegExpMatchInfo::kLastSubjectOffset, subject, r10,
1612 kLRHasNotBeenSaved, kDontSaveFPRegs);
1613 __ mr(subject, r5); 1613 __ mr(subject, r5);
1614 __ StoreP(subject, FieldMemOperand(last_match_info_elements, 1614 __ StoreP(subject, FieldMemOperand(last_match_info_elements,
1615 RegExpImpl::kLastInputOffset), 1615 RegExpMatchInfo::kLastInputOffset),
1616 r0); 1616 r0);
1617 __ RecordWriteField(last_match_info_elements, RegExpImpl::kLastInputOffset, 1617 __ RecordWriteField(last_match_info_elements,
1618 subject, r10, kLRHasNotBeenSaved, kDontSaveFPRegs); 1618 RegExpMatchInfo::kLastInputOffset, subject, r10,
1619 kLRHasNotBeenSaved, kDontSaveFPRegs);
1619 1620
1620 // Get the static offsets vector filled by the native regexp code. 1621 // Get the static offsets vector filled by the native regexp code.
1621 ExternalReference address_of_static_offsets_vector = 1622 ExternalReference address_of_static_offsets_vector =
1622 ExternalReference::address_of_static_offsets_vector(isolate()); 1623 ExternalReference::address_of_static_offsets_vector(isolate());
1623 __ mov(r5, Operand(address_of_static_offsets_vector)); 1624 __ mov(r5, Operand(address_of_static_offsets_vector));
1624 1625
1625 // r4: number of capture registers 1626 // r4: number of capture registers
1626 // r5: offsets vector 1627 // r5: offsets vector
1627 Label next_capture; 1628 Label next_capture;
1628 // Capture register counter starts from number of capture registers and 1629 // Capture register counter starts from number of capture registers and
1629 // counts down until wraping after zero. 1630 // counts down until wrapping after zero.
1630 __ addi( 1631 __ addi(r3, last_match_info_elements,
1631 r3, last_match_info_elements, 1632 Operand(RegExpMatchInfo::kFirstCaptureOffset - kHeapObjectTag -
1632 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag - kPointerSize)); 1633 kPointerSize));
1633 __ addi(r5, r5, Operand(-kIntSize)); // bias down for lwzu 1634 __ addi(r5, r5, Operand(-kIntSize)); // bias down for lwzu
1634 __ mtctr(r4); 1635 __ mtctr(r4);
1635 __ bind(&next_capture); 1636 __ bind(&next_capture);
1636 // Read the value from the static offsets vector buffer. 1637 // Read the value from the static offsets vector buffer.
1637 __ lwzu(r6, MemOperand(r5, kIntSize)); 1638 __ lwzu(r6, MemOperand(r5, kIntSize));
1638 // Store the smi value in the last match info. 1639 // Store the smi value in the last match info.
1639 __ SmiTag(r6); 1640 __ SmiTag(r6);
1640 __ StorePU(r6, MemOperand(r3, kPointerSize)); 1641 __ StorePU(r6, MemOperand(r3, kPointerSize));
1641 __ bdnz(&next_capture); 1642 __ bdnz(&next_capture);
1642 1643
1643 // Return last match info. 1644 // Return last match info.
1644 __ LoadP(r3, MemOperand(sp, kLastMatchInfoOffset)); 1645 __ mr(r3, last_match_info_elements);
1645 __ addi(sp, sp, Operand(4 * kPointerSize)); 1646 __ addi(sp, sp, Operand(4 * kPointerSize));
1646 __ Ret(); 1647 __ Ret();
1647 1648
1648 // Do the runtime call to execute the regexp. 1649 // Do the runtime call to execute the regexp.
1649 __ bind(&runtime); 1650 __ bind(&runtime);
1650 __ TailCallRuntime(Runtime::kRegExpExec); 1651 __ TailCallRuntime(Runtime::kRegExpExec);
1651 1652
1652 // Deferred code for string handling. 1653 // Deferred code for string handling.
1653 // (5) Long external string? If not, go to (7). 1654 // (5) Long external string? If not, go to (7).
1654 __ bind(&not_seq_nor_cons); 1655 __ bind(&not_seq_nor_cons);
(...skipping 3250 matching lines...) Expand 10 before | Expand all | Expand 10 after
4905 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); 4906 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize);
4906 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 4907 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
4907 kStackUnwindSpace, NULL, return_value_operand, NULL); 4908 kStackUnwindSpace, NULL, return_value_operand, NULL);
4908 } 4909 }
4909 4910
4910 #undef __ 4911 #undef __
4911 } // namespace internal 4912 } // namespace internal
4912 } // namespace v8 4913 } // namespace v8
4913 4914
4914 #endif // V8_TARGET_ARCH_PPC 4915 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« src/arm/code-stubs-arm.cc ('K') | « src/objects-inl.h ('k') | src/regexp/jsregexp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698