Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1027)

Unified Diff: src/transitions-inl.h

Issue 661133002: TransitionArray now uses <is_data_property, name, attributes> tuple as a key, which allows to have … (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/transitions.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « src/transitions.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698