OLD | NEW |
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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
6 | 6 |
7 #include "src/regexp/mips64/regexp-macro-assembler-mips64.h" | 7 #include "src/regexp/mips64/regexp-macro-assembler-mips64.h" |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/log.h" | 10 #include "src/log.h" |
11 #include "src/macro-assembler.h" | 11 #include "src/macro-assembler.h" |
12 #include "src/regexp/regexp-macro-assembler.h" | 12 #include "src/regexp/regexp-macro-assembler.h" |
13 #include "src/regexp/regexp-stack.h" | 13 #include "src/regexp/regexp-stack.h" |
14 #include "src/unicode.h" | 14 #include "src/unicode.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 | 18 |
19 #ifndef V8_INTERPRETED_REGEXP | 19 #ifndef V8_INTERPRETED_REGEXP |
20 /* | 20 |
| 21 /* clang-format off |
| 22 * |
21 * This assembler uses the following register assignment convention | 23 * This assembler uses the following register assignment convention |
22 * - t3 : Temporarily stores the index of capture start after a matching pass | 24 * - t3 : Temporarily stores the index of capture start after a matching pass |
23 * for a global regexp. | 25 * for a global regexp. |
24 * - a5 : Pointer to current code object (Code*) including heap object tag. | 26 * - a5 : Pointer to current code object (Code*) including heap object tag. |
25 * - a6 : Current position in input, as negative offset from end of string. | 27 * - a6 : Current position in input, as negative offset from end of string. |
26 * Please notice that this is the byte offset, not the character offset! | 28 * Please notice that this is the byte offset, not the character offset! |
27 * - a7 : Currently loaded character. Must be loaded using | 29 * - a7 : Currently loaded character. Must be loaded using |
28 * LoadCurrentCharacter before using any of the dispatch methods. | 30 * LoadCurrentCharacter before using any of the dispatch methods. |
29 * - t0 : Points to tip of backtrack stack | 31 * - t0 : Points to tip of backtrack stack |
30 * - t1 : Unused. | 32 * - t1 : Unused. |
31 * - t2 : End of input (points to byte after last character in input). | 33 * - t2 : End of input (points to byte after last character in input). |
32 * - fp : Frame pointer. Used to access arguments, local variables and | 34 * - fp : Frame pointer. Used to access arguments, local variables and |
33 * RegExp registers. | 35 * RegExp registers. |
34 * - sp : Points to tip of C stack. | 36 * - sp : Points to tip of C stack. |
35 * | 37 * |
36 * The remaining registers are free for computations. | 38 * The remaining registers are free for computations. |
37 * Each call to a public method should retain this convention. | 39 * Each call to a public method should retain this convention. |
38 * | 40 * |
39 * TODO(plind): O32 documented here with intent of having single 32/64 codebase | 41 * TODO(plind): O32 documented here with intent of having single 32/64 codebase |
40 * in the future. | 42 * in the future. |
41 * | 43 * |
42 * The O32 stack will have the following structure: | 44 * The O32 stack will have the following structure: |
43 * | 45 * |
44 * - fp[76] Isolate* isolate (address of the current isolate) | 46 * - fp[72] Isolate* isolate (address of the current isolate) |
45 * - fp[72] direct_call (if 1, direct call from JavaScript code, | 47 * - fp[68] direct_call (if 1, direct call from JavaScript code, |
46 * if 0, call through the runtime system). | 48 * if 0, call through the runtime system). |
47 * - fp[68] stack_area_base (High end of the memory area to use as | 49 * - fp[64] stack_area_base (High end of the memory area to use as |
48 * backtracking stack). | 50 * backtracking stack). |
49 * - fp[64] capture array size (may fit multiple sets of matches) | 51 * - fp[60] capture array size (may fit multiple sets of matches) |
50 * - fp[60] int* capture_array (int[num_saved_registers_], for output). | |
51 * - fp[44..59] MIPS O32 four argument slots | 52 * - fp[44..59] MIPS O32 four argument slots |
52 * - fp[40] secondary link/return address used by native call. | 53 * - fp[40] int* capture_array (int[num_saved_registers_], for output). |
53 * --- sp when called --- | 54 * --- sp when called --- |
54 * - fp[36] return address (lr). | 55 * - fp[36] return address (lr). |
55 * - fp[32] old frame pointer (r11). | 56 * - fp[32] old frame pointer (r11). |
56 * - fp[0..31] backup of registers s0..s7. | 57 * - fp[0..31] backup of registers s0..s7. |
57 * --- frame pointer ---- | 58 * --- frame pointer ---- |
58 * - fp[-4] end of input (address of end of string). | 59 * - fp[-4] end of input (address of end of string). |
59 * - fp[-8] start of input (address of first character in string). | 60 * - fp[-8] start of input (address of first character in string). |
60 * - fp[-12] start index (character index of start). | 61 * - fp[-12] start index (character index of start). |
61 * - fp[-16] void* input_string (location of a handle containing the string). | 62 * - fp[-16] void* input_string (location of a handle containing the string). |
62 * - fp[-20] success counter (only for global regexps to count matches). | 63 * - fp[-20] success counter (only for global regexps to count matches). |
63 * - fp[-24] Offset of location before start of input (effectively character | 64 * - fp[-24] Offset of location before start of input (effectively character |
64 * string start - 1). Used to initialize capture registers to a | 65 * string start - 1). Used to initialize capture registers to a |
65 * non-position. | 66 * non-position. |
66 * - fp[-28] At start (if 1, we are starting at the start of the | 67 * - fp[-28] At start (if 1, we are starting at the start of the |
67 * string, otherwise 0) | 68 * string, otherwise 0) |
68 * - fp[-32] register 0 (Only positions must be stored in the first | 69 * - fp[-32] register 0 (Only positions must be stored in the first |
69 * - register 1 num_saved_registers_ registers) | 70 * - register 1 num_saved_registers_ registers) |
70 * - ... | 71 * - ... |
71 * - register num_registers-1 | 72 * - register num_registers-1 |
72 * --- sp --- | 73 * --- sp --- |
73 * | 74 * |
74 * | 75 * |
75 * The N64 stack will have the following structure: | 76 * The N64 stack will have the following structure: |
76 * | 77 * |
77 * - fp[88] Isolate* isolate (address of the current isolate)
kIsolate | 78 * - fp[80] Isolate* isolate (address of the current isolate)
kIsolate |
78 * - fp[80] secondary link/return address used by exit frame on native call.
kSecondaryReturnAddress | 79 *
kStackFrameHeader |
79
kStackFrameHeader | |
80 * --- sp when called --- | 80 * --- sp when called --- |
81 * - fp[72] ra Return from RegExp code (ra).
kReturnAddress | 81 * - fp[72] ra Return from RegExp code (ra).
kReturnAddress |
82 * - fp[64] s9, old-fp Old fp, callee saved(s9). | 82 * - fp[64] s9, old-fp Old fp, callee saved(s9). |
83 * - fp[0..63] s0..s7 Callee-saved registers s0..s7. | 83 * - fp[0..63] s0..s7 Callee-saved registers s0..s7. |
84 * --- frame pointer ---- | 84 * --- frame pointer ---- |
85 * - fp[-8] direct_call (1 = direct call from JS, 0 = from runtime)
kDirectCall | 85 * - fp[-8] direct_call (1 = direct call from JS, 0 = from runtime)
kDirectCall |
86 * - fp[-16] stack_base (Top of backtracking stack).
kStackHighEnd | 86 * - fp[-16] stack_base (Top of backtracking stack).
kStackHighEnd |
87 * - fp[-24] capture array size (may fit multiple sets of matches)
kNumOutputRegisters | 87 * - fp[-24] capture array size (may fit multiple sets of matches)
kNumOutputRegisters |
88 * - fp[-32] int* capture_array (int[num_saved_registers_], for output).
kRegisterOutput | 88 * - fp[-32] int* capture_array (int[num_saved_registers_], for output).
kRegisterOutput |
89 * - fp[-40] end of input (address of end of string).
kInputEnd | 89 * - fp[-40] end of input (address of end of string).
kInputEnd |
(...skipping 15 matching lines...) Expand all Loading... |
105 * "character -1" in the string (i.e., char_size() bytes before the first | 105 * "character -1" in the string (i.e., char_size() bytes before the first |
106 * character of the string). The remaining registers start out as garbage. | 106 * character of the string). The remaining registers start out as garbage. |
107 * | 107 * |
108 * The data up to the return address must be placed there by the calling | 108 * The data up to the return address must be placed there by the calling |
109 * code and the remaining arguments are passed in registers, e.g. by calling the | 109 * code and the remaining arguments are passed in registers, e.g. by calling the |
110 * code entry as cast to a function with the signature: | 110 * code entry as cast to a function with the signature: |
111 * int (*match)(String* input_string, | 111 * int (*match)(String* input_string, |
112 * int start_index, | 112 * int start_index, |
113 * Address start, | 113 * Address start, |
114 * Address end, | 114 * Address end, |
115 * Address secondary_return_address, // Only used by native call. | |
116 * int* capture_output_array, | 115 * int* capture_output_array, |
| 116 * int num_capture_registers, |
117 * byte* stack_area_base, | 117 * byte* stack_area_base, |
118 * bool direct_call = false, | 118 * bool direct_call = false, |
119 * void* return_address, | |
120 * Isolate* isolate); | 119 * Isolate* isolate); |
121 * The call is performed by NativeRegExpMacroAssembler::Execute() | 120 * The call is performed by NativeRegExpMacroAssembler::Execute() |
122 * (in regexp-macro-assembler.cc) via the CALL_GENERATED_REGEXP_CODE macro | 121 * (in regexp-macro-assembler.cc) via the CALL_GENERATED_REGEXP_CODE macro |
123 * in mips/simulator-mips.h. | 122 * in mips/simulator-mips.h. |
124 * When calling as a non-direct call (i.e., from C++ code), the return address | 123 * |
125 * area is overwritten with the ra register by the RegExp code. When doing a | 124 * clang-format on |
126 * direct call from generated code, the return address is placed there by | |
127 * the calling code, as in a normal exit frame. | |
128 */ | 125 */ |
129 | 126 |
130 #define __ ACCESS_MASM(masm_) | 127 #define __ ACCESS_MASM(masm_) |
131 | 128 |
132 RegExpMacroAssemblerMIPS::RegExpMacroAssemblerMIPS(Isolate* isolate, Zone* zone, | 129 RegExpMacroAssemblerMIPS::RegExpMacroAssemblerMIPS(Isolate* isolate, Zone* zone, |
133 Mode mode, | 130 Mode mode, |
134 int registers_to_save) | 131 int registers_to_save) |
135 : NativeRegExpMacroAssembler(isolate, zone), | 132 : NativeRegExpMacroAssembler(isolate, zone), |
136 masm_(new MacroAssembler(isolate, NULL, kRegExpCodeSize, | 133 masm_(new MacroAssembler(isolate, NULL, kRegExpCodeSize, |
137 CodeObjectRequired::kYes)), | 134 CodeObjectRequired::kYes)), |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 } | 1325 } |
1329 | 1326 |
1330 #undef __ | 1327 #undef __ |
1331 | 1328 |
1332 #endif // V8_INTERPRETED_REGEXP | 1329 #endif // V8_INTERPRETED_REGEXP |
1333 | 1330 |
1334 } // namespace internal | 1331 } // namespace internal |
1335 } // namespace v8 | 1332 } // namespace v8 |
1336 | 1333 |
1337 #endif // V8_TARGET_ARCH_MIPS64 | 1334 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |