OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 4712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4723 last_match_array, subject, capture_count, NULL); | 4723 last_match_array, subject, capture_count, NULL); |
4724 | 4724 |
4725 if (subject_length > kMinLengthToCache) { | 4725 if (subject_length > kMinLengthToCache) { |
4726 // Store the length of the result array into the last element of the | 4726 // Store the length of the result array into the last element of the |
4727 // backing FixedArray. | 4727 // backing FixedArray. |
4728 builder.EnsureCapacity(1); | 4728 builder.EnsureCapacity(1); |
4729 Handle<FixedArray> fixed_array = builder.array(); | 4729 Handle<FixedArray> fixed_array = builder.array(); |
4730 fixed_array->set(fixed_array->length() - 1, | 4730 fixed_array->set(fixed_array->length() - 1, |
4731 Smi::FromInt(builder.length())); | 4731 Smi::FromInt(builder.length())); |
4732 // Cache the result and turn the FixedArray into a COW array. | 4732 // Cache the result and turn the FixedArray into a COW array. |
4733 RegExpResultsCache::Enter(isolate, | 4733 RegExpResultsCache::Enter(isolate->heap(), |
4734 subject, | 4734 *subject, |
4735 handle(regexp->data(), isolate), | 4735 regexp->data(), |
4736 fixed_array, | 4736 *fixed_array, |
4737 RegExpResultsCache::REGEXP_MULTIPLE_INDICES); | 4737 RegExpResultsCache::REGEXP_MULTIPLE_INDICES); |
4738 } | 4738 } |
4739 return *builder.ToJSArray(result_array); | 4739 return *builder.ToJSArray(result_array); |
4740 } else { | 4740 } else { |
4741 return isolate->heap()->null_value(); // No matches at all. | 4741 return isolate->heap()->null_value(); // No matches at all. |
4742 } | 4742 } |
4743 } | 4743 } |
4744 | 4744 |
4745 | 4745 |
4746 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets | 4746 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets |
(...skipping 1996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6743 HandleScope local_loop_handle(isolate); | 6743 HandleScope local_loop_handle(isolate); |
6744 int part_end = indices.at(i); | 6744 int part_end = indices.at(i); |
6745 Handle<String> substring = | 6745 Handle<String> substring = |
6746 isolate->factory()->NewProperSubString(subject, part_start, part_end); | 6746 isolate->factory()->NewProperSubString(subject, part_start, part_end); |
6747 elements->set(i, *substring); | 6747 elements->set(i, *substring); |
6748 part_start = part_end + pattern_length; | 6748 part_start = part_end + pattern_length; |
6749 } | 6749 } |
6750 | 6750 |
6751 if (limit == 0xffffffffu) { | 6751 if (limit == 0xffffffffu) { |
6752 if (result->HasFastObjectElements()) { | 6752 if (result->HasFastObjectElements()) { |
6753 RegExpResultsCache::Enter(isolate, | 6753 RegExpResultsCache::Enter(isolate->heap(), |
6754 subject, | 6754 *subject, |
6755 pattern, | 6755 *pattern, |
6756 elements, | 6756 *elements, |
6757 RegExpResultsCache::STRING_SPLIT_SUBSTRINGS); | 6757 RegExpResultsCache::STRING_SPLIT_SUBSTRINGS); |
6758 } | 6758 } |
6759 } | 6759 } |
6760 | 6760 |
6761 return *result; | 6761 return *result; |
6762 } | 6762 } |
6763 | 6763 |
6764 | 6764 |
6765 // Copies ASCII characters to the given fixed array looking up | 6765 // Copies ASCII characters to the given fixed array looking up |
6766 // one-char strings in the cache. Gives up on the first char that is | 6766 // one-char strings in the cache. Gives up on the first char that is |
(...skipping 8318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15085 } | 15085 } |
15086 } | 15086 } |
15087 | 15087 |
15088 | 15088 |
15089 void Runtime::OutOfMemory() { | 15089 void Runtime::OutOfMemory() { |
15090 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15090 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15091 UNREACHABLE(); | 15091 UNREACHABLE(); |
15092 } | 15092 } |
15093 | 15093 |
15094 } } // namespace v8::internal | 15094 } } // namespace v8::internal |
OLD | NEW |