Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 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 V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_ |
| 29 | #define V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_ |
| 30 | |
| 31 | namespace v8 { |
| 32 | namespace internal { |
| 33 | |
| 34 | // Decorator on a RegExpMacroAssembler that write all calls. |
| 35 | class RegExpMacroAssemblerTracer: public RegExpMacroAssembler { |
| 36 | public: |
| 37 | explicit RegExpMacroAssemblerTracer(RegExpMacroAssembler* assembler); |
| 38 | virtual ~RegExpMacroAssemblerTracer(); |
| 39 | virtual int stack_limit_slack() { return assembler_->stack_limit_slack(); } |
| 40 | virtual bool CanReadUnaligned() { return assembler_->CanReadUnaligned(); } |
| 41 | virtual void AdvanceCurrentPosition(int by); // Signed cp change. |
| 42 | virtual void AdvanceRegister(int reg, int by); // r[reg] += by. |
| 43 | virtual void Backtrack(); |
| 44 | virtual void Bind(Label* label); |
| 45 | virtual void CheckAtStart(Label* on_at_start); |
| 46 | virtual void CheckCharacter(uint32_t c, Label* on_equal); |
| 47 | virtual void CheckCharacterAfterAnd(uint32_t c, |
| 48 | uint32_t and_with, |
| 49 | Label* on_equal); |
| 50 | virtual void CheckCharacterGT(uc16 limit, Label* on_greater); |
| 51 | virtual void CheckCharacterLT(uc16 limit, Label* on_less); |
| 52 | virtual void CheckCharacters( |
| 53 | Vector<const uc16> str, |
| 54 | int cp_offset, |
| 55 | Label* on_failure, |
| 56 | bool check_end_of_string); |
| 57 | virtual void CheckGreedyLoop(Label* on_tos_equals_current_position); |
| 58 | virtual void CheckNotAtStart(Label* on_not_at_start); |
| 59 | virtual void CheckNotBackReference(int start_reg, Label* on_no_match); |
| 60 | virtual void CheckNotBackReferenceIgnoreCase(int start_reg, |
| 61 | Label* on_no_match); |
| 62 | virtual void CheckNotRegistersEqual(int reg1, int reg2, Label* on_not_equal); |
| 63 | virtual void CheckNotCharacter(uint32_t c, Label* on_not_equal); |
| 64 | virtual void CheckNotCharacterAfterAnd(uint32_t c, |
| 65 | uint32_t and_with, |
| 66 | Label* on_not_equal); |
| 67 | virtual void CheckNotCharacterAfterMinusAnd(uc16 c, |
| 68 | uc16 minus, |
| 69 | uc16 and_with, |
| 70 | Label* on_not_equal); |
| 71 | virtual bool CheckSpecialCharacterClass(uc16 type, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 72 | Label* on_no_match); |
| 73 | virtual void Fail(); |
| 74 | virtual Handle<Object> GetCode(Handle<String> source); |
| 75 | virtual void GoTo(Label* label); |
| 76 | virtual void IfRegisterGE(int reg, int comparand, Label* if_ge); |
| 77 | virtual void IfRegisterLT(int reg, int comparand, Label* if_lt); |
| 78 | virtual void IfRegisterEqPos(int reg, Label* if_eq); |
| 79 | virtual IrregexpImplementation Implementation(); |
| 80 | virtual void LoadCurrentCharacter(int cp_offset, |
| 81 | Label* on_end_of_input, |
| 82 | bool check_bounds = true, |
| 83 | int characters = 1); |
| 84 | virtual void PopCurrentPosition(); |
| 85 | virtual void PopRegister(int register_index); |
| 86 | virtual void PushBacktrack(Label* label); |
| 87 | virtual void PushCurrentPosition(); |
| 88 | virtual void PushRegister(int register_index, |
| 89 | StackCheckFlag check_stack_limit); |
| 90 | virtual void ReadCurrentPositionFromRegister(int reg); |
| 91 | virtual void ReadStackPointerFromRegister(int reg); |
| 92 | virtual void SetRegister(int register_index, int to); |
| 93 | virtual void Succeed(); |
| 94 | virtual void WriteCurrentPositionToRegister(int reg, int cp_offset); |
| 95 | virtual void ClearRegisters(int reg_from, int reg_to); |
| 96 | virtual void WriteStackPointerToRegister(int reg); |
| 97 | private: |
| 98 | RegExpMacroAssembler* assembler_; |
| 99 | }; |
| 100 | |
| 101 | }} // namespace v8::internal |
| 102 | |
| 103 | #endif // V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_ |