Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: src/assembler-irregexp.h

Issue 12427: Merge regexp2000 back into bleeding_edge (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
Erik Corry 2008/11/25 11:03:52 Missing license boilerplate.
2
3 // A light-weight assembler for the Irregexp byte code.
4
5 #ifndef V8_ASSEMBLER_IRREGEXP_H_
6 #define V8_ASSEMBLER_IRREGEXP_H_
7
8 namespace v8 { namespace internal {
9
10
11 class IrregexpAssembler {
12 public:
13 // Create an assembler. Instructions and relocation information are emitted
14 // into a buffer, with the instructions starting from the beginning and the
15 // relocation information starting from the end of the buffer. See CodeDesc
16 // for a detailed comment on the layout (globals.h).
17 //
18 // If the provided buffer is NULL, the assembler allocates and grows its own
19 // buffer, and buffer_size determines the initial buffer size. The buffer is
20 // owned by the assembler and deallocated upon destruction of the assembler.
21 //
22 // If the provided buffer is not NULL, the assembler uses the provided buffer
23 // for code generation and assumes its size to be buffer_size. If the buffer
24 // is too small, a fatal error occurs. No deallocation of the buffer is done
25 // upon destruction of the assembler.
26 explicit IrregexpAssembler(Vector<byte>);
27 ~IrregexpAssembler();
28
29 // CP = current position in source.
30 // BT = backtrack label.
31
32 // Stack.
33 void PushCurrentPosition(int cp_offset = 0);
34 void PushBacktrack(Label* l);
35 void PushRegister(int index);
36 void WriteCurrentPositionToRegister(int index, int cp_offset = 0);
37 void ReadCurrentPositionFromRegister(int index);
38 void WriteStackPointerToRegister(int index);
39 void ReadStackPointerFromRegister(int index);
40 void SetRegister(int index, int value);
41 void AdvanceRegister(int index, int by);
42
43 void PopCurrentPosition();
44 void PopBacktrack();
45 void PopRegister(int index);
46
47 void Fail();
48 void Succeed();
49
50 void Break(); // This instruction will cause a fatal VM error if hit.
Mads Ager (chromium) 2008/11/25 21:09:41 I would prefer to have this comment on the line be
Erik Corry 2008/11/26 12:18:36 Fixed.
51
52 void Bind(Label* l); // Binds an unbound label L to the current code posn.
Mads Ager (chromium) 2008/11/25 21:09:41 Ditto.
Erik Corry 2008/11/26 12:18:36 Fixed.
53
54 void AdvanceCP(int by);
55
56 void GoTo(Label* l);
57
58 // Loads current char into a machine register. Jumps to the label if we
59 // reached the end of the subject string. Fall through otherwise.
60 void LoadCurrentChar(int cp_offset, Label* on_end);
61
62 // Checks current char register against a singleton.
63 void CheckCharacter(uc16 c, Label* on_match);
64 void CheckNotCharacter(uc16 c, Label* on_mismatch);
65 void OrThenCheckNotCharacter(uc16 c, uc16 mask, Label* on_mismatch);
66 void MinusOrThenCheckNotCharacter(uc16 c, uc16 mask, Label* on_mismatch);
67
68 // Used to check current char register against a range.
69 void CheckCharacterLT(uc16 limit, Label* on_less);
70 void CheckCharacterGT(uc16 limit, Label* on_greater);
71
72 // Checks current position for a match against a
73 // previous capture. Advances current position by the length of the capture
74 // iff it matches. The capture is stored in a given register and the
75 // the register after. If a register contains -1 then the other register
Mads Ager (chromium) 2008/11/25 21:09:41 Two occurrences of 'the' after each other. Also,
Erik Corry 2008/11/26 12:18:36 Fixed
76 // must always contain -1 and the on_mismatch label will never be called.
77 void CheckNotBackReference(int capture_index, Label* on_mismatch);
78
79 // Checks a register for strictly-less-than or greater-than-or-equal.
80 void CheckRegisterLT(int reg_index, uint16_t vs, Label* on_less_than);
81 void CheckRegisterGE(int reg_index, uint16_t vs, Label* on_greater_equal);
82
83 // Subtracts a 16 bit value from the current character, uses the result to
84 // look up in a bit array, uses the result of that decide whether to fall
Mads Ager (chromium) 2008/11/25 21:09:41 decide -> to decide
Erik Corry 2008/11/26 12:18:36 Fixed
85 // though (on 1) or jump to the on_zero label (on 0).
86 void LookupMap1(uc16 start, Label* bit_map, Label* on_zero);
87
88 // Subtracts a 16 bit value from the current character, uses the result to
89 // look up in a 2-bit array, uses the result of that to look up in a label
90 // table and jumps to the label.
91 void LookupMap2(uc16 start,
92 Label* half_nibble_map,
93 const Vector<Label*>& table);
94
95 // Subtracts a 16 bit value from the current character, uses the result to
96 // look up in a byte array, uses the result of that to look up in a label
97 // array and jumps to the label.
98 void LookupMap8(uc16 start, Label* byte_map, const Vector<Label*>& table);
99
100 // Takes the high byte of the current character, uses the result to
101 // look up in a byte array, uses the result of that to look up in a label
102 // array and jumps to the label.
103 void LookupHighMap8(byte start, Label* byte_map, const Vector<Label*>& table);
104
105 // Code and bitmap emission.
106 inline void Emit32(uint32_t x);
107 inline void Emit16(uint32_t x);
108 inline void Emit(uint32_t x);
109
110 // Bytecode buffer.
111 int length();
112 void Copy(Address a);
113
114 inline void EmitOrLink(Label* l);
115 private:
116 // Don't use this.
117 IrregexpAssembler() { UNREACHABLE(); }
Mads Ager (chromium) 2008/11/25 21:09:41 Can you use DISALLOW_IMPLICIT_CONSTRUCTORS(Irregex
Erik Corry 2008/11/26 12:18:36 Fixed.
118 // The buffer into which code and relocation info are generated.
119 Vector<byte> buffer_;
120
121 inline void CheckRegister(int byte_code,
122 int reg_index,
123 uint16_t vs,
124 Label* on_true);
125 // Code generation.
126 int pc_; // The program counter; moves forward.
Mads Ager (chromium) 2008/11/25 21:09:41 Move this comment to the line before the declarati
Erik Corry 2008/11/26 12:18:36 I blame the Strongtalk team. Fixed. Also removed
127
128 // True if the assembler owns the buffer, false if buffer is external.
129 bool own_buffer_;
130
131 void Expand();
iposva 2008/11/26 06:56:22 Please move the method definition before the field
Erik Corry 2008/11/26 12:18:36 I moved this method but haven't reordered the enti
132 };
133
134
135 } } // namespace v8::internal
136
137 #endif // V8_ASSEMBLER_IRREGEXP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698