v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
regexp-macro-assembler-mips.h
Go to the documentation of this file.
1 // Copyright 2011 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 
29 #ifndef V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_
30 #define V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_
31 
32 #include "mips/assembler-mips.h"
34 #include "macro-assembler.h"
35 #include "code.h"
37 
38 namespace v8 {
39 namespace internal {
40 
41 #ifndef V8_INTERPRETED_REGEXP
43  public:
44  RegExpMacroAssemblerMIPS(Mode mode, int registers_to_save, Zone* zone);
45  virtual ~RegExpMacroAssemblerMIPS();
46  virtual int stack_limit_slack();
47  virtual void AdvanceCurrentPosition(int by);
48  virtual void AdvanceRegister(int reg, int by);
49  virtual void Backtrack();
50  virtual void Bind(Label* label);
51  virtual void CheckAtStart(Label* on_at_start);
52  virtual void CheckCharacter(uint32_t c, Label* on_equal);
53  virtual void CheckCharacterAfterAnd(uint32_t c,
54  uint32_t mask,
55  Label* on_equal);
56  virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
57  virtual void CheckCharacterLT(uc16 limit, Label* on_less);
58  // A "greedy loop" is a loop that is both greedy and with a simple
59  // body. It has a particularly simple implementation.
60  virtual void CheckGreedyLoop(Label* on_tos_equals_current_position);
61  virtual void CheckNotAtStart(Label* on_not_at_start);
62  virtual void CheckNotBackReference(int start_reg, Label* on_no_match);
63  virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
64  Label* on_no_match);
65  virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal);
66  virtual void CheckNotCharacterAfterAnd(uint32_t c,
67  uint32_t mask,
68  Label* on_not_equal);
69  virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
70  uc16 minus,
71  uc16 mask,
72  Label* on_not_equal);
73  virtual void CheckCharacterInRange(uc16 from,
74  uc16 to,
75  Label* on_in_range);
76  virtual void CheckCharacterNotInRange(uc16 from,
77  uc16 to,
78  Label* on_not_in_range);
79  virtual void CheckBitInTable(Handle<ByteArray> table, Label* on_bit_set);
80 
81  // Checks whether the given offset from the current position is before
82  // the end of the string.
83  virtual void CheckPosition(int cp_offset, Label* on_outside_input);
84  virtual bool CheckSpecialCharacterClass(uc16 type,
85  Label* on_no_match);
86  virtual void Fail();
88  virtual void GoTo(Label* label);
89  virtual void IfRegisterGE(int reg, int comparand, Label* if_ge);
90  virtual void IfRegisterLT(int reg, int comparand, Label* if_lt);
91  virtual void IfRegisterEqPos(int reg, Label* if_eq);
93  virtual void LoadCurrentCharacter(int cp_offset,
94  Label* on_end_of_input,
95  bool check_bounds = true,
96  int characters = 1);
97  virtual void PopCurrentPosition();
98  virtual void PopRegister(int register_index);
99  virtual void PushBacktrack(Label* label);
100  virtual void PushCurrentPosition();
101  virtual void PushRegister(int register_index,
102  StackCheckFlag check_stack_limit);
103  virtual void ReadCurrentPositionFromRegister(int reg);
104  virtual void ReadStackPointerFromRegister(int reg);
105  virtual void SetCurrentPositionFromEnd(int by);
106  virtual void SetRegister(int register_index, int to);
107  virtual bool Succeed();
108  virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
109  virtual void ClearRegisters(int reg_from, int reg_to);
110  virtual void WriteStackPointerToRegister(int reg);
111  virtual bool CanReadUnaligned();
112 
113  // Called from RegExp if the stack-guard is triggered.
114  // If the code object is relocated, the return address is fixed before
115  // returning.
116  static int CheckStackGuardState(Address* return_address,
117  Code* re_code,
118  Address re_frame);
119 
120  private:
121  // Offsets from frame_pointer() of function parameters and stored registers.
122  static const int kFramePointer = 0;
123 
124  // Above the frame pointer - Stored registers and stack passed parameters.
125  // Registers s0 to s7, fp, and ra.
126  static const int kStoredRegisters = kFramePointer;
127  // Return address (stored from link register, read into pc on return).
128  static const int kReturnAddress = kStoredRegisters + 9 * kPointerSize;
129  static const int kSecondaryReturnAddress = kReturnAddress + kPointerSize;
130  // Stack frame header.
131  static const int kStackFrameHeader = kReturnAddress + kPointerSize;
132  // Stack parameters placed by caller.
133  static const int kRegisterOutput = kStackFrameHeader + 20;
134  static const int kNumOutputRegisters = kRegisterOutput + kPointerSize;
135  static const int kStackHighEnd = kNumOutputRegisters + kPointerSize;
136  static const int kDirectCall = kStackHighEnd + kPointerSize;
137  static const int kIsolate = kDirectCall + kPointerSize;
138 
139  // Below the frame pointer.
140  // Register parameters stored by setup code.
141  static const int kInputEnd = kFramePointer - kPointerSize;
142  static const int kInputStart = kInputEnd - kPointerSize;
143  static const int kStartIndex = kInputStart - kPointerSize;
144  static const int kInputString = kStartIndex - kPointerSize;
145  // When adding local variables remember to push space for them in
146  // the frame in GetCode.
147  static const int kSuccessfulCaptures = kInputString - kPointerSize;
148  static const int kInputStartMinusOne = kSuccessfulCaptures - kPointerSize;
149  // First register address. Following registers are below it on the stack.
150  static const int kRegisterZero = kInputStartMinusOne - kPointerSize;
151 
152  // Initial size of code buffer.
153  static const size_t kRegExpCodeSize = 1024;
154 
155  // Load a number of characters at the given offset from the
156  // current position, into the current-character register.
157  void LoadCurrentCharacterUnchecked(int cp_offset, int character_count);
158 
159  // Check whether preemption has been requested.
160  void CheckPreemption();
161 
162  // Check whether we are exceeding the stack limit on the backtrack stack.
163  void CheckStackLimit();
164 
165 
166  // Generate a call to CheckStackGuardState.
167  void CallCheckStackGuardState(Register scratch);
168 
169  // The ebp-relative location of a regexp register.
170  MemOperand register_location(int register_index);
171 
172  // Register holding the current input position as negative offset from
173  // the end of the string.
174  inline Register current_input_offset() { return t2; }
175 
176  // The register containing the current character after LoadCurrentCharacter.
177  inline Register current_character() { return t3; }
178 
179  // Register holding address of the end of the input string.
180  inline Register end_of_input_address() { return t6; }
181 
182  // Register holding the frame address. Local variables, parameters and
183  // regexp registers are addressed relative to this.
184  inline Register frame_pointer() { return fp; }
185 
186  // The register containing the backtrack stack top. Provides a meaningful
187  // name to the register.
188  inline Register backtrack_stackpointer() { return t4; }
189 
190  // Register holding pointer to the current code object.
191  inline Register code_pointer() { return t1; }
192 
193  // Byte size of chars in the string to match (decided by the Mode argument).
194  inline int char_size() { return static_cast<int>(mode_); }
195 
196  // Equivalent to a conditional branch to the label, unless the label
197  // is NULL, in which case it is a conditional Backtrack.
198  void BranchOrBacktrack(Label* to,
199  Condition condition,
200  Register rs,
201  const Operand& rt);
202 
203  // Call and return internally in the generated code in a way that
204  // is GC-safe (i.e., doesn't leave absolute code addresses on the stack)
205  inline void SafeCall(Label* to,
206  Condition cond,
207  Register rs,
208  const Operand& rt);
209  inline void SafeReturn();
210  inline void SafeCallTarget(Label* name);
211 
212  // Pushes the value of a register on the backtrack stack. Decrements the
213  // stack pointer by a word size and stores the register's value there.
214  inline void Push(Register source);
215 
216  // Pops a value from the backtrack stack. Reads the word at the stack pointer
217  // and increments it by a word size.
218  inline void Pop(Register target);
219 
220  Isolate* isolate() const { return masm_->isolate(); }
221 
222  MacroAssembler* masm_;
223 
224  // Which mode to generate code for (ASCII or UC16).
225  Mode mode_;
226 
227  // One greater than maximal register index actually used.
228  int num_registers_;
229 
230  // Number of registers to output at the end (the saved registers
231  // are always 0..num_saved_registers_-1).
232  int num_saved_registers_;
233 
234  // Labels used internally.
235  Label entry_label_;
236  Label start_label_;
237  Label success_label_;
238  Label backtrack_label_;
239  Label exit_label_;
240  Label check_preempt_label_;
241  Label stack_overflow_label_;
242  Label internal_failure_label_;
243 };
244 
245 #endif // V8_INTERPRETED_REGEXP
246 
247 
248 }} // namespace v8::internal
249 
250 #endif // V8_MIPS_REGEXP_MACRO_ASSEMBLER_MIPS_H_
byte * Address
Definition: globals.h:186
Isolate * isolate() const
Definition: assembler.h:62
RegExpMacroAssemblerMIPS(Mode mode, int registers_to_save, Zone *zone)
virtual void AdvanceRegister(int reg, int by)
virtual void CheckCharacter(uint32_t c, Label *on_equal)
virtual void CheckNotCharacterAfterAnd(uint32_t c, uint32_t mask, Label *on_not_equal)
virtual bool CheckSpecialCharacterClass(uc16 type, Label *on_no_match)
virtual void CheckCharacterAfterAnd(uint32_t c, uint32_t mask, Label *on_equal)
virtual void CheckNotAtStart(Label *on_not_at_start)
virtual void ReadCurrentPositionFromRegister(int reg)
virtual void GoTo(Label *label)
virtual void CheckNotBackReference(int start_reg, Label *on_no_match)
virtual void PushBacktrack(Label *label)
virtual void IfRegisterGE(int reg, int comparand, Label *if_ge)
virtual void CheckNotCharacter(uint32_t c, Label *on_not_equal)
virtual void SetCurrentPositionFromEnd(int by)
virtual void CheckNotBackReferenceIgnoreCase(int start_reg, Label *on_no_match)
virtual Handle< HeapObject > GetCode(Handle< String > source)
virtual void CheckAtStart(Label *on_at_start)
virtual void PopRegister(int register_index)
virtual void SetRegister(int register_index, int to)
virtual void IfRegisterLT(int reg, int comparand, Label *if_lt)
virtual void ClearRegisters(int reg_from, int reg_to)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long mode(MIPS only)") DEFINE_string(expose_natives_as
const int kPointerSize
Definition: globals.h:268
virtual void PushRegister(int register_index, StackCheckFlag check_stack_limit)
virtual void CheckCharacterLT(uc16 limit, Label *on_less)
virtual void AdvanceCurrentPosition(int by)
virtual void WriteStackPointerToRegister(int reg)
virtual void IfRegisterEqPos(int reg, Label *if_eq)
virtual void LoadCurrentCharacter(int cp_offset, Label *on_end_of_input, bool check_bounds=true, int characters=1)
virtual IrregexpImplementation Implementation()
static int CheckStackGuardState(Address *return_address, Code *re_code, Address re_frame)
uint16_t uc16
Definition: globals.h:309
virtual void CheckCharacterInRange(uc16 from, uc16 to, Label *on_in_range)
virtual void CheckCharacterNotInRange(uc16 from, uc16 to, Label *on_not_in_range)
virtual void CheckBitInTable(Handle< ByteArray > table, Label *on_bit_set)
virtual void CheckCharacterGT(uc16 limit, Label *on_greater)
virtual void CheckPosition(int cp_offset, Label *on_outside_input)
const Register fp
virtual void WriteCurrentPositionToRegister(int reg, int cp_offset)
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter trace hydrogen to given file name trace inlining decisions trace store elimination trace all use positions trace global value numbering trace hydrogen escape analysis trace the tracking of allocation sites trace map generalization environment for every instruction deoptimize every n garbage collections put a break point before deoptimizing deoptimize uncommon cases use on stack replacement trace array bounds check elimination perform array index dehoisting use load elimination use store elimination use constant folding eliminate unreachable code number of stress runs when picking a function to watch for shared function not JSFunction itself flushes the cache of optimized code for closures on every GC functions with arguments object maximum number of escape analysis fix point iterations allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms concurrent on stack replacement do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes number of stack frames inspected by the profiler percentage of ICs that must have type info to allow optimization extra verbose compilation tracing generate extra emit comments in code disassembly enable use of SSE3 instructions if available enable use of CMOV instruction if available enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long expose natives in global object expose freeBuffer extension expose gc extension under the specified name expose externalize string extension number of stack frames to capture disable builtin natives files print name of functions for which code is generated use random jit cookie to mask large constants trace lazy optimization use adaptive optimizations always try to OSR functions trace optimize function deoptimization minimum length for automatic enable preparsing maximum number of optimization attempts before giving up cache prototype transitions trace debugging JSON request response trace out of bounds accesses to external arrays trace_js_array_abuse automatically set the debug break flag when debugger commands are in the queue abort by crashing maximum length of function source code printed in a stack trace max size of the new max size of the old max size of executable always perform global GCs print one trace line following each garbage collection do not print trace line after scavenger collection print statistics of the maximum memory committed for the heap in name
Definition: flags.cc:505
virtual void CheckGreedyLoop(Label *on_tos_equals_current_position)
virtual void Bind(Label *label)
virtual void CheckNotCharacterAfterMinusAnd(uc16 c, uc16 minus, uc16 mask, Label *on_not_equal)
virtual void ReadStackPointerFromRegister(int reg)