OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 6862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6873 #endif | 6873 #endif |
6874 | 6874 |
6875 | 6875 |
6876 bool String::LooksValid() { | 6876 bool String::LooksValid() { |
6877 if (!Isolate::Current()->heap()->Contains(this)) return false; | 6877 if (!Isolate::Current()->heap()->Contains(this)) return false; |
6878 return true; | 6878 return true; |
6879 } | 6879 } |
6880 | 6880 |
6881 | 6881 |
6882 String::FlatContent String::GetFlatContent() { | 6882 String::FlatContent String::GetFlatContent() { |
| 6883 ASSERT(!GetHeap()->allow_allocation(false)); |
6883 int length = this->length(); | 6884 int length = this->length(); |
6884 StringShape shape(this); | 6885 StringShape shape(this); |
6885 String* string = this; | 6886 String* string = this; |
6886 int offset = 0; | 6887 int offset = 0; |
6887 if (shape.representation_tag() == kConsStringTag) { | 6888 if (shape.representation_tag() == kConsStringTag) { |
6888 ConsString* cons = ConsString::cast(string); | 6889 ConsString* cons = ConsString::cast(string); |
6889 if (cons->second()->length() != 0) { | 6890 if (cons->second()->length() != 0) { |
6890 return FlatContent(); | 6891 return FlatContent(); |
6891 } | 6892 } |
6892 string = cons->first(); | 6893 string = cons->first(); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7099 str_(0), | 7100 str_(0), |
7100 is_ascii_(true), | 7101 is_ascii_(true), |
7101 length_(input.length()), | 7102 length_(input.length()), |
7102 start_(input.start()) { } | 7103 start_(input.start()) { } |
7103 | 7104 |
7104 | 7105 |
7105 void FlatStringReader::PostGarbageCollection() { | 7106 void FlatStringReader::PostGarbageCollection() { |
7106 if (str_ == NULL) return; | 7107 if (str_ == NULL) return; |
7107 Handle<String> str(str_); | 7108 Handle<String> str(str_); |
7108 ASSERT(str->IsFlat()); | 7109 ASSERT(str->IsFlat()); |
| 7110 AssertNoAllocation no_gc; |
| 7111 // This does not actually prevent the vector from being relocated later. |
7109 String::FlatContent content = str->GetFlatContent(); | 7112 String::FlatContent content = str->GetFlatContent(); |
7110 ASSERT(content.IsFlat()); | 7113 ASSERT(content.IsFlat()); |
7111 is_ascii_ = content.IsAscii(); | 7114 is_ascii_ = content.IsAscii(); |
7112 if (is_ascii_) { | 7115 if (is_ascii_) { |
7113 start_ = content.ToOneByteVector().start(); | 7116 start_ = content.ToOneByteVector().start(); |
7114 } else { | 7117 } else { |
7115 start_ = content.ToUC16Vector().start(); | 7118 start_ = content.ToUC16Vector().start(); |
7116 } | 7119 } |
7117 } | 7120 } |
7118 | 7121 |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7649 utf8_data += cursor; | 7652 utf8_data += cursor; |
7650 remaining_in_str -= cursor; | 7653 remaining_in_str -= cursor; |
7651 } | 7654 } |
7652 return i == slen && remaining_in_str == 0; | 7655 return i == slen && remaining_in_str == 0; |
7653 } | 7656 } |
7654 | 7657 |
7655 | 7658 |
7656 bool String::IsOneByteEqualTo(Vector<const uint8_t> str) { | 7659 bool String::IsOneByteEqualTo(Vector<const uint8_t> str) { |
7657 int slen = length(); | 7660 int slen = length(); |
7658 if (str.length() != slen) return false; | 7661 if (str.length() != slen) return false; |
| 7662 AssertNoAllocation no_gc; |
7659 FlatContent content = GetFlatContent(); | 7663 FlatContent content = GetFlatContent(); |
7660 if (content.IsAscii()) { | 7664 if (content.IsAscii()) { |
7661 return CompareChars(content.ToOneByteVector().start(), | 7665 return CompareChars(content.ToOneByteVector().start(), |
7662 str.start(), slen) == 0; | 7666 str.start(), slen) == 0; |
7663 } | 7667 } |
7664 for (int i = 0; i < slen; i++) { | 7668 for (int i = 0; i < slen; i++) { |
7665 if (Get(i) != static_cast<uint16_t>(str[i])) return false; | 7669 if (Get(i) != static_cast<uint16_t>(str[i])) return false; |
7666 } | 7670 } |
7667 return true; | 7671 return true; |
7668 } | 7672 } |
7669 | 7673 |
7670 | 7674 |
7671 bool String::IsTwoByteEqualTo(Vector<const uc16> str) { | 7675 bool String::IsTwoByteEqualTo(Vector<const uc16> str) { |
7672 int slen = length(); | 7676 int slen = length(); |
7673 if (str.length() != slen) return false; | 7677 if (str.length() != slen) return false; |
| 7678 AssertNoAllocation no_gc; |
7674 FlatContent content = GetFlatContent(); | 7679 FlatContent content = GetFlatContent(); |
7675 if (content.IsTwoByte()) { | 7680 if (content.IsTwoByte()) { |
7676 return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0; | 7681 return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0; |
7677 } | 7682 } |
7678 for (int i = 0; i < slen; i++) { | 7683 for (int i = 0; i < slen; i++) { |
7679 if (Get(i) != str[i]) return false; | 7684 if (Get(i) != str[i]) return false; |
7680 } | 7685 } |
7681 return true; | 7686 return true; |
7682 } | 7687 } |
7683 | 7688 |
(...skipping 6781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14465 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 14470 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
14466 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 14471 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
14467 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 14472 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
14468 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 14473 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
14469 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 14474 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
14470 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 14475 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
14471 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 14476 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
14472 } | 14477 } |
14473 | 14478 |
14474 } } // namespace v8::internal | 14479 } } // namespace v8::internal |
OLD | NEW |