| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // internally. | 431 // internally. |
| 432 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; | 432 return (IrregexpNumberOfCaptures(FixedArray::cast(regexp->data())) + 1) * 2; |
| 433 #endif // V8_INTERPRETED_REGEXP | 433 #endif // V8_INTERPRETED_REGEXP |
| 434 } | 434 } |
| 435 | 435 |
| 436 | 436 |
| 437 RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce( | 437 RegExpImpl::IrregexpResult RegExpImpl::IrregexpExecOnce( |
| 438 Handle<JSRegExp> regexp, | 438 Handle<JSRegExp> regexp, |
| 439 Handle<String> subject, | 439 Handle<String> subject, |
| 440 int index, | 440 int index, |
| 441 Vector<int32_t> output) { | 441 Vector<int> output) { |
| 442 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data())); | 442 Handle<FixedArray> irregexp(FixedArray::cast(regexp->data())); |
| 443 | 443 |
| 444 ASSERT(index >= 0); | 444 ASSERT(index >= 0); |
| 445 ASSERT(index <= subject->length()); | 445 ASSERT(index <= subject->length()); |
| 446 ASSERT(subject->IsFlat()); | 446 ASSERT(subject->IsFlat()); |
| 447 | 447 |
| 448 // A flat ASCII string might have a two-byte first part. | 448 // A flat ASCII string might have a two-byte first part. |
| 449 if (subject->IsConsString()) { | 449 if (subject->IsConsString()) { |
| 450 subject = Handle<String>(ConsString::cast(*subject)->first()); | 450 subject = Handle<String>(ConsString::cast(*subject)->first()); |
| 451 } | 451 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); | 528 int required_registers = RegExpImpl::IrregexpPrepare(jsregexp, subject); |
| 529 if (required_registers < 0) { | 529 if (required_registers < 0) { |
| 530 // Compiling failed with an exception. | 530 // Compiling failed with an exception. |
| 531 ASSERT(Isolate::Current()->has_pending_exception()); | 531 ASSERT(Isolate::Current()->has_pending_exception()); |
| 532 return Handle<Object>::null(); | 532 return Handle<Object>::null(); |
| 533 } | 533 } |
| 534 | 534 |
| 535 OffsetsVector registers(required_registers); | 535 OffsetsVector registers(required_registers); |
| 536 | 536 |
| 537 IrregexpResult res = RegExpImpl::IrregexpExecOnce( | 537 IrregexpResult res = RegExpImpl::IrregexpExecOnce( |
| 538 jsregexp, subject, previous_index, Vector<int32_t>(registers.vector(), | 538 jsregexp, subject, previous_index, Vector<int>(registers.vector(), |
| 539 registers.length())); | 539 registers.length())); |
| 540 if (res == RE_SUCCESS) { | 540 if (res == RE_SUCCESS) { |
| 541 int capture_register_count = | 541 int capture_register_count = |
| 542 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; | 542 (IrregexpNumberOfCaptures(FixedArray::cast(jsregexp->data())) + 1) * 2; |
| 543 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); | 543 last_match_info->EnsureSize(capture_register_count + kLastMatchOverhead); |
| 544 AssertNoAllocation no_gc; | 544 AssertNoAllocation no_gc; |
| 545 int* register_vector = registers.vector(); | 545 int* register_vector = registers.vector(); |
| 546 FixedArray* array = FixedArray::cast(last_match_info->elements()); | 546 FixedArray* array = FixedArray::cast(last_match_info->elements()); |
| 547 for (int i = 0; i < capture_register_count; i += 2) { | 547 for (int i = 0; i < capture_register_count; i += 2) { |
| 548 SetCapture(array, i, register_vector[i]); | 548 SetCapture(array, i, register_vector[i]); |
| 549 SetCapture(array, i + 1, register_vector[i + 1]); | 549 SetCapture(array, i + 1, register_vector[i + 1]); |
| (...skipping 4802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5352 } | 5352 } |
| 5353 | 5353 |
| 5354 return compiler.Assemble(¯o_assembler, | 5354 return compiler.Assemble(¯o_assembler, |
| 5355 node, | 5355 node, |
| 5356 data->capture_count, | 5356 data->capture_count, |
| 5357 pattern); | 5357 pattern); |
| 5358 } | 5358 } |
| 5359 | 5359 |
| 5360 | 5360 |
| 5361 }} // namespace v8::internal | 5361 }} // namespace v8::internal |
| OLD | NEW |