Chromium Code Reviews| 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 2524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2535 template <typename schar> | 2535 template <typename schar> |
| 2536 static inline int SingleCharIndexOf(Vector<const schar> string, | 2536 static inline int SingleCharIndexOf(Vector<const schar> string, |
| 2537 schar pattern_char, | 2537 schar pattern_char, |
| 2538 int start_index) { | 2538 int start_index) { |
| 2539 if (sizeof(schar) == 1) { | 2539 if (sizeof(schar) == 1) { |
| 2540 const schar* pos = reinterpret_cast<const schar*>( | 2540 const schar* pos = reinterpret_cast<const schar*>( |
| 2541 memchr(string.start() + start_index, | 2541 memchr(string.start() + start_index, |
| 2542 pattern_char, | 2542 pattern_char, |
| 2543 string.length() - start_index)); | 2543 string.length() - start_index)); |
| 2544 if (pos == NULL) return -1; | 2544 if (pos == NULL) return -1; |
| 2545 return pos - string.start(); | 2545 return static_cast<int>(pos - string.start()); |
| 2546 } | 2546 } |
| 2547 for (int i = start_index, n = string.length(); i < n; i++) { | 2547 for (int i = start_index, n = string.length(); i < n; i++) { |
| 2548 if (pattern_char == string[i]) { | 2548 if (pattern_char == string[i]) { |
| 2549 return i; | 2549 return i; |
| 2550 } | 2550 } |
| 2551 } | 2551 } |
| 2552 return -1; | 2552 return -1; |
| 2553 } | 2553 } |
| 2554 | 2554 |
| 2555 | 2555 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2593 } | 2593 } |
| 2594 if (sizeof(schar) == 1 && sizeof(pchar) == 1) { | 2594 if (sizeof(schar) == 1 && sizeof(pchar) == 1) { |
| 2595 const schar* pos = reinterpret_cast<const schar*>( | 2595 const schar* pos = reinterpret_cast<const schar*>( |
| 2596 memchr(subject.start() + i, | 2596 memchr(subject.start() + i, |
| 2597 pattern_first_char, | 2597 pattern_first_char, |
| 2598 n - i + 1)); | 2598 n - i + 1)); |
| 2599 if (pos == NULL) { | 2599 if (pos == NULL) { |
| 2600 *complete = true; | 2600 *complete = true; |
| 2601 return -1; | 2601 return -1; |
| 2602 } | 2602 } |
| 2603 i = pos - subject.start(); | 2603 i = static_cast<int>(pos - subject.start()); |
| 2604 } else { | 2604 } else { |
| 2605 if (subject[i] != pattern_first_char) continue; | 2605 if (subject[i] != pattern_first_char) continue; |
| 2606 } | 2606 } |
| 2607 int j = 1; | 2607 int j = 1; |
| 2608 do { | 2608 do { |
| 2609 if (pattern[j] != subject[i+j]) { | 2609 if (pattern[j] != subject[i+j]) { |
| 2610 break; | 2610 break; |
| 2611 } | 2611 } |
| 2612 j++; | 2612 j++; |
| 2613 } while (j < pattern.length()); | 2613 } while (j < pattern.length()); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 2627 Vector<const pchar> pattern, | 2627 Vector<const pchar> pattern, |
| 2628 int idx) { | 2628 int idx) { |
| 2629 pchar pattern_first_char = pattern[0]; | 2629 pchar pattern_first_char = pattern[0]; |
| 2630 for (int i = idx, n = subject.length() - pattern.length(); i <= n; i++) { | 2630 for (int i = idx, n = subject.length() - pattern.length(); i <= n; i++) { |
| 2631 if (sizeof(schar) == 1 && sizeof(pchar) == 1) { | 2631 if (sizeof(schar) == 1 && sizeof(pchar) == 1) { |
| 2632 const schar* pos = reinterpret_cast<const schar*>( | 2632 const schar* pos = reinterpret_cast<const schar*>( |
| 2633 memchr(subject.start() + i, | 2633 memchr(subject.start() + i, |
| 2634 pattern_first_char, | 2634 pattern_first_char, |
| 2635 n - i + 1)); | 2635 n - i + 1)); |
| 2636 if (pos == NULL) return -1; | 2636 if (pos == NULL) return -1; |
| 2637 i = pos - subject.start(); | 2637 i = static_cast<int>(pos - subject.start()); |
| 2638 } else { | 2638 } else { |
| 2639 if (subject[i] != pattern_first_char) continue; | 2639 if (subject[i] != pattern_first_char) continue; |
| 2640 } | 2640 } |
| 2641 int j = 1; | 2641 int j = 1; |
| 2642 do { | 2642 do { |
| 2643 if (pattern[j] != subject[i+j]) { | 2643 if (pattern[j] != subject[i+j]) { |
| 2644 break; | 2644 break; |
| 2645 } | 2645 } |
| 2646 j++; | 2646 j++; |
| 2647 } while (j < pattern.length()); | 2647 } while (j < pattern.length()); |
| (...skipping 3711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6359 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | 6359 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, |
| 6360 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | 6360 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, |
| 6361 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | 6361 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, |
| 6362 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11}; | 6362 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11}; |
| 6363 | 6363 |
| 6364 | 6364 |
| 6365 // This function works for dates from 1970 to 2099. | 6365 // This function works for dates from 1970 to 2099. |
| 6366 static inline void DateYMDFromTimeAfter1970(int date, | 6366 static inline void DateYMDFromTimeAfter1970(int date, |
| 6367 int& year, int& month, int& day) { | 6367 int& year, int& month, int& day) { |
| 6368 #ifdef DEBUG | 6368 #ifdef DEBUG |
| 6369 int save_date = date; // Need this for ASSERT in the end. | 6369 int save_date = date; // Need this for ASSERT in the end. |
| 6370 #endif | 6370 #endif |
| 6371 | 6371 |
| 6372 year = 1970 + (4 * date + 2) / kDaysIn4Years; | 6372 year = 1970 + (4 * date + 2) / kDaysIn4Years; |
| 6373 date %= kDaysIn4Years; | 6373 date %= kDaysIn4Years; |
| 6374 | 6374 |
| 6375 month = kMonthInYear[date]; | 6375 month = kMonthInYear[date]; |
| 6376 day = kDayInYear[date]; | 6376 day = kDayInYear[date]; |
| 6377 | 6377 |
| 6378 ASSERT(MakeDay(year, month, day) == save_date); | 6378 ASSERT(MakeDay(year, month, day) == save_date); |
| 6379 } | 6379 } |
| 6380 | 6380 |
| 6381 | 6381 |
| 6382 static inline void DateYMDFromTimeSlow(int date, | 6382 static inline void DateYMDFromTimeSlow(int date, |
| 6383 int& year, int& month, int& day) { | 6383 int& year, int& month, int& day) { |
| 6384 #ifdef DEBUG | 6384 #ifdef DEBUG |
| 6385 int save_date = date; // Need this for ASSERT in the end. | 6385 int save_date = date; // Need this for ASSErRT in the end. |
|
Søren Thygesen Gjesse
2010/04/13 11:35:37
???
Lasse Reichstein
2010/04/13 11:52:44
Fixed.
| |
| 6386 #endif | 6386 #endif |
| 6387 | 6387 |
| 6388 date += kDaysOffset; | 6388 date += kDaysOffset; |
| 6389 year = 400 * (date / kDaysIn400Years) - kYearsOffset; | 6389 year = 400 * (date / kDaysIn400Years) - kYearsOffset; |
| 6390 date %= kDaysIn400Years; | 6390 date %= kDaysIn400Years; |
| 6391 | 6391 |
| 6392 ASSERT(MakeDay(year, 0, 1) + date == save_date); | 6392 ASSERT(MakeDay(year, 0, 1) + date == save_date); |
| 6393 | 6393 |
| 6394 date--; | 6394 date--; |
| 6395 int yd1 = date / kDaysIn100Years; | 6395 int yd1 = date / kDaysIn100Years; |
| (...skipping 3376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9772 Handle<Code> code(function->code()); | 9772 Handle<Code> code(function->code()); |
| 9773 | 9773 |
| 9774 RelocIterator it(*code, 1 << RelocInfo::STATEMENT_POSITION); | 9774 RelocIterator it(*code, 1 << RelocInfo::STATEMENT_POSITION); |
| 9775 int closest_pc = 0; | 9775 int closest_pc = 0; |
| 9776 int distance = kMaxInt; | 9776 int distance = kMaxInt; |
| 9777 while (!it.done()) { | 9777 while (!it.done()) { |
| 9778 int statement_position = static_cast<int>(it.rinfo()->data()); | 9778 int statement_position = static_cast<int>(it.rinfo()->data()); |
| 9779 // Check if this break point is closer that what was previously found. | 9779 // Check if this break point is closer that what was previously found. |
| 9780 if (source_position <= statement_position && | 9780 if (source_position <= statement_position && |
| 9781 statement_position - source_position < distance) { | 9781 statement_position - source_position < distance) { |
| 9782 closest_pc = it.rinfo()->pc() - code->instruction_start(); | 9782 closest_pc = |
| 9783 static_cast<int>(it.rinfo()->pc() - code->instruction_start()); | |
| 9783 distance = statement_position - source_position; | 9784 distance = statement_position - source_position; |
| 9784 // Check whether we can't get any closer. | 9785 // Check whether we can't get any closer. |
| 9785 if (distance == 0) break; | 9786 if (distance == 0) break; |
| 9786 } | 9787 } |
| 9787 it.next(); | 9788 it.next(); |
| 9788 } | 9789 } |
| 9789 | 9790 |
| 9790 return Smi::FromInt(closest_pc); | 9791 return Smi::FromInt(closest_pc); |
| 9791 } | 9792 } |
| 9792 | 9793 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10098 } else { | 10099 } else { |
| 10099 // Handle last resort GC and make sure to allow future allocations | 10100 // Handle last resort GC and make sure to allow future allocations |
| 10100 // to grow the heap without causing GCs (if possible). | 10101 // to grow the heap without causing GCs (if possible). |
| 10101 Counters::gc_last_resort_from_js.Increment(); | 10102 Counters::gc_last_resort_from_js.Increment(); |
| 10102 Heap::CollectAllGarbage(false); | 10103 Heap::CollectAllGarbage(false); |
| 10103 } | 10104 } |
| 10104 } | 10105 } |
| 10105 | 10106 |
| 10106 | 10107 |
| 10107 } } // namespace v8::internal | 10108 } } // namespace v8::internal |
| OLD | NEW |