1a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Copyright 2008 the V8 project authors. All rights reserved.
2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without
3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are
4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met:
5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions of source code must retain the above copyright
7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       notice, this list of conditions and the following disclaimer.
8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Redistributions in binary form must reproduce the above
9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       copyright notice, this list of conditions and the following
10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       disclaimer in the documentation and/or other materials provided
11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       with the distribution.
12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//     * Neither the name of Google Inc. nor the names of its
13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       contributors may be used to endorse or promote products derived
14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//       from this software without specific prior written permission.
15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block//
16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifndef V8_REGEXP_MACRO_ASSEMBLER_H_
29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define V8_REGEXP_MACRO_ASSEMBLER_H_
30a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
31a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 {
32a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal {
33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstruct DisjunctDecisionRow {
35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  RegExpCharacterClass cc;
36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  Label* on_match;
37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass RegExpMacroAssembler {
41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // The implementation must be able to handle at least:
43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kMaxRegister = (1 << 16) - 1;
44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kMaxCPOffset = (1 << 15) - 1;
45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const int kMinCPOffset = -(1 << 15);
46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  enum IrregexpImplementation {
47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    kIA32Implementation,
48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    kARMImplementation,
49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    kX64Implementation,
50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    kBytecodeImplementation
51a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
52a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
53a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  enum StackCheckFlag {
54a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    kNoStackLimitCheck = false,
55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    kCheckStackLimit = true
56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  };
57a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  RegExpMacroAssembler();
59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual ~RegExpMacroAssembler();
60a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // The maximal number of pushes between stack checks. Users must supply
61a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck)
62a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // at least once for every stack_limit() pushes that are executed.
63a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual int stack_limit_slack() = 0;
64a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual bool CanReadUnaligned();
65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void AdvanceCurrentPosition(int by) = 0;  // Signed cp change.
66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void AdvanceRegister(int reg, int by) = 0;  // r[reg] += by.
67a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Continues execution from the position pushed on the top of the backtrack
68a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // stack by an earlier PushBacktrack(Label*).
69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void Backtrack() = 0;
70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void Bind(Label* label) = 0;
71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckAtStart(Label* on_at_start) = 0;
72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Dispatch after looking the current character up in a 2-bits-per-entry
73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // map.  The destinations vector has up to 4 labels.
74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckCharacter(uint32_t c, Label* on_equal) = 0;
75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Bitwise and the current character with the given constant and then
76a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // check for a match with c.
77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckCharacterAfterAnd(uint32_t c,
78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                      uint32_t and_with,
79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                      Label* on_equal) = 0;
80a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckCharacterGT(uc16 limit, Label* on_greater) = 0;
81a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckCharacterLT(uc16 limit, Label* on_less) = 0;
82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check the current character for a match with a literal string.  If we
83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // fail to match then goto the on_failure label.  If check_eos is set then
84a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // the end of input always fails.  If check_eos is clear then it is the
85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // caller's responsibility to ensure that the end of string is not hit.
86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // If the label is NULL then we should pop a backtrack address off
87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // the stack and go to that.
88a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckCharacters(
89a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      Vector<const uc16> str,
90a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      int cp_offset,
91a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      Label* on_failure,
92a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block      bool check_eos) = 0;
93a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckGreedyLoop(Label* on_tos_equals_current_position) = 0;
94a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckNotAtStart(Label* on_not_at_start) = 0;
95a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckNotBackReference(int start_reg, Label* on_no_match) = 0;
96a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
97a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                               Label* on_no_match) = 0;
98a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check the current character for a match with a literal character.  If we
99a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // fail to match then goto the on_failure label.  End of input always
100a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // matches.  If the label is NULL then we should pop a backtrack address off
101a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // the stack and go to that.
102a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal) = 0;
103a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckNotCharacterAfterAnd(uint32_t c,
104a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                         uint32_t and_with,
105a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                         Label* on_not_equal) = 0;
106a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Subtract a constant from the current character, then or with the given
107a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // constant and then check for a match with c.
108a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
109a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                              uc16 minus,
110a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                              uc16 and_with,
111a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                              Label* on_not_equal) = 0;
112a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckNotRegistersEqual(int reg1,
113a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                      int reg2,
114a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                      Label* on_not_equal) = 0;
115a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
116a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Checks whether the given offset from the current position is before
117a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // the end of the string.  May overwrite the current character.
118a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void CheckPosition(int cp_offset, Label* on_outside_input) {
119a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    LoadCurrentCharacter(cp_offset, on_outside_input, true);
120a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
121a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check whether a standard/default character class matches the current
122a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // character. Returns false if the type of special character class does
123a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // not have custom support.
124a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // May clobber the current loaded character.
125a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual bool CheckSpecialCharacterClass(uc16 type,
126a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                          Label* on_no_match) {
127a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block    return false;
128a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  }
129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void Fail() = 0;
130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual Handle<Object> GetCode(Handle<String> source) = 0;
131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void GoTo(Label* label) = 0;
132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check whether a register is >= a given constant and go to a label if it
133a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // is.  Backtracks instead if the label is NULL.
134a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void IfRegisterGE(int reg, int comparand, Label* if_ge) = 0;
135a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check whether a register is < a given constant and go to a label if it is.
136a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Backtracks instead if the label is NULL.
137a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void IfRegisterLT(int reg, int comparand, Label* if_lt) = 0;
138a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Check whether a register is == to the current position and go to a
139a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // label if it is.
140a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void IfRegisterEqPos(int reg, Label* if_eq) = 0;
141a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual IrregexpImplementation Implementation() = 0;
142a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void LoadCurrentCharacter(int cp_offset,
143a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                    Label* on_end_of_input,
144a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                    bool check_bounds = true,
145a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                    int characters = 1) = 0;
146a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void PopCurrentPosition() = 0;
147a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void PopRegister(int register_index) = 0;
148a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Pushes the label on the backtrack stack, so that a following Backtrack
149a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // will go to this label. Always checks the backtrack stack limit.
150a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void PushBacktrack(Label* label) = 0;
151a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void PushCurrentPosition() = 0;
152a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void PushRegister(int register_index,
153a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                            StackCheckFlag check_stack_limit) = 0;
154a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void ReadCurrentPositionFromRegister(int reg) = 0;
155a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void ReadStackPointerFromRegister(int reg) = 0;
156a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void SetRegister(int register_index, int to) = 0;
157a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void Succeed() = 0;
158a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void WriteCurrentPositionToRegister(int reg, int cp_offset) = 0;
159a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void ClearRegisters(int reg_from, int reg_to) = 0;
160a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual void WriteStackPointerToRegister(int reg) = 0;
161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
162a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
163a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
164a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef V8_NATIVE_REGEXP  // Avoid compiling unused code.
165a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
166a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockclass NativeRegExpMacroAssembler: public RegExpMacroAssembler {
167a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block public:
168a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Type of input string to generate code for.
169a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  enum Mode { ASCII = 1, UC16 = 2 };
170a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
171a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Result of calling generated native RegExp code.
172a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // RETRY: Something significant changed during execution, and the matching
173a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //        should be retried from scratch.
174a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // EXCEPTION: Something failed during execution. If no exception has been
175a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //        thrown, it's an internal out-of-memory, and the caller should
176a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //        throw the exception.
177a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // FAILURE: Matching failed.
178a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // SUCCESS: Matching succeeded, and the output array has been filled with
179a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  //        capture positions.
180a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  enum Result { RETRY = -2, EXCEPTION = -1, FAILURE = 0, SUCCESS = 1 };
181a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
182a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  NativeRegExpMacroAssembler();
183a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual ~NativeRegExpMacroAssembler();
184a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  virtual bool CanReadUnaligned();
185a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
186a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Result Match(Handle<Code> regexp,
187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                      Handle<String> subject,
188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                      int* offsets_vector,
189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                      int offsets_vector_length,
190a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                      int previous_index);
191a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
192a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Compares two-byte strings case insensitively.
193a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Called from generated RegExp code.
194a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static int CaseInsensitiveCompareUC16(Address byte_offset1,
195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                        Address byte_offset2,
196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                                        size_t byte_length);
197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Called from RegExp if the backtrack stack limit is hit.
199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // Tries to expand the stack. Returns the new stack-pointer if
200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // successful, and updates the stack_top address, or returns 0 if unable
201a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // to grow the stack.
202a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  // This function must not trigger a garbage collection.
203a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Address GrowStack(Address stack_pointer, Address* stack_top);
204a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
205a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static const byte* StringCharacterPosition(String* subject, int start_index);
206a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
207e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  // Byte map of ASCII characters with a 0xff if the character is a word
208e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  // character (digit, letter or underscore) and 0x00 otherwise.
209e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  // Used by generated RegExp code.
210e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  static byte word_character_map[128];
211e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke
212e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  static Address word_character_map_address() {
213e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke    return &word_character_map[0];
214e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke  }
215e46be819fca9468a0cd4e74859ce0f778eb8ca60Leon Clarke
216a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block  static Result Execute(Code* code,
217a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                        String* input,
218a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                        int start_offset,
219a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                        const byte* input_start,
220a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block                        const byte* input_end,
221d91b9f7d46489a9ee00f9cb415630299c76a502bLeon Clarke                        int* output);
222a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block};
223a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
224a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_NATIVE_REGEXP
225a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
226a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} }  // namespace v8::internal
227a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block
228a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif  // V8_REGEXP_MACRO_ASSEMBLER_H_
229