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

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

Issue 1009603003: Add debug checks to catch crashes with WeakCell::cast(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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/isolate.cc » ('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 2080 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 // Do not retain dead maps if flag disables it or there is 2091 // Do not retain dead maps if flag disables it or there is
2092 // - memory pressure (reduce_memory_footprint_), 2092 // - memory pressure (reduce_memory_footprint_),
2093 // - GC is requested by tests or dev-tools (abort_incremental_marking_). 2093 // - GC is requested by tests or dev-tools (abort_incremental_marking_).
2094 return; 2094 return;
2095 } 2095 }
2096 2096
2097 ArrayList* retained_maps = heap()->retained_maps(); 2097 ArrayList* retained_maps = heap()->retained_maps();
2098 int length = retained_maps->Length(); 2098 int length = retained_maps->Length();
2099 int new_length = 0; 2099 int new_length = 0;
2100 for (int i = 0; i < length; i += 2) { 2100 for (int i = 0; i < length; i += 2) {
2101 DCHECK(retained_maps->Get(i)->IsWeakCell());
2101 WeakCell* cell = WeakCell::cast(retained_maps->Get(i)); 2102 WeakCell* cell = WeakCell::cast(retained_maps->Get(i));
2102 if (cell->cleared()) continue; 2103 if (cell->cleared()) continue;
2103 int age = Smi::cast(retained_maps->Get(i + 1))->value(); 2104 int age = Smi::cast(retained_maps->Get(i + 1))->value();
2104 int new_age; 2105 int new_age;
2105 Map* map = Map::cast(cell->value()); 2106 Map* map = Map::cast(cell->value());
2106 MarkBit map_mark = Marking::MarkBitFrom(map); 2107 MarkBit map_mark = Marking::MarkBitFrom(map);
2107 if (!map_mark.Get()) { 2108 if (!map_mark.Get()) {
2108 if (age == 0) { 2109 if (age == 0) {
2109 // The map has aged. Do not retain this map. 2110 // The map has aged. Do not retain this map.
2110 continue; 2111 continue;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 } 2342 }
2342 2343
2343 WeakHashTable* table = heap_->weak_object_to_code_table(); 2344 WeakHashTable* table = heap_->weak_object_to_code_table();
2344 uint32_t capacity = table->Capacity(); 2345 uint32_t capacity = table->Capacity();
2345 for (uint32_t i = 0; i < capacity; i++) { 2346 for (uint32_t i = 0; i < capacity; i++) {
2346 uint32_t key_index = table->EntryToIndex(i); 2347 uint32_t key_index = table->EntryToIndex(i);
2347 Object* key = table->get(key_index); 2348 Object* key = table->get(key_index);
2348 if (!table->IsKey(key)) continue; 2349 if (!table->IsKey(key)) continue;
2349 uint32_t value_index = table->EntryToValueIndex(i); 2350 uint32_t value_index = table->EntryToValueIndex(i);
2350 Object* value = table->get(value_index); 2351 Object* value = table->get(value_index);
2352 DCHECK(key->IsWeakCell());
2351 if (WeakCell::cast(key)->cleared()) { 2353 if (WeakCell::cast(key)->cleared()) {
2352 have_code_to_deoptimize_ |= 2354 have_code_to_deoptimize_ |=
2353 DependentCode::cast(value)->MarkCodeForDeoptimization( 2355 DependentCode::cast(value)->MarkCodeForDeoptimization(
2354 isolate(), DependentCode::kWeakCodeGroup); 2356 isolate(), DependentCode::kWeakCodeGroup);
2355 table->set(key_index, heap_->the_hole_value()); 2357 table->set(key_index, heap_->the_hole_value());
2356 table->set(value_index, heap_->the_hole_value()); 2358 table->set(value_index, heap_->the_hole_value());
2357 table->ElementRemoved(); 2359 table->ElementRemoved();
2358 } 2360 }
2359 } 2361 }
2360 } 2362 }
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
4552 SlotsBuffer* buffer = *buffer_address; 4554 SlotsBuffer* buffer = *buffer_address;
4553 while (buffer != NULL) { 4555 while (buffer != NULL) {
4554 SlotsBuffer* next_buffer = buffer->next(); 4556 SlotsBuffer* next_buffer = buffer->next();
4555 DeallocateBuffer(buffer); 4557 DeallocateBuffer(buffer);
4556 buffer = next_buffer; 4558 buffer = next_buffer;
4557 } 4559 }
4558 *buffer_address = NULL; 4560 *buffer_address = NULL;
4559 } 4561 }
4560 } 4562 }
4561 } // namespace v8::internal 4563 } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698