1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_
6 #define V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_
7 
8 namespace v8 {
9 namespace internal {
10 
11 // Decorator on a RegExpMacroAssembler that write all calls.
12 class RegExpMacroAssemblerTracer: public RegExpMacroAssembler {
13  public:
14   explicit RegExpMacroAssemblerTracer(RegExpMacroAssembler* assembler);
15   virtual ~RegExpMacroAssemblerTracer();
stack_limit_slack()16   virtual int stack_limit_slack() { return assembler_->stack_limit_slack(); }
CanReadUnaligned()17   virtual bool CanReadUnaligned() { return assembler_->CanReadUnaligned(); }
18   virtual void AdvanceCurrentPosition(int by);  // Signed cp change.
19   virtual void AdvanceRegister(int reg, int by);  // r[reg] += by.
20   virtual void Backtrack();
21   virtual void Bind(Label* label);
22   virtual void CheckAtStart(Label* on_at_start);
23   virtual void CheckCharacter(unsigned c, Label* on_equal);
24   virtual void CheckCharacterAfterAnd(unsigned c,
25                                       unsigned and_with,
26                                       Label* on_equal);
27   virtual void CheckCharacterGT(uc16 limit, Label* on_greater);
28   virtual void CheckCharacterLT(uc16 limit, Label* on_less);
29   virtual void CheckGreedyLoop(Label* on_tos_equals_current_position);
30   virtual void CheckNotAtStart(Label* on_not_at_start);
31   virtual void CheckNotBackReference(int start_reg, Label* on_no_match);
32   virtual void CheckNotBackReferenceIgnoreCase(int start_reg,
33                                                Label* on_no_match);
34   virtual void CheckNotCharacter(unsigned c, Label* on_not_equal);
35   virtual void CheckNotCharacterAfterAnd(unsigned c,
36                                          unsigned and_with,
37                                          Label* on_not_equal);
38   virtual void CheckNotCharacterAfterMinusAnd(uc16 c,
39                                               uc16 minus,
40                                               uc16 and_with,
41                                               Label* on_not_equal);
42   virtual void CheckCharacterInRange(uc16 from,
43                                      uc16 to,
44                                      Label* on_in_range);
45   virtual void CheckCharacterNotInRange(uc16 from,
46                                         uc16 to,
47                                         Label* on_not_in_range);
48   virtual void CheckBitInTable(Handle<ByteArray> table, Label* on_bit_set);
49   virtual bool CheckSpecialCharacterClass(uc16 type,
50                                           Label* on_no_match);
51   virtual void Fail();
52   virtual Handle<HeapObject> GetCode(Handle<String> source);
53   virtual void GoTo(Label* label);
54   virtual void IfRegisterGE(int reg, int comparand, Label* if_ge);
55   virtual void IfRegisterLT(int reg, int comparand, Label* if_lt);
56   virtual void IfRegisterEqPos(int reg, Label* if_eq);
57   virtual IrregexpImplementation Implementation();
58   virtual void LoadCurrentCharacter(int cp_offset,
59                                     Label* on_end_of_input,
60                                     bool check_bounds = true,
61                                     int characters = 1);
62   virtual void PopCurrentPosition();
63   virtual void PopRegister(int register_index);
64   virtual void PushBacktrack(Label* label);
65   virtual void PushCurrentPosition();
66   virtual void PushRegister(int register_index,
67                             StackCheckFlag check_stack_limit);
68   virtual void ReadCurrentPositionFromRegister(int reg);
69   virtual void ReadStackPointerFromRegister(int reg);
70   virtual void SetCurrentPositionFromEnd(int by);
71   virtual void SetRegister(int register_index, int to);
72   virtual bool Succeed();
73   virtual void WriteCurrentPositionToRegister(int reg, int cp_offset);
74   virtual void ClearRegisters(int reg_from, int reg_to);
75   virtual void WriteStackPointerToRegister(int reg);
76 
77  private:
78   RegExpMacroAssembler* assembler_;
79 };
80 
81 }}  // namespace v8::internal
82 
83 #endif  // V8_REGEXP_MACRO_ASSEMBLER_TRACER_H_
84