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

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

Issue 8343056: Fix Harmony sets and maps to allow null as key. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/heap-inl.h ('k') | src/objects.h » ('j') | src/objects-inl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 if (o->IsHeapObject() && 1509 if (o->IsHeapObject() &&
1510 !Marking::MarkBitFrom(HeapObject::cast(o)).Get()) { 1510 !Marking::MarkBitFrom(HeapObject::cast(o)).Get()) {
1511 // Check if the symbol being pruned is an external symbol. We need to 1511 // Check if the symbol being pruned is an external symbol. We need to
1512 // delete the associated external data as this symbol is going away. 1512 // delete the associated external data as this symbol is going away.
1513 1513
1514 // Since no objects have yet been moved we can safely access the map of 1514 // Since no objects have yet been moved we can safely access the map of
1515 // the object. 1515 // the object.
1516 if (o->IsExternalString()) { 1516 if (o->IsExternalString()) {
1517 heap_->FinalizeExternalString(String::cast(*p)); 1517 heap_->FinalizeExternalString(String::cast(*p));
1518 } 1518 }
1519 // Set the entry to null_value (as deleted). 1519 // Set the entry to the_hole_value (as deleted).
1520 *p = heap_->null_value(); 1520 *p = heap_->the_hole_value();
1521 pointers_removed_++; 1521 pointers_removed_++;
1522 } 1522 }
1523 } 1523 }
1524 } 1524 }
1525 1525
1526 int PointersRemoved() { 1526 int PointersRemoved() {
1527 return pointers_removed_; 1527 return pointers_removed_;
1528 } 1528 }
1529 1529
1530 private: 1530 private:
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 if (!IsMarked(raw_map_cache) && 2117 if (!IsMarked(raw_map_cache) &&
2118 raw_map_cache != heap()->undefined_value()) { 2118 raw_map_cache != heap()->undefined_value()) {
2119 MapCache* map_cache = reinterpret_cast<MapCache*>(raw_map_cache); 2119 MapCache* map_cache = reinterpret_cast<MapCache*>(raw_map_cache);
2120 int existing_elements = map_cache->NumberOfElements(); 2120 int existing_elements = map_cache->NumberOfElements();
2121 int used_elements = 0; 2121 int used_elements = 0;
2122 for (int i = MapCache::kElementsStartIndex; 2122 for (int i = MapCache::kElementsStartIndex;
2123 i < map_cache->length(); 2123 i < map_cache->length();
2124 i += MapCache::kEntrySize) { 2124 i += MapCache::kEntrySize) {
2125 Object* raw_key = map_cache->get(i); 2125 Object* raw_key = map_cache->get(i);
2126 if (raw_key == heap()->undefined_value() || 2126 if (raw_key == heap()->undefined_value() ||
2127 raw_key == heap()->null_value()) continue; 2127 raw_key == heap()->the_hole_value()) continue;
2128 STATIC_ASSERT(MapCache::kEntrySize == 2); 2128 STATIC_ASSERT(MapCache::kEntrySize == 2);
2129 Object* raw_map = map_cache->get(i + 1); 2129 Object* raw_map = map_cache->get(i + 1);
2130 if (raw_map->IsHeapObject() && IsMarked(raw_map)) { 2130 if (raw_map->IsHeapObject() && IsMarked(raw_map)) {
2131 ++used_elements; 2131 ++used_elements;
2132 } else { 2132 } else {
2133 // Delete useless entries with unmarked maps. 2133 // Delete useless entries with unmarked maps.
2134 ASSERT(raw_map->IsMap()); 2134 ASSERT(raw_map->IsMap());
2135 map_cache->set_null_unchecked(heap(), i); 2135 map_cache->set_the_hole(i);
2136 map_cache->set_null_unchecked(heap(), i + 1); 2136 map_cache->set_the_hole(i + 1);
2137 } 2137 }
2138 } 2138 }
2139 if (used_elements == 0) { 2139 if (used_elements == 0) {
2140 context->set(Context::MAP_CACHE_INDEX, heap()->undefined_value()); 2140 context->set(Context::MAP_CACHE_INDEX, heap()->undefined_value());
2141 } else { 2141 } else {
2142 // Note: we don't actually shrink the cache here to avoid 2142 // Note: we don't actually shrink the cache here to avoid
2143 // extra complexity during GC. We rely on subsequent cache 2143 // extra complexity during GC. We rely on subsequent cache
2144 // usages (EnsureCapacity) to do this. 2144 // usages (EnsureCapacity) to do this.
2145 map_cache->ElementsRemoved(existing_elements - used_elements); 2145 map_cache->ElementsRemoved(existing_elements - used_elements);
2146 MarkBit map_cache_markbit = Marking::MarkBitFrom(map_cache); 2146 MarkBit map_cache_markbit = Marking::MarkBitFrom(map_cache);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 2313
2314 2314
2315 void MarkCompactCollector::ClearWeakMaps() { 2315 void MarkCompactCollector::ClearWeakMaps() {
2316 Object* weak_map_obj = encountered_weak_maps(); 2316 Object* weak_map_obj = encountered_weak_maps();
2317 while (weak_map_obj != Smi::FromInt(0)) { 2317 while (weak_map_obj != Smi::FromInt(0)) {
2318 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj))); 2318 ASSERT(MarkCompactCollector::IsMarked(HeapObject::cast(weak_map_obj)));
2319 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj); 2319 JSWeakMap* weak_map = reinterpret_cast<JSWeakMap*>(weak_map_obj);
2320 ObjectHashTable* table = weak_map->unchecked_table(); 2320 ObjectHashTable* table = weak_map->unchecked_table();
2321 for (int i = 0; i < table->Capacity(); i++) { 2321 for (int i = 0; i < table->Capacity(); i++) {
2322 if (!MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) { 2322 if (!MarkCompactCollector::IsMarked(HeapObject::cast(table->KeyAt(i)))) {
2323 table->RemoveEntry(i, heap()); 2323 table->RemoveEntry(i);
2324 } 2324 }
2325 } 2325 }
2326 weak_map_obj = weak_map->next(); 2326 weak_map_obj = weak_map->next();
2327 weak_map->set_next(Smi::FromInt(0)); 2327 weak_map->set_next(Smi::FromInt(0));
2328 } 2328 }
2329 set_encountered_weak_maps(Smi::FromInt(0)); 2329 set_encountered_weak_maps(Smi::FromInt(0));
2330 } 2330 }
2331 2331
2332 2332
2333 // We scavange new space simultaneously with sweeping. This is done in two 2333 // We scavange new space simultaneously with sweeping. This is done in two
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3774 while (buffer != NULL) { 3774 while (buffer != NULL) {
3775 SlotsBuffer* next_buffer = buffer->next(); 3775 SlotsBuffer* next_buffer = buffer->next();
3776 DeallocateBuffer(buffer); 3776 DeallocateBuffer(buffer);
3777 buffer = next_buffer; 3777 buffer = next_buffer;
3778 } 3778 }
3779 *buffer_address = NULL; 3779 *buffer_address = NULL;
3780 } 3780 }
3781 3781
3782 3782
3783 } } // namespace v8::internal 3783 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap-inl.h ('k') | src/objects.h » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698