| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_REGEXP_MACRO_ASSEMBLER_H_ | 28 #ifndef V8_REGEXP_MACRO_ASSEMBLER_H_ |
| 29 #define V8_REGEXP_MACRO_ASSEMBLER_H_ | 29 #define V8_REGEXP_MACRO_ASSEMBLER_H_ |
| 30 | 30 |
| 31 namespace v8 { namespace internal { | 31 namespace v8 { namespace internal { |
| 32 | 32 |
| 33 | |
| 34 struct DisjunctDecisionRow { | 33 struct DisjunctDecisionRow { |
| 35 RegExpCharacterClass cc; | 34 RegExpCharacterClass cc; |
| 36 Label* on_match; | 35 Label* on_match; |
| 37 }; | 36 }; |
| 38 | 37 |
| 39 | 38 |
| 40 class RegExpMacroAssembler { | 39 class RegExpMacroAssembler { |
| 41 public: | 40 public: |
| 42 enum IrregexpImplementation { | 41 enum IrregexpImplementation { |
| 43 kIA32Implementation, | 42 kIA32Implementation, |
| 44 kARMImplementation, | 43 kARMImplementation, |
| 45 kBytecodeImplementation}; | 44 kBytecodeImplementation |
| 45 }; |
| 46 |
| 47 enum StackCheckFlag { |
| 48 kNoStackLimitCheck = false, |
| 49 kCheckStackLimit = true |
| 50 }; |
| 46 | 51 |
| 47 RegExpMacroAssembler(); | 52 RegExpMacroAssembler(); |
| 48 virtual ~RegExpMacroAssembler(); | 53 virtual ~RegExpMacroAssembler(); |
| 54 // The maximal number of pushes between stack checks. Users must supply |
| 55 // kCheckStackLimit flag to push operations (instead of kNoStackLimitCheck) |
| 56 // at least once for every stack_limit() pushes that are executed. |
| 57 virtual int stack_limit_slack() = 0; |
| 49 virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change. | 58 virtual void AdvanceCurrentPosition(int by) = 0; // Signed cp change. |
| 50 virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by. | 59 virtual void AdvanceRegister(int reg, int by) = 0; // r[reg] += by. |
| 60 // Continues execution from the position pushed on the top of the backtrack |
| 61 // stack by an earlier PushBacktrack(Label*). |
| 51 virtual void Backtrack() = 0; | 62 virtual void Backtrack() = 0; |
| 52 virtual void Bind(Label* label) = 0; | 63 virtual void Bind(Label* label) = 0; |
| 53 // Check the current character against a bitmap. The range of the current | 64 // Check the current character against a bitmap. The range of the current |
| 54 // character must be from start to start + length_of_bitmap_in_bits. | 65 // character must be from start to start + length_of_bitmap_in_bits. |
| 55 virtual void CheckBitmap( | 66 virtual void CheckBitmap( |
| 56 uc16 start, // The bitmap is indexed from this character. | 67 uc16 start, // The bitmap is indexed from this character. |
| 57 Label* bitmap, // Where the bitmap is emitted. | 68 Label* bitmap, // Where the bitmap is emitted. |
| 58 Label* on_zero) = 0; // Where to go if the bit is 0. Fall through on 1. | 69 Label* on_zero) = 0; // Where to go if the bit is 0. Fall through on 1. |
| 59 // Dispatch after looking the current character up in a 2-bits-per-entry | 70 // Dispatch after looking the current character up in a 2-bits-per-entry |
| 60 // map. The destinations vector has up to 4 labels. | 71 // map. The destinations vector has up to 4 labels. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 virtual void EmitOrLink(Label* label) = 0; | 139 virtual void EmitOrLink(Label* label) = 0; |
| 129 virtual void Fail() = 0; | 140 virtual void Fail() = 0; |
| 130 virtual Handle<Object> GetCode(Handle<String> source) = 0; | 141 virtual Handle<Object> GetCode(Handle<String> source) = 0; |
| 131 virtual void GoTo(Label* label) = 0; | 142 virtual void GoTo(Label* label) = 0; |
| 132 // Check whether a register is >= a given constant and go to a label if it | 143 // Check whether a register is >= a given constant and go to a label if it |
| 133 // is. Backtracks instead if the label is NULL. | 144 // is. Backtracks instead if the label is NULL. |
| 134 virtual void IfRegisterGE(int reg, int comparand, Label* if_ge) = 0; | 145 virtual void IfRegisterGE(int reg, int comparand, Label* if_ge) = 0; |
| 135 // Check whether a register is < a given constant and go to a label if it is. | 146 // Check whether a register is < a given constant and go to a label if it is. |
| 136 // Backtracks instead if the label is NULL. | 147 // Backtracks instead if the label is NULL. |
| 137 virtual void IfRegisterLT(int reg, int comparand, Label* if_lt) = 0; | 148 virtual void IfRegisterLT(int reg, int comparand, Label* if_lt) = 0; |
| 149 // Check whether a register is == to the current position and go to a |
| 150 // label if it is. |
| 151 virtual void IfRegisterEqPos(int reg, Label* if_eq) = 0; |
| 138 virtual IrregexpImplementation Implementation() = 0; | 152 virtual IrregexpImplementation Implementation() = 0; |
| 139 virtual void LoadCurrentCharacter(int cp_offset, | 153 virtual void LoadCurrentCharacter(int cp_offset, |
| 140 Label* on_end_of_input, | 154 Label* on_end_of_input, |
| 141 bool check_bounds = true, | 155 bool check_bounds = true, |
| 142 int characters = 1) = 0; | 156 int characters = 1) = 0; |
| 143 virtual void PopCurrentPosition() = 0; | 157 virtual void PopCurrentPosition() = 0; |
| 144 virtual void PopRegister(int register_index) = 0; | 158 virtual void PopRegister(int register_index) = 0; |
| 159 // Pushes the label on the backtrack stack, so that a following Backtrack |
| 160 // will go to this label. Always checks the backtrack stack limit. |
| 145 virtual void PushBacktrack(Label* label) = 0; | 161 virtual void PushBacktrack(Label* label) = 0; |
| 146 virtual void PushCurrentPosition() = 0; | 162 virtual void PushCurrentPosition() = 0; |
| 147 virtual void PushRegister(int register_index) = 0; | 163 virtual void PushRegister(int register_index, |
| 164 StackCheckFlag check_stack_limit) = 0; |
| 148 virtual void ReadCurrentPositionFromRegister(int reg) = 0; | 165 virtual void ReadCurrentPositionFromRegister(int reg) = 0; |
| 149 virtual void ReadStackPointerFromRegister(int reg) = 0; | 166 virtual void ReadStackPointerFromRegister(int reg) = 0; |
| 150 virtual void SetRegister(int register_index, int to) = 0; | 167 virtual void SetRegister(int register_index, int to) = 0; |
| 151 virtual void Succeed() = 0; | 168 virtual void Succeed() = 0; |
| 152 virtual void WriteCurrentPositionToRegister(int reg, int cp_offset) = 0; | 169 virtual void WriteCurrentPositionToRegister(int reg, int cp_offset) = 0; |
| 170 virtual void ClearRegister(int reg) = 0; |
| 153 virtual void WriteStackPointerToRegister(int reg) = 0; | 171 virtual void WriteStackPointerToRegister(int reg) = 0; |
| 154 | 172 |
| 155 private: | 173 private: |
| 156 }; | 174 }; |
| 157 | 175 |
| 158 | 176 |
| 159 struct ArraySlice { | 177 struct ArraySlice { |
| 160 public: | 178 public: |
| 161 ArraySlice(Handle<ByteArray> array, size_t offset) | 179 ArraySlice(Handle<ByteArray> array, size_t offset) |
| 162 : array_(array), offset_(offset) {} | 180 : array_(array), offset_(offset) {} |
| (...skipping 29 matching lines...) Expand all Loading... |
| 192 ArraySlice GetBuffer(Vector<T> values); | 210 ArraySlice GetBuffer(Vector<T> values); |
| 193 private: | 211 private: |
| 194 size_t byte_array_size_; | 212 size_t byte_array_size_; |
| 195 Handle<ByteArray> current_byte_array_; | 213 Handle<ByteArray> current_byte_array_; |
| 196 int current_byte_array_free_offset_; | 214 int current_byte_array_free_offset_; |
| 197 }; | 215 }; |
| 198 | 216 |
| 199 } } // namespace v8::internal | 217 } } // namespace v8::internal |
| 200 | 218 |
| 201 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ | 219 #endif // V8_REGEXP_MACRO_ASSEMBLER_H_ |
| OLD | NEW |