Commit 8aca22b1 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Implementing weak referencing elements transition maps.

Review URL: https://chromiumcodereview.appspot.com/10559032

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11842 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 49ad5bdf
...@@ -1881,12 +1881,9 @@ void Marker<T>::MarkDescriptorArray(DescriptorArray* descriptors) { ...@@ -1881,12 +1881,9 @@ void Marker<T>::MarkDescriptorArray(DescriptorArray* descriptors) {
enum_cache); enum_cache);
} }
// TODO(verwaest) Make sure we free unused transitions.
if (descriptors->elements_transition_map() != NULL) { if (descriptors->elements_transition_map() != NULL) {
Object** transitions_slot = descriptors->GetTransitionsSlot(); Object** transitions_slot = descriptors->GetTransitionsSlot();
Object* transitions = *transitions_slot; Object* transitions = *transitions_slot;
base_marker()->MarkObjectAndPush(
reinterpret_cast<HeapObject*>(transitions));
mark_compact_collector()->RecordSlot(descriptor_start, mark_compact_collector()->RecordSlot(descriptor_start,
transitions_slot, transitions_slot,
transitions); transitions);
......
...@@ -922,6 +922,11 @@ static bool CheckOneBackPointer(Map* current_map, Object* target) { ...@@ -922,6 +922,11 @@ static bool CheckOneBackPointer(Map* current_map, Object* target) {
bool DescriptorArray::IsConsistentWithBackPointers(Map* current_map) { bool DescriptorArray::IsConsistentWithBackPointers(Map* current_map) {
Map* elements_transition = elements_transition_map();
if (elements_transition != NULL &&
!CheckOneBackPointer(current_map, elements_transition)) {
return false;
}
for (int i = 0; i < number_of_descriptors(); ++i) { for (int i = 0; i < number_of_descriptors(); ++i) {
switch (GetType(i)) { switch (GetType(i)) {
case MAP_TRANSITION: case MAP_TRANSITION:
......
...@@ -1958,6 +1958,11 @@ void DescriptorArray::set_elements_transition_map( ...@@ -1958,6 +1958,11 @@ void DescriptorArray::set_elements_transition_map(
} }
void DescriptorArray::ClearElementsTransition() {
WRITE_FIELD(this, kTransitionsOffset, Smi::FromInt(0));
}
Object** DescriptorArray::GetKeySlot(int descriptor_number) { Object** DescriptorArray::GetKeySlot(int descriptor_number) {
ASSERT(descriptor_number < number_of_descriptors()); ASSERT(descriptor_number < number_of_descriptors());
return HeapObject::RawField( return HeapObject::RawField(
......
...@@ -7353,6 +7353,11 @@ void Map::ClearNonLiveTransitions(Heap* heap) { ...@@ -7353,6 +7353,11 @@ void Map::ClearNonLiveTransitions(Heap* heap) {
DescriptorArray* d = DescriptorArray::cast( DescriptorArray* d = DescriptorArray::cast(
*RawField(this, Map::kInstanceDescriptorsOrBitField3Offset)); *RawField(this, Map::kInstanceDescriptorsOrBitField3Offset));
if (d->IsEmpty()) return; if (d->IsEmpty()) return;
Map* elements_transition = d->elements_transition_map();
if (elements_transition != NULL &&
ClearBackPointer(heap, elements_transition)) {
d->ClearElementsTransition();
}
Smi* NullDescriptorDetails = Smi* NullDescriptorDetails =
PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi(); PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi();
for (int i = 0; i < d->number_of_descriptors(); ++i) { for (int i = 0; i < d->number_of_descriptors(); ++i) {
......
...@@ -2438,6 +2438,7 @@ class DescriptorArray: public FixedArray { ...@@ -2438,6 +2438,7 @@ class DescriptorArray: public FixedArray {
inline bool MayContainTransitions(); inline bool MayContainTransitions();
DECL_ACCESSORS(elements_transition_map, Map) DECL_ACCESSORS(elements_transition_map, Map)
inline void ClearElementsTransition();
// Returns the number of descriptors in the array. // Returns the number of descriptors in the array.
int number_of_descriptors() { int number_of_descriptors() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment