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 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 // Guessing the number of parts that the final result string is built | 1743 // Guessing the number of parts that the final result string is built |
1744 // from. Global regexps can match any number of times, so we guess | 1744 // from. Global regexps can match any number of times, so we guess |
1745 // conservatively. | 1745 // conservatively. |
1746 int expected_parts = | 1746 int expected_parts = |
1747 (compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1; | 1747 (compiled_replacement.parts() + 1) * (is_global ? 4 : 1) + 1; |
1748 ReplacementStringBuilder builder(subject_handle, expected_parts); | 1748 ReplacementStringBuilder builder(subject_handle, expected_parts); |
1749 | 1749 |
1750 // Index of end of last match. | 1750 // Index of end of last match. |
1751 int prev = 0; | 1751 int prev = 0; |
1752 | 1752 |
1753 // Number of parts added by compiled replacement plus preceeding string | 1753 // Number of parts added by compiled replacement plus preceeding |
1754 // and possibly suffix after last match. It is possible for compiled | 1754 // string and possibly suffix after last match. It is possible for |
1755 // replacements to use two elements when encoded as two smis. | 1755 // all components to use two elements when encoded as two smis. |
1756 const int parts_added_per_loop = compiled_replacement.parts() * 2 + 2; | 1756 const int parts_added_per_loop = 2 * (compiled_replacement.parts() + 2); |
1757 bool matched = true; | 1757 bool matched = true; |
1758 do { | 1758 do { |
1759 ASSERT(last_match_info_handle->HasFastElements()); | 1759 ASSERT(last_match_info_handle->HasFastElements()); |
1760 // Increase the capacity of the builder before entering local handle-scope, | 1760 // Increase the capacity of the builder before entering local handle-scope, |
1761 // so its internal buffer can safely allocate a new handle if it grows. | 1761 // so its internal buffer can safely allocate a new handle if it grows. |
1762 builder.EnsureCapacity(parts_added_per_loop); | 1762 builder.EnsureCapacity(parts_added_per_loop); |
1763 | 1763 |
1764 HandleScope loop_scope; | 1764 HandleScope loop_scope; |
1765 int start, end; | 1765 int start, end; |
1766 { | 1766 { |
(...skipping 6136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7903 } else { | 7903 } else { |
7904 // Handle last resort GC and make sure to allow future allocations | 7904 // Handle last resort GC and make sure to allow future allocations |
7905 // to grow the heap without causing GCs (if possible). | 7905 // to grow the heap without causing GCs (if possible). |
7906 Counters::gc_last_resort_from_js.Increment(); | 7906 Counters::gc_last_resort_from_js.Increment(); |
7907 Heap::CollectAllGarbage(false); | 7907 Heap::CollectAllGarbage(false); |
7908 } | 7908 } |
7909 } | 7909 } |
7910 | 7910 |
7911 | 7911 |
7912 } } // namespace v8::internal | 7912 } } // namespace v8::internal |
OLD | NEW |