Index: src/transitions-inl.h |
diff --git a/src/transitions-inl.h b/src/transitions-inl.h |
index 087755d1bdde10f941d17e23f903a0660f5030b2..8a6d1bba1cf56216b0a3896beba4659f6a2f2c92 100644 |
--- a/src/transitions-inl.h |
+++ b/src/transitions-inl.h |
@@ -34,7 +34,7 @@ TransitionArray* TransitionArray::cast(Object* object) { |
bool TransitionArray::HasElementsTransition() { |
- return Search(GetHeap()->elements_transition_symbol()) != kNotFound; |
+ return SearchSpecial(GetHeap()->elements_transition_symbol()) != kNotFound; |
} |
@@ -140,7 +140,7 @@ Object* TransitionArray::GetTargetValue(int transition_number) { |
} |
-int TransitionArray::Search(Name* name, int* out_insertion_index) { |
+int TransitionArray::SearchName(Name* name, int* out_insertion_index) { |
if (IsSimpleTransition()) { |
Name* key = GetKey(kSimpleTransitionIndex); |
if (key->Equals(name)) return kSimpleTransitionIndex; |
@@ -153,6 +153,71 @@ int TransitionArray::Search(Name* name, int* out_insertion_index) { |
} |
+#ifdef DEBUG |
+bool TransitionArray::IsSpecialTransition(Name* name) { |
+ if (!name->IsSymbol()) return false; |
+ Heap* heap = name->GetHeap(); |
+ return name == heap->frozen_symbol() || |
+ name == heap->elements_transition_symbol() || |
+ name == heap->observed_symbol(); |
+} |
+#endif |
+ |
+ |
+int TransitionArray::CompareKeys(Name* key1, uint32_t hash1, |
+ bool is_data_property1, |
+ PropertyAttributes attributes1, Name* key2, |
+ uint32_t hash2, bool is_data_property2, |
+ PropertyAttributes attributes2) { |
+ int cmp = CompareNames(key1, hash1, key2, hash2); |
+ if (cmp != 0) return cmp; |
+ |
+ return CompareDetails(is_data_property1, attributes1, is_data_property2, |
+ attributes2); |
+} |
+ |
+ |
+int TransitionArray::CompareNames(Name* key1, uint32_t hash1, Name* key2, |
+ uint32_t hash2) { |
+ if (key1 != key2) { |
+ // In case of hash collisions key1 is always "less" than key2. |
+ return hash1 <= hash2 ? -1 : 1; |
+ } |
+ |
+ return 0; |
+} |
+ |
+ |
+int TransitionArray::CompareDetails(bool is_data_property1, |
+ PropertyAttributes attributes1, |
+ bool is_data_property2, |
+ PropertyAttributes attributes2) { |
+ if (is_data_property1 != is_data_property2) { |
+ return static_cast<int>(is_data_property1) < |
+ static_cast<int>(is_data_property2) |
+ ? -1 |
+ : 1; |
+ } |
+ |
+ if (attributes1 != attributes2) { |
+ return static_cast<int>(attributes1) < static_cast<int>(attributes2) ? -1 |
+ : 1; |
+ } |
+ |
+ return 0; |
+} |
+ |
+ |
+PropertyDetails TransitionArray::GetTargetDetails(Name* name, Map* target) { |
+ DCHECK(!IsSpecialTransition(name)); |
+ int descriptor = target->LastAdded(); |
+ DescriptorArray* descriptors = target->instance_descriptors(); |
+ // Transitions are allowed only for the last added property. |
+ DCHECK(descriptors->GetKey(descriptor)->Equals(name)); |
+ return descriptors->GetDetails(descriptor); |
+} |
+ |
+ |
void TransitionArray::NoIncrementalWriteBarrierSet(int transition_number, |
Name* key, |
Map* target) { |