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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if (l->is_linked()) { | 77 if (l->is_linked()) { |
78 pos = l->pos(); | 78 pos = l->pos(); |
79 } | 79 } |
80 l->link_to(pc_); | 80 l->link_to(pc_); |
81 Emit32(pos); | 81 Emit32(pos); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) { | 86 void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) { |
87 Emit(BC_POP_REGISTER); | 87 Emit(BC_POP_REGISTER, register_index); |
88 Emit(register_index); | |
89 } | 88 } |
90 | 89 |
91 | 90 |
92 void RegExpMacroAssemblerIrregexp::PushRegister( | 91 void RegExpMacroAssemblerIrregexp::PushRegister( |
93 int register_index, | 92 int register_index, |
94 StackCheckFlag check_stack_limit) { | 93 StackCheckFlag check_stack_limit) { |
95 ASSERT(register_index >= 0); | 94 ASSERT(register_index >= 0); |
96 Emit(BC_PUSH_REGISTER); | 95 Emit(BC_PUSH_REGISTER, register_index); |
97 Emit(register_index); | |
98 } | 96 } |
99 | 97 |
100 | 98 |
101 void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister( | 99 void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister( |
102 int register_index, int cp_offset) { | 100 int register_index, int cp_offset) { |
103 ASSERT(register_index >= 0); | 101 ASSERT(register_index >= 0); |
104 Emit(BC_SET_REGISTER_TO_CP); | 102 Emit(BC_SET_REGISTER_TO_CP, register_index); |
105 Emit(register_index); | |
106 Emit32(cp_offset); // Current position offset. | 103 Emit32(cp_offset); // Current position offset. |
107 } | 104 } |
108 | 105 |
109 | 106 |
110 void RegExpMacroAssemblerIrregexp::ClearRegister(int reg) { | 107 void RegExpMacroAssemblerIrregexp::ClearRegister(int reg) { |
111 SetRegister(reg, -1); | 108 SetRegister(reg, -1); |
112 } | 109 } |
113 | 110 |
114 | 111 |
115 void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister( | 112 void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister( |
116 int register_index) { | 113 int register_index) { |
117 ASSERT(register_index >= 0); | 114 ASSERT(register_index >= 0); |
118 Emit(BC_SET_CP_TO_REGISTER); | 115 Emit(BC_SET_CP_TO_REGISTER, register_index); |
119 Emit(register_index); | |
120 } | 116 } |
121 | 117 |
122 | 118 |
123 void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister( | 119 void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister( |
124 int register_index) { | 120 int register_index) { |
125 ASSERT(register_index >= 0); | 121 ASSERT(register_index >= 0); |
126 Emit(BC_SET_REGISTER_TO_SP); | 122 Emit(BC_SET_REGISTER_TO_SP, register_index); |
127 Emit(register_index); | |
128 } | 123 } |
129 | 124 |
130 | 125 |
131 void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister( | 126 void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister( |
132 int register_index) { | 127 int register_index) { |
133 ASSERT(register_index >= 0); | 128 ASSERT(register_index >= 0); |
134 Emit(BC_SET_SP_TO_REGISTER); | 129 Emit(BC_SET_SP_TO_REGISTER, register_index); |
135 Emit(register_index); | |
136 } | 130 } |
137 | 131 |
138 | 132 |
139 void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) { | 133 void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) { |
140 ASSERT(register_index >= 0); | 134 ASSERT(register_index >= 0); |
141 Emit(BC_SET_REGISTER); | 135 Emit(BC_SET_REGISTER, register_index); |
142 Emit(register_index); | |
143 Emit32(to); | 136 Emit32(to); |
144 } | 137 } |
145 | 138 |
146 | 139 |
147 void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) { | 140 void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) { |
148 ASSERT(register_index >= 0); | 141 ASSERT(register_index >= 0); |
149 Emit(BC_ADVANCE_REGISTER); | 142 Emit(BC_ADVANCE_REGISTER, register_index); |
150 Emit(register_index); | |
151 Emit32(by); | 143 Emit32(by); |
152 } | 144 } |
153 | 145 |
154 | 146 |
155 void RegExpMacroAssemblerIrregexp::PopCurrentPosition() { | 147 void RegExpMacroAssemblerIrregexp::PopCurrentPosition() { |
156 Emit(BC_POP_CP); | 148 Emit(BC_POP_CP, 0); |
157 } | 149 } |
158 | 150 |
159 | 151 |
160 void RegExpMacroAssemblerIrregexp::PushCurrentPosition() { | 152 void RegExpMacroAssemblerIrregexp::PushCurrentPosition() { |
161 Emit(BC_PUSH_CP); | 153 Emit(BC_PUSH_CP, 0); |
162 Emit32(0); // Current position offset. | |
163 } | 154 } |
164 | 155 |
165 | 156 |
166 void RegExpMacroAssemblerIrregexp::Backtrack() { | 157 void RegExpMacroAssemblerIrregexp::Backtrack() { |
167 Emit(BC_POP_BT); | 158 Emit(BC_POP_BT, 0); |
168 } | 159 } |
169 | 160 |
170 | 161 |
171 void RegExpMacroAssemblerIrregexp::GoTo(Label* l) { | 162 void RegExpMacroAssemblerIrregexp::GoTo(Label* l) { |
172 Emit(BC_GOTO); | 163 Emit(BC_GOTO, 0); |
173 EmitOrLink(l); | 164 EmitOrLink(l); |
174 } | 165 } |
175 | 166 |
176 | 167 |
177 void RegExpMacroAssemblerIrregexp::PushBacktrack(Label* l) { | 168 void RegExpMacroAssemblerIrregexp::PushBacktrack(Label* l) { |
178 Emit(BC_PUSH_BT); | 169 Emit(BC_PUSH_BT, 0); |
179 EmitOrLink(l); | 170 EmitOrLink(l); |
180 } | 171 } |
181 | 172 |
182 | 173 |
183 void RegExpMacroAssemblerIrregexp::Succeed() { | 174 void RegExpMacroAssemblerIrregexp::Succeed() { |
184 Emit(BC_SUCCEED); | 175 Emit(BC_SUCCEED, 0); |
185 } | 176 } |
186 | 177 |
187 | 178 |
188 void RegExpMacroAssemblerIrregexp::Fail() { | 179 void RegExpMacroAssemblerIrregexp::Fail() { |
189 Emit(BC_FAIL); | 180 Emit(BC_FAIL, 0); |
190 } | 181 } |
191 | 182 |
192 | 183 |
193 void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) { | 184 void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) { |
194 Emit(BC_ADVANCE_CP); | 185 Emit(BC_ADVANCE_CP, by); |
195 Emit32(by); | |
196 } | 186 } |
197 | 187 |
198 | 188 |
199 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop( | 189 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop( |
200 Label* on_tos_equals_current_position) { | 190 Label* on_tos_equals_current_position) { |
201 Emit(BC_CHECK_GREEDY); | 191 Emit(BC_CHECK_GREEDY, 0); |
202 EmitOrLink(on_tos_equals_current_position); | 192 EmitOrLink(on_tos_equals_current_position); |
203 } | 193 } |
204 | 194 |
205 | 195 |
206 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, | 196 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, |
207 Label* on_failure, | 197 Label* on_failure, |
208 bool check_bounds, | 198 bool check_bounds, |
209 int characters) { | 199 int characters) { |
210 int bytecode; | 200 int bytecode; |
211 if (check_bounds) { | 201 if (check_bounds) { |
212 if (characters == 4) { | 202 if (characters == 4) { |
213 bytecode = BC_LOAD_4_CURRENT_CHARS; | 203 bytecode = BC_LOAD_4_CURRENT_CHARS; |
214 } else if (characters == 2) { | 204 } else if (characters == 2) { |
215 bytecode = BC_LOAD_2_CURRENT_CHARS; | 205 bytecode = BC_LOAD_2_CURRENT_CHARS; |
216 } else { | 206 } else { |
217 ASSERT(characters == 1); | 207 ASSERT(characters == 1); |
218 bytecode = BC_LOAD_CURRENT_CHAR; | 208 bytecode = BC_LOAD_CURRENT_CHAR; |
219 } | 209 } |
220 } else { | 210 } else { |
221 if (characters == 4) { | 211 if (characters == 4) { |
222 bytecode = BC_LOAD_4_CURRENT_CHARS_UNCHECKED; | 212 bytecode = BC_LOAD_4_CURRENT_CHARS_UNCHECKED; |
223 } else if (characters == 2) { | 213 } else if (characters == 2) { |
224 bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED; | 214 bytecode = BC_LOAD_2_CURRENT_CHARS_UNCHECKED; |
225 } else { | 215 } else { |
226 ASSERT(characters == 1); | 216 ASSERT(characters == 1); |
227 bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED; | 217 bytecode = BC_LOAD_CURRENT_CHAR_UNCHECKED; |
228 } | 218 } |
229 } | 219 } |
230 Emit(bytecode); | 220 Emit(bytecode, cp_offset); |
231 Emit32(cp_offset); | |
232 if (check_bounds) EmitOrLink(on_failure); | 221 if (check_bounds) EmitOrLink(on_failure); |
233 } | 222 } |
234 | 223 |
235 | 224 |
236 void RegExpMacroAssemblerIrregexp::CheckCharacterLT(uc16 limit, | 225 void RegExpMacroAssemblerIrregexp::CheckCharacterLT(uc16 limit, |
237 Label* on_less) { | 226 Label* on_less) { |
238 Emit(BC_CHECK_LT); | 227 Emit(BC_CHECK_LT, limit); |
239 Emit16(limit); | |
240 EmitOrLink(on_less); | 228 EmitOrLink(on_less); |
241 } | 229 } |
242 | 230 |
243 | 231 |
244 void RegExpMacroAssemblerIrregexp::CheckCharacterGT(uc16 limit, | 232 void RegExpMacroAssemblerIrregexp::CheckCharacterGT(uc16 limit, |
245 Label* on_greater) { | 233 Label* on_greater) { |
246 Emit(BC_CHECK_GT); | 234 Emit(BC_CHECK_GT, limit); |
247 Emit16(limit); | |
248 EmitOrLink(on_greater); | 235 EmitOrLink(on_greater); |
249 } | 236 } |
250 | 237 |
251 | 238 |
252 void RegExpMacroAssemblerIrregexp::CheckCharacter(uint32_t c, Label* on_equal) { | 239 void RegExpMacroAssemblerIrregexp::CheckCharacter(uint32_t c, Label* on_equal) { |
253 Emit(BC_CHECK_CHAR); | 240 if (c > MAX_FIRST_ARG) { |
254 Emit32(c); | 241 Emit(BC_CHECK_4_CHARS, 0); |
| 242 Emit32(c); |
| 243 } else { |
| 244 Emit(BC_CHECK_CHAR, c); |
| 245 } |
255 EmitOrLink(on_equal); | 246 EmitOrLink(on_equal); |
256 } | 247 } |
257 | 248 |
258 | 249 |
259 void RegExpMacroAssemblerIrregexp::CheckAtStart(Label* on_at_start) { | 250 void RegExpMacroAssemblerIrregexp::CheckAtStart(Label* on_at_start) { |
260 Emit(BC_CHECK_AT_START); | 251 Emit(BC_CHECK_AT_START, 0); |
261 EmitOrLink(on_at_start); | 252 EmitOrLink(on_at_start); |
262 } | 253 } |
263 | 254 |
264 | 255 |
265 void RegExpMacroAssemblerIrregexp::CheckNotAtStart(Label* on_not_at_start) { | 256 void RegExpMacroAssemblerIrregexp::CheckNotAtStart(Label* on_not_at_start) { |
266 Emit(BC_CHECK_NOT_AT_START); | 257 Emit(BC_CHECK_NOT_AT_START, 0); |
267 EmitOrLink(on_not_at_start); | 258 EmitOrLink(on_not_at_start); |
268 } | 259 } |
269 | 260 |
270 | 261 |
271 void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uint32_t c, | 262 void RegExpMacroAssemblerIrregexp::CheckNotCharacter(uint32_t c, |
272 Label* on_not_equal) { | 263 Label* on_not_equal) { |
273 Emit(BC_CHECK_NOT_CHAR); | 264 if (c > MAX_FIRST_ARG) { |
274 Emit32(c); | 265 Emit(BC_CHECK_NOT_4_CHARS, 0); |
| 266 Emit32(c); |
| 267 } else { |
| 268 Emit(BC_CHECK_NOT_CHAR, c); |
| 269 } |
275 EmitOrLink(on_not_equal); | 270 EmitOrLink(on_not_equal); |
276 } | 271 } |
277 | 272 |
278 | 273 |
279 void RegExpMacroAssemblerIrregexp::CheckCharacterAfterAnd( | 274 void RegExpMacroAssemblerIrregexp::CheckCharacterAfterAnd( |
280 uint32_t c, | 275 uint32_t c, |
281 uint32_t mask, | 276 uint32_t mask, |
282 Label* on_equal) { | 277 Label* on_equal) { |
283 Emit(BC_AND_CHECK_CHAR); | 278 if (c > MAX_FIRST_ARG) { |
284 Emit32(c); | 279 Emit(BC_AND_CHECK_4_CHARS, 0); |
| 280 Emit32(c); |
| 281 } else { |
| 282 Emit(BC_AND_CHECK_CHAR, c); |
| 283 } |
285 Emit32(mask); | 284 Emit32(mask); |
286 EmitOrLink(on_equal); | 285 EmitOrLink(on_equal); |
287 } | 286 } |
288 | 287 |
289 | 288 |
290 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterAnd( | 289 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterAnd( |
291 uint32_t c, | 290 uint32_t c, |
292 uint32_t mask, | 291 uint32_t mask, |
293 Label* on_not_equal) { | 292 Label* on_not_equal) { |
294 Emit(BC_AND_CHECK_NOT_CHAR); | 293 if (c > MAX_FIRST_ARG) { |
295 Emit32(c); | 294 Emit(BC_AND_CHECK_NOT_4_CHARS, 0); |
| 295 Emit32(c); |
| 296 } else { |
| 297 Emit(BC_AND_CHECK_NOT_CHAR, c); |
| 298 } |
296 Emit32(mask); | 299 Emit32(mask); |
297 EmitOrLink(on_not_equal); | 300 EmitOrLink(on_not_equal); |
298 } | 301 } |
299 | 302 |
300 | 303 |
301 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusAnd( | 304 void RegExpMacroAssemblerIrregexp::CheckNotCharacterAfterMinusAnd( |
302 uc16 c, | 305 uc16 c, |
303 uc16 minus, | 306 uc16 minus, |
304 uc16 mask, | 307 uc16 mask, |
305 Label* on_not_equal) { | 308 Label* on_not_equal) { |
306 Emit(BC_MINUS_AND_CHECK_NOT_CHAR); | 309 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c); |
307 Emit16(c); | |
308 Emit16(minus); | 310 Emit16(minus); |
309 Emit16(mask); | 311 Emit16(mask); |
310 EmitOrLink(on_not_equal); | 312 EmitOrLink(on_not_equal); |
311 } | 313 } |
312 | 314 |
313 | 315 |
314 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, | 316 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, |
315 Label* on_not_equal) { | 317 Label* on_not_equal) { |
316 Emit(BC_CHECK_NOT_BACK_REF); | 318 Emit(BC_CHECK_NOT_BACK_REF, start_reg); |
317 Emit(start_reg); | |
318 EmitOrLink(on_not_equal); | 319 EmitOrLink(on_not_equal); |
319 } | 320 } |
320 | 321 |
321 | 322 |
322 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase( | 323 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase( |
323 int start_reg, | 324 int start_reg, |
324 Label* on_not_equal) { | 325 Label* on_not_equal) { |
325 Emit(BC_CHECK_NOT_BACK_REF_NO_CASE); | 326 Emit(BC_CHECK_NOT_BACK_REF_NO_CASE, start_reg); |
326 Emit(start_reg); | |
327 EmitOrLink(on_not_equal); | 327 EmitOrLink(on_not_equal); |
328 } | 328 } |
329 | 329 |
330 | 330 |
331 void RegExpMacroAssemblerIrregexp::CheckNotRegistersEqual(int reg1, | 331 void RegExpMacroAssemblerIrregexp::CheckNotRegistersEqual(int reg1, |
332 int reg2, | 332 int reg2, |
333 Label* on_not_equal) { | 333 Label* on_not_equal) { |
334 Emit(BC_CHECK_NOT_REGS_EQUAL); | 334 Emit(BC_CHECK_NOT_REGS_EQUAL, reg1); |
335 Emit(reg1); | 335 Emit32(reg2); |
336 Emit(reg2); | |
337 EmitOrLink(on_not_equal); | 336 EmitOrLink(on_not_equal); |
338 } | 337 } |
339 | 338 |
340 | 339 |
341 void RegExpMacroAssemblerIrregexp::CheckBitmap(uc16 start, | 340 void RegExpMacroAssemblerIrregexp::CheckBitmap(uc16 start, |
342 Label* bitmap, | 341 Label* bitmap, |
343 Label* on_zero) { | 342 Label* on_zero) { |
344 UNIMPLEMENTED(); | 343 UNIMPLEMENTED(); |
345 } | 344 } |
346 | 345 |
(...skipping 24 matching lines...) Expand all Loading... |
371 | 370 |
372 void RegExpMacroAssemblerIrregexp::CheckCharacters( | 371 void RegExpMacroAssemblerIrregexp::CheckCharacters( |
373 Vector<const uc16> str, | 372 Vector<const uc16> str, |
374 int cp_offset, | 373 int cp_offset, |
375 Label* on_failure, | 374 Label* on_failure, |
376 bool check_end_of_string) { | 375 bool check_end_of_string) { |
377 // It is vital that this loop is backwards due to the unchecked character | 376 // It is vital that this loop is backwards due to the unchecked character |
378 // load below. | 377 // load below. |
379 for (int i = str.length() - 1; i >= 0; i--) { | 378 for (int i = str.length() - 1; i >= 0; i--) { |
380 if (check_end_of_string && i == str.length() - 1) { | 379 if (check_end_of_string && i == str.length() - 1) { |
381 Emit(BC_LOAD_CURRENT_CHAR); | 380 Emit(BC_LOAD_CURRENT_CHAR, cp_offset + i); |
382 Emit32(cp_offset + i); | |
383 EmitOrLink(on_failure); | 381 EmitOrLink(on_failure); |
384 } else { | 382 } else { |
385 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED); | 383 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED, cp_offset + i); |
386 Emit32(cp_offset + i); | |
387 } | 384 } |
388 Emit(BC_CHECK_NOT_CHAR); | 385 Emit(BC_CHECK_NOT_CHAR, str[i]); |
389 Emit32(str[i]); | |
390 EmitOrLink(on_failure); | 386 EmitOrLink(on_failure); |
391 } | 387 } |
392 } | 388 } |
393 | 389 |
394 | 390 |
395 void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, | 391 void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, |
396 int comparand, | 392 int comparand, |
397 Label* on_less_than) { | 393 Label* on_less_than) { |
398 ASSERT(comparand >= 0 && comparand <= 65535); | 394 ASSERT(comparand >= 0 && comparand <= 65535); |
399 Emit(BC_CHECK_REGISTER_LT); | 395 Emit(BC_CHECK_REGISTER_LT, register_index); |
400 Emit(register_index); | 396 Emit32(comparand); |
401 Emit16(comparand); | |
402 EmitOrLink(on_less_than); | 397 EmitOrLink(on_less_than); |
403 } | 398 } |
404 | 399 |
405 | 400 |
406 void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index, | 401 void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index, |
407 int comparand, | 402 int comparand, |
408 Label* on_greater_or_equal) { | 403 Label* on_greater_or_equal) { |
409 ASSERT(comparand >= 0 && comparand <= 65535); | 404 ASSERT(comparand >= 0 && comparand <= 65535); |
410 Emit(BC_CHECK_REGISTER_GE); | 405 Emit(BC_CHECK_REGISTER_GE, register_index); |
411 Emit(register_index); | 406 Emit32(comparand); |
412 Emit16(comparand); | |
413 EmitOrLink(on_greater_or_equal); | 407 EmitOrLink(on_greater_or_equal); |
414 } | 408 } |
415 | 409 |
416 | 410 |
417 void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(int register_index, | 411 void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(int register_index, |
418 Label* on_eq) { | 412 Label* on_eq) { |
419 Emit(BC_CHECK_REGISTER_EQ_POS); | 413 Emit(BC_CHECK_REGISTER_EQ_POS, register_index); |
420 Emit(register_index); | |
421 EmitOrLink(on_eq); | 414 EmitOrLink(on_eq); |
422 } | 415 } |
423 | 416 |
424 | 417 |
425 Handle<Object> RegExpMacroAssemblerIrregexp::GetCode(Handle<String> source) { | 418 Handle<Object> RegExpMacroAssemblerIrregexp::GetCode(Handle<String> source) { |
426 Bind(&backtrack_); | 419 Bind(&backtrack_); |
427 Emit(BC_POP_BT); | 420 Emit(BC_POP_BT, 0); |
428 Handle<ByteArray> array = Factory::NewByteArray(length()); | 421 Handle<ByteArray> array = Factory::NewByteArray(length()); |
429 Copy(array->GetDataStartAddress()); | 422 Copy(array->GetDataStartAddress()); |
430 return array; | 423 return array; |
431 } | 424 } |
432 | 425 |
433 | 426 |
434 int RegExpMacroAssemblerIrregexp::length() { | 427 int RegExpMacroAssemblerIrregexp::length() { |
435 return pc_; | 428 return pc_; |
436 } | 429 } |
437 | 430 |
438 | 431 |
439 void RegExpMacroAssemblerIrregexp::Copy(Address a) { | 432 void RegExpMacroAssemblerIrregexp::Copy(Address a) { |
440 memcpy(a, buffer_.start(), length()); | 433 memcpy(a, buffer_.start(), length()); |
441 } | 434 } |
442 | 435 |
443 | 436 |
444 void RegExpMacroAssemblerIrregexp::Expand() { | 437 void RegExpMacroAssemblerIrregexp::Expand() { |
445 bool old_buffer_was_our_own = own_buffer_; | 438 bool old_buffer_was_our_own = own_buffer_; |
446 Vector<byte> old_buffer = buffer_; | 439 Vector<byte> old_buffer = buffer_; |
447 buffer_ = Vector<byte>::New(old_buffer.length() * 2); | 440 buffer_ = Vector<byte>::New(old_buffer.length() * 2); |
448 own_buffer_ = true; | 441 own_buffer_ = true; |
449 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); | 442 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); |
450 if (old_buffer_was_our_own) { | 443 if (old_buffer_was_our_own) { |
451 old_buffer.Dispose(); | 444 old_buffer.Dispose(); |
452 } | 445 } |
453 } | 446 } |
454 | 447 |
455 | 448 |
456 } } // namespace v8::internal | 449 } } // namespace v8::internal |
OLD | NEW |