| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2008 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 REGEXP_MACRO_ASSEMBLER_IA32_H_ |
| 29 #define REGEXP_MACRO_ASSEMBLER_IA32_H_ |
| 30 |
| 31 #include "regexp-macro-assembler.h" |
| 32 #include "macro-assembler-ia32.h" |
| 33 |
| 34 namespace v8 { namespace internal { |
| 35 |
| 36 template <typename SubjectChar> |
| 37 class RegExpMacroAssemblerIA32: public RegExpMacroAssembler<SubjectChar> { |
| 38 public: |
| 39 RegExpMacroAssemblerIA32() { } |
| 40 virtual ~RegExpMacroAssembler(); |
| 41 void Initialize(int num_registers, bool ignore_case); |
| 42 virtual void AdvanceCurrentPosition(int by); // Signed cp change. |
| 43 virtual void AdvanceRegister(int reg, int by); // r[reg] += by. |
| 44 virtual void Backtrack(); |
| 45 virtual void Bind(Label* label); |
| 46 |
| 47 // Check the current character against a bitmap. The range of the current |
| 48 // character must be from start to start + length_of_bitmap_in_bits. |
| 49 // Where to go if the bit is 0. Fall through on 1. |
| 50 virtual void CheckBitmap( |
| 51 uc16 start, // The bitmap is indexed from this character. |
| 52 Label* bitmap, // Where the bitmap is emitted. |
| 53 Label* on_zero); |
| 54 |
| 55 |
| 56 // Looks at the next character from the subject and if it doesn't match |
| 57 // then goto the on_failure label. End of input never matches. If the |
| 58 // label is NULL then we should pop a backtrack address off the stack and |
| 59 // go to that. |
| 60 virtual void CheckCharacterClass( |
| 61 RegExpCharacterClass* cclass, |
| 62 Label* on_failure); |
| 63 |
| 64 // Check the current character for a match with a literal string. If we |
| 65 // fail to match then goto the on_failure label. End of input always |
| 66 // matches. If the label is NULL then we should pop a backtrack address off |
| 67 // the stack and go to that. |
| 68 virtual void CheckCharacters( |
| 69 Vector<uc16> str, |
| 70 Label* on_failure); |
| 71 |
| 72 // Check the current input position against a register. If the register is |
| 73 // equal to the current position then go to the label. If the label is NULL |
| 74 // then backtrack instead. |
| 75 virtual void CheckCurrentPosition( |
| 76 int register_index, |
| 77 Label* on_equal); |
| 78 |
| 79 // Dispatch after looking the current character up in a byte map. The |
| 80 // destinations vector has up to 256 labels. |
| 81 virtual void DispatchByteMap( |
| 82 uc16 start, |
| 83 Label* byte_map, |
| 84 Vector<Label*>& destinations); |
| 85 |
| 86 // Dispatch after looking the current character up in a 2-bits-per-entry |
| 87 // map. The destinations vector has up to 4 labels. |
| 88 virtual void DispatchHalfNibbleMap( |
| 89 uc16 start, |
| 90 Label* half_nibble_map, |
| 91 Vector<Label*>& destinations); |
| 92 |
| 93 // Dispatch after looking the high byte of the current character up in a byte |
| 94 // map. The destinations vector has up to 256 labels. |
| 95 virtual void DispatchHighByteMap( |
| 96 byte start, |
| 97 Label* byte_map, |
| 98 Vector<Label*>& destinations); |
| 99 |
| 100 virtual void EmitOrLink(Label* label); |
| 101 |
| 102 virtual void Fail(); |
| 103 |
| 104 virtual Handle<Object> GetCode(); |
| 105 |
| 106 virtual void GoTo(Label* label); |
| 107 |
| 108 // Check whether a register is >= a given constant and go to a label if it |
| 109 // is. Backtracks instead if the label is NULL. |
| 110 virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); |
| 111 |
| 112 // Check whether a register is < a given constant and go to a label if it is. |
| 113 // Backtracks instead if the label is NULL. |
| 114 virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); |
| 115 |
| 116 virtual Re2kImplementation Implementation(); |
| 117 |
| 118 virtual void PopCurrentPosition(); |
| 119 virtual void PopRegister(int register_index); |
| 120 virtual void PushBacktrack(Label* label); |
| 121 virtual void PushCurrentPosition(); |
| 122 virtual void PushRegister(int register_index); |
| 123 virtual void SetRegister(int register_index, int to); |
| 124 virtual void Succeed(); |
| 125 virtual void WriteCurrentPositionToRegister(int reg); |
| 126 private: |
| 127 Operand register_location(int register_index); |
| 128 bool ignore_case(); |
| 129 // Generate code to perform case-canonicalization on the register. |
| 130 void BranchOrBacktrack(Condition condition, Label* to); |
| 131 void Canonicalize(Register register); |
| 132 void Exit(bool success); |
| 133 // Read a character from input at the given offset from the current |
| 134 // position. |
| 135 void ReadChar(Register destination, int offset); |
| 136 // Read the current character into the destination register. |
| 137 void ReadCurrentChar(Register destination); |
| 138 |
| 139 static const int kRegExpConstantsSize = 256; |
| 140 static const int kMaxInlineStringTests = 8; |
| 141 static const uint32_t kEndOfInput = ~0; |
| 142 |
| 143 MacroAssembler* masm_; |
| 144 ByteArrayProvider constants_; |
| 145 int num_registers_; |
| 146 bool ignore_case_; |
| 147 }; |
| 148 |
| 149 }} |
| 150 |
| 151 #endif /* REGEXP_MACRO_ASSEMBLER_IA32_H_ */ |
| OLD | NEW |