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

Side by Side Diff: src/heap/mark-compact.cc

Issue 1157943003: Replace ad-hoc weakness in transition array with WeakCell. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove redundant dchecks Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/heap/objects-visiting.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/base/atomicops.h" 7 #include "src/base/atomicops.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/compilation-cache.h" 10 #include "src/compilation-cache.h"
(...skipping 2450 matching lines...) Expand 10 before | Expand all | Expand 10 after
2461 descriptors == dead_transition->instance_descriptors() && 2461 descriptors == dead_transition->instance_descriptors() &&
2462 number_of_own_descriptors > 0) { 2462 number_of_own_descriptors > 0) {
2463 TrimDescriptorArray(map, descriptors, number_of_own_descriptors); 2463 TrimDescriptorArray(map, descriptors, number_of_own_descriptors);
2464 DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors); 2464 DCHECK(descriptors->number_of_descriptors() == number_of_own_descriptors);
2465 map->set_owns_descriptors(true); 2465 map->set_owns_descriptors(true);
2466 return; 2466 return;
2467 } 2467 }
2468 2468
2469 int transition_index = 0; 2469 int transition_index = 0;
2470 2470
2471 bool descriptors_owner_died = false; 2471 // This flag will be cleared if we find the live owner in the loop below.
2472 bool descriptors_owner_died = true;
2472 2473
2473 // Compact all live descriptors to the left. 2474 // Compact all live descriptors to the left.
2474 for (int i = 0; i < num_transitions; ++i) { 2475 if (TransitionArray::IsFullTransitionArray(transitions)) {
2475 Map* target = TransitionArray::GetTarget(transitions, i); 2476 for (int i = 0; i < num_transitions; ++i) {
2476 if (ClearMapBackPointer(target)) { 2477 WeakCell* target_cell =
2477 if (target->instance_descriptors() == descriptors) { 2478 TransitionArray::cast(transitions)->GetTargetCell(i);
2478 descriptors_owner_died = true; 2479 if (!target_cell->cleared()) {
2480 if (Map::cast(target_cell->value())->instance_descriptors() ==
2481 descriptors) {
2482 descriptors_owner_died = false;
2483 }
2484 if (i != transition_index) {
2485 TransitionArray* t = TransitionArray::cast(transitions);
2486 Name* key = t->GetKey(i);
2487 t->SetKey(transition_index, key);
2488 Object** key_slot = t->GetKeySlot(transition_index);
2489 RecordSlot(key_slot, key_slot, key);
2490 WeakCell* target_cell = t->GetTargetCell(i);
brucedawson 2015/06/20 00:08:03 This variable declaration shadows the target_cell
2491 t->SetTargetCell(transition_index, target_cell);
2492 Object** target_slot = t->GetTargetSlot(transition_index);
2493 RecordSlot(target_slot, target_slot, target_cell);
2494 }
2495 transition_index++;
2479 } 2496 }
2480 } else { 2497 }
2481 if (i != transition_index) { 2498 } else if (transitions->IsWeakCell()) {
2482 DCHECK(TransitionArray::IsFullTransitionArray(transitions)); 2499 WeakCell* target_cell = WeakCell::cast(transitions);
2483 TransitionArray* t = TransitionArray::cast(transitions); 2500 if (!target_cell->cleared()) {
2484 Name* key = t->GetKey(i); 2501 if (Map::cast(target_cell->value())->instance_descriptors() ==
2485 t->SetKey(transition_index, key); 2502 descriptors) {
2486 Object** key_slot = t->GetKeySlot(transition_index); 2503 descriptors_owner_died = false;
2487 RecordSlot(key_slot, key_slot, key);
2488 // Target slots do not need to be recorded since maps are not compacted.
2489 t->SetTarget(transition_index, t->GetTarget(i));
2490 } 2504 }
2491 transition_index++; 2505 transition_index++;
2492 } 2506 }
2493 } 2507 }
2494 2508
2495 // If there are no transitions to be cleared, return. 2509 // If there are no transitions to be cleared, return.
2496 // TODO(verwaest) Should be an assert, otherwise back pointers are not 2510 // TODO(verwaest) Should be an assert, otherwise back pointers are not
2497 // properly cleared. 2511 // properly cleared.
2498 if (transition_index == num_transitions) return; 2512 if (transition_index == num_transitions) return;
2499 2513
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4736 SlotsBuffer* buffer = *buffer_address; 4750 SlotsBuffer* buffer = *buffer_address;
4737 while (buffer != NULL) { 4751 while (buffer != NULL) {
4738 SlotsBuffer* next_buffer = buffer->next(); 4752 SlotsBuffer* next_buffer = buffer->next();
4739 DeallocateBuffer(buffer); 4753 DeallocateBuffer(buffer);
4740 buffer = next_buffer; 4754 buffer = next_buffer;
4741 } 4755 }
4742 *buffer_address = NULL; 4756 *buffer_address = NULL;
4743 } 4757 }
4744 } // namespace internal 4758 } // namespace internal
4745 } // namespace v8 4759 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/objects-visiting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698