OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 7379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7390 void String::PrintOn(FILE* file) { | 7390 void String::PrintOn(FILE* file) { |
7391 int length = this->length(); | 7391 int length = this->length(); |
7392 for (int i = 0; i < length; i++) { | 7392 for (int i = 0; i < length; i++) { |
7393 fprintf(file, "%c", Get(i)); | 7393 fprintf(file, "%c", Get(i)); |
7394 } | 7394 } |
7395 } | 7395 } |
7396 | 7396 |
7397 | 7397 |
7398 // Clear a possible back pointer in case the transition leads to a dead map. | 7398 // Clear a possible back pointer in case the transition leads to a dead map. |
7399 // Return true in case a back pointer has been cleared and false otherwise. | 7399 // Return true in case a back pointer has been cleared and false otherwise. |
7400 // Set *keep_entry to true when a live map transition has been found. | 7400 static bool ClearBackPointer(Heap* heap, Object* target) { |
7401 static bool ClearBackPointer(Heap* heap, Object* target, bool* keep_entry) { | 7401 ASSERT(target->IsMap()); |
7402 if (!target->IsMap()) return false; | |
7403 Map* map = Map::cast(target); | 7402 Map* map = Map::cast(target); |
7404 if (Marking::MarkBitFrom(map).Get()) { | 7403 if (Marking::MarkBitFrom(map).Get()) { |
Sven Panne
2012/06/05 10:52:01
Nit: To be more consistent with the rest of the co
Toon Verwaest
2012/06/05 11:23:28
Done.
| |
7405 *keep_entry = true; | |
7406 return false; | 7404 return false; |
7407 } else { | |
7408 map->SetBackPointer(heap->undefined_value(), SKIP_WRITE_BARRIER); | |
7409 return true; | |
7410 } | 7405 } |
7406 map->SetBackPointer(heap->undefined_value(), SKIP_WRITE_BARRIER); | |
7407 return true; | |
7411 } | 7408 } |
7412 | 7409 |
7413 | 7410 |
7414 void Map::ClearNonLiveTransitions(Heap* heap) { | 7411 void Map::ClearNonLiveTransitions(Heap* heap) { |
7415 DescriptorArray* d = DescriptorArray::cast( | 7412 DescriptorArray* d = DescriptorArray::cast( |
7416 *RawField(this, Map::kInstanceDescriptorsOrBitField3Offset)); | 7413 *RawField(this, Map::kInstanceDescriptorsOrBitField3Offset)); |
7417 if (d->IsEmpty()) return; | 7414 if (d->IsEmpty()) return; |
7418 Smi* NullDescriptorDetails = | 7415 Smi* NullDescriptorDetails = |
7419 PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi(); | 7416 PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi(); |
7420 for (int i = 0; i < d->number_of_descriptors(); ++i) { | 7417 for (int i = 0; i < d->number_of_descriptors(); ++i) { |
7421 // If the pair (value, details) is a map transition, check if the target is | 7418 // If the pair (value, details) is a map transition, check if the target is |
7422 // live. If not, null the descriptor. Also drop the back pointer for that | 7419 // live. If not, null the descriptor. Also drop the back pointer for that |
7423 // map transition, so that this map is not reached again by following a back | 7420 // map transition, so that this map is not reached again by following a back |
7424 // pointer from that non-live map. | 7421 // pointer from that non-live map. |
7425 bool keep_entry = false; | 7422 bool keep_entry = false; |
Sven Panne
2012/06/05 10:52:01
Move the initialization to the CALLBACKS case, thi
Toon Verwaest
2012/06/05 11:23:28
Done.
| |
7426 PropertyDetails details(d->GetDetails(i)); | 7423 PropertyDetails details(d->GetDetails(i)); |
7427 switch (details.type()) { | 7424 switch (details.type()) { |
7428 case MAP_TRANSITION: | 7425 case MAP_TRANSITION: |
7429 case CONSTANT_TRANSITION: | 7426 case CONSTANT_TRANSITION: |
7430 ClearBackPointer(heap, d->GetValue(i), &keep_entry); | 7427 keep_entry = !ClearBackPointer(heap, d->GetValue(i)); |
7431 break; | 7428 break; |
7432 case ELEMENTS_TRANSITION: { | 7429 case ELEMENTS_TRANSITION: { |
7433 Object* object = d->GetValue(i); | 7430 Object* object = d->GetValue(i); |
7434 if (object->IsMap()) { | 7431 if (object->IsMap()) { |
7435 ClearBackPointer(heap, object, &keep_entry); | 7432 keep_entry = !ClearBackPointer(heap, object); |
7436 } else { | 7433 } else { |
7437 FixedArray* array = FixedArray::cast(object); | 7434 FixedArray* array = FixedArray::cast(object); |
7438 for (int j = 0; j < array->length(); ++j) { | 7435 for (int j = 0; j < array->length(); ++j) { |
7439 if (ClearBackPointer(heap, array->get(j), &keep_entry)) { | 7436 Object* target = array->get(j); |
7440 array->set_undefined(j); | 7437 if (target->IsMap()) { |
7438 if (ClearBackPointer(heap, array->get(j))) { | |
Sven Panne
2012/06/05 10:52:01
Just use "target", it's cleaner... ;-)
Toon Verwaest
2012/06/05 11:23:28
Done.
| |
7439 array->set_undefined(j); | |
7440 } else { | |
7441 keep_entry = true; | |
7442 } | |
7441 } | 7443 } |
7442 } | 7444 } |
7443 } | 7445 } |
7444 break; | 7446 break; |
7445 } | 7447 } |
7446 case CALLBACKS: { | 7448 case CALLBACKS: { |
7447 Object* object = d->GetValue(i); | 7449 Object* object = d->GetValue(i); |
7448 if (object->IsAccessorPair()) { | 7450 if (object->IsAccessorPair()) { |
7449 AccessorPair* accessors = AccessorPair::cast(object); | 7451 AccessorPair* accessors = AccessorPair::cast(object); |
7450 if (ClearBackPointer(heap, accessors->getter(), &keep_entry)) { | 7452 Object* getter = accessors->getter(); |
7451 accessors->set_getter(heap->the_hole_value()); | 7453 Object* setter = accessors->setter(); |
Sven Panne
2012/06/05 10:52:01
Move this down before "if (setter->IsMap())...", a
Toon Verwaest
2012/06/05 11:23:28
Done.
| |
7454 if (getter->IsMap()) { | |
7455 if (ClearBackPointer(heap, getter)) { | |
7456 accessors->set_getter(heap->the_hole_value()); | |
7457 } else { | |
7458 keep_entry = true; | |
7459 } | |
7460 } else if (!getter->IsTheHole()) { | |
7461 keep_entry = true; | |
7452 } | 7462 } |
7453 if (ClearBackPointer(heap, accessors->setter(), &keep_entry)) { | 7463 if (setter->IsMap()) { |
7454 accessors->set_setter(heap->the_hole_value()); | 7464 if (ClearBackPointer(heap, setter)) { |
7465 accessors->set_setter(heap->the_hole_value()); | |
7466 } else { | |
7467 keep_entry = true; | |
7468 } | |
7469 } else if (!getter->IsTheHole()) { | |
7470 keep_entry = true; | |
7455 } | 7471 } |
7456 } else { | 7472 } else { |
7457 keep_entry = true; | 7473 keep_entry = true; |
7458 } | 7474 } |
7459 break; | 7475 break; |
7460 } | 7476 } |
7461 case NORMAL: | 7477 case NORMAL: |
7462 case FIELD: | 7478 case FIELD: |
7463 case CONSTANT_FUNCTION: | 7479 case CONSTANT_FUNCTION: |
7464 case HANDLER: | 7480 case HANDLER: |
(...skipping 5753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13218 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13234 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
13219 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13235 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
13220 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13236 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
13221 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13237 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
13222 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13238 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
13223 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13239 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
13224 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13240 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
13225 } | 13241 } |
13226 | 13242 |
13227 } } // namespace v8::internal | 13243 } } // namespace v8::internal |
OLD | NEW |