Index: src/objects-inl.h |
diff --git a/src/objects-inl.h b/src/objects-inl.h |
index fb3fe647f1a8be00eb543a54dfe8aecd69299fa6..36d0b6c15c5be65ccea2b5d09a3894308288fc50 100644 |
--- a/src/objects-inl.h |
+++ b/src/objects-inl.h |
@@ -1906,12 +1906,6 @@ bool DescriptorArray::IsEmpty() { |
} |
-void DescriptorArray::SetNumberOfDescriptors(int number_of_descriptors) { |
- WRITE_FIELD( |
- this, kDescriptorLengthOffset, Smi::FromInt(number_of_descriptors)); |
-} |
- |
- |
// Perform a binary search in a fixed array. Low and high are entry indices. If |
// there are three entries in this array it should be called with low=0 and |
// high=2. |
@@ -2144,30 +2138,11 @@ void DescriptorArray::Set(int descriptor_number, |
} |
-void DescriptorArray::Set(int descriptor_number, Descriptor* desc) { |
- // Range check. |
- ASSERT(descriptor_number < number_of_descriptors()); |
- ASSERT(desc->GetDetails().descriptor_index() <= |
- number_of_descriptors()); |
- ASSERT(desc->GetDetails().descriptor_index() > 0); |
- |
- set(ToKeyIndex(descriptor_number), desc->GetKey()); |
- set(ToValueIndex(descriptor_number), desc->GetValue()); |
- set(ToDetailsIndex(descriptor_number), desc->GetDetails().AsSmi()); |
-} |
- |
- |
-void DescriptorArray::EraseDescriptor(Heap* heap, int descriptor_number) { |
- set_null_unchecked(heap, ToKeyIndex(descriptor_number)); |
- set_null_unchecked(heap, ToValueIndex(descriptor_number)); |
-} |
- |
- |
void DescriptorArray::Append(Descriptor* desc, |
- const WhitenessWitness& witness) { |
- int descriptor_number = number_of_descriptors(); |
+ const WhitenessWitness& witness, |
+ int number_of_set_descriptors) { |
+ int descriptor_number = number_of_set_descriptors; |
int enumeration_index = descriptor_number + 1; |
- SetNumberOfDescriptors(descriptor_number + 1); |
desc->SetEnumerationIndex(enumeration_index); |
Set(descriptor_number, desc, witness); |
@@ -2185,27 +2160,6 @@ void DescriptorArray::Append(Descriptor* desc, |
} |
-void DescriptorArray::Append(Descriptor* desc) { |
- int descriptor_number = number_of_descriptors(); |
- int enumeration_index = descriptor_number + 1; |
- SetNumberOfDescriptors(descriptor_number + 1); |
- desc->SetEnumerationIndex(enumeration_index); |
- Set(descriptor_number, desc); |
- |
- uint32_t hash = desc->GetKey()->Hash(); |
- |
- int insertion; |
- |
- for (insertion = descriptor_number; insertion > 0; --insertion) { |
- String* key = GetSortedKey(insertion - 1); |
- if (key->Hash() <= hash) break; |
- SetSortedKey(insertion, GetSortedKeyIndex(insertion - 1)); |
- } |
- |
- SetSortedKey(insertion, descriptor_number); |
-} |
- |
- |
void DescriptorArray::SwapSortedKeys(int first, int second) { |
int first_key = GetSortedKeyIndex(first); |
SetSortedKey(first, GetSortedKeyIndex(second)); |
@@ -3560,31 +3514,17 @@ DescriptorArray* Map::instance_descriptors() { |
} |
-enum TransitionsKind { DESCRIPTORS_HOLDER, FULL_TRANSITION_ARRAY }; |
- |
- |
// If the descriptor is using the empty transition array, install a new empty |
// transition array that will have place for an element transition. |
-static MaybeObject* EnsureHasTransitionArray(Map* map, TransitionsKind kind) { |
+static MaybeObject* EnsureHasTransitionArray(Map* map) { |
+ if (map->HasTransitionArray()) return map; |
+ |
TransitionArray* transitions; |
- MaybeObject* maybe_transitions; |
- if (map->HasTransitionArray()) { |
- if (kind != FULL_TRANSITION_ARRAY || |
- map->transitions()->IsFullTransitionArray()) { |
- return map; |
- } |
- maybe_transitions = map->transitions()->ExtendToFullTransitionArray(); |
- if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
- } else { |
- JSGlobalPropertyCell* pointer = map->RetrieveDescriptorsPointer(); |
- if (kind == FULL_TRANSITION_ARRAY) { |
- maybe_transitions = TransitionArray::Allocate(0, pointer); |
- } else { |
- maybe_transitions = TransitionArray::AllocateDescriptorsHolder(pointer); |
- } |
- if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
- transitions->set_back_pointer_storage(map->GetBackPointer()); |
- } |
+ JSGlobalPropertyCell* pointer = map->RetrieveDescriptorsPointer(); |
+ MaybeObject* maybe_transitions = TransitionArray::Allocate(0, pointer); |
+ if (!maybe_transitions->To(&transitions)) return maybe_transitions; |
+ |
+ transitions->set_back_pointer_storage(map->GetBackPointer()); |
map->set_transitions(transitions); |
return transitions; |
} |
@@ -3592,8 +3532,7 @@ static MaybeObject* EnsureHasTransitionArray(Map* map, TransitionsKind kind) { |
MaybeObject* Map::SetDescriptors(DescriptorArray* value) { |
ASSERT(!is_shared()); |
- MaybeObject* maybe_failure = |
- EnsureHasTransitionArray(this, DESCRIPTORS_HOLDER); |
+ MaybeObject* maybe_failure = EnsureHasTransitionArray(this); |
if (maybe_failure->IsFailure()) return maybe_failure; |
ASSERT(NumberOfOwnDescriptors() <= value->number_of_descriptors()); |
@@ -3652,8 +3591,8 @@ void Map::AppendDescriptor(Descriptor* desc, |
const DescriptorArray::WhitenessWitness& witness) { |
DescriptorArray* descriptors = instance_descriptors(); |
int number_of_own_descriptors = NumberOfOwnDescriptors(); |
- ASSERT(descriptors->number_of_descriptors() == number_of_own_descriptors); |
- descriptors->Append(desc, witness); |
+ ASSERT(number_of_own_descriptors < descriptors->number_of_descriptors()); |
+ descriptors->Append(desc, witness, number_of_own_descriptors); |
SetNumberOfOwnDescriptors(number_of_own_descriptors + 1); |
} |
@@ -3703,13 +3642,11 @@ JSGlobalPropertyCell* Map::RetrieveDescriptorsPointer() { |
} |
-MaybeObject* Map::AddTransition(String* key, |
- Map* target, |
- SimpleTransitionFlag flag) { |
+MaybeObject* Map::AddTransition(String* key, Map* target) { |
if (HasTransitionArray()) return transitions()->CopyInsert(key, target); |
JSGlobalPropertyCell* descriptors_pointer = RetrieveDescriptorsPointer(); |
return TransitionArray::NewWith( |
- flag, key, target, descriptors_pointer, GetBackPointer()); |
+ key, target, descriptors_pointer, GetBackPointer()); |
} |
@@ -3724,8 +3661,7 @@ Map* Map::GetTransition(int transition_index) { |
MaybeObject* Map::set_elements_transition_map(Map* transitioned_map) { |
- MaybeObject* allow_elements = |
- EnsureHasTransitionArray(this, FULL_TRANSITION_ARRAY); |
+ MaybeObject* allow_elements = EnsureHasTransitionArray(this); |
if (allow_elements->IsFailure()) return allow_elements; |
transitions()->set_elements_transition(transitioned_map); |
return this; |
@@ -3742,8 +3678,7 @@ FixedArray* Map::GetPrototypeTransitions() { |
MaybeObject* Map::SetPrototypeTransitions(FixedArray* proto_transitions) { |
- MaybeObject* allow_prototype = |
- EnsureHasTransitionArray(this, FULL_TRANSITION_ARRAY); |
+ MaybeObject* allow_prototype = EnsureHasTransitionArray(this); |
if (allow_prototype->IsFailure()) return allow_prototype; |
#ifdef DEBUG |
if (HasPrototypeTransitions()) { |
@@ -4949,7 +4884,8 @@ StringHasher::StringHasher(int length, uint32_t seed) |
raw_running_hash_(seed), |
array_index_(0), |
is_array_index_(0 < length_ && length_ <= String::kMaxArrayIndexSize), |
- is_first_char_(true) { |
+ is_first_char_(true), |
+ is_valid_(true) { |
ASSERT(FLAG_randomize_hashes || raw_running_hash_ == 0); |
} |
@@ -4959,25 +4895,6 @@ bool StringHasher::has_trivial_hash() { |
} |
-uint32_t StringHasher::AddCharacterCore(uint32_t running_hash, uint32_t c) { |
- running_hash += c; |
- running_hash += (running_hash << 10); |
- running_hash ^= (running_hash >> 6); |
- return running_hash; |
-} |
- |
- |
-uint32_t StringHasher::GetHashCore(uint32_t running_hash) { |
- running_hash += (running_hash << 3); |
- running_hash ^= (running_hash >> 11); |
- running_hash += (running_hash << 15); |
- if ((running_hash & String::kHashBitMask) == 0) { |
- return 27; |
- } |
- return running_hash; |
-} |
- |
- |
void StringHasher::AddCharacter(uint32_t c) { |
if (c > unibrow::Utf16::kMaxNonSurrogateCharCode) { |
AddSurrogatePair(c); // Not inlined. |
@@ -4985,7 +4902,9 @@ void StringHasher::AddCharacter(uint32_t c) { |
} |
// Use the Jenkins one-at-a-time hash function to update the hash |
// for the given character. |
- raw_running_hash_ = AddCharacterCore(raw_running_hash_, c); |
+ raw_running_hash_ += c; |
+ raw_running_hash_ += (raw_running_hash_ << 10); |
+ raw_running_hash_ ^= (raw_running_hash_ >> 6); |
// Incremental array index computation. |
if (is_array_index_) { |
if (c < '0' || c > '9') { |
@@ -5015,14 +4934,23 @@ void StringHasher::AddCharacterNoIndex(uint32_t c) { |
AddSurrogatePairNoIndex(c); // Not inlined. |
return; |
} |
- raw_running_hash_ = AddCharacterCore(raw_running_hash_, c); |
+ raw_running_hash_ += c; |
+ raw_running_hash_ += (raw_running_hash_ << 10); |
+ raw_running_hash_ ^= (raw_running_hash_ >> 6); |
} |
uint32_t StringHasher::GetHash() { |
// Get the calculated raw hash value and do some more bit ops to distribute |
// the hash further. Ensure that we never return zero as the hash value. |
- return GetHashCore(raw_running_hash_); |
+ uint32_t result = raw_running_hash_; |
+ result += (result << 3); |
+ result ^= (result >> 11); |
+ result += (result << 15); |
+ if ((result & String::kHashBitMask) == 0) { |
+ result = 27; |
+ } |
+ return result; |
} |