Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#5153 from The-OpenROAD-Projec…
Browse files Browse the repository at this point in the history
…t-staging/odb-id-preservation

odb: carefully preserve the object ids across recycling
  • Loading branch information
maliberty authored May 23, 2024
2 parents 7899e3b + 08cbc8f commit 0371d6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/odb/src/db/dbArrayTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ T* dbArrayTable<T>::create()
}

_dbFreeObject* o = popQ(_free_list);
o->_oid |= DB_ALLOC_BIT;
const uint oid = o->_oid;
new (o) T(_db);
T* t = (T*) o;
t->_oid = oid | DB_ALLOC_BIT;

dbArrayTablePage* page = (dbArrayTablePage*) t->getObjectPage();
page->_alloccnt++;
Expand Down Expand Up @@ -302,8 +303,9 @@ void dbArrayTable<T>::destroy(T* t)
_dbFreeObject* o = (_dbFreeObject*) t;

page->_alloccnt--;
const uint oid = t->_oid;
t->~T(); // call destructor
o->_oid &= ~DB_ALLOC_BIT;
o->_oid = oid & ~DB_ALLOC_BIT;

// Add to freelist
pushQ(_free_list, o);
Expand Down Expand Up @@ -395,8 +397,8 @@ void dbArrayTable<T>::copy_page(uint page_id, dbArrayTablePage* page)

for (; t < e; t++, o++) {
if (t->_oid & DB_ALLOC_BIT) {
o->_oid = t->_oid;
new (o) T(_db, *t);
o->_oid = t->_oid;
} else {
*((_dbFreeObject*) o) = *((_dbFreeObject*) t);
}
Expand Down
11 changes: 7 additions & 4 deletions src/odb/src/db/dbTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ T* dbTable<T>::create()
}

_dbFreeObject* o = popQ(_free_list);
const uint oid = o->_oid;
new (o) T(_db);
o->_oid |= DB_ALLOC_BIT;
T* t = (T*) o;
t->_oid = oid | DB_ALLOC_BIT;

dbTablePage* page = (dbTablePage*) t->getObjectPage();
page->_alloccnt++;
Expand Down Expand Up @@ -279,9 +280,10 @@ T* dbTable<T>::duplicate(T* c)
}

_dbFreeObject* o = popQ(_free_list);
o->_oid |= DB_ALLOC_BIT;
uint oid = o->_oid;
new (o) T(_db, *c);
T* t = (T*) o;
t->_oid = oid | DB_ALLOC_BIT;

dbTablePage* page = (dbTablePage*) t->getObjectPage();
page->_alloccnt++;
Expand Down Expand Up @@ -422,8 +424,9 @@ void dbTable<T>::destroy(T* t)
_dbFreeObject* o = (_dbFreeObject*) t;

page->_alloccnt--;
const uint oid = t->_oid;
t->~T(); // call destructor
o->_oid &= ~DB_ALLOC_BIT;
o->_oid = oid & ~DB_ALLOC_BIT;

uint offset = t - (T*) page->_objects;
uint id = page->_page_addr + offset;
Expand Down Expand Up @@ -613,8 +616,8 @@ void dbTable<T>::copy_page(uint page_id, dbTablePage* page)

for (; t < e; t++, o++) {
if (t->_oid & DB_ALLOC_BIT) {
o->_oid = t->_oid;
new (o) T(_db, *t);
o->_oid = t->_oid;
} else {
*((_dbFreeObject*) o) = *((_dbFreeObject*) t);
}
Expand Down

0 comments on commit 0371d6e

Please sign in to comment.