OLD | NEW |
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 | 81 |
82 void Re2kAssembler::SetRegister(int index, int value) { | 82 void Re2kAssembler::SetRegister(int index, int value) { |
83 ASSERT(index >= 0); | 83 ASSERT(index >= 0); |
84 Emit(BC_SET_REGISTER); | 84 Emit(BC_SET_REGISTER); |
85 Emit(index); | 85 Emit(index); |
86 Emit32(value); | 86 Emit32(value); |
87 } | 87 } |
88 | 88 |
89 | 89 |
| 90 void Re2kAssembler::AdvanceRegister(int index, int by) { |
| 91 ASSERT(index >= 0); |
| 92 Emit(BC_ADVANCE_REGISTER); |
| 93 Emit(index); |
| 94 Emit32(by); |
| 95 } |
| 96 |
| 97 |
90 void Re2kAssembler::PopCurrentPosition() { | 98 void Re2kAssembler::PopCurrentPosition() { |
91 Emit(BC_POP_CP); | 99 Emit(BC_POP_CP); |
92 } | 100 } |
93 | 101 |
94 | 102 |
95 void Re2kAssembler::PopBacktrack() { | 103 void Re2kAssembler::PopBacktrack() { |
96 Emit(BC_POP_BT); | 104 Emit(BC_POP_BT); |
97 } | 105 } |
98 | 106 |
99 | 107 |
100 void Re2kAssembler::PopRegister(int index) { | 108 void Re2kAssembler::PopRegister(int index) { |
101 Emit(BC_POP_REGISTER); | 109 Emit(BC_POP_REGISTER); |
102 Emit(index); | 110 Emit(index); |
103 } | 111 } |
104 | 112 |
105 | 113 |
106 void Re2kAssembler::Fail() { | 114 void Re2kAssembler::Fail() { |
107 Emit(BC_FAIL); | 115 Emit(BC_FAIL); |
108 } | 116 } |
109 | 117 |
110 | 118 |
111 void Re2kAssembler::Break() { | 119 void Re2kAssembler::Break() { |
112 Emit(BC_BREAK); | 120 Emit(BC_BREAK); |
113 } | 121 } |
114 | 122 |
115 | 123 |
116 void Re2kAssembler::FailIfWithin(int distance_from_end) { | |
117 Emit(BC_FAIL_IF_WITHIN); | |
118 Emit32(distance_from_end); | |
119 } | |
120 | |
121 | |
122 void Re2kAssembler::Succeed() { | 124 void Re2kAssembler::Succeed() { |
123 Emit(BC_SUCCEED); | 125 Emit(BC_SUCCEED); |
124 } | 126 } |
125 | 127 |
126 | 128 |
127 void Re2kAssembler::Bind(Label* l) { | 129 void Re2kAssembler::Bind(Label* l) { |
128 ASSERT(!l->is_bound()); | 130 ASSERT(!l->is_bound()); |
129 if (l->is_linked()) { | 131 if (l->is_linked()) { |
130 int pos = l->pos(); | 132 int pos = l->pos(); |
131 while (pos != 0) { | 133 while (pos != 0) { |
(...skipping 11 matching lines...) Expand all Loading... |
143 Emit32(cp_offset); | 145 Emit32(cp_offset); |
144 } | 146 } |
145 | 147 |
146 | 148 |
147 void Re2kAssembler::GoTo(Label* l) { | 149 void Re2kAssembler::GoTo(Label* l) { |
148 Emit(BC_GOTO); | 150 Emit(BC_GOTO); |
149 EmitOrLink(l); | 151 EmitOrLink(l); |
150 } | 152 } |
151 | 153 |
152 | 154 |
153 void Re2kAssembler::LoadCurrentChar(int cp_offset) { | 155 void Re2kAssembler::LoadCurrentChar(int cp_offset, Label* on_end) { |
154 Emit(BC_LOAD_CURRENT_CHAR); | 156 Emit(BC_LOAD_CURRENT_CHAR); |
155 Emit32(cp_offset); | 157 Emit32(cp_offset); |
| 158 EmitOrLink(on_end); |
156 } | 159 } |
157 | 160 |
158 | 161 |
159 void Re2kAssembler::CheckChar(uc16 c, Label* on_mismatch) { | 162 void Re2kAssembler::CheckChar(uc16 c, Label* on_mismatch) { |
160 Emit(BC_CHECK_CHAR); | 163 Emit(BC_CHECK_CHAR); |
161 Emit16(c); | 164 Emit16(c); |
162 EmitOrLink(on_mismatch); | 165 EmitOrLink(on_mismatch); |
163 } | 166 } |
164 | 167 |
165 | 168 |
166 void Re2kAssembler::CheckNotChar(uc16 c, Label* on_match) { | 169 void Re2kAssembler::CheckNotChar(uc16 c, Label* on_match) { |
167 Emit(BC_CHECK_NOT_CHAR); | 170 Emit(BC_CHECK_NOT_CHAR); |
168 Emit16(c); | 171 Emit16(c); |
169 EmitOrLink(on_match); | 172 EmitOrLink(on_match); |
170 } | 173 } |
171 | 174 |
172 | 175 |
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 | |
185 void Re2kAssembler::CheckRange(uc16 start, uc16 end, Label* on_mismatch) { | 176 void Re2kAssembler::CheckRange(uc16 start, uc16 end, Label* on_mismatch) { |
| 177 if (start == end) { |
| 178 CheckChar(start, on_mismatch); |
| 179 } |
186 Emit(BC_CHECK_RANGE); | 180 Emit(BC_CHECK_RANGE); |
187 Emit16(start); | 181 Emit16(start); |
188 Emit16(end); | 182 Emit16(end); |
189 EmitOrLink(on_mismatch); | 183 EmitOrLink(on_mismatch); |
190 } | 184 } |
191 | 185 |
192 | 186 |
193 void Re2kAssembler::CheckNotRange(uc16 start, uc16 end, Label* on_match) { | 187 void Re2kAssembler::CheckNotRange(uc16 start, uc16 end, Label* on_match) { |
194 Emit(BC_CHECK_NOT_RANGE); | 188 Emit(BC_CHECK_NOT_RANGE); |
195 Emit16(start); | 189 Emit16(start); |
196 Emit16(end); | 190 Emit16(end); |
197 EmitOrLink(on_match); | 191 EmitOrLink(on_match); |
198 } | 192 } |
199 | 193 |
200 | 194 |
201 void Re2kAssembler::CheckBackref(int capture_index, | 195 void Re2kAssembler::CheckBackref(int capture_index, |
202 Label* on_mismatch, | 196 Label* on_mismatch) { |
203 int cp_offset) { | |
204 Emit(BC_CHECK_BACKREF); | 197 Emit(BC_CHECK_BACKREF); |
205 Emit32(cp_offset); | 198 Emit32(0); |
206 Emit(capture_index); | 199 Emit(capture_index); |
207 EmitOrLink(on_mismatch); | 200 EmitOrLink(on_mismatch); |
208 } | 201 } |
209 | 202 |
210 | 203 |
211 void Re2kAssembler::CheckNotBackref(int capture_index, | |
212 Label* on_match, | |
213 int cp_offset) { | |
214 Emit(BC_CHECK_NOT_BACKREF); | |
215 Emit32(cp_offset); | |
216 Emit(capture_index); | |
217 EmitOrLink(on_match); | |
218 } | |
219 | |
220 | |
221 void Re2kAssembler::CheckRegister(int byte_code, | 204 void Re2kAssembler::CheckRegister(int byte_code, |
222 int reg_index, | 205 int reg_index, |
223 uint16_t vs, | 206 uint16_t vs, |
224 Label* on_true) { | 207 Label* on_true) { |
225 Emit(byte_code); | 208 Emit(byte_code); |
226 Emit(reg_index); | 209 Emit(reg_index); |
227 Emit16(vs); | 210 Emit16(vs); |
228 EmitOrLink(on_true); | 211 EmitOrLink(on_true); |
229 } | 212 } |
230 | 213 |
231 | 214 |
232 void Re2kAssembler::CheckRegisterLt(int reg_index, | 215 void Re2kAssembler::CheckRegisterLT(int reg_index, |
233 uint16_t vs, | 216 uint16_t vs, |
234 Label* on_less_than) { | 217 Label* on_less_than) { |
235 CheckRegister(BC_CHECK_REGISTER_LT, reg_index, vs, on_less_than); | 218 CheckRegister(BC_CHECK_REGISTER_LT, reg_index, vs, on_less_than); |
236 } | 219 } |
237 | 220 |
238 | 221 |
239 void Re2kAssembler::CheckRegisterGe(int reg_index, | 222 void Re2kAssembler::CheckRegisterGE(int reg_index, |
240 uint16_t vs, | 223 uint16_t vs, |
241 Label* on_greater_than_equal) { | 224 Label* on_greater_than_equal) { |
242 CheckRegister(BC_CHECK_REGISTER_GE, reg_index, vs, on_greater_than_equal); | 225 CheckRegister(BC_CHECK_REGISTER_GE, reg_index, vs, on_greater_than_equal); |
243 } | 226 } |
244 | 227 |
245 | 228 |
| 229 void Re2kAssembler::LookupMap1(uc16 start, Label* bit_map, Label* on_zero) { |
| 230 Emit(BC_LOOKUP_MAP1); |
| 231 Emit16(start); |
| 232 EmitOrLink(bit_map); |
| 233 EmitOrLink(on_zero); |
| 234 } |
| 235 |
| 236 |
| 237 void Re2kAssembler::LookupMap2(uc16 start, |
| 238 Label* half_nibble_map, |
| 239 const Vector<Label*>& table) { |
| 240 Emit(BC_LOOKUP_MAP2); |
| 241 Emit16(start); |
| 242 EmitOrLink(half_nibble_map); |
| 243 ASSERT(table.length() > 0); |
| 244 ASSERT(table.length() <= 4); |
| 245 for (int i = 0; i < table.length(); i++) { |
| 246 EmitOrLink(table[i]); |
| 247 } |
| 248 } |
| 249 |
| 250 |
| 251 void Re2kAssembler::LookupMap8(uc16 start, |
| 252 Label* byte_map, |
| 253 const Vector<Label*>& table) { |
| 254 Emit(BC_LOOKUP_MAP8); |
| 255 Emit16(start); |
| 256 EmitOrLink(byte_map); |
| 257 ASSERT(table.length() > 0); |
| 258 ASSERT(table.length() <= 256); |
| 259 for (int i = 0; i < table.length(); i++) { |
| 260 EmitOrLink(table[i]); |
| 261 } |
| 262 } |
| 263 |
| 264 |
| 265 void Re2kAssembler::LookupHighMap8(byte start, |
| 266 Label* byte_map, |
| 267 const Vector<Label*>& table) { |
| 268 Emit(BC_LOOKUP_HI_MAP8); |
| 269 Emit(start); |
| 270 EmitOrLink(byte_map); |
| 271 ASSERT(table.length() > 0); |
| 272 ASSERT(table.length() <= 256); |
| 273 for (int i = 0; i < table.length(); i++) { |
| 274 EmitOrLink(table[i]); |
| 275 } |
| 276 } |
| 277 |
| 278 |
246 int Re2kAssembler::length() { | 279 int Re2kAssembler::length() { |
247 return pc_; | 280 return pc_; |
248 } | 281 } |
249 | 282 |
250 | 283 |
251 void Re2kAssembler::Copy(Address a) { | 284 void Re2kAssembler::Copy(Address a) { |
252 memcpy(a, buffer_.start(), length()); | 285 memcpy(a, buffer_.start(), length()); |
253 } | 286 } |
254 | 287 |
255 } } // namespace v8::internal | 288 } } // namespace v8::internal |
OLD | NEW |