| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 if (rc) { | 509 if (rc) { |
| 510 // Capture values are relative to start_offset only. | 510 // Capture values are relative to start_offset only. |
| 511 for (int i = 0; i < offsets_vector_length; i++) { | 511 for (int i = 0; i < offsets_vector_length; i++) { |
| 512 if (offsets_vector[i] >= 0) { | 512 if (offsets_vector[i] >= 0) { |
| 513 offsets_vector[i] += previous_index; | 513 offsets_vector[i] += previous_index; |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 } | 516 } |
| 517 break; | 517 break; |
| 518 } | 518 } |
| 519 default: | |
| 520 case RegExpMacroAssembler::kARMImplementation: | |
| 521 UNREACHABLE(); | |
| 522 rc = false; | |
| 523 break; | |
| 524 case RegExpMacroAssembler::kBytecodeImplementation: { | 519 case RegExpMacroAssembler::kBytecodeImplementation: { |
| 525 Handle<ByteArray> byte_codes = IrregexpCode(regexp); | 520 Handle<ByteArray> byte_codes = IrregexpCode(regexp); |
| 526 | 521 |
| 527 rc = IrregexpInterpreter::Match(byte_codes, | 522 rc = IrregexpInterpreter::Match(byte_codes, |
| 528 two_byte_subject, | 523 two_byte_subject, |
| 529 offsets_vector, | 524 offsets_vector, |
| 530 previous_index); | 525 previous_index); |
| 531 break; | 526 break; |
| 532 } | 527 } |
| 528 case RegExpMacroAssembler::kARMImplementation: |
| 529 default: |
| 530 UNREACHABLE(); |
| 531 rc = false; |
| 532 break; |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 | 535 |
| 536 if (!rc) { | 536 if (!rc) { |
| 537 return Factory::null_value(); | 537 return Factory::null_value(); |
| 538 } | 538 } |
| 539 | 539 |
| 540 Handle<FixedArray> array = Factory::NewFixedArray(2 * (num_captures+1)); | 540 Handle<FixedArray> array = Factory::NewFixedArray(2 * (num_captures+1)); |
| 541 // The captures come in (start, end+1) pairs. | 541 // The captures come in (start, end+1) pairs. |
| 542 for (int i = 0; i < 2 * (num_captures+1); i += 2) { | 542 for (int i = 0; i < 2 * (num_captures+1); i += 2) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 for (int i = 0; i < 2 * (num_captures+1); i += 2) { | 593 for (int i = 0; i < 2 * (num_captures+1); i += 2) { |
| 594 array->set(i, Smi::FromInt(offsets_vector[i])); | 594 array->set(i, Smi::FromInt(offsets_vector[i])); |
| 595 array->set(i+1, Smi::FromInt(offsets_vector[i+1])); | 595 array->set(i+1, Smi::FromInt(offsets_vector[i+1])); |
| 596 } | 596 } |
| 597 return Factory::NewJSArrayWithElements(array); | 597 return Factory::NewJSArrayWithElements(array); |
| 598 } | 598 } |
| 599 | 599 |
| 600 | 600 |
| 601 class OffsetsVector { | 601 class OffsetsVector { |
| 602 public: | 602 public: |
| 603 inline OffsetsVector(int num_registers) : | 603 inline OffsetsVector(int num_registers) |
| 604 offsets_vector_length_(num_registers) { | 604 : offsets_vector_length_(num_registers) { |
| 605 if (offsets_vector_length_ > kStaticOffsetsVectorSize) { | 605 if (offsets_vector_length_ > kStaticOffsetsVectorSize) { |
| 606 vector_ = NewArray<int>(offsets_vector_length_); | 606 vector_ = NewArray<int>(offsets_vector_length_); |
| 607 } else { | 607 } else { |
| 608 vector_ = static_offsets_vector_; | 608 vector_ = static_offsets_vector_; |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 | 612 |
| 613 inline ~OffsetsVector() { | 613 inline ~OffsetsVector() { |
| 614 if (offsets_vector_length_ > kStaticOffsetsVectorSize) { | 614 if (offsets_vector_length_ > kStaticOffsetsVectorSize) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 633 static const int kStaticOffsetsVectorSize = 50; | 633 static const int kStaticOffsetsVectorSize = 50; |
| 634 static int static_offsets_vector_[kStaticOffsetsVectorSize]; | 634 static int static_offsets_vector_[kStaticOffsetsVectorSize]; |
| 635 }; | 635 }; |
| 636 | 636 |
| 637 | 637 |
| 638 int OffsetsVector::static_offsets_vector_[ | 638 int OffsetsVector::static_offsets_vector_[ |
| 639 OffsetsVector::kStaticOffsetsVectorSize]; | 639 OffsetsVector::kStaticOffsetsVectorSize]; |
| 640 | 640 |
| 641 | 641 |
| 642 Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> regexp, | 642 Handle<Object> RegExpImpl::IrregexpExec(Handle<JSRegExp> regexp, |
| 643 Handle<String> subject, | 643 Handle<String> subject, |
| 644 Handle<Object> index) { | 644 Handle<Object> index) { |
| 645 ASSERT_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP); | 645 ASSERT_EQ(regexp->TypeTag(), JSRegExp::IRREGEXP); |
| 646 ASSERT(!regexp->DataAt(JSRegExp::kIrregexpDataIndex)->IsUndefined()); | 646 ASSERT(!regexp->DataAt(JSRegExp::kIrregexpDataIndex)->IsUndefined()); |
| 647 | 647 |
| 648 // Prepare space for the return values. | 648 // Prepare space for the return values. |
| 649 int number_of_registers = IrregexpNumberOfRegisters(regexp); | 649 int number_of_registers = IrregexpNumberOfRegisters(regexp); |
| 650 OffsetsVector offsets(number_of_registers); | 650 OffsetsVector offsets(number_of_registers); |
| 651 | 651 |
| 652 int num_captures = IrregexpNumberOfCaptures(regexp); | 652 int num_captures = IrregexpNumberOfCaptures(regexp); |
| 653 | 653 |
| 654 int previous_index = static_cast<int>(DoubleToInteger(index->Number())); | 654 int previous_index = static_cast<int>(DoubleToInteger(index->Number())); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 if (matches->IsNull()) { // Exited loop normally. | 797 if (matches->IsNull()) { // Exited loop normally. |
| 798 return result; | 798 return result; |
| 799 } else { // Exited loop with the exception in matches. | 799 } else { // Exited loop with the exception in matches. |
| 800 return matches; | 800 return matches; |
| 801 } | 801 } |
| 802 } | 802 } |
| 803 | 803 |
| 804 | 804 |
| 805 int RegExpImpl::JscreNumberOfCaptures(Handle<JSRegExp> re) { | 805 int RegExpImpl::JscreNumberOfCaptures(Handle<JSRegExp> re) { |
| 806 FixedArray* value = FixedArray::cast(re->DataAt(JSRegExp::kJscreDataIndex)); | 806 FixedArray* value = FixedArray::cast(re->DataAt(JSRegExp::kJscreDataIndex)); |
| 807 return Smi::cast(value->get(kJscreNumberOfCapturesIndex))-> | 807 return Smi::cast(value->get(kJscreNumberOfCapturesIndex))-> value(); |
| 808 value(); | |
| 809 } | 808 } |
| 810 | 809 |
| 811 | 810 |
| 812 ByteArray* RegExpImpl::JscreInternal(Handle<JSRegExp> re) { | 811 ByteArray* RegExpImpl::JscreInternal(Handle<JSRegExp> re) { |
| 813 FixedArray* value = FixedArray::cast(re->DataAt(JSRegExp::kJscreDataIndex)); | 812 FixedArray* value = FixedArray::cast(re->DataAt(JSRegExp::kJscreDataIndex)); |
| 814 return ByteArray::cast(value->get(kJscreInternalIndex)); | 813 return ByteArray::cast(value->get(kJscreInternalIndex)); |
| 815 } | 814 } |
| 816 | 815 |
| 817 | 816 |
| 818 int RegExpImpl::IrregexpNumberOfCaptures(Handle<JSRegExp> re) { | 817 int RegExpImpl::IrregexpNumberOfCaptures(Handle<JSRegExp> re) { |
| (...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2595 byte codes[1024]; | 2594 byte codes[1024]; |
| 2596 IrregexpAssembler assembler(Vector<byte>(codes, 1024)); | 2595 IrregexpAssembler assembler(Vector<byte>(codes, 1024)); |
| 2597 RegExpMacroAssemblerIrregexp macro_assembler(&assembler); | 2596 RegExpMacroAssemblerIrregexp macro_assembler(&assembler); |
| 2598 return compiler.Assemble(¯o_assembler, | 2597 return compiler.Assemble(¯o_assembler, |
| 2599 node, | 2598 node, |
| 2600 input->capture_count); | 2599 input->capture_count); |
| 2601 } | 2600 } |
| 2602 | 2601 |
| 2603 | 2602 |
| 2604 }} // namespace v8::internal | 2603 }} // namespace v8::internal |
| OLD | NEW |