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

Unified Diff: src/objects-inl.h

Issue 10444055: Promoting elements transitions to their own field. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: full patch Created 8 years, 7 months 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
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 687b525f64026179fe36006abc6a40d6258b4dd1..84971213eb72fcd2715928f28bd27ad9ff82d09a 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1870,10 +1870,17 @@ Object** FixedArray::data_start() {
bool DescriptorArray::IsEmpty() {
- ASSERT(this->IsSmi() ||
- this->length() > kFirstIndex ||
- this == HEAP->empty_descriptor_array());
- return this->IsSmi() || length() <= kFirstIndex;
+ // TODO(verwaest) Reenable and change >= above when descriptor array is
+ // immutable again.
danno 2012/06/01 13:49:55 Re-enable this assert appropriately.
Toon Verwaest 2012/06/04 09:17:48 Done.
+ // ASSERT(this->IsSmi() ||
+ // this->length() > kFirstIndex ||
+ // this == HEAP->empty_descriptor_array());
+ return this->IsSmi() || length() < kFirstIndex;
+}
+
+
+bool DescriptorArray::MayContainTransitions() {
+ return length() >= kTransitionsIndex;
}
@@ -1883,7 +1890,7 @@ int DescriptorArray::bit_field3_storage() {
}
void DescriptorArray::set_bit_field3_storage(int value) {
- ASSERT(!IsEmpty());
+ ASSERT(this->MayContainTransitions());
WRITE_FIELD(this, kBitField3StorageOffset, Smi::FromInt(value));
}
@@ -1925,6 +1932,30 @@ int DescriptorArray::SearchWithCache(String* name) {
}
+Map* DescriptorArray::elements_transition() {
+ if (!this->MayContainTransitions()) {
+ return NULL;
+ }
+ Object* transition_map = get(kTransitionsIndex);
+ if (transition_map == Smi::FromInt(0)) {
+ return NULL;
+ } else {
+ return Map::cast(transition_map);
+ }
+}
+
+
+void DescriptorArray::set_elements_transition(
+ Map* transition_map, WriteBarrierMode mode) {
+ ASSERT(this->length() >= kFirstIndex);
+ Heap* heap = GetHeap();
+ WRITE_FIELD(this, kTransitionsOffset, transition_map);
+ CONDITIONAL_WRITE_BARRIER(
+ heap, this, kTransitionsOffset, transition_map, mode);
+ ASSERT(DescriptorArray::cast(this));
+}
+
+
Object** DescriptorArray::GetKeySlot(int descriptor_number) {
ASSERT(descriptor_number < number_of_descriptors());
return HeapObject::RawField(
@@ -2011,7 +2042,6 @@ bool DescriptorArray::IsTransitionOnly(int descriptor_number) {
switch (GetType(descriptor_number)) {
case MAP_TRANSITION:
case CONSTANT_TRANSITION:
- case ELEMENTS_TRANSITION:
return true;
case CALLBACKS: {
Object* value = GetValue(descriptor_number);
@@ -3453,6 +3483,16 @@ Object* Map::GetBackPointer() {
}
+Map* Map::elements_transition() {
+ return instance_descriptors()->elements_transition();
+}
+
+
+void Map::set_elements_transition(Map* transitioned_map) {
+ return instance_descriptors()->set_elements_transition(transitioned_map);
+}
+
+
void Map::SetBackPointer(Object* value, WriteBarrierMode mode) {
Heap* heap = GetHeap();
ASSERT(instance_type() >= FIRST_JS_RECEIVER_TYPE);
@@ -4050,15 +4090,12 @@ MaybeObject* JSFunction::set_initial_map_and_cache_transitions(
maps->set(kind, current_map);
for (int i = GetSequenceIndexFromFastElementsKind(kind) + 1;
i < kFastElementsKindCount; ++i) {
- ElementsKind transitioned_kind = GetFastElementsKindFromSequenceIndex(i);
- MaybeObject* maybe_new_map = current_map->CopyDropTransitions();
- Map* new_map = NULL;
- if (!maybe_new_map->To<Map>(&new_map)) return maybe_new_map;
- new_map->set_elements_kind(transitioned_kind);
- maybe_new_map = current_map->AddElementsTransition(transitioned_kind,
- new_map);
- if (maybe_new_map->IsFailure()) return maybe_new_map;
- maps->set(transitioned_kind, new_map);
+ Map* new_map;
+ ElementsKind next_kind = GetFastElementsKindFromSequenceIndex(i);
+ MaybeObject* maybe_new_map =
+ current_map->CreateNextElementsTransition(next_kind);
+ if (!maybe_new_map->To(&new_map)) return maybe_new_map;
+ maps->set(next_kind, new_map);
current_map = new_map;
}
global_context->set_js_array_maps(maps);

Powered by Google App Engine
This is Rietveld 408576698