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

Side by Side Diff: src/jsregexp.cc

Issue 218403002: Fix Type::Intersect to allocate large enough union. Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | « src/hydrogen-instructions.cc ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 ranges->at(cut_index), 1900 ranges->at(cut_index),
1901 ranges->at(cut_index + 1) - 1, 1901 ranges->at(cut_index + 1) - 1,
1902 &dummy, 1902 &dummy,
1903 in_range_label, 1903 in_range_label,
1904 &dummy); 1904 &dummy);
1905 ASSERT(!dummy.is_linked()); 1905 ASSERT(!dummy.is_linked());
1906 // Cut out the single range by rewriting the array. This creates a new 1906 // Cut out the single range by rewriting the array. This creates a new
1907 // range that is a merger of the two ranges on either side of the one we 1907 // range that is a merger of the two ranges on either side of the one we
1908 // are cutting out. The oddity of the labels is preserved. 1908 // are cutting out. The oddity of the labels is preserved.
1909 for (int j = cut_index; j > start_index; j--) { 1909 for (int j = cut_index; j > start_index; j--) {
1910 ranges->at(j) = ranges->at(j - 1); 1910 ranges->Set(j, ranges->at(j - 1));
1911 } 1911 }
1912 for (int j = cut_index + 1; j < end_index; j++) { 1912 for (int j = cut_index + 1; j < end_index; j++) {
1913 ranges->at(j) = ranges->at(j + 1); 1913 ranges->Set(j, ranges->at(j + 1));
1914 } 1914 }
1915 } 1915 }
1916 1916
1917 1917
1918 // Unicode case. Split the search space into kSize spaces that are handled 1918 // Unicode case. Split the search space into kSize spaces that are handled
1919 // with recursion. 1919 // with recursion.
1920 static void SplitSearchSpace(ZoneList<int>* ranges, 1920 static void SplitSearchSpace(ZoneList<int>* ranges,
1921 int start_index, 1921 int start_index,
1922 int end_index, 1922 int end_index,
1923 int* new_start_index, 1923 int* new_start_index,
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
3628 3628
3629 void BoyerMoorePositionInfo::SetInterval(const Interval& interval) { 3629 void BoyerMoorePositionInfo::SetInterval(const Interval& interval) {
3630 s_ = AddRange(s_, kSpaceRanges, kSpaceRangeCount, interval); 3630 s_ = AddRange(s_, kSpaceRanges, kSpaceRangeCount, interval);
3631 w_ = AddRange(w_, kWordRanges, kWordRangeCount, interval); 3631 w_ = AddRange(w_, kWordRanges, kWordRangeCount, interval);
3632 d_ = AddRange(d_, kDigitRanges, kDigitRangeCount, interval); 3632 d_ = AddRange(d_, kDigitRanges, kDigitRangeCount, interval);
3633 surrogate_ = 3633 surrogate_ =
3634 AddRange(surrogate_, kSurrogateRanges, kSurrogateRangeCount, interval); 3634 AddRange(surrogate_, kSurrogateRanges, kSurrogateRangeCount, interval);
3635 if (interval.to() - interval.from() >= kMapSize - 1) { 3635 if (interval.to() - interval.from() >= kMapSize - 1) {
3636 if (map_count_ != kMapSize) { 3636 if (map_count_ != kMapSize) {
3637 map_count_ = kMapSize; 3637 map_count_ = kMapSize;
3638 for (int i = 0; i < kMapSize; i++) map_->at(i) = true; 3638 for (int i = 0; i < kMapSize; i++) map_->Set(i, true);
3639 } 3639 }
3640 return; 3640 return;
3641 } 3641 }
3642 for (int i = interval.from(); i <= interval.to(); i++) { 3642 for (int i = interval.from(); i <= interval.to(); i++) {
3643 int mod_character = (i & kMask); 3643 int mod_character = (i & kMask);
3644 if (!map_->at(mod_character)) { 3644 if (!map_->at(mod_character)) {
3645 map_count_++; 3645 map_count_++;
3646 map_->at(mod_character) = true; 3646 map_->Set(mod_character, true);
3647 } 3647 }
3648 if (map_count_ == kMapSize) return; 3648 if (map_count_ == kMapSize) return;
3649 } 3649 }
3650 } 3650 }
3651 3651
3652 3652
3653 void BoyerMoorePositionInfo::SetAll() { 3653 void BoyerMoorePositionInfo::SetAll() {
3654 s_ = w_ = d_ = kLatticeUnknown; 3654 s_ = w_ = d_ = kLatticeUnknown;
3655 if (map_count_ != kMapSize) { 3655 if (map_count_ != kMapSize) {
3656 map_count_ = kMapSize; 3656 map_count_ = kMapSize;
3657 for (int i = 0; i < kMapSize; i++) map_->at(i) = true; 3657 for (int i = 0; i < kMapSize; i++) map_->Set(i, true);
3658 } 3658 }
3659 } 3659 }
3660 3660
3661 3661
3662 BoyerMooreLookahead::BoyerMooreLookahead( 3662 BoyerMooreLookahead::BoyerMooreLookahead(
3663 int length, RegExpCompiler* compiler, Zone* zone) 3663 int length, RegExpCompiler* compiler, Zone* zone)
3664 : length_(length), 3664 : length_(length),
3665 compiler_(compiler) { 3665 compiler_(compiler) {
3666 if (compiler->ascii()) { 3666 if (compiler->ascii()) {
3667 max_char_ = String::kMaxOneByteCharCode; 3667 max_char_ = String::kMaxOneByteCharCode;
(...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after
5389 5389
5390 // Move a number of elements in a zonelist to another position 5390 // Move a number of elements in a zonelist to another position
5391 // in the same list. Handles overlapping source and target areas. 5391 // in the same list. Handles overlapping source and target areas.
5392 static void MoveRanges(ZoneList<CharacterRange>* list, 5392 static void MoveRanges(ZoneList<CharacterRange>* list,
5393 int from, 5393 int from,
5394 int to, 5394 int to,
5395 int count) { 5395 int count) {
5396 // Ranges are potentially overlapping. 5396 // Ranges are potentially overlapping.
5397 if (from < to) { 5397 if (from < to) {
5398 for (int i = count - 1; i >= 0; i--) { 5398 for (int i = count - 1; i >= 0; i--) {
5399 list->at(to + i) = list->at(from + i); 5399 list->Set(to + i, list->at(from + i));
5400 } 5400 }
5401 } else { 5401 } else {
5402 for (int i = 0; i < count; i++) { 5402 for (int i = 0; i < count; i++) {
5403 list->at(to + i) = list->at(from + i); 5403 list->Set(to + i, list->at(from + i));
5404 } 5404 }
5405 } 5405 }
5406 } 5406 }
5407 5407
5408 5408
5409 static int InsertRangeInCanonicalList(ZoneList<CharacterRange>* list, 5409 static int InsertRangeInCanonicalList(ZoneList<CharacterRange>* list,
5410 int count, 5410 int count,
5411 CharacterRange insert) { 5411 CharacterRange insert) {
5412 // Inserts a range into list[0..count[, which must be sorted 5412 // Inserts a range into list[0..count[, which must be sorted
5413 // by from value and non-overlapping and non-adjacent, using at most 5413 // by from value and non-overlapping and non-adjacent, using at most
(...skipping 19 matching lines...) Expand all
5433 // not affected by the insertion. 5433 // not affected by the insertion.
5434 // If start_pos == end_pos, the range must be inserted before start_pos. 5434 // If start_pos == end_pos, the range must be inserted before start_pos.
5435 // if start_pos < end_pos, the entire range from start_pos to end_pos 5435 // if start_pos < end_pos, the entire range from start_pos to end_pos
5436 // must be merged with the insert range. 5436 // must be merged with the insert range.
5437 5437
5438 if (start_pos == end_pos) { 5438 if (start_pos == end_pos) {
5439 // Insert between existing ranges at position start_pos. 5439 // Insert between existing ranges at position start_pos.
5440 if (start_pos < count) { 5440 if (start_pos < count) {
5441 MoveRanges(list, start_pos, start_pos + 1, count - start_pos); 5441 MoveRanges(list, start_pos, start_pos + 1, count - start_pos);
5442 } 5442 }
5443 list->at(start_pos) = insert; 5443 list->Set(start_pos, insert);
5444 return count + 1; 5444 return count + 1;
5445 } 5445 }
5446 if (start_pos + 1 == end_pos) { 5446 if (start_pos + 1 == end_pos) {
5447 // Replace single existing range at position start_pos. 5447 // Replace single existing range at position start_pos.
5448 CharacterRange to_replace = list->at(start_pos); 5448 CharacterRange to_replace = list->at(start_pos);
5449 int new_from = Min(to_replace.from(), from); 5449 int new_from = Min(to_replace.from(), from);
5450 int new_to = Max(to_replace.to(), to); 5450 int new_to = Max(to_replace.to(), to);
5451 list->at(start_pos) = CharacterRange(new_from, new_to); 5451 list->Set(start_pos, CharacterRange(new_from, new_to));
5452 return count; 5452 return count;
5453 } 5453 }
5454 // Replace a number of existing ranges from start_pos to end_pos - 1. 5454 // Replace a number of existing ranges from start_pos to end_pos - 1.
5455 // Move the remaining ranges down. 5455 // Move the remaining ranges down.
5456 5456
5457 int new_from = Min(list->at(start_pos).from(), from); 5457 int new_from = Min(list->at(start_pos).from(), from);
5458 int new_to = Max(list->at(end_pos - 1).to(), to); 5458 int new_to = Max(list->at(end_pos - 1).to(), to);
5459 if (end_pos < count) { 5459 if (end_pos < count) {
5460 MoveRanges(list, end_pos, start_pos + 1, count - end_pos); 5460 MoveRanges(list, end_pos, start_pos + 1, count - end_pos);
5461 } 5461 }
5462 list->at(start_pos) = CharacterRange(new_from, new_to); 5462 list->Set(start_pos, CharacterRange(new_from, new_to));
5463 return count - (end_pos - start_pos) + 1; 5463 return count - (end_pos - start_pos) + 1;
5464 } 5464 }
5465 5465
5466 5466
5467 void CharacterSet::Canonicalize() { 5467 void CharacterSet::Canonicalize() {
5468 // Special/default classes are always considered canonical. The result 5468 // Special/default classes are always considered canonical. The result
5469 // of calling ranges() will be sorted. 5469 // of calling ranges() will be sorted.
5470 if (ranges_ == NULL) return; 5470 if (ranges_ == NULL) return;
5471 CharacterRange::Canonicalize(ranges_); 5471 CharacterRange::Canonicalize(ranges_);
5472 } 5472 }
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
6125 } 6125 }
6126 6126
6127 return compiler.Assemble(&macro_assembler, 6127 return compiler.Assemble(&macro_assembler,
6128 node, 6128 node,
6129 data->capture_count, 6129 data->capture_count,
6130 pattern); 6130 pattern);
6131 } 6131 }
6132 6132
6133 6133
6134 }} // namespace v8::internal 6134 }} // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698