| 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 3358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3369 } | 3369 } |
| 3370 | 3370 |
| 3371 // Guessing the number of parts that the final result string is built | 3371 // Guessing the number of parts that the final result string is built |
| 3372 // from. Global regexps can match any number of times, so we guess | 3372 // from. Global regexps can match any number of times, so we guess |
| 3373 // conservatively. | 3373 // conservatively. |
| 3374 int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1; | 3374 int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1; |
| 3375 ReplacementStringBuilder builder(isolate->heap(), | 3375 ReplacementStringBuilder builder(isolate->heap(), |
| 3376 subject, | 3376 subject, |
| 3377 expected_parts); | 3377 expected_parts); |
| 3378 | 3378 |
| 3379 // Number of parts added by compiled replacement plus preceeding | 3379 // Number of parts added by compiled replacement plus preceding |
| 3380 // string and possibly suffix after last match. It is possible for | 3380 // string and possibly suffix after last match. It is possible for |
| 3381 // all components to use two elements when encoded as two smis. | 3381 // all components to use two elements when encoded as two smis. |
| 3382 const int parts_added_per_loop = 2 * (compiled_replacement.parts() + 2); | 3382 const int parts_added_per_loop = 2 * (compiled_replacement.parts() + 2); |
| 3383 | 3383 |
| 3384 int prev = 0; | 3384 int prev = 0; |
| 3385 | 3385 |
| 3386 do { | 3386 do { |
| 3387 builder.EnsureCapacity(parts_added_per_loop); | 3387 builder.EnsureCapacity(parts_added_per_loop); |
| 3388 | 3388 |
| 3389 int start = current_match[0]; | 3389 int start = current_match[0]; |
| (...skipping 9979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13369 // Handle last resort GC and make sure to allow future allocations | 13369 // Handle last resort GC and make sure to allow future allocations |
| 13370 // to grow the heap without causing GCs (if possible). | 13370 // to grow the heap without causing GCs (if possible). |
| 13371 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13371 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13372 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13372 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13373 "Runtime::PerformGC"); | 13373 "Runtime::PerformGC"); |
| 13374 } | 13374 } |
| 13375 } | 13375 } |
| 13376 | 13376 |
| 13377 | 13377 |
| 13378 } } // namespace v8::internal | 13378 } } // namespace v8::internal |
| OLD | NEW |