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 7014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7025 void Map::RemoveFromCodeCache(Name* name, Code* code, int index) { | 7025 void Map::RemoveFromCodeCache(Name* name, Code* code, int index) { |
7026 // No GC is supposed to happen between a call to IndexInCodeCache and | 7026 // No GC is supposed to happen between a call to IndexInCodeCache and |
7027 // RemoveFromCodeCache so the code cache must be there. | 7027 // RemoveFromCodeCache so the code cache must be there. |
7028 ASSERT(!code_cache()->IsFixedArray()); | 7028 ASSERT(!code_cache()->IsFixedArray()); |
7029 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); | 7029 CodeCache::cast(code_cache())->RemoveByIndex(name, code, index); |
7030 } | 7030 } |
7031 | 7031 |
7032 | 7032 |
7033 // An iterator over all map transitions in an descriptor array, reusing the map | 7033 // An iterator over all map transitions in an descriptor array, reusing the map |
7034 // field of the contens array while it is running. | 7034 // field of the contens array while it is running. |
7035 class IntrusiveMapTransitionIterator V8_FINAL { | 7035 class IntrusiveMapTransitionIterator { |
7036 public: | 7036 public: |
7037 explicit IntrusiveMapTransitionIterator(TransitionArray* transition_array) | 7037 explicit IntrusiveMapTransitionIterator(TransitionArray* transition_array) |
7038 : transition_array_(transition_array) { } | 7038 : transition_array_(transition_array) { } |
7039 | 7039 |
7040 void Start() { | 7040 void Start() { |
7041 ASSERT(!IsIterating()); | 7041 ASSERT(!IsIterating()); |
7042 *TransitionArrayHeader() = Smi::FromInt(0); | 7042 *TransitionArrayHeader() = Smi::FromInt(0); |
7043 } | 7043 } |
7044 | 7044 |
7045 bool IsIterating() { | 7045 bool IsIterating() { |
(...skipping 17 matching lines...) Expand all Loading... |
7063 Object** TransitionArrayHeader() { | 7063 Object** TransitionArrayHeader() { |
7064 return HeapObject::RawField(transition_array_, TransitionArray::kMapOffset); | 7064 return HeapObject::RawField(transition_array_, TransitionArray::kMapOffset); |
7065 } | 7065 } |
7066 | 7066 |
7067 TransitionArray* transition_array_; | 7067 TransitionArray* transition_array_; |
7068 }; | 7068 }; |
7069 | 7069 |
7070 | 7070 |
7071 // An iterator over all prototype transitions, reusing the map field of the | 7071 // An iterator over all prototype transitions, reusing the map field of the |
7072 // underlying array while it is running. | 7072 // underlying array while it is running. |
7073 class IntrusivePrototypeTransitionIterator V8_FINAL { | 7073 class IntrusivePrototypeTransitionIterator { |
7074 public: | 7074 public: |
7075 explicit IntrusivePrototypeTransitionIterator(HeapObject* proto_trans) | 7075 explicit IntrusivePrototypeTransitionIterator(HeapObject* proto_trans) |
7076 : proto_trans_(proto_trans) { } | 7076 : proto_trans_(proto_trans) { } |
7077 | 7077 |
7078 void Start() { | 7078 void Start() { |
7079 ASSERT(!IsIterating()); | 7079 ASSERT(!IsIterating()); |
7080 *Header() = Smi::FromInt(0); | 7080 *Header() = Smi::FromInt(0); |
7081 } | 7081 } |
7082 | 7082 |
7083 bool IsIterating() { | 7083 bool IsIterating() { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7136 // the current index in the map of the FixedArray of the desciptor | 7136 // the current index in the map of the FixedArray of the desciptor |
7137 // array's contents, and restore it to the fixed array map afterwards. | 7137 // array's contents, and restore it to the fixed array map afterwards. |
7138 // Note that a single descriptor can have 0, 1, or 2 transitions. | 7138 // Note that a single descriptor can have 0, 1, or 2 transitions. |
7139 // | 7139 // |
7140 // (b) If we currently follow prototype transitions, we temporarily store | 7140 // (b) If we currently follow prototype transitions, we temporarily store |
7141 // the current index in the map of the FixedArray holding the prototype | 7141 // the current index in the map of the FixedArray holding the prototype |
7142 // transitions, and restore it to the fixed array map afterwards. | 7142 // transitions, and restore it to the fixed array map afterwards. |
7143 // | 7143 // |
7144 // Note that the child iterator is just a concatenation of two iterators: One | 7144 // Note that the child iterator is just a concatenation of two iterators: One |
7145 // iterating over map transitions and one iterating over prototype transisitons. | 7145 // iterating over map transitions and one iterating over prototype transisitons. |
7146 class TraversableMap V8_FINAL : public Map { | 7146 class TraversableMap : public Map { |
7147 public: | 7147 public: |
7148 // Record the parent in the traversal within this map. Note that this destroys | 7148 // Record the parent in the traversal within this map. Note that this destroys |
7149 // this map's map! | 7149 // this map's map! |
7150 void SetParent(TraversableMap* parent) { set_map_no_write_barrier(parent); } | 7150 void SetParent(TraversableMap* parent) { set_map_no_write_barrier(parent); } |
7151 | 7151 |
7152 // Reset the current map's map, returning the parent previously stored in it. | 7152 // Reset the current map's map, returning the parent previously stored in it. |
7153 TraversableMap* GetAndResetParent() { | 7153 TraversableMap* GetAndResetParent() { |
7154 TraversableMap* old_parent = static_cast<TraversableMap*>(map()); | 7154 TraversableMap* old_parent = static_cast<TraversableMap*>(map()); |
7155 set_map_no_write_barrier(GetHeap()->meta_map()); | 7155 set_map_no_write_barrier(GetHeap()->meta_map()); |
7156 return old_parent; | 7156 return old_parent; |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7384 array->set_null(index - 1); // Name. | 7384 array->set_null(index - 1); // Name. |
7385 array->set_null(index); // Code. | 7385 array->set_null(index); // Code. |
7386 } | 7386 } |
7387 } | 7387 } |
7388 | 7388 |
7389 | 7389 |
7390 // The key in the code cache hash table consists of the property name and the | 7390 // The key in the code cache hash table consists of the property name and the |
7391 // code object. The actual match is on the name and the code flags. If a key | 7391 // code object. The actual match is on the name and the code flags. If a key |
7392 // is created using the flags and not a code object it can only be used for | 7392 // is created using the flags and not a code object it can only be used for |
7393 // lookup not to create a new entry. | 7393 // lookup not to create a new entry. |
7394 class CodeCacheHashTableKey V8_FINAL : public HashTableKey { | 7394 class CodeCacheHashTableKey : public HashTableKey { |
7395 public: | 7395 public: |
7396 CodeCacheHashTableKey(Name* name, Code::Flags flags) | 7396 CodeCacheHashTableKey(Name* name, Code::Flags flags) |
7397 : name_(name), flags_(flags), code_(NULL) { } | 7397 : name_(name), flags_(flags), code_(NULL) { } |
7398 | 7398 |
7399 CodeCacheHashTableKey(Name* name, Code* code) | 7399 CodeCacheHashTableKey(Name* name, Code* code) |
7400 : name_(name), | 7400 : name_(name), |
7401 flags_(code->flags()), | 7401 flags_(code->flags()), |
7402 code_(code) { } | 7402 code_(code) { } |
7403 | 7403 |
7404 | 7404 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7539 return Handle<Object>(hash_table->Lookup(maps, flags), GetIsolate()); | 7539 return Handle<Object>(hash_table->Lookup(maps, flags), GetIsolate()); |
7540 } else { | 7540 } else { |
7541 return GetIsolate()->factory()->undefined_value(); | 7541 return GetIsolate()->factory()->undefined_value(); |
7542 } | 7542 } |
7543 } | 7543 } |
7544 | 7544 |
7545 | 7545 |
7546 // Despite their name, object of this class are not stored in the actual | 7546 // Despite their name, object of this class are not stored in the actual |
7547 // hash table; instead they're temporarily used for lookups. It is therefore | 7547 // hash table; instead they're temporarily used for lookups. It is therefore |
7548 // safe to have a weak (non-owning) pointer to a MapList as a member field. | 7548 // safe to have a weak (non-owning) pointer to a MapList as a member field. |
7549 class PolymorphicCodeCacheHashTableKey V8_FINAL : public HashTableKey { | 7549 class PolymorphicCodeCacheHashTableKey : public HashTableKey { |
7550 public: | 7550 public: |
7551 // Callers must ensure that |maps| outlives the newly constructed object. | 7551 // Callers must ensure that |maps| outlives the newly constructed object. |
7552 PolymorphicCodeCacheHashTableKey(MapHandleList* maps, int code_flags) | 7552 PolymorphicCodeCacheHashTableKey(MapHandleList* maps, int code_flags) |
7553 : maps_(maps), | 7553 : maps_(maps), |
7554 code_flags_(code_flags) {} | 7554 code_flags_(code_flags) {} |
7555 | 7555 |
7556 bool IsMatch(Object* other) { | 7556 bool IsMatch(Object* other) { |
7557 MapHandleList other_maps(kDefaultListAllocationSize); | 7557 MapHandleList other_maps(kDefaultListAllocationSize); |
7558 int other_flags; | 7558 int other_flags; |
7559 FromObject(other, &other_flags, &other_maps); | 7559 FromObject(other, &other_flags, &other_maps); |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8539 for (; i < length; i++) { | 8539 for (; i < length; i++) { |
8540 if (a[i] != b[i]) { | 8540 if (a[i] != b[i]) { |
8541 return false; | 8541 return false; |
8542 } | 8542 } |
8543 } | 8543 } |
8544 return true; | 8544 return true; |
8545 } | 8545 } |
8546 | 8546 |
8547 | 8547 |
8548 template<typename Chars1, typename Chars2> | 8548 template<typename Chars1, typename Chars2> |
8549 class RawStringComparator V8_FINAL : public AllStatic { | 8549 class RawStringComparator : public AllStatic { |
8550 public: | 8550 public: |
8551 static inline bool compare(const Chars1* a, const Chars2* b, int len) { | 8551 static inline bool compare(const Chars1* a, const Chars2* b, int len) { |
8552 ASSERT(sizeof(Chars1) != sizeof(Chars2)); | 8552 ASSERT(sizeof(Chars1) != sizeof(Chars2)); |
8553 for (int i = 0; i < len; i++) { | 8553 for (int i = 0; i < len; i++) { |
8554 if (a[i] != b[i]) { | 8554 if (a[i] != b[i]) { |
8555 return false; | 8555 return false; |
8556 } | 8556 } |
8557 } | 8557 } |
8558 return true; | 8558 return true; |
8559 } | 8559 } |
8560 }; | 8560 }; |
8561 | 8561 |
8562 | 8562 |
8563 template<> | 8563 template<> |
8564 class RawStringComparator<uint16_t, uint16_t> V8_FINAL { | 8564 class RawStringComparator<uint16_t, uint16_t> { |
8565 public: | 8565 public: |
8566 static inline bool compare(const uint16_t* a, const uint16_t* b, int len) { | 8566 static inline bool compare(const uint16_t* a, const uint16_t* b, int len) { |
8567 return CompareRawStringContents(a, b, len); | 8567 return CompareRawStringContents(a, b, len); |
8568 } | 8568 } |
8569 }; | 8569 }; |
8570 | 8570 |
8571 | 8571 |
8572 template<> | 8572 template<> |
8573 class RawStringComparator<uint8_t, uint8_t> V8_FINAL { | 8573 class RawStringComparator<uint8_t, uint8_t> { |
8574 public: | 8574 public: |
8575 static inline bool compare(const uint8_t* a, const uint8_t* b, int len) { | 8575 static inline bool compare(const uint8_t* a, const uint8_t* b, int len) { |
8576 return CompareRawStringContents(a, b, len); | 8576 return CompareRawStringContents(a, b, len); |
8577 } | 8577 } |
8578 }; | 8578 }; |
8579 | 8579 |
8580 | 8580 |
8581 class StringComparator V8_FINAL { | 8581 class StringComparator { |
8582 class State V8_FINAL { | 8582 class State { |
8583 public: | 8583 public: |
8584 explicit inline State(ConsStringIteratorOp* op) | 8584 explicit inline State(ConsStringIteratorOp* op) |
8585 : op_(op), is_one_byte_(true), length_(0), buffer8_(NULL) {} | 8585 : op_(op), is_one_byte_(true), length_(0), buffer8_(NULL) {} |
8586 | 8586 |
8587 inline void Init(String* string, unsigned len) { | 8587 inline void Init(String* string, unsigned len) { |
8588 op_->Reset(); | 8588 op_->Reset(); |
8589 int32_t type = string->map()->instance_type(); | 8589 int32_t type = string->map()->instance_type(); |
8590 String::Visit(string, 0, *this, *op_, type, len); | 8590 String::Visit(string, 0, *this, *op_, type, len); |
8591 } | 8591 } |
8592 | 8592 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8808 if (content.IsTwoByte()) { | 8808 if (content.IsTwoByte()) { |
8809 return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0; | 8809 return CompareChars(content.ToUC16Vector().start(), str.start(), slen) == 0; |
8810 } | 8810 } |
8811 for (int i = 0; i < slen; i++) { | 8811 for (int i = 0; i < slen; i++) { |
8812 if (Get(i) != str[i]) return false; | 8812 if (Get(i) != str[i]) return false; |
8813 } | 8813 } |
8814 return true; | 8814 return true; |
8815 } | 8815 } |
8816 | 8816 |
8817 | 8817 |
8818 class IteratingStringHasher V8_FINAL : public StringHasher { | 8818 class IteratingStringHasher: public StringHasher { |
8819 public: | 8819 public: |
8820 static inline uint32_t Hash(String* string, uint32_t seed) { | 8820 static inline uint32_t Hash(String* string, uint32_t seed) { |
8821 const unsigned len = static_cast<unsigned>(string->length()); | 8821 const unsigned len = static_cast<unsigned>(string->length()); |
8822 IteratingStringHasher hasher(len, seed); | 8822 IteratingStringHasher hasher(len, seed); |
8823 if (hasher.has_trivial_hash()) { | 8823 if (hasher.has_trivial_hash()) { |
8824 return hasher.GetHashField(); | 8824 return hasher.GetHashField(); |
8825 } | 8825 } |
8826 int32_t type = string->map()->instance_type(); | 8826 int32_t type = string->map()->instance_type(); |
8827 ConsStringNullOp null_op; | 8827 ConsStringNullOp null_op; |
8828 String::Visit(string, 0, hasher, null_op, type, len); | 8828 String::Visit(string, 0, hasher, null_op, type, len); |
(...skipping 4443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13272 } | 13272 } |
13273 | 13273 |
13274 | 13274 |
13275 int JSObject::GetEnumElementKeys(FixedArray* storage) { | 13275 int JSObject::GetEnumElementKeys(FixedArray* storage) { |
13276 return GetLocalElementKeys(storage, | 13276 return GetLocalElementKeys(storage, |
13277 static_cast<PropertyAttributes>(DONT_ENUM)); | 13277 static_cast<PropertyAttributes>(DONT_ENUM)); |
13278 } | 13278 } |
13279 | 13279 |
13280 | 13280 |
13281 // StringKey simply carries a string object as key. | 13281 // StringKey simply carries a string object as key. |
13282 class StringKey V8_FINAL : public HashTableKey { | 13282 class StringKey : public HashTableKey { |
13283 public: | 13283 public: |
13284 explicit StringKey(String* string) : | 13284 explicit StringKey(String* string) : |
13285 string_(string), | 13285 string_(string), |
13286 hash_(HashForObject(string)) { } | 13286 hash_(HashForObject(string)) { } |
13287 | 13287 |
13288 bool IsMatch(Object* string) { | 13288 bool IsMatch(Object* string) { |
13289 // We know that all entries in a hash table had their hash keys created. | 13289 // We know that all entries in a hash table had their hash keys created. |
13290 // Use that knowledge to have fast failure. | 13290 // Use that knowledge to have fast failure. |
13291 if (hash_ != HashForObject(string)) { | 13291 if (hash_ != HashForObject(string)) { |
13292 return false; | 13292 return false; |
13293 } | 13293 } |
13294 return string_->Equals(String::cast(string)); | 13294 return string_->Equals(String::cast(string)); |
13295 } | 13295 } |
13296 | 13296 |
13297 uint32_t Hash() { return hash_; } | 13297 uint32_t Hash() { return hash_; } |
13298 | 13298 |
13299 uint32_t HashForObject(Object* other) { return String::cast(other)->Hash(); } | 13299 uint32_t HashForObject(Object* other) { return String::cast(other)->Hash(); } |
13300 | 13300 |
13301 Object* AsObject(Heap* heap) { return string_; } | 13301 Object* AsObject(Heap* heap) { return string_; } |
13302 | 13302 |
13303 String* string_; | 13303 String* string_; |
13304 uint32_t hash_; | 13304 uint32_t hash_; |
13305 }; | 13305 }; |
13306 | 13306 |
13307 | 13307 |
13308 // StringSharedKeys are used as keys in the eval cache. | 13308 // StringSharedKeys are used as keys in the eval cache. |
13309 class StringSharedKey V8_FINAL : public HashTableKey { | 13309 class StringSharedKey : public HashTableKey { |
13310 public: | 13310 public: |
13311 StringSharedKey(String* source, | 13311 StringSharedKey(String* source, |
13312 SharedFunctionInfo* shared, | 13312 SharedFunctionInfo* shared, |
13313 LanguageMode language_mode, | 13313 LanguageMode language_mode, |
13314 int scope_position) | 13314 int scope_position) |
13315 : source_(source), | 13315 : source_(source), |
13316 shared_(shared), | 13316 shared_(shared), |
13317 language_mode_(language_mode), | 13317 language_mode_(language_mode), |
13318 scope_position_(scope_position) { } | 13318 scope_position_(scope_position) { } |
13319 | 13319 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13388 | 13388 |
13389 private: | 13389 private: |
13390 String* source_; | 13390 String* source_; |
13391 SharedFunctionInfo* shared_; | 13391 SharedFunctionInfo* shared_; |
13392 LanguageMode language_mode_; | 13392 LanguageMode language_mode_; |
13393 int scope_position_; | 13393 int scope_position_; |
13394 }; | 13394 }; |
13395 | 13395 |
13396 | 13396 |
13397 // RegExpKey carries the source and flags of a regular expression as key. | 13397 // RegExpKey carries the source and flags of a regular expression as key. |
13398 class RegExpKey V8_FINAL : public HashTableKey { | 13398 class RegExpKey : public HashTableKey { |
13399 public: | 13399 public: |
13400 RegExpKey(String* string, JSRegExp::Flags flags) | 13400 RegExpKey(String* string, JSRegExp::Flags flags) |
13401 : string_(string), | 13401 : string_(string), |
13402 flags_(Smi::FromInt(flags.value())) { } | 13402 flags_(Smi::FromInt(flags.value())) { } |
13403 | 13403 |
13404 // Rather than storing the key in the hash table, a pointer to the | 13404 // Rather than storing the key in the hash table, a pointer to the |
13405 // stored value is stored where the key should be. IsMatch then | 13405 // stored value is stored where the key should be. IsMatch then |
13406 // compares the search key to the found object, rather than comparing | 13406 // compares the search key to the found object, rather than comparing |
13407 // a key to a key. | 13407 // a key to a key. |
13408 bool IsMatch(Object* obj) { | 13408 bool IsMatch(Object* obj) { |
(...skipping 20 matching lines...) Expand all Loading... |
13429 static uint32_t RegExpHash(String* string, Smi* flags) { | 13429 static uint32_t RegExpHash(String* string, Smi* flags) { |
13430 return string->Hash() + flags->value(); | 13430 return string->Hash() + flags->value(); |
13431 } | 13431 } |
13432 | 13432 |
13433 String* string_; | 13433 String* string_; |
13434 Smi* flags_; | 13434 Smi* flags_; |
13435 }; | 13435 }; |
13436 | 13436 |
13437 | 13437 |
13438 // Utf8StringKey carries a vector of chars as key. | 13438 // Utf8StringKey carries a vector of chars as key. |
13439 class Utf8StringKey V8_FINAL : public HashTableKey { | 13439 class Utf8StringKey : public HashTableKey { |
13440 public: | 13440 public: |
13441 explicit Utf8StringKey(Vector<const char> string, uint32_t seed) | 13441 explicit Utf8StringKey(Vector<const char> string, uint32_t seed) |
13442 : string_(string), hash_field_(0), seed_(seed) { } | 13442 : string_(string), hash_field_(0), seed_(seed) { } |
13443 | 13443 |
13444 bool IsMatch(Object* string) { | 13444 bool IsMatch(Object* string) { |
13445 return String::cast(string)->IsUtf8EqualTo(string_); | 13445 return String::cast(string)->IsUtf8EqualTo(string_); |
13446 } | 13446 } |
13447 | 13447 |
13448 uint32_t Hash() { | 13448 uint32_t Hash() { |
13449 if (hash_field_ != 0) return hash_field_ >> String::kHashShift; | 13449 if (hash_field_ != 0) return hash_field_ >> String::kHashShift; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13492 return String::cast(other)->Hash(); | 13492 return String::cast(other)->Hash(); |
13493 } | 13493 } |
13494 | 13494 |
13495 Vector<const Char> string_; | 13495 Vector<const Char> string_; |
13496 uint32_t hash_field_; | 13496 uint32_t hash_field_; |
13497 uint32_t seed_; | 13497 uint32_t seed_; |
13498 }; | 13498 }; |
13499 | 13499 |
13500 | 13500 |
13501 | 13501 |
13502 class OneByteStringKey V8_FINAL : public SequentialStringKey<uint8_t> { | 13502 class OneByteStringKey : public SequentialStringKey<uint8_t> { |
13503 public: | 13503 public: |
13504 OneByteStringKey(Vector<const uint8_t> str, uint32_t seed) | 13504 OneByteStringKey(Vector<const uint8_t> str, uint32_t seed) |
13505 : SequentialStringKey<uint8_t>(str, seed) { } | 13505 : SequentialStringKey<uint8_t>(str, seed) { } |
13506 | 13506 |
13507 bool IsMatch(Object* string) { | 13507 bool IsMatch(Object* string) { |
13508 return String::cast(string)->IsOneByteEqualTo(string_); | 13508 return String::cast(string)->IsOneByteEqualTo(string_); |
13509 } | 13509 } |
13510 | 13510 |
13511 MaybeObject* AsObject(Heap* heap) { | 13511 MaybeObject* AsObject(Heap* heap) { |
13512 if (hash_field_ == 0) Hash(); | 13512 if (hash_field_ == 0) Hash(); |
13513 return heap->AllocateOneByteInternalizedString(string_, hash_field_); | 13513 return heap->AllocateOneByteInternalizedString(string_, hash_field_); |
13514 } | 13514 } |
13515 }; | 13515 }; |
13516 | 13516 |
13517 | 13517 |
13518 class SubStringOneByteStringKey V8_FINAL : public HashTableKey { | 13518 class SubStringOneByteStringKey : public HashTableKey { |
13519 public: | 13519 public: |
13520 explicit SubStringOneByteStringKey(Handle<SeqOneByteString> string, | 13520 explicit SubStringOneByteStringKey(Handle<SeqOneByteString> string, |
13521 int from, | 13521 int from, |
13522 int length) | 13522 int length) |
13523 : string_(string), from_(from), length_(length) { } | 13523 : string_(string), from_(from), length_(length) { } |
13524 | 13524 |
13525 uint32_t Hash() { | 13525 uint32_t Hash() { |
13526 ASSERT(length_ >= 0); | 13526 ASSERT(length_ >= 0); |
13527 ASSERT(from_ + length_ <= string_->length()); | 13527 ASSERT(from_ + length_ <= string_->length()); |
13528 uint8_t* chars = string_->GetChars() + from_; | 13528 uint8_t* chars = string_->GetChars() + from_; |
(...skipping 21 matching lines...) Expand all Loading... |
13550 } | 13550 } |
13551 | 13551 |
13552 private: | 13552 private: |
13553 Handle<SeqOneByteString> string_; | 13553 Handle<SeqOneByteString> string_; |
13554 int from_; | 13554 int from_; |
13555 int length_; | 13555 int length_; |
13556 uint32_t hash_field_; | 13556 uint32_t hash_field_; |
13557 }; | 13557 }; |
13558 | 13558 |
13559 | 13559 |
13560 class TwoByteStringKey V8_FINAL : public SequentialStringKey<uc16> { | 13560 class TwoByteStringKey : public SequentialStringKey<uc16> { |
13561 public: | 13561 public: |
13562 explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed) | 13562 explicit TwoByteStringKey(Vector<const uc16> str, uint32_t seed) |
13563 : SequentialStringKey<uc16>(str, seed) { } | 13563 : SequentialStringKey<uc16>(str, seed) { } |
13564 | 13564 |
13565 bool IsMatch(Object* string) { | 13565 bool IsMatch(Object* string) { |
13566 return String::cast(string)->IsTwoByteEqualTo(string_); | 13566 return String::cast(string)->IsTwoByteEqualTo(string_); |
13567 } | 13567 } |
13568 | 13568 |
13569 MaybeObject* AsObject(Heap* heap) { | 13569 MaybeObject* AsObject(Heap* heap) { |
13570 if (hash_field_ == 0) Hash(); | 13570 if (hash_field_ == 0) Hash(); |
13571 return heap->AllocateTwoByteInternalizedString(string_, hash_field_); | 13571 return heap->AllocateTwoByteInternalizedString(string_, hash_field_); |
13572 } | 13572 } |
13573 }; | 13573 }; |
13574 | 13574 |
13575 | 13575 |
13576 // InternalizedStringKey carries a string/internalized-string object as key. | 13576 // InternalizedStringKey carries a string/internalized-string object as key. |
13577 class InternalizedStringKey V8_FINAL : public HashTableKey { | 13577 class InternalizedStringKey : public HashTableKey { |
13578 public: | 13578 public: |
13579 explicit InternalizedStringKey(String* string) | 13579 explicit InternalizedStringKey(String* string) |
13580 : string_(string) { } | 13580 : string_(string) { } |
13581 | 13581 |
13582 bool IsMatch(Object* string) { | 13582 bool IsMatch(Object* string) { |
13583 return String::cast(string)->Equals(string_); | 13583 return String::cast(string)->Equals(string_); |
13584 } | 13584 } |
13585 | 13585 |
13586 uint32_t Hash() { return string_->Hash(); } | 13586 uint32_t Hash() { return string_->Hash(); } |
13587 | 13587 |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14417 InternalizedStringKey key(string); | 14417 InternalizedStringKey key(string); |
14418 return LookupKey(&key, s); | 14418 return LookupKey(&key, s); |
14419 } | 14419 } |
14420 | 14420 |
14421 | 14421 |
14422 // This class is used for looking up two character strings in the string table. | 14422 // This class is used for looking up two character strings in the string table. |
14423 // If we don't have a hit we don't want to waste much time so we unroll the | 14423 // If we don't have a hit we don't want to waste much time so we unroll the |
14424 // string hash calculation loop here for speed. Doesn't work if the two | 14424 // string hash calculation loop here for speed. Doesn't work if the two |
14425 // characters form a decimal integer, since such strings have a different hash | 14425 // characters form a decimal integer, since such strings have a different hash |
14426 // algorithm. | 14426 // algorithm. |
14427 class TwoCharHashTableKey V8_FINAL : public HashTableKey { | 14427 class TwoCharHashTableKey : public HashTableKey { |
14428 public: | 14428 public: |
14429 TwoCharHashTableKey(uint16_t c1, uint16_t c2, uint32_t seed) | 14429 TwoCharHashTableKey(uint16_t c1, uint16_t c2, uint32_t seed) |
14430 : c1_(c1), c2_(c2) { | 14430 : c1_(c1), c2_(c2) { |
14431 // Char 1. | 14431 // Char 1. |
14432 uint32_t hash = seed; | 14432 uint32_t hash = seed; |
14433 hash += c1; | 14433 hash += c1; |
14434 hash += hash << 10; | 14434 hash += hash << 10; |
14435 hash ^= hash >> 6; | 14435 hash ^= hash >> 6; |
14436 // Char 2. | 14436 // Char 2. |
14437 hash += c2; | 14437 hash += c2; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14706 NoWriteBarrierSet(this, entry_index, the_hole_value); | 14706 NoWriteBarrierSet(this, entry_index, the_hole_value); |
14707 NoWriteBarrierSet(this, value_index, the_hole_value); | 14707 NoWriteBarrierSet(this, value_index, the_hole_value); |
14708 ElementRemoved(); | 14708 ElementRemoved(); |
14709 } | 14709 } |
14710 } | 14710 } |
14711 return; | 14711 return; |
14712 } | 14712 } |
14713 | 14713 |
14714 | 14714 |
14715 // StringsKey used for HashTable where key is array of internalized strings. | 14715 // StringsKey used for HashTable where key is array of internalized strings. |
14716 class StringsKey V8_FINAL : public HashTableKey { | 14716 class StringsKey : public HashTableKey { |
14717 public: | 14717 public: |
14718 explicit StringsKey(FixedArray* strings) : strings_(strings) { } | 14718 explicit StringsKey(FixedArray* strings) : strings_(strings) { } |
14719 | 14719 |
14720 bool IsMatch(Object* strings) { | 14720 bool IsMatch(Object* strings) { |
14721 FixedArray* o = FixedArray::cast(strings); | 14721 FixedArray* o = FixedArray::cast(strings); |
14722 int len = strings_->length(); | 14722 int len = strings_->length(); |
14723 if (o->length() != len) return false; | 14723 if (o->length() != len) return false; |
14724 for (int i = 0; i < len; i++) { | 14724 for (int i = 0; i < len; i++) { |
14725 if (o->get(i) != strings_->get(i)) return false; | 14725 if (o->get(i) != strings_->get(i)) return false; |
14726 } | 14726 } |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16007 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16007 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16008 static const char* error_messages_[] = { | 16008 static const char* error_messages_[] = { |
16009 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16009 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16010 }; | 16010 }; |
16011 #undef ERROR_MESSAGES_TEXTS | 16011 #undef ERROR_MESSAGES_TEXTS |
16012 return error_messages_[reason]; | 16012 return error_messages_[reason]; |
16013 } | 16013 } |
16014 | 16014 |
16015 | 16015 |
16016 } } // namespace v8::internal | 16016 } } // namespace v8::internal |
OLD | NEW |