The data contained in this repository can be downloaded to your computer using one of several clients.
Please see the documentation of your version control software client for more information.

Please select the desired protocol below to get the URL.

This URL has Read-Only access.

Statistics
| Branch: | Revision:

main_repo / deps / v8 / src / arm / regexp-macro-assembler-arm.h @ f230a1cf

History | View | Annotate | Download (10.4 KB)

1
// Copyright 2012 the V8 project authors. All rights reserved.
2
// Redistribution and use in source and binary forms, with or without
3
// modification, are permitted provided that the following conditions are
4
// met:
5
//
6
//     * Redistributions of source code must retain the above copyright
7
//       notice, this list of conditions and the following disclaimer.
8
//     * Redistributions in binary form must reproduce the above
9
//       copyright notice, this list of conditions and the following
10
//       disclaimer in the documentation and/or other materials provided
11
//       with the distribution.
12
//     * Neither the name of Google Inc. nor the names of its
13
//       contributors may be used to endorse or promote products derived
14
//       from this software without specific prior written permission.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27

    
28
#ifndef V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_
29
#define V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_
30

    
31
#include "arm/assembler-arm.h"
32
#include "arm/assembler-arm-inl.h"
33
#include "macro-assembler.h"
34

    
35
namespace v8 {
36
namespace internal {
37

    
38

    
39
#ifndef V8_INTERPRETED_REGEXP
40
class RegExpMacroAssemblerARM: public NativeRegExpMacroAssembler {
41
 public:
42
  RegExpMacroAssemblerARM(Mode mode, int registers_to_save, Zone* zone);
43
  virtual ~RegExpMacroAssemblerARM();
44
  virtual int stack_limit_slack();
45
  virtual void AdvanceCurrentPosition(int by);
46
  virtual void AdvanceRegister(int reg, int by);
47
  virtual void Backtrack();
48
  virtual void Bind(Label* label);
49
  virtual void CheckAtStart(Label* on_at_start);
50
  virtual void CheckCharacter(unsigned c, Label* on_equal);
51
  virtual void CheckCharacterAfterAnd(unsigned c,
52
                                      unsigned mask,
53
                                      Label* on_equal);
54
  virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
55
  virtual void CheckCharacterLT(uc16 limit, Label* on_less);
56
  // A "greedy loop" is a loop that is both greedy and with a simple
57
  // body. It has a particularly simple implementation.
58
  virtual void CheckGreedyLoop(Label* on_tos_equals_current_position);
59
  virtual void CheckNotAtStart(Label* on_not_at_start);
60
  virtual void CheckNotBackReference(int start_reg, Label* on_no_match);
61
  virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
62
                                               Label* on_no_match);
63
  virtual void CheckNotCharacter(unsigned c, Label* on_not_equal);
64
  virtual void CheckNotCharacterAfterAnd(unsigned c,
65
                                         unsigned mask,
66
                                         Label* on_not_equal);
67
  virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
68
                                              uc16 minus,
69
                                              uc16 mask,
70
                                              Label* on_not_equal);
71
  virtual void CheckCharacterInRange(uc16 from,
72
                                     uc16 to,
73
                                     Label* on_in_range);
74
  virtual void CheckCharacterNotInRange(uc16 from,
75
                                        uc16 to,
76
                                        Label* on_not_in_range);
77
  virtual void CheckBitInTable(Handle<ByteArray> table, Label* on_bit_set);
78

    
79
  // Checks whether the given offset from the current position is before
80
  // the end of the string.
81
  virtual void CheckPosition(int cp_offset, Label* on_outside_input);
82
  virtual bool CheckSpecialCharacterClass(uc16 type,
83
                                          Label* on_no_match);
84
  virtual void Fail();
85
  virtual Handle<HeapObject> GetCode(Handle<String> source);
86
  virtual void GoTo(Label* label);
87
  virtual void IfRegisterGE(int reg, int comparand, Label* if_ge);
88
  virtual void IfRegisterLT(int reg, int comparand, Label* if_lt);
89
  virtual void IfRegisterEqPos(int reg, Label* if_eq);
90
  virtual IrregexpImplementation Implementation();
91
  virtual void LoadCurrentCharacter(int cp_offset,
92
                                    Label* on_end_of_input,
93
                                    bool check_bounds = true,
94
                                    int characters = 1);
95
  virtual void PopCurrentPosition();
96
  virtual void PopRegister(int register_index);
97
  virtual void PushBacktrack(Label* label);
98
  virtual void PushCurrentPosition();
99
  virtual void PushRegister(int register_index,
100
                            StackCheckFlag check_stack_limit);
101
  virtual void ReadCurrentPositionFromRegister(int reg);
102
  virtual void ReadStackPointerFromRegister(int reg);
103
  virtual void SetCurrentPositionFromEnd(int by);
104
  virtual void SetRegister(int register_index, int to);
105
  virtual bool Succeed();
106
  virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
107
  virtual void ClearRegisters(int reg_from, int reg_to);
108
  virtual void WriteStackPointerToRegister(int reg);
109
  virtual bool CanReadUnaligned();
110

    
111
  // Called from RegExp if the stack-guard is triggered.
112
  // If the code object is relocated, the return address is fixed before
113
  // returning.
114
  static int CheckStackGuardState(Address* return_address,
115
                                  Code* re_code,
116
                                  Address re_frame);
117

    
118
 private:
119
  // Offsets from frame_pointer() of function parameters and stored registers.
120
  static const int kFramePointer = 0;
121

    
122
  // Above the frame pointer - Stored registers and stack passed parameters.
123
  // Register 4..11.
124
  static const int kStoredRegisters = kFramePointer;
125
  // Return address (stored from link register, read into pc on return).
126
  static const int kReturnAddress = kStoredRegisters + 8 * kPointerSize;
127
  static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize;
128
  // Stack parameters placed by caller.
129
  static const int kRegisterOutput = kSecondaryReturnAddress + kPointerSize;
130
  static const int kNumOutputRegisters = kRegisterOutput + kPointerSize;
131
  static const int kStackHighEnd = kNumOutputRegisters + kPointerSize;
132
  static const int kDirectCall = kStackHighEnd + kPointerSize;
133
  static const int kIsolate = kDirectCall + kPointerSize;
134

    
135
  // Below the frame pointer.
136
  // Register parameters stored by setup code.
137
  static const int kInputEnd = kFramePointer - kPointerSize;
138
  static const int kInputStart = kInputEnd - kPointerSize;
139
  static const int kStartIndex = kInputStart - kPointerSize;
140
  static const int kInputString = kStartIndex - kPointerSize;
141
  // When adding local variables remember to push space for them in
142
  // the frame in GetCode.
143
  static const int kSuccessfulCaptures = kInputString - kPointerSize;
144
  static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize;
145
  // First register address. Following registers are below it on the stack.
146
  static const int kRegisterZero = kInputStartMinusOne - kPointerSize;
147

    
148
  // Initial size of code buffer.
149
  static const size_t kRegExpCodeSize = 1024;
150

    
151
  static const int kBacktrackConstantPoolSize = 4;
152

    
153
  // Load a number of characters at the given offset from the
154
  // current position, into the current-character register.
155
  void LoadCurrentCharacterUnchecked(int cp_offset, int character_count);
156

    
157
  // Check whether preemption has been requested.
158
  void CheckPreemption();
159

    
160
  // Check whether we are exceeding the stack limit on the backtrack stack.
161
  void CheckStackLimit();
162

    
163

    
164
  // Generate a call to CheckStackGuardState.
165
  void CallCheckStackGuardState(Register scratch);
166

    
167
  // The ebp-relative location of a regexp register.
168
  MemOperand register_location(int register_index);
169

    
170
  // Register holding the current input position as negative offset from
171
  // the end of the string.
172
  inline Register current_input_offset() { return r6; }
173

    
174
  // The register containing the current character after LoadCurrentCharacter.
175
  inline Register current_character() { return r7; }
176

    
177
  // Register holding address of the end of the input string.
178
  inline Register end_of_input_address() { return r10; }
179

    
180
  // Register holding the frame address. Local variables, parameters and
181
  // regexp registers are addressed relative to this.
182
  inline Register frame_pointer() { return fp; }
183

    
184
  // The register containing the backtrack stack top. Provides a meaningful
185
  // name to the register.
186
  inline Register backtrack_stackpointer() { return r8; }
187

    
188
  // Register holding pointer to the current code object.
189
  inline Register code_pointer() { return r5; }
190

    
191
  // Byte size of chars in the string to match (decided by the Mode argument)
192
  inline int char_size() { return static_cast<int>(mode_); }
193

    
194
  // Equivalent to a conditional branch to the label, unless the label
195
  // is NULL, in which case it is a conditional Backtrack.
196
  void BranchOrBacktrack(Condition condition, Label* to);
197

    
198
  // Call and return internally in the generated code in a way that
199
  // is GC-safe (i.e., doesn't leave absolute code addresses on the stack)
200
  inline void SafeCall(Label* to, Condition cond = al);
201
  inline void SafeReturn();
202
  inline void SafeCallTarget(Label* name);
203

    
204
  // Pushes the value of a register on the backtrack stack. Decrements the
205
  // stack pointer by a word size and stores the register's value there.
206
  inline void Push(Register source);
207

    
208
  // Pops a value from the backtrack stack. Reads the word at the stack pointer
209
  // and increments it by a word size.
210
  inline void Pop(Register target);
211

    
212
  Isolate* isolate() const { return masm_->isolate(); }
213

    
214
  MacroAssembler* masm_;
215

    
216
  // Which mode to generate code for (ASCII or UC16).
217
  Mode mode_;
218

    
219
  // One greater than maximal register index actually used.
220
  int num_registers_;
221

    
222
  // Number of registers to output at the end (the saved registers
223
  // are always 0..num_saved_registers_-1)
224
  int num_saved_registers_;
225

    
226
  // Labels used internally.
227
  Label entry_label_;
228
  Label start_label_;
229
  Label success_label_;
230
  Label backtrack_label_;
231
  Label exit_label_;
232
  Label check_preempt_label_;
233
  Label stack_overflow_label_;
234
};
235

    
236
#endif  // V8_INTERPRETED_REGEXP
237

    
238

    
239
}}  // namespace v8::internal
240

    
241
#endif  // V8_ARM_REGEXP_MACRO_ASSEMBLER_ARM_H_