OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 if (match.is_null()) { | 2606 if (match.is_null()) { |
2607 return Failure::Exception(); | 2607 return Failure::Exception(); |
2608 } | 2608 } |
2609 if (match->IsNull()) { | 2609 if (match->IsNull()) { |
2610 return *subject_handle; | 2610 return *subject_handle; |
2611 } | 2611 } |
2612 | 2612 |
2613 int capture_count = regexp_handle->CaptureCount(); | 2613 int capture_count = regexp_handle->CaptureCount(); |
2614 | 2614 |
2615 // CompiledReplacement uses zone allocation. | 2615 // CompiledReplacement uses zone allocation. |
2616 CompilationZoneScope zone(DELETE_ON_EXIT); | 2616 CompilationZoneScope zone(isolate, DELETE_ON_EXIT); |
2617 CompiledReplacement compiled_replacement; | 2617 CompiledReplacement compiled_replacement; |
2618 compiled_replacement.Compile(replacement_handle, | 2618 compiled_replacement.Compile(replacement_handle, |
2619 capture_count, | 2619 capture_count, |
2620 length); | 2620 length); |
2621 | 2621 |
2622 bool is_global = regexp_handle->GetFlags().is_global(); | 2622 bool is_global = regexp_handle->GetFlags().is_global(); |
2623 | 2623 |
2624 // Guessing the number of parts that the final result string is built | 2624 // Guessing the number of parts that the final result string is built |
2625 // from. Global regexps can match any number of times, so we guess | 2625 // from. Global regexps can match any number of times, so we guess |
2626 // conservatively. | 2626 // conservatively. |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3120 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); | 3120 Handle<Object> match = RegExpImpl::Exec(regexp, subject, 0, regexp_info); |
3121 | 3121 |
3122 if (match.is_null()) { | 3122 if (match.is_null()) { |
3123 return Failure::Exception(); | 3123 return Failure::Exception(); |
3124 } | 3124 } |
3125 if (match->IsNull()) { | 3125 if (match->IsNull()) { |
3126 return isolate->heap()->null_value(); | 3126 return isolate->heap()->null_value(); |
3127 } | 3127 } |
3128 int length = subject->length(); | 3128 int length = subject->length(); |
3129 | 3129 |
3130 CompilationZoneScope zone_space(DELETE_ON_EXIT); | 3130 CompilationZoneScope zone_space(isolate, DELETE_ON_EXIT); |
3131 ZoneList<int> offsets(8); | 3131 ZoneList<int> offsets(8); |
3132 do { | 3132 do { |
3133 int start; | 3133 int start; |
3134 int end; | 3134 int end; |
3135 { | 3135 { |
3136 AssertNoAllocation no_alloc; | 3136 AssertNoAllocation no_alloc; |
3137 FixedArray* elements = FixedArray::cast(regexp_info->elements()); | 3137 FixedArray* elements = FixedArray::cast(regexp_info->elements()); |
3138 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); | 3138 start = Smi::cast(elements->get(RegExpImpl::kFirstCapture))->value(); |
3139 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); | 3139 end = Smi::cast(elements->get(RegExpImpl::kFirstCapture + 1))->value(); |
3140 } | 3140 } |
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5594 RUNTIME_ASSERT(pattern_length > 0); | 5594 RUNTIME_ASSERT(pattern_length > 0); |
5595 | 5595 |
5596 // The limit can be very large (0xffffffffu), but since the pattern | 5596 // The limit can be very large (0xffffffffu), but since the pattern |
5597 // isn't empty, we can never create more parts than ~half the length | 5597 // isn't empty, we can never create more parts than ~half the length |
5598 // of the subject. | 5598 // of the subject. |
5599 | 5599 |
5600 if (!subject->IsFlat()) FlattenString(subject); | 5600 if (!subject->IsFlat()) FlattenString(subject); |
5601 | 5601 |
5602 static const int kMaxInitialListCapacity = 16; | 5602 static const int kMaxInitialListCapacity = 16; |
5603 | 5603 |
5604 ZoneScope scope(DELETE_ON_EXIT); | 5604 ZoneScope scope(isolate, DELETE_ON_EXIT); |
5605 | 5605 |
5606 // Find (up to limit) indices of separator and end-of-string in subject | 5606 // Find (up to limit) indices of separator and end-of-string in subject |
5607 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); | 5607 int initial_capacity = Min<uint32_t>(kMaxInitialListCapacity, limit); |
5608 ZoneList<int> indices(initial_capacity); | 5608 ZoneList<int> indices(initial_capacity); |
5609 if (!pattern->IsFlat()) FlattenString(pattern); | 5609 if (!pattern->IsFlat()) FlattenString(pattern); |
5610 | 5610 |
5611 // No allocation block. | 5611 // No allocation block. |
5612 { | 5612 { |
5613 AssertNoAllocation nogc; | 5613 AssertNoAllocation nogc; |
5614 if (subject->IsAsciiRepresentation()) { | 5614 if (subject->IsAsciiRepresentation()) { |
(...skipping 6601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12216 } else { | 12216 } else { |
12217 // Handle last resort GC and make sure to allow future allocations | 12217 // Handle last resort GC and make sure to allow future allocations |
12218 // to grow the heap without causing GCs (if possible). | 12218 // to grow the heap without causing GCs (if possible). |
12219 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12219 isolate->counters()->gc_last_resort_from_js()->Increment(); |
12220 isolate->heap()->CollectAllGarbage(false); | 12220 isolate->heap()->CollectAllGarbage(false); |
12221 } | 12221 } |
12222 } | 12222 } |
12223 | 12223 |
12224 | 12224 |
12225 } } // namespace v8::internal | 12225 } } // namespace v8::internal |
OLD | NEW |