| 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 5741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5752 ASSERT(limit > 0); | 5752 ASSERT(limit > 0); |
| 5753 // Collect indices of pattern in subject using memchr. | 5753 // Collect indices of pattern in subject using memchr. |
| 5754 // Stop after finding at most limit values. | 5754 // Stop after finding at most limit values. |
| 5755 const char* subject_start = reinterpret_cast<const char*>(subject.start()); | 5755 const char* subject_start = reinterpret_cast<const char*>(subject.start()); |
| 5756 const char* subject_end = subject_start + subject.length(); | 5756 const char* subject_end = subject_start + subject.length(); |
| 5757 const char* pos = subject_start; | 5757 const char* pos = subject_start; |
| 5758 while (limit > 0) { | 5758 while (limit > 0) { |
| 5759 pos = reinterpret_cast<const char*>( | 5759 pos = reinterpret_cast<const char*>( |
| 5760 memchr(pos, pattern, subject_end - pos)); | 5760 memchr(pos, pattern, subject_end - pos)); |
| 5761 if (pos == NULL) return; | 5761 if (pos == NULL) return; |
| 5762 indices->Add(pos - subject_start); | 5762 indices->Add(static_cast<int>(pos - subject_start)); |
| 5763 pos++; | 5763 pos++; |
| 5764 limit--; | 5764 limit--; |
| 5765 } | 5765 } |
| 5766 } | 5766 } |
| 5767 | 5767 |
| 5768 | 5768 |
| 5769 template <typename SubjectChar, typename PatternChar> | 5769 template <typename SubjectChar, typename PatternChar> |
| 5770 void FindStringIndices(Isolate* isolate, | 5770 void FindStringIndices(Isolate* isolate, |
| 5771 Vector<const SubjectChar> subject, | 5771 Vector<const SubjectChar> subject, |
| 5772 Vector<const PatternChar> pattern, | 5772 Vector<const PatternChar> pattern, |
| (...skipping 6827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12600 } else { | 12600 } else { |
| 12601 // Handle last resort GC and make sure to allow future allocations | 12601 // Handle last resort GC and make sure to allow future allocations |
| 12602 // to grow the heap without causing GCs (if possible). | 12602 // to grow the heap without causing GCs (if possible). |
| 12603 isolate->counters()->gc_last_resort_from_js()->Increment(); | 12603 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 12604 isolate->heap()->CollectAllGarbage(false); | 12604 isolate->heap()->CollectAllGarbage(false); |
| 12605 } | 12605 } |
| 12606 } | 12606 } |
| 12607 | 12607 |
| 12608 | 12608 |
| 12609 } } // namespace v8::internal | 12609 } } // namespace v8::internal |
| OLD | NEW |