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

Side by Side Diff: src/assembler-re2k.cc

Issue 9690: Rename codegen to macro-assembler.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month 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
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // A light-weight assembler for the Regexp2000 byte code. 28 // A light-weight assembler for the Regexp2000 byte code.
29 29
30 30
31 #include "v8.h" 31 #include "v8.h"
32 #include "ast.h" 32 #include "ast.h"
33 #include "bytecodes-re2k.h" 33 #include "bytecodes-re2k.h"
34 #include "regexp-codegen.h"
35 #include "assembler-re2k.h" 34 #include "assembler-re2k.h"
36 35
37 #include "assembler-re2k-inl.h" 36 #include "assembler-re2k-inl.h"
38 37
39 38
40 namespace v8 { namespace internal { 39 namespace v8 { namespace internal {
41 40
42 41
43 Re2kAssembler::Re2kAssembler(Vector<byte> buffer) 42 Re2kAssembler::Re2kAssembler(Vector<byte> buffer)
44 : buffer_(buffer), 43 : buffer_(buffer),
(...skipping 19 matching lines...) Expand all
64 } 63 }
65 64
66 65
67 void Re2kAssembler::PushRegister(int index) { 66 void Re2kAssembler::PushRegister(int index) {
68 ASSERT(index >= 0); 67 ASSERT(index >= 0);
69 Emit(BC_PUSH_REGISTER); 68 Emit(BC_PUSH_REGISTER);
70 Emit(index); 69 Emit(index);
71 } 70 }
72 71
73 72
74 void Re2kAssembler::SetRegister(int index, int cp_offset) { 73 void Re2kAssembler::SetRegisterToCurrentPosition(int index, int cp_offset) {
75 ASSERT(cp_offset >= 0); 74 ASSERT(cp_offset >= 0);
76 ASSERT(index >= 0); 75 ASSERT(index >= 0);
76 Emit(BC_SET_REGISTER_TO_CP);
77 Emit(index);
78 Emit32(cp_offset);
79 }
80
81
82 void Re2kAssembler::SetRegister(int index, int value) {
83 ASSERT(index >= 0);
77 Emit(BC_SET_REGISTER); 84 Emit(BC_SET_REGISTER);
78 Emit(index); 85 Emit(index);
79 Emit32(cp_offset); 86 Emit32(value);
80 } 87 }
81 88
82 89
83 void Re2kAssembler::PopCurrentPosition() { 90 void Re2kAssembler::PopCurrentPosition() {
84 Emit(BC_POP_CP); 91 Emit(BC_POP_CP);
85 } 92 }
86 93
87 94
88 void Re2kAssembler::PopBacktrack() { 95 void Re2kAssembler::PopBacktrack() {
89 Emit(BC_POP_BT); 96 Emit(BC_POP_BT);
90 } 97 }
91 98
92 99
93 void Re2kAssembler::PopRegister(int index) { 100 void Re2kAssembler::PopRegister(int index) {
94 Emit(BC_POP_REGISTER); 101 Emit(BC_POP_REGISTER);
95 Emit(index); 102 Emit(index);
96 } 103 }
97 104
98 105
99 void Re2kAssembler::Fail() { 106 void Re2kAssembler::Fail() {
100 Emit(BC_FAIL); 107 Emit(BC_FAIL);
101 } 108 }
102 109
103 110
111 void Re2kAssembler::Break() {
112 Emit(BC_BREAK);
113 }
114
115
104 void Re2kAssembler::FailIfWithin(int distance_from_end) { 116 void Re2kAssembler::FailIfWithin(int distance_from_end) {
105 Emit(BC_FAIL_IF_WITHIN); 117 Emit(BC_FAIL_IF_WITHIN);
106 Emit32(distance_from_end); 118 Emit32(distance_from_end);
107 } 119 }
108 120
109 121
110 void Re2kAssembler::Succeed() { 122 void Re2kAssembler::Succeed() {
111 Emit(BC_SUCCEED); 123 Emit(BC_SUCCEED);
112 } 124 }
113 125
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 163 }
152 164
153 165
154 void Re2kAssembler::CheckNotChar(uc16 c, Label* on_match) { 166 void Re2kAssembler::CheckNotChar(uc16 c, Label* on_match) {
155 Emit(BC_CHECK_NOT_CHAR); 167 Emit(BC_CHECK_NOT_CHAR);
156 Emit16(c); 168 Emit16(c);
157 EmitOrLink(on_match); 169 EmitOrLink(on_match);
158 } 170 }
159 171
160 172
173 void Re2kAssembler::CheckEnd(Label* on_not_end) {
174 Emit(BC_CHECK_END);
175 EmitOrLink(on_not_end);
176 }
177
178
179 void Re2kAssembler::CheckNotEnd(Label* on_end) {
180 Emit(BC_CHECK_NOT_END);
181 EmitOrLink(on_end);
182 }
183
184
161 void Re2kAssembler::CheckRange(uc16 start, uc16 end, Label* on_mismatch) { 185 void Re2kAssembler::CheckRange(uc16 start, uc16 end, Label* on_mismatch) {
162 Emit(BC_CHECK_RANGE); 186 Emit(BC_CHECK_RANGE);
163 Emit16(start); 187 Emit16(start);
164 Emit16(end); 188 Emit16(end);
165 EmitOrLink(on_mismatch); 189 EmitOrLink(on_mismatch);
166 } 190 }
167 191
168 192
169 void Re2kAssembler::CheckNotRange(uc16 start, uc16 end, Label* on_match) { 193 void Re2kAssembler::CheckNotRange(uc16 start, uc16 end, Label* on_match) {
170 Emit(BC_CHECK_NOT_RANGE); 194 Emit(BC_CHECK_NOT_RANGE);
(...skipping 27 matching lines...) Expand all
198 int reg_index, 222 int reg_index,
199 uint16_t vs, 223 uint16_t vs,
200 Label* on_true) { 224 Label* on_true) {
201 Emit(byte_code); 225 Emit(byte_code);
202 Emit(reg_index); 226 Emit(reg_index);
203 Emit16(vs); 227 Emit16(vs);
204 EmitOrLink(on_true); 228 EmitOrLink(on_true);
205 } 229 }
206 230
207 231
208 void Re2kAssembler::CheckRegisterEq(int reg_index,
209 uint16_t vs,
210 Label* on_equal) {
211 CheckRegister(BC_CHECK_REGISTER_EQ, reg_index, vs, on_equal);
212 }
213
214
215 void Re2kAssembler::CheckRegisterLe(int reg_index,
216 uint16_t vs,
217 Label* on_less_than_equal) {
218 CheckRegister(BC_CHECK_REGISTER_LE, reg_index, vs, on_less_than_equal);
219 }
220
221
222 void Re2kAssembler::CheckRegisterLt(int reg_index, 232 void Re2kAssembler::CheckRegisterLt(int reg_index,
223 uint16_t vs, 233 uint16_t vs,
224 Label* on_less_than) { 234 Label* on_less_than) {
225 CheckRegister(BC_CHECK_REGISTER_LT, reg_index, vs, on_less_than); 235 CheckRegister(BC_CHECK_REGISTER_LT, reg_index, vs, on_less_than);
226 } 236 }
227 237
228 238
229 void Re2kAssembler::CheckRegisterGe(int reg_index, 239 void Re2kAssembler::CheckRegisterGe(int reg_index,
230 uint16_t vs, 240 uint16_t vs,
231 Label* on_greater_than_equal) { 241 Label* on_greater_than_equal) {
232 CheckRegister(BC_CHECK_REGISTER_GE, reg_index, vs, on_greater_than_equal); 242 CheckRegister(BC_CHECK_REGISTER_GE, reg_index, vs, on_greater_than_equal);
233 } 243 }
234 244
235 245
236 void Re2kAssembler::CheckRegisterGt(int reg_index,
237 uint16_t vs,
238 Label* on_greater_than) {
239 CheckRegister(BC_CHECK_REGISTER_GT, reg_index, vs, on_greater_than);
240 }
241
242
243 void Re2kAssembler::CheckRegisterNe(int reg_index,
244 uint16_t vs,
245 Label* on_not_equal) {
246 CheckRegister(BC_CHECK_REGISTER_NE, reg_index, vs, on_not_equal);
247 }
248
249
250 int Re2kAssembler::length() { 246 int Re2kAssembler::length() {
251 return pc_; 247 return pc_;
252 } 248 }
253 249
254 250
255 void Re2kAssembler::Copy(Address a) { 251 void Re2kAssembler::Copy(Address a) {
256 memcpy(a, buffer_.start(), length()); 252 memcpy(a, buffer_.start(), length());
257 } 253 }
258 254
259 } } // namespace v8::internal 255 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698