852fb80417ba91fb49098dfb14aabc1e3a7dc5d5
[platform/framework/web/crosswalk.git] / src / v8 / src / regexp-macro-assembler-tracer.h
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(unsigned c, Label* on_equal);
47   virtual void CheckCharacterAfterAnd(unsigned c,
48                                       unsigned 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 CheckGreedyLoop(Label* on_tos_equals_current_position);
53   virtual void CheckNotAtStart(Label* on_not_at_start);
54   virtual void CheckNotBackReference(int start_reg, Label* on_no_match);
55   virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
56                                                Label* on_no_match);
57   virtual void CheckNotCharacter(unsigned c, Label* on_not_equal);
58   virtual void CheckNotCharacterAfterAnd(unsigned c,
59                                          unsigned and_with,
60                                          Label* on_not_equal);
61   virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
62                                               uc16 minus,
63                                               uc16 and_with,
64                                               Label* on_not_equal);
65   virtual void CheckCharacterInRange(uc16 from,
66                                      uc16 to,
67                                      Label* on_in_range);
68   virtual void CheckCharacterNotInRange(uc16 from,
69                                         uc16 to,
70                                         Label* on_not_in_range);
71   virtual void CheckBitInTable(Handle<ByteArray> table, Label* on_bit_set);
72   virtual bool CheckSpecialCharacterClass(uc16 type,
73                                           Label* on_no_match);
74   virtual void Fail();
75   virtual Handle<HeapObject> GetCode(Handle<String> source);
76   virtual void GoTo(Label* label);
77   virtual void IfRegisterGE(int reg, int comparand, Label* if_ge);
78   virtual void IfRegisterLT(int reg, int comparand, Label* if_lt);
79   virtual void IfRegisterEqPos(int reg, Label* if_eq);
80   virtual IrregexpImplementation Implementation();
81   virtual void LoadCurrentCharacter(int cp_offset,
82                                     Label* on_end_of_input,
83                                     bool check_bounds = true,
84                                     int characters = 1);
85   virtual void PopCurrentPosition();
86   virtual void PopRegister(int register_index);
87   virtual void PushBacktrack(Label* label);
88   virtual void PushCurrentPosition();
89   virtual void PushRegister(int register_index,
90                             StackCheckFlag check_stack_limit);
91   virtual void ReadCurrentPositionFromRegister(int reg);
92   virtual void ReadStackPointerFromRegister(int reg);
93   virtual void SetCurrentPositionFromEnd(int by);
94   virtual void SetRegister(int register_index, int to);
95   virtual bool Succeed();
96   virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
97   virtual void ClearRegisters(int reg_from, int reg_to);
98   virtual void WriteStackPointerToRegister(int reg);
99
100  private:
101   RegExpMacroAssembler* assembler_;
102 };
103
104 }}  // namespace v8::internal
105
106 #endif  // V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_