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

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: Fix 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') | src/transitions-inl.h » ('J')
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 DCHECK(TransitionArray::IsFullTransitionArray(transitions));
Jakob Kummerow 2015/06/17 10:38:51 This DCHECK is unneeded, as it duplicates line 247
2486 TransitionArray* t = TransitionArray::cast(transitions);
2487 Name* key = t->GetKey(i);
2488 t->SetKey(transition_index, key);
2489 Object** key_slot = t->GetKeySlot(transition_index);
2490 RecordSlot(key_slot, key_slot, key);
2491 WeakCell* target_cell = t->GetTargetCell(i);
2492 t->SetTargetCell(transition_index, target_cell);
2493 Object** target_slot = t->GetTargetSlot(transition_index);
2494 RecordSlot(target_slot, target_slot, target_cell);
2495 }
2496 transition_index++;
2479 } 2497 }
2480 } else { 2498 }
2481 if (i != transition_index) { 2499 } else if (transitions->IsWeakCell()) {
2482 DCHECK(TransitionArray::IsFullTransitionArray(transitions)); 2500 WeakCell* target_cell = WeakCell::cast(transitions);
2483 TransitionArray* t = TransitionArray::cast(transitions); 2501 if (!target_cell->cleared()) {
2484 Name* key = t->GetKey(i); 2502 if (Map::cast(target_cell->value())->instance_descriptors() ==
2485 t->SetKey(transition_index, key); 2503 descriptors) {
2486 Object** key_slot = t->GetKeySlot(transition_index); 2504 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 } 2505 }
2491 transition_index++; 2506 transition_index++;
2492 } 2507 }
2493 } 2508 }
2494 2509
2495 // If there are no transitions to be cleared, return. 2510 // If there are no transitions to be cleared, return.
2496 // TODO(verwaest) Should be an assert, otherwise back pointers are not 2511 // TODO(verwaest) Should be an assert, otherwise back pointers are not
2497 // properly cleared. 2512 // properly cleared.
2498 if (transition_index == num_transitions) return; 2513 if (transition_index == num_transitions) return;
2499 2514
(...skipping 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after
4736 SlotsBuffer* buffer = *buffer_address; 4751 SlotsBuffer* buffer = *buffer_address;
4737 while (buffer != NULL) { 4752 while (buffer != NULL) {
4738 SlotsBuffer* next_buffer = buffer->next(); 4753 SlotsBuffer* next_buffer = buffer->next();
4739 DeallocateBuffer(buffer); 4754 DeallocateBuffer(buffer);
4740 buffer = next_buffer; 4755 buffer = next_buffer;
4741 } 4756 }
4742 *buffer_address = NULL; 4757 *buffer_address = NULL;
4743 } 4758 }
4744 } // namespace internal 4759 } // namespace internal
4745 } // namespace v8 4760 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/heap/objects-visiting.h » ('j') | src/transitions-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698