| OLD | NEW |
| (Empty) | |
| 1 #ifndef V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ |
| 2 #define V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ |
| 3 |
| 4 namespace v8 { |
| 5 namespace internal { |
| 6 |
| 7 // FROM arm code |
| 8 |
| 9 #ifndef V8_NATIVE_REGEXP |
| 10 class RegExpMacroAssemblerMIPS: public RegExpMacroAssembler { |
| 11 public: |
| 12 RegExpMacroAssemblerMIPS(); |
| 13 virtual ~RegExpMacroAssemblerMIPS(); |
| 14 }; |
| 15 |
| 16 #else |
| 17 class RegExpMacroAssemblerMIPS: public NativeRegExpMacroAssembler { |
| 18 public: |
| 19 RegExpMacroAssemblerMIPS(Mode mode, int registers_to_save); |
| 20 virtual ~RegExpMacroAssemblerMIPS(); |
| 21 virtual int stack_limit_slack(); |
| 22 virtual void AdvanceCurrentPosition(int by); |
| 23 virtual void AdvanceRegister(int reg, int by); |
| 24 virtual void Backtrack(); |
| 25 virtual void Bind(Label* label); |
| 26 virtual void CheckAtStart(Label* on_at_start); |
| 27 virtual void CheckCharacter(uint32_t c, Label* on_equal); |
| 28 virtual void CheckCharacterAfterAnd(uint32_t c, |
| 29 uint32_t mask, |
| 30 Label* on_equal); |
| 31 virtual void CheckCharacterGT(uc16 limit, Label* on_greater); |
| 32 virtual void CheckCharacterLT(uc16 limit, Label* on_less); |
| 33 virtual void CheckCharacters(Vector<const uc16> str, |
| 34 int cp_offset, |
| 35 Label* on_failure, |
| 36 bool check_end_of_string); |
| 37 // A "greedy loop" is a loop that is both greedy and with a simple |
| 38 // body. It has a particularly simple implementation. |
| 39 virtual void CheckGreedyLoop(Label* on_tos_equals_current_position); |
| 40 virtual void CheckNotAtStart(Label* on_not_at_start); |
| 41 virtual void CheckNotBackReference(int start_reg, Label* on_no_match); |
| 42 virtual void CheckNotBackReferenceIgnoreCase(int start_reg, |
| 43 Label* on_no_match); |
| 44 virtual void CheckNotRegistersEqual(int reg1, int reg2, Label* on_not_equal); |
| 45 virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal); |
| 46 virtual void CheckNotCharacterAfterAnd(uint32_t c, |
| 47 uint32_t mask, |
| 48 Label* on_not_equal); |
| 49 virtual void CheckNotCharacterAfterMinusAnd(uc16 c, |
| 50 uc16 minus, |
| 51 uc16 mask, |
| 52 Label* on_not_equal); |
| 53 // Checks whether the given offset from the current position is before |
| 54 // the end of the string. |
| 55 virtual void CheckPosition(int cp_offset, Label* on_outside_input); |
| 56 virtual bool CheckSpecialCharacterClass(uc16 type, |
| 57 int cp_offset, |
| 58 bool check_offset, |
| 59 Label* on_no_match); |
| 60 virtual void Fail(); |
| 61 virtual Handle<Object> GetCode(Handle<String> source); |
| 62 virtual void GoTo(Label* label); |
| 63 virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); |
| 64 virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); |
| 65 virtual void IfRegisterEqPos(int reg, Label* if_eq); |
| 66 virtual IrregexpImplementation Implementation(); |
| 67 virtual void LoadCurrentCharacter(int cp_offset, |
| 68 Label* on_end_of_input, |
| 69 bool check_bounds = true, |
| 70 int characters = 1); |
| 71 virtual void PopCurrentPosition(); |
| 72 virtual void PopRegister(int register_index); |
| 73 virtual void PushBacktrack(Label* label); |
| 74 virtual void PushCurrentPosition(); |
| 75 virtual void PushRegister(int register_index, |
| 76 StackCheckFlag check_stack_limit); |
| 77 virtual void ReadCurrentPositionFromRegister(int reg); |
| 78 virtual void ReadStackPointerFromRegister(int reg); |
| 79 virtual void SetRegister(int register_index, int to); |
| 80 virtual void Succeed(); |
| 81 virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); |
| 82 virtual void ClearRegisters(int reg_from, int reg_to); |
| 83 virtual void WriteStackPointerToRegister(int reg); |
| 84 |
| 85 // Called from RegExp if the stack-guard is triggered. |
| 86 // If the code object is relocated, the return address is fixed before |
| 87 // returning. |
| 88 static int CheckStackGuardState(Address* return_address, |
| 89 Code* re_code, |
| 90 Address re_frame); |
| 91 private: |
| 92 // Offsets from frame_pointer() of function parameters and stored registers. |
| 93 static const int kFramePointer = 0; |
| 94 |
| 95 // Above the frame pointer - Stored registers and stack passed parameters. |
| 96 // Register 4..11. |
| 97 static const int kStoredRegisters = kFramePointer; |
| 98 // Return address (stored from link register, read into pc on return). |
| 99 static const int kReturnAddress = kStoredRegisters + 8 * kPointerSize; |
| 100 // Stack parameters placed by caller. |
| 101 static const int kRegisterOutput = kReturnAddress + kPointerSize; |
| 102 static const int kAtStart = kRegisterOutput + kPointerSize; |
| 103 static const int kStackHighEnd = kAtStart + kPointerSize; |
| 104 |
| 105 // Below the frame pointer. |
| 106 // Register parameters stored by setup code. |
| 107 static const int kInputEnd = kFramePointer - kPointerSize; |
| 108 static const int kInputStart = kInputEnd - kPointerSize; |
| 109 static const int kStartIndex = kInputStart - kPointerSize; |
| 110 static const int kInputString = kStartIndex - kPointerSize; |
| 111 // When adding local variables remember to push space for them in |
| 112 // the frame in GetCode. |
| 113 static const int kInputStartMinusOne = kInputString - kPointerSize; |
| 114 // First register address. Following registers are below it on the stack. |
| 115 static const int kRegisterZero = kInputStartMinusOne - kPointerSize; |
| 116 |
| 117 // Initial size of code buffer. |
| 118 static const size_t kRegExpCodeSize = 1024; |
| 119 |
| 120 static const int kBacktrackConstantPoolSize = 4; |
| 121 |
| 122 // Load a number of characters at the given offset from the |
| 123 // current position, into the current-character register. |
| 124 void LoadCurrentCharacterUnchecked(int cp_offset, int character_count); |
| 125 |
| 126 // Check whether preemption has been requested. |
| 127 void CheckPreemption(); |
| 128 |
| 129 // Check whether we are exceeding the stack limit on the backtrack stack. |
| 130 void CheckStackLimit(); |
| 131 |
| 132 void EmitBacktrackConstantPool(); |
| 133 int GetBacktrackConstantPoolEntry(); |
| 134 |
| 135 |
| 136 // Generate a call to CheckStackGuardState. |
| 137 void CallCheckStackGuardState(Register scratch); |
| 138 |
| 139 // The ebp-relative location of a regexp register. |
| 140 MemOperand register_location(int register_index); |
| 141 |
| 142 // TODO : return correct register. end of modified lines indicated with _-_-_-_-
_-_-_-_-_-_-_-_-_-_- |
| 143 |
| 144 // Register holding the current input position as negative offset from |
| 145 // the end of the string. |
| 146 // inline Register current_input_offset() { return r6; } |
| 147 inline Register current_input_offset() { return no_reg; } |
| 148 |
| 149 // The register containing the current character after LoadCurrentCharacter. |
| 150 // inline Register current_character() { return r7; } |
| 151 inline Register current_character() { return no_reg; } |
| 152 |
| 153 // Register holding address of the end of the input string. |
| 154 // inline Register end_of_input_address() { return r10; } |
| 155 inline Register end_of_input_address() { return no_reg; } |
| 156 |
| 157 // Register holding the frame address. Local variables, parameters and |
| 158 // regexp registers are addressed relative to this. |
| 159 // inline Register frame_pointer() { return fp; } |
| 160 inline Register frame_pointer() { return no_reg; } |
| 161 |
| 162 // The register containing the backtrack stack top. Provides a meaningful |
| 163 // name to the register. |
| 164 // inline Register backtrack_stackpointer() { return r8; } |
| 165 inline Register backtrack_stackpointer() { return no_reg; } |
| 166 |
| 167 // Register holding pointer to the current code object. |
| 168 // inline Register code_pointer() { return r5; } |
| 169 inline Register code_pointer() { return no_reg; } |
| 170 |
| 171 // Byte size of chars in the string to match (decided by the Mode argument) |
| 172 // inline int char_size() { return static_cast<int>(mode_); } |
| 173 inline int char_size() { return static_cast<int>(mode_); } |
| 174 |
| 175 //_-_-_-_-_-_-_-_-_-_-_-_-_-_- |
| 176 |
| 177 // Equivalent to a conditional branch to the label, unless the label |
| 178 // is NULL, in which case it is a conditional Backtrack. |
| 179 void BranchOrBacktrack(Condition condition, Label* to); |
| 180 |
| 181 // Call and return internally in the generated code in a way that |
| 182 // is GC-safe (i.e., doesn't leave absolute code addresses on the stack) |
| 183 inline void SafeCall(Label* to, Condition cond = cc_always); |
| 184 inline void SafeReturn(); |
| 185 inline void SafeCallTarget(Label* name); |
| 186 |
| 187 // Pushes the value of a register on the backtrack stack. Decrements the |
| 188 // stack pointer by a word size and stores the register's value there. |
| 189 inline void Push(Register source); |
| 190 |
| 191 // Pops a value from the backtrack stack. Reads the word at the stack pointer |
| 192 // and increments it by a word size. |
| 193 inline void Pop(Register target); |
| 194 |
| 195 // Before calling a C-function from generated code, align arguments on stack. |
| 196 // After aligning the frame, non-register arguments must be stored in |
| 197 // sp[0], sp[4], etc., not pushed. The argument count assumes all arguments |
| 198 // are word sized. |
| 199 // Some compilers/platforms require the stack to be aligned when calling |
| 200 // C++ code. |
| 201 // Needs a scratch register to do some arithmetic. This register will be |
| 202 // trashed. |
| 203 inline void FrameAlign(int num_arguments, Register scratch); |
| 204 |
| 205 // Calls a C function and cleans up the space for arguments allocated |
| 206 // by FrameAlign. The called function is not allowed to trigger a garbage |
| 207 // collection. |
| 208 inline void CallCFunction(ExternalReference function, |
| 209 int num_arguments); |
| 210 |
| 211 // Calls a C function and cleans up the frame alignment done by |
| 212 // by FrameAlign. The called function *is* allowed to trigger a garbage |
| 213 // collection, but may not take more than four arguments (no arguments |
| 214 // passed on the stack), and the first argument will be a pointer to the |
| 215 // return address. |
| 216 inline void CallCFunctionUsingStub(ExternalReference function, |
| 217 int num_arguments); |
| 218 |
| 219 |
| 220 MacroAssembler* masm_; |
| 221 |
| 222 // Which mode to generate code for (ASCII or UC16). |
| 223 Mode mode_; |
| 224 |
| 225 // One greater than maximal register index actually used. |
| 226 int num_registers_; |
| 227 |
| 228 // Number of registers to output at the end (the saved registers |
| 229 // are always 0..num_saved_registers_-1) |
| 230 int num_saved_registers_; |
| 231 |
| 232 // Manage a small pre-allocated pool for writing label targets |
| 233 // to for pushing backtrack addresses. |
| 234 int backtrack_constant_pool_offset_; |
| 235 int backtrack_constant_pool_capacity_; |
| 236 |
| 237 // Labels used internally. |
| 238 Label entry_label_; |
| 239 Label start_label_; |
| 240 Label success_label_; |
| 241 Label backtrack_label_; |
| 242 Label exit_label_; |
| 243 Label check_preempt_label_; |
| 244 Label stack_overflow_label_; |
| 245 }; |
| 246 |
| 247 |
| 248 #endif // V8_NATIVE_REGEXP |
| 249 |
| 250 |
| 251 }} // namespace v8::internal |
| 252 |
| 253 #endif // V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_ |
| OLD | NEW |