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

Side by Side Diff: src/arm/code-stubs-arm.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
« no previous file with comments | « no previous file | src/arm64/code-stubs-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ARM 5 #if V8_TARGET_ARCH_ARM
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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 // Process the result from the native regexp code. 1487 // Process the result from the native regexp code.
1488 __ bind(&success); 1488 __ bind(&success);
1489 __ ldr(r1, 1489 __ ldr(r1,
1490 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset)); 1490 FieldMemOperand(regexp_data, JSRegExp::kIrregexpCaptureCountOffset));
1491 // Calculate number of capture registers (number_of_captures + 1) * 2. 1491 // Calculate number of capture registers (number_of_captures + 1) * 2.
1492 // Multiplying by 2 comes for free since r1 is smi-tagged. 1492 // Multiplying by 2 comes for free since r1 is smi-tagged.
1493 STATIC_ASSERT(kSmiTag == 0); 1493 STATIC_ASSERT(kSmiTag == 0);
1494 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1); 1494 STATIC_ASSERT(kSmiTagSize + kSmiShiftSize == 1);
1495 __ add(r1, r1, Operand(2)); // r1 was a smi. 1495 __ add(r1, r1, Operand(2)); // r1 was a smi.
1496 1496
1497 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); 1497 // Check that the last match info is a FixedArray.
1498 __ JumpIfSmi(r0, &runtime); 1498 __ ldr(last_match_info_elements, MemOperand(sp, kLastMatchInfoOffset));
1499 __ CompareObjectType(r0, r2, r2, JS_OBJECT_TYPE); 1499 __ JumpIfSmi(last_match_info_elements, &runtime);
1500 __ b(ne, &runtime);
1501 // Check that the object has fast elements. 1500 // Check that the object has fast elements.
1502 __ ldr(last_match_info_elements,
1503 FieldMemOperand(r0, JSArray::kElementsOffset));
1504 __ ldr(r0, FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset)); 1501 __ ldr(r0, FieldMemOperand(last_match_info_elements, HeapObject::kMapOffset));
1505 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex); 1502 __ CompareRoot(r0, Heap::kFixedArrayMapRootIndex);
1506 __ b(ne, &runtime); 1503 __ b(ne, &runtime);
1507 // Check that the last match info has space for the capture registers and the 1504 // Check that the last match info has space for the capture registers and the
1508 // additional information. 1505 // additional information.
1509 __ ldr(r0, 1506 __ ldr(r0,
1510 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset)); 1507 FieldMemOperand(last_match_info_elements, FixedArray::kLengthOffset));
1511 __ add(r2, r1, Operand(RegExpImpl::kLastMatchOverhead)); 1508 __ add(r2, r1, Operand(RegExpMatchInfo::kLastMatchOverhead));
1512 __ cmp(r2, Operand::SmiUntag(r0)); 1509 __ cmp(r2, Operand::SmiUntag(r0));
1513 __ b(gt, &runtime); 1510 __ b(gt, &runtime);
1514 1511
1515 // r1: number of capture registers 1512 // r1: number of capture registers
1516 // r4: subject string 1513 // r4: subject string
1517 // Store the capture count. 1514 // Store the capture count.
1518 __ SmiTag(r2, r1); 1515 __ SmiTag(r2, r1);
1519 __ str(r2, FieldMemOperand(last_match_info_elements, 1516 __ str(r2, FieldMemOperand(last_match_info_elements,
1520 RegExpImpl::kLastCaptureCountOffset)); 1517 RegExpMatchInfo::kNumberOfCapturesOffset));
1521 // Store last subject and last input. 1518 // Store last subject and last input.
1522 __ str(subject, 1519 __ str(subject, FieldMemOperand(last_match_info_elements,
1523 FieldMemOperand(last_match_info_elements, 1520 RegExpMatchInfo::kLastSubjectOffset));
1524 RegExpImpl::kLastSubjectOffset));
1525 __ mov(r2, subject); 1521 __ mov(r2, subject);
1526 __ RecordWriteField(last_match_info_elements, 1522 __ RecordWriteField(last_match_info_elements,
1527 RegExpImpl::kLastSubjectOffset, 1523 RegExpMatchInfo::kLastSubjectOffset, subject, r3,
1528 subject, 1524 kLRHasNotBeenSaved, kDontSaveFPRegs);
1529 r3,
1530 kLRHasNotBeenSaved,
1531 kDontSaveFPRegs);
1532 __ mov(subject, r2); 1525 __ mov(subject, r2);
1533 __ str(subject, 1526 __ str(subject, FieldMemOperand(last_match_info_elements,
1534 FieldMemOperand(last_match_info_elements, 1527 RegExpMatchInfo::kLastInputOffset));
1535 RegExpImpl::kLastInputOffset));
1536 __ RecordWriteField(last_match_info_elements, 1528 __ RecordWriteField(last_match_info_elements,
1537 RegExpImpl::kLastInputOffset, 1529 RegExpMatchInfo::kLastInputOffset, subject, r3,
1538 subject, 1530 kLRHasNotBeenSaved, kDontSaveFPRegs);
1539 r3,
1540 kLRHasNotBeenSaved,
1541 kDontSaveFPRegs);
1542 1531
1543 // Get the static offsets vector filled by the native regexp code. 1532 // Get the static offsets vector filled by the native regexp code.
1544 ExternalReference address_of_static_offsets_vector = 1533 ExternalReference address_of_static_offsets_vector =
1545 ExternalReference::address_of_static_offsets_vector(isolate()); 1534 ExternalReference::address_of_static_offsets_vector(isolate());
1546 __ mov(r2, Operand(address_of_static_offsets_vector)); 1535 __ mov(r2, Operand(address_of_static_offsets_vector));
1547 1536
1548 // r1: number of capture registers 1537 // r1: number of capture registers
1549 // r2: offsets vector 1538 // r2: offsets vector
1550 Label next_capture, done; 1539 Label next_capture, done;
1551 // Capture register counter starts from number of capture registers and 1540 // Capture register counter starts from number of capture registers and
1552 // counts down until wraping after zero. 1541 // counts down until wrapping after zero.
1553 __ add(r0, 1542 __ add(r0, last_match_info_elements,
1554 last_match_info_elements, 1543 Operand(RegExpMatchInfo::kFirstCaptureOffset - kHeapObjectTag));
1555 Operand(RegExpImpl::kFirstCaptureOffset - kHeapObjectTag));
1556 __ bind(&next_capture); 1544 __ bind(&next_capture);
1557 __ sub(r1, r1, Operand(1), SetCC); 1545 __ sub(r1, r1, Operand(1), SetCC);
1558 __ b(mi, &done); 1546 __ b(mi, &done);
1559 // Read the value from the static offsets vector buffer. 1547 // Read the value from the static offsets vector buffer.
1560 __ ldr(r3, MemOperand(r2, kPointerSize, PostIndex)); 1548 __ ldr(r3, MemOperand(r2, kPointerSize, PostIndex));
1561 // Store the smi value in the last match info. 1549 // Store the smi value in the last match info.
1562 __ SmiTag(r3); 1550 __ SmiTag(r3);
1563 __ str(r3, MemOperand(r0, kPointerSize, PostIndex)); 1551 __ str(r3, MemOperand(r0, kPointerSize, PostIndex));
1564 __ jmp(&next_capture); 1552 __ jmp(&next_capture);
1565 __ bind(&done); 1553 __ bind(&done);
1566 1554
1567 // Return last match info. 1555 // Return last match info.
1568 __ ldr(r0, MemOperand(sp, kLastMatchInfoOffset)); 1556 __ mov(r0, last_match_info_elements);
1569 __ add(sp, sp, Operand(4 * kPointerSize)); 1557 __ add(sp, sp, Operand(4 * kPointerSize));
1570 __ Ret(); 1558 __ Ret();
1571 1559
1572 // Do the runtime call to execute the regexp. 1560 // Do the runtime call to execute the regexp.
1573 __ bind(&runtime); 1561 __ bind(&runtime);
1574 __ TailCallRuntime(Runtime::kRegExpExec); 1562 __ TailCallRuntime(Runtime::kRegExpExec);
1575 1563
1576 // Deferred code for string handling. 1564 // Deferred code for string handling.
1577 // (5) Long external string? If not, go to (7). 1565 // (5) Long external string? If not, go to (7).
1578 __ bind(&not_seq_nor_cons); 1566 __ bind(&not_seq_nor_cons);
(...skipping 3071 matching lines...) Expand 10 before | Expand all | Expand 10 after
4650 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 4638 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
4651 kStackUnwindSpace, NULL, return_value_operand, NULL); 4639 kStackUnwindSpace, NULL, return_value_operand, NULL);
4652 } 4640 }
4653 4641
4654 #undef __ 4642 #undef __
4655 4643
4656 } // namespace internal 4644 } // namespace internal
4657 } // namespace v8 4645 } // namespace v8
4658 4646
4659 #endif // V8_TARGET_ARCH_ARM 4647 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/code-stubs-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698