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 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2439 } | 2439 } |
2440 | 2440 |
2441 // Simple indexOf that never bails out. For short patterns only. | 2441 // Simple indexOf that never bails out. For short patterns only. |
2442 template <typename pchar, typename schar> | 2442 template <typename pchar, typename schar> |
2443 static int SimpleIndexOf(Vector<const schar> subject, | 2443 static int SimpleIndexOf(Vector<const schar> subject, |
2444 Vector<const pchar> pattern, | 2444 Vector<const pchar> pattern, |
2445 int idx) { | 2445 int idx) { |
2446 pchar pattern_first_char = pattern[0]; | 2446 pchar pattern_first_char = pattern[0]; |
2447 for (int i = idx, n = subject.length() - pattern.length(); i <= n; i++) { | 2447 for (int i = idx, n = subject.length() - pattern.length(); i <= n; i++) { |
2448 if (sizeof(schar) == 1 && sizeof(pchar) == 1) { | 2448 if (sizeof(schar) == 1 && sizeof(pchar) == 1) { |
2449 schar* pos = reinterpret_cast<schar*>(memchr(subject.start() + i, | 2449 const schar* pos = reinterpret_cast<const schar*>( |
2450 pattern_first_char, | 2450 memchr(subject.start() + i, |
2451 n - i + 1)); | 2451 pattern_first_char, |
| 2452 n - i + 1)); |
2452 if (pos == NULL) return -1; | 2453 if (pos == NULL) return -1; |
2453 i = pos - subject.start(); | 2454 i = pos - subject.start(); |
2454 } else { | 2455 } else { |
2455 if (subject[i] != pattern_first_char) continue; | 2456 if (subject[i] != pattern_first_char) continue; |
2456 } | 2457 } |
2457 int j = 1; | 2458 int j = 1; |
2458 do { | 2459 do { |
2459 if (pattern[j] != subject[i+j]) { | 2460 if (pattern[j] != subject[i+j]) { |
2460 break; | 2461 break; |
2461 } | 2462 } |
(...skipping 6939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9401 } else { | 9402 } else { |
9402 // Handle last resort GC and make sure to allow future allocations | 9403 // Handle last resort GC and make sure to allow future allocations |
9403 // to grow the heap without causing GCs (if possible). | 9404 // to grow the heap without causing GCs (if possible). |
9404 Counters::gc_last_resort_from_js.Increment(); | 9405 Counters::gc_last_resort_from_js.Increment(); |
9405 Heap::CollectAllGarbage(false); | 9406 Heap::CollectAllGarbage(false); |
9406 } | 9407 } |
9407 } | 9408 } |
9408 | 9409 |
9409 | 9410 |
9410 } } // namespace v8::internal | 9411 } } // namespace v8::internal |
OLD | NEW |