OLD | NEW |
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 11578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11589 if (hash_field_ == 0) Hash(); | 11589 if (hash_field_ == 0) Hash(); |
11590 return HEAP->AllocateAsciiSymbol(string_, hash_field_); | 11590 return HEAP->AllocateAsciiSymbol(string_, hash_field_); |
11591 } | 11591 } |
11592 }; | 11592 }; |
11593 | 11593 |
11594 | 11594 |
11595 class SubStringAsciiSymbolKey : public HashTableKey { | 11595 class SubStringAsciiSymbolKey : public HashTableKey { |
11596 public: | 11596 public: |
11597 explicit SubStringAsciiSymbolKey(Handle<SeqOneByteString> string, | 11597 explicit SubStringAsciiSymbolKey(Handle<SeqOneByteString> string, |
11598 int from, | 11598 int from, |
11599 int length, | 11599 int length) |
11600 uint32_t seed) | 11600 : string_(string), from_(from), length_(length) { } |
11601 : string_(string), from_(from), length_(length), seed_(seed) { } | |
11602 | 11601 |
11603 uint32_t Hash() { | 11602 uint32_t Hash() { |
11604 ASSERT(length_ >= 0); | 11603 ASSERT(length_ >= 0); |
11605 ASSERT(from_ + length_ <= string_->length()); | 11604 ASSERT(from_ + length_ <= string_->length()); |
11606 StringHasher hasher(length_, string_->GetHeap()->HashSeed()); | 11605 StringHasher hasher(length_, string_->GetHeap()->HashSeed()); |
11607 | 11606 |
11608 // Very long strings have a trivial hash that doesn't inspect the | 11607 // Very long strings have a trivial hash that doesn't inspect the |
11609 // string contents. | 11608 // string contents. |
11610 if (hasher.has_trivial_hash()) { | 11609 if (hasher.has_trivial_hash()) { |
11611 hash_field_ = hasher.GetHashField(); | 11610 hash_field_ = hasher.GetHashField(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11648 if (hash_field_ == 0) Hash(); | 11647 if (hash_field_ == 0) Hash(); |
11649 Vector<const char> chars(string_->GetChars() + from_, length_); | 11648 Vector<const char> chars(string_->GetChars() + from_, length_); |
11650 return HEAP->AllocateAsciiSymbol(chars, hash_field_); | 11649 return HEAP->AllocateAsciiSymbol(chars, hash_field_); |
11651 } | 11650 } |
11652 | 11651 |
11653 private: | 11652 private: |
11654 Handle<SeqOneByteString> string_; | 11653 Handle<SeqOneByteString> string_; |
11655 int from_; | 11654 int from_; |
11656 int length_; | 11655 int length_; |
11657 uint32_t hash_field_; | 11656 uint32_t hash_field_; |
11658 uint32_t seed_; | |
11659 }; | 11657 }; |
11660 | 11658 |
11661 | 11659 |
11662 class TwoByteSymbolKey : public SequentialSymbolKey<uc16> { | 11660 class TwoByteSymbolKey : public SequentialSymbolKey<uc16> { |
11663 public: | 11661 public: |
11664 explicit TwoByteSymbolKey(Vector<const uc16> str, uint32_t seed) | 11662 explicit TwoByteSymbolKey(Vector<const uc16> str, uint32_t seed) |
11665 : SequentialSymbolKey<uc16>(str, seed) { } | 11663 : SequentialSymbolKey<uc16>(str, seed) { } |
11666 | 11664 |
11667 bool IsMatch(Object* string) { | 11665 bool IsMatch(Object* string) { |
11668 return String::cast(string)->IsTwoByteEqualTo(string_); | 11666 return String::cast(string)->IsTwoByteEqualTo(string_); |
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12574 AsciiSymbolKey key(str, GetHeap()->HashSeed()); | 12572 AsciiSymbolKey key(str, GetHeap()->HashSeed()); |
12575 return LookupKey(&key, s); | 12573 return LookupKey(&key, s); |
12576 } | 12574 } |
12577 | 12575 |
12578 | 12576 |
12579 MaybeObject* SymbolTable::LookupSubStringAsciiSymbol( | 12577 MaybeObject* SymbolTable::LookupSubStringAsciiSymbol( |
12580 Handle<SeqOneByteString> str, | 12578 Handle<SeqOneByteString> str, |
12581 int from, | 12579 int from, |
12582 int length, | 12580 int length, |
12583 Object** s) { | 12581 Object** s) { |
12584 SubStringAsciiSymbolKey key(str, from, length, GetHeap()->HashSeed()); | 12582 SubStringAsciiSymbolKey key(str, from, length); |
12585 return LookupKey(&key, s); | 12583 return LookupKey(&key, s); |
12586 } | 12584 } |
12587 | 12585 |
12588 | 12586 |
12589 MaybeObject* SymbolTable::LookupTwoByteSymbol(Vector<const uc16> str, | 12587 MaybeObject* SymbolTable::LookupTwoByteSymbol(Vector<const uc16> str, |
12590 Object** s) { | 12588 Object** s) { |
12591 TwoByteSymbolKey key(str, GetHeap()->HashSeed()); | 12589 TwoByteSymbolKey key(str, GetHeap()->HashSeed()); |
12592 return LookupKey(&key, s); | 12590 return LookupKey(&key, s); |
12593 } | 12591 } |
12594 | 12592 |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13882 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13880 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13883 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13881 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13884 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13882 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13885 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13883 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13886 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13884 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13887 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13885 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13888 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13886 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13889 } | 13887 } |
13890 | 13888 |
13891 } } // namespace v8::internal | 13889 } } // namespace v8::internal |
OLD | NEW |