Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: src/runtime.cc

Issue 42327: Spolling. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1772 } 1772 }
1773 return bad_char_occurrence[char_code]; 1773 return bad_char_occurrence[char_code];
1774 } 1774 }
1775 return bad_char_occurrence[char_code % kBMAlphabetSize]; 1775 return bad_char_occurrence[char_code % kBMAlphabetSize];
1776 } 1776 }
1777 1777
1778 // Restricted simplified Boyer-Moore string matching. 1778 // Restricted simplified Boyer-Moore string matching.
1779 // Uses only the bad-shift table of Boyer-Moore and only uses it 1779 // Uses only the bad-shift table of Boyer-Moore and only uses it
1780 // for the character compared to the last character of the needle. 1780 // for the character compared to the last character of the needle.
1781 template <typename schar, typename pchar> 1781 template <typename schar, typename pchar>
1782 static int BoyerMooreHorsepool(Vector<const schar> subject, 1782 static int BoyerMooreHorspool(Vector<const schar> subject,
1783 Vector<const pchar> pattern, 1783 Vector<const pchar> pattern,
1784 int start_index, 1784 int start_index,
1785 bool* complete) { 1785 bool* complete) {
1786 int n = subject.length(); 1786 int n = subject.length();
1787 int m = pattern.length(); 1787 int m = pattern.length();
1788 // Only preprocess at most kBMMaxShift last characters of pattern. 1788 // Only preprocess at most kBMMaxShift last characters of pattern.
1789 int start = m < kBMMaxShift ? 0 : m - kBMMaxShift; 1789 int start = m < kBMMaxShift ? 0 : m - kBMMaxShift;
1790 1790
1791 BoyerMoorePopulateBadCharTable(pattern, start); 1791 BoyerMoorePopulateBadCharTable(pattern, start);
1792 1792
1793 int badness = -m; // How bad we are doing without a good-suffix table. 1793 int badness = -m; // How bad we are doing without a good-suffix table.
1794 int idx; // No matches found prior to this index. 1794 int idx; // No matches found prior to this index.
1795 pchar last_char = pattern[m - 1]; 1795 pchar last_char = pattern[m - 1];
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 if (pat.length() < kBMMinPatternLength) { 1975 if (pat.length() < kBMMinPatternLength) {
1976 // We don't believe fancy searching can ever be more efficient. 1976 // We don't believe fancy searching can ever be more efficient.
1977 // The max shift of Boyer-Moore on a pattern of this length does 1977 // The max shift of Boyer-Moore on a pattern of this length does
1978 // not compensate for the overhead. 1978 // not compensate for the overhead.
1979 return SimpleIndexOf(sub, pat, start_index); 1979 return SimpleIndexOf(sub, pat, start_index);
1980 } 1980 }
1981 // Try algorithms in order of increasing setup cost and expected performance. 1981 // Try algorithms in order of increasing setup cost and expected performance.
1982 bool complete; 1982 bool complete;
1983 int idx = SimpleIndexOf(sub, pat, start_index, &complete); 1983 int idx = SimpleIndexOf(sub, pat, start_index, &complete);
1984 if (complete) return idx; 1984 if (complete) return idx;
1985 idx = BoyerMooreHorsepool(sub, pat, idx, &complete); 1985 idx = BoyerMooreHorspool(sub, pat, idx, &complete);
1986 if (complete) return idx; 1986 if (complete) return idx;
1987 return BoyerMooreIndexOf(sub, pat, idx); 1987 return BoyerMooreIndexOf(sub, pat, idx);
1988 } 1988 }
1989 1989
1990 // Perform string match of pattern on subject, starting at start index. 1990 // Perform string match of pattern on subject, starting at start index.
1991 // Caller must ensure that 0 <= start_index <= sub->length(), 1991 // Caller must ensure that 0 <= start_index <= sub->length(),
1992 // and should check that pat->length() + start_index <= sub->length() 1992 // and should check that pat->length() + start_index <= sub->length()
1993 int Runtime::StringMatch(Handle<String> sub, 1993 int Runtime::StringMatch(Handle<String> sub,
1994 Handle<String> pat, 1994 Handle<String> pat,
1995 int start_index) { 1995 int start_index) {
(...skipping 4644 matching lines...) Expand 10 before | Expand all | Expand 10 after
6640 } else { 6640 } else {
6641 // Handle last resort GC and make sure to allow future allocations 6641 // Handle last resort GC and make sure to allow future allocations
6642 // to grow the heap without causing GCs (if possible). 6642 // to grow the heap without causing GCs (if possible).
6643 Counters::gc_last_resort_from_js.Increment(); 6643 Counters::gc_last_resort_from_js.Increment();
6644 Heap::CollectAllGarbage(); 6644 Heap::CollectAllGarbage();
6645 } 6645 }
6646 } 6646 }
6647 6647
6648 6648
6649 } } // namespace v8::internal 6649 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698