OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 * - r13/sp : points to tip of C stack. | 56 * - r13/sp : points to tip of C stack. |
57 * | 57 * |
58 * The remaining registers are free for computations. | 58 * The remaining registers are free for computations. |
59 * | 59 * |
60 * Each call to a public method should retain this convention. | 60 * Each call to a public method should retain this convention. |
61 * The stack will have the following structure: | 61 * The stack will have the following structure: |
62 * - direct_call (if 1, direct call from JavaScript code, if 0 call | 62 * - direct_call (if 1, direct call from JavaScript code, if 0 call |
63 * through the runtime system) | 63 * through the runtime system) |
64 * - stack_area_base (High end of the memory area to use as | 64 * - stack_area_base (High end of the memory area to use as |
65 * backtracking stack) | 65 * backtracking stack) |
66 * - at_start (if 1, we are starting at the start of the | |
67 * string, otherwise 0) | |
68 * - int* capture_array (int[num_saved_registers_], for output). | 66 * - int* capture_array (int[num_saved_registers_], for output). |
69 * --- sp when called --- | 67 * --- sp when called --- |
70 * - link address | 68 * - link address |
71 * - backup of registers r4..r11 | 69 * - backup of registers r4..r11 |
72 * - end of input (Address of end of string) | 70 * - end of input (Address of end of string) |
73 * - start of input (Address of first character in string) | 71 * - start of input (Address of first character in string) |
74 * - start index (character index of start) | 72 * - start index (character index of start) |
75 * --- frame pointer ---- | 73 * --- frame pointer ---- |
76 * - void* input_string (location of a handle containing the string) | 74 * - void* input_string (location of a handle containing the string) |
77 * - Offset of location before start of input (effectively character | 75 * - Offset of location before start of input (effectively character |
78 * position -1). Used to initialize capture registers to a non-position. | 76 * position -1). Used to initialize capture registers to a non-position. |
| 77 * - At start (if 1, we are starting at the start of the |
| 78 * string, otherwise 0) |
79 * - register 0 (Only positions must be stored in the first | 79 * - register 0 (Only positions must be stored in the first |
80 * - register 1 num_saved_registers_ registers) | 80 * - register 1 num_saved_registers_ registers) |
81 * - ... | 81 * - ... |
82 * - register num_registers-1 | 82 * - register num_registers-1 |
83 * --- sp --- | 83 * --- sp --- |
84 * | 84 * |
85 * The first num_saved_registers_ registers are initialized to point to | 85 * The first num_saved_registers_ registers are initialized to point to |
86 * "character -1" in the string (i.e., char_size() bytes before the first | 86 * "character -1" in the string (i.e., char_size() bytes before the first |
87 * character of the string). The remaining registers start out as garbage. | 87 * character of the string). The remaining registers start out as garbage. |
88 * | 88 * |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 // Save callee-save registers. | 603 // Save callee-save registers. |
604 // Start new stack frame. | 604 // Start new stack frame. |
605 // Order here should correspond to order of offset constants in header file. | 605 // Order here should correspond to order of offset constants in header file. |
606 RegList registers_to_retain = r4.bit() | r5.bit() | r6.bit() | | 606 RegList registers_to_retain = r4.bit() | r5.bit() | r6.bit() | |
607 r7.bit() | r8.bit() | r9.bit() | r10.bit() | fp.bit(); | 607 r7.bit() | r8.bit() | r9.bit() | r10.bit() | fp.bit(); |
608 RegList argument_registers = r0.bit() | r1.bit() | r2.bit() | r3.bit(); | 608 RegList argument_registers = r0.bit() | r1.bit() | r2.bit() | r3.bit(); |
609 __ stm(db_w, sp, argument_registers | registers_to_retain | lr.bit()); | 609 __ stm(db_w, sp, argument_registers | registers_to_retain | lr.bit()); |
610 // Set frame pointer just above the arguments. | 610 // Set frame pointer just above the arguments. |
611 __ add(frame_pointer(), sp, Operand(4 * kPointerSize)); | 611 __ add(frame_pointer(), sp, Operand(4 * kPointerSize)); |
612 __ push(r0); // Make room for "position - 1" constant (value is irrelevant). | 612 __ push(r0); // Make room for "position - 1" constant (value is irrelevant). |
| 613 __ push(r0); // Make room for "at start" constant (value is irrelevant). |
613 | 614 |
614 // Check if we have space on the stack for registers. | 615 // Check if we have space on the stack for registers. |
615 Label stack_limit_hit; | 616 Label stack_limit_hit; |
616 Label stack_ok; | 617 Label stack_ok; |
617 | 618 |
618 ExternalReference stack_limit = | 619 ExternalReference stack_limit = |
619 ExternalReference::address_of_stack_limit(); | 620 ExternalReference::address_of_stack_limit(); |
620 __ mov(r0, Operand(stack_limit)); | 621 __ mov(r0, Operand(stack_limit)); |
621 __ ldr(r0, MemOperand(r0)); | 622 __ ldr(r0, MemOperand(r0)); |
622 __ sub(r0, sp, r0, SetCC); | 623 __ sub(r0, sp, r0, SetCC); |
(...skipping 23 matching lines...) Expand all Loading... |
646 // Load input start. | 647 // Load input start. |
647 __ ldr(r0, MemOperand(frame_pointer(), kInputStart)); | 648 __ ldr(r0, MemOperand(frame_pointer(), kInputStart)); |
648 // Find negative length (offset of start relative to end). | 649 // Find negative length (offset of start relative to end). |
649 __ sub(current_input_offset(), r0, end_of_input_address()); | 650 __ sub(current_input_offset(), r0, end_of_input_address()); |
650 // Set r0 to address of char before start of input | 651 // Set r0 to address of char before start of input |
651 // (effectively string position -1). | 652 // (effectively string position -1). |
652 __ sub(r0, current_input_offset(), Operand(char_size())); | 653 __ sub(r0, current_input_offset(), Operand(char_size())); |
653 // Store this value in a local variable, for use when clearing | 654 // Store this value in a local variable, for use when clearing |
654 // position registers. | 655 // position registers. |
655 __ str(r0, MemOperand(frame_pointer(), kInputStartMinusOne)); | 656 __ str(r0, MemOperand(frame_pointer(), kInputStartMinusOne)); |
| 657 |
| 658 // Determine whether the start index is zero, that is at the start of the |
| 659 // string, and store that value in a local variable. |
| 660 __ ldr(r1, MemOperand(frame_pointer(), kStartIndex)); |
| 661 __ tst(r1, Operand(r1)); |
| 662 __ mov(r1, Operand(1), LeaveCC, eq); |
| 663 __ mov(r1, Operand(0), LeaveCC, ne); |
| 664 __ str(r1, MemOperand(frame_pointer(), kAtStart)); |
| 665 |
656 if (num_saved_registers_ > 0) { // Always is, if generated from a regexp. | 666 if (num_saved_registers_ > 0) { // Always is, if generated from a regexp. |
657 // Fill saved registers with initial value = start offset - 1 | 667 // Fill saved registers with initial value = start offset - 1 |
658 | 668 |
659 // Address of register 0. | 669 // Address of register 0. |
660 __ add(r1, frame_pointer(), Operand(kRegisterZero)); | 670 __ add(r1, frame_pointer(), Operand(kRegisterZero)); |
661 __ mov(r2, Operand(num_saved_registers_)); | 671 __ mov(r2, Operand(num_saved_registers_)); |
662 Label init_loop; | 672 Label init_loop; |
663 __ bind(&init_loop); | 673 __ bind(&init_loop); |
664 __ str(r0, MemOperand(r1, kPointerSize, NegPostIndex)); | 674 __ str(r0, MemOperand(r1, kPointerSize, NegPostIndex)); |
665 __ sub(r2, r2, Operand(1), SetCC); | 675 __ sub(r2, r2, Operand(1), SetCC); |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 __ mov(r0, sp); | 1257 __ mov(r0, sp); |
1248 __ Call(r5); | 1258 __ Call(r5); |
1249 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); | 1259 __ ldr(pc, MemOperand(sp, stack_alignment, PostIndex)); |
1250 } | 1260 } |
1251 | 1261 |
1252 #undef __ | 1262 #undef __ |
1253 | 1263 |
1254 #endif // V8_NATIVE_REGEXP | 1264 #endif // V8_NATIVE_REGEXP |
1255 | 1265 |
1256 }} // namespace v8::internal | 1266 }} // namespace v8::internal |
OLD | NEW |