| 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 3895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3906 | 3906 |
| 3907 int matches = indices.length(); | 3907 int matches = indices.length(); |
| 3908 if (matches == 0) return *subject; | 3908 if (matches == 0) return *subject; |
| 3909 | 3909 |
| 3910 // Detect integer overflow. | 3910 // Detect integer overflow. |
| 3911 int64_t result_len_64 = | 3911 int64_t result_len_64 = |
| 3912 (static_cast<int64_t>(replacement_len) - | 3912 (static_cast<int64_t>(replacement_len) - |
| 3913 static_cast<int64_t>(pattern_len)) * | 3913 static_cast<int64_t>(pattern_len)) * |
| 3914 static_cast<int64_t>(matches) + | 3914 static_cast<int64_t>(matches) + |
| 3915 static_cast<int64_t>(subject_len); | 3915 static_cast<int64_t>(subject_len); |
| 3916 if (result_len_64 > INT_MAX) return Failure::OutOfMemoryException(0x11); | 3916 if (result_len_64 > INT_MAX) { |
| 3917 v8::internal::Heap::FatalProcessOutOfMemory("invalid string length", true); |
| 3918 } |
| 3917 int result_len = static_cast<int>(result_len_64); | 3919 int result_len = static_cast<int>(result_len_64); |
| 3918 | 3920 |
| 3919 int subject_pos = 0; | 3921 int subject_pos = 0; |
| 3920 int result_pos = 0; | 3922 int result_pos = 0; |
| 3921 | 3923 |
| 3922 Handle<ResultSeqString> result; | 3924 Handle<ResultSeqString> result; |
| 3923 if (ResultSeqString::kHasAsciiEncoding) { | 3925 if (ResultSeqString::kHasAsciiEncoding) { |
| 3924 result = Handle<ResultSeqString>::cast( | 3926 result = Handle<ResultSeqString>::cast( |
| 3925 isolate->factory()->NewRawOneByteString(result_len)); | 3927 isolate->factory()->NewRawOneByteString(result_len)); |
| 3926 } else { | 3928 } else { |
| (...skipping 11133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15060 // Handle last resort GC and make sure to allow future allocations | 15062 // Handle last resort GC and make sure to allow future allocations |
| 15061 // to grow the heap without causing GCs (if possible). | 15063 // to grow the heap without causing GCs (if possible). |
| 15062 isolate->counters()->gc_last_resort_from_js()->Increment(); | 15064 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 15063 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 15065 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 15064 "Runtime::PerformGC"); | 15066 "Runtime::PerformGC"); |
| 15065 } | 15067 } |
| 15066 } | 15068 } |
| 15067 | 15069 |
| 15068 | 15070 |
| 15069 } } // namespace v8::internal | 15071 } } // namespace v8::internal |
| OLD | NEW |