OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 uint64_t existing = FindEntry(addr); | 1526 uint64_t existing = FindEntry(addr); |
1527 if (existing != 0) return existing; | 1527 if (existing != 0) return existing; |
1528 } | 1528 } |
1529 uint64_t id = next_id_++; | 1529 uint64_t id = next_id_++; |
1530 AddEntry(addr, id); | 1530 AddEntry(addr, id); |
1531 return id; | 1531 return id; |
1532 } | 1532 } |
1533 | 1533 |
1534 | 1534 |
1535 void HeapObjectsMap::MoveObject(Address from, Address to) { | 1535 void HeapObjectsMap::MoveObject(Address from, Address to) { |
| 1536 if (from == to) return; |
1536 HashMap::Entry* entry = entries_map_.Lookup(from, AddressHash(from), false); | 1537 HashMap::Entry* entry = entries_map_.Lookup(from, AddressHash(from), false); |
1537 if (entry != NULL) { | 1538 if (entry != NULL) { |
1538 void* value = entry->value; | 1539 void* value = entry->value; |
1539 entries_map_.Remove(from, AddressHash(from)); | 1540 entries_map_.Remove(from, AddressHash(from)); |
1540 entry = entries_map_.Lookup(to, AddressHash(to), true); | 1541 entry = entries_map_.Lookup(to, AddressHash(to), true); |
1541 ASSERT(entry->value == NULL); | 1542 // We can have an entry at the new location, it is OK, as GC can overwrite |
| 1543 // dead objects with alive objects being moved. |
1542 entry->value = value; | 1544 entry->value = value; |
1543 } | 1545 } |
1544 } | 1546 } |
1545 | 1547 |
1546 | 1548 |
1547 void HeapObjectsMap::AddEntry(Address addr, uint64_t id) { | 1549 void HeapObjectsMap::AddEntry(Address addr, uint64_t id) { |
1548 HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), true); | 1550 HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), true); |
1549 ASSERT(entry->value == NULL); | 1551 ASSERT(entry->value == NULL); |
1550 entry->value = reinterpret_cast<void*>(entries_->length()); | 1552 entry->value = reinterpret_cast<void*>(entries_->length()); |
1551 entries_->Add(EntryInfo(id)); | 1553 entries_->Add(EntryInfo(id)); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 HeapEntry* entry = added_entries[i]; | 1818 HeapEntry* entry = added_entries[i]; |
1817 if (entry->painted_reachable()) | 1819 if (entry->painted_reachable()) |
1818 diff->AddAddedEntry(entry); | 1820 diff->AddAddedEntry(entry); |
1819 } | 1821 } |
1820 return diff; | 1822 return diff; |
1821 } | 1823 } |
1822 | 1824 |
1823 } } // namespace v8::internal | 1825 } } // namespace v8::internal |
1824 | 1826 |
1825 #endif // ENABLE_LOGGING_AND_PROFILING | 1827 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |