optimize common case of setting a single object field so we don't acquire the heap lock unnecessarily

This commit is contained in:
Joel Dice 2008-04-23 18:08:24 -06:00
parent 1d7b00baff
commit 18d25468fe
3 changed files with 10 additions and 1 deletions

View File

@ -1709,6 +1709,11 @@ class MyHeap: public Heap {
}
}
virtual bool needsMark(void* p, unsigned offset) {
return needsMark(p) and targetNeedsMark
(mask(*(static_cast<void**>(p) + offset)));
}
bool targetNeedsMark(void* target) {
return target
and not c.gen2.contains(target)

View File

@ -62,6 +62,7 @@ class Heap: public Allocator {
virtual void* allocateImmortal(Allocator* allocator, unsigned sizeInWords,
bool objectMask, unsigned* totalInBytes) = 0;
virtual bool needsMark(void* p) = 0;
virtual bool needsMark(void* p, unsigned offset) = 0;
virtual void mark(void* p, unsigned offset, unsigned count) = 0;
virtual void pad(void* p) = 0;
virtual void* follow(void* p) = 0;

View File

@ -1487,7 +1487,10 @@ mark(Thread* t, object o, unsigned offset, unsigned count)
inline void
mark(Thread* t, object o, unsigned offset)
{
mark(t, o, offset, 1);
if (t->m->heap->needsMark(o, offset / BytesPerWord)) {
ACQUIRE_RAW(t, t->m->heapLock);
t->m->heap->mark(o, offset / BytesPerWord, 1);
}
}
inline void