OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // Byte-code regexp needs space allocated for all its registers. | 373 // Byte-code regexp needs space allocated for all its registers. |
374 return IrregexpNumberOfRegisters(FixedArray::cast(regexp->data())); | 374 return IrregexpNumberOfRegisters(FixedArray::cast(regexp->data())); |
375 #else // V8_INTERPRETED_REGEXP | 375 #else // V8_INTERPRETED_REGEXP |
376 // Native regexp only needs room to output captures. Registers are handled | 376 // Native regexp only needs room to output captures. Registers are handled |
377 // internally. | 377 // internally. |
378 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; | 378 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; |
379 #endif // V8_INTERPRETED_REGEXP | 379 #endif // V8_INTERPRETED_REGEXP |
380 } | 380 } |
381 | 381 |
382 | 382 |
383 RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce(Handle<JSRegExp> regexp, | 383 RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce( |
384 Handle<String> subject, | 384 Handle<JSRegExp> regexp, |
385 int index, | 385 Handle<String> subject, |
386 Vector<int> output) { | 386 int index, |
| 387 Vector<int32_t> output) { |
387 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data())); | 388 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data())); |
388 | 389 |
389 ASSERT(index >= 0); | 390 ASSERT(index >= 0); |
390 ASSERT(index <= subject->length()); | 391 ASSERT(index <= subject->length()); |
391 ASSERT(subject->IsFlat()); | 392 ASSERT(subject->IsFlat()); |
392 | 393 |
393 // A flat ASCII string might have a two-byte first part. | 394 // A flat ASCII string might have a two-byte first part. |
394 if (subject->IsConsString()) { | 395 if (subject->IsConsString()) { |
395 subject = Handle<String>(ConsString::cast(*subject)->first()); | 396 subject = Handle<String>(ConsString::cast(*subject)->first()); |
396 } | 397 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); | 473 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); |
473 if (required_registers < 0) { | 474 if (required_registers < 0) { |
474 // Compiling failed with an exception. | 475 // Compiling failed with an exception. |
475 ASSERT(Top::has_pending_exception()); | 476 ASSERT(Top::has_pending_exception()); |
476 return Handle<Object>::null(); | 477 return Handle<Object>::null(); |
477 } | 478 } |
478 | 479 |
479 OffsetsVector registers(required_registers); | 480 OffsetsVector registers(required_registers); |
480 | 481 |
481 IrregexpResult res = RegExpImpl::IrregexpExecOnce( | 482 IrregexpResult res = RegExpImpl::IrregexpExecOnce( |
482 jsregexp, subject, previous_index, Vector<int>(registers.vector(), | 483 jsregexp, subject, previous_index, Vector<int32_t>(registers.vector(), |
483 registers.length())); | 484 registers.length())); |
484 if (res == RE_SUCCESS) { | 485 if (res == RE_SUCCESS) { |
485 int capture_register_count = | 486 int capture_register_count = |
486 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; | 487 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; |
487 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); | 488 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); |
488 AssertNoAllocation no_gc; | 489 AssertNoAllocation no_gc; |
489 int* register_vector = registers.vector(); | 490 int* register_vector = registers.vector(); |
490 FixedArray* array = FixedArray::cast(last_match_info->elements()); | 491 FixedArray* array = FixedArray::cast(last_match_info->elements()); |
491 for (int i = 0; i < capture_register_count; i += 2) { | 492 for (int i = 0; i < capture_register_count; i += 2) { |
492 SetCapture(array, i, register_vector[i]); | 493 SetCapture(array, i, register_vector[i]); |
493 SetCapture(array, i + 1, register_vector[i + 1]); | 494 SetCapture(array, i + 1, register_vector[i + 1]); |
(...skipping 4745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5239 node, | 5240 node, |
5240 data->capture_count, | 5241 data->capture_count, |
5241 pattern); | 5242 pattern); |
5242 } | 5243 } |
5243 | 5244 |
5244 | 5245 |
5245 int OffsetsVector::static_offsets_vector_[ | 5246 int OffsetsVector::static_offsets_vector_[ |
5246 OffsetsVector::kStaticOffsetsVectorSize]; | 5247 OffsetsVector::kStaticOffsetsVectorSize]; |
5247 | 5248 |
5248 }} // namespace v8::internal | 5249 }} // namespace v8::internal |
OLD | NEW |