eliminate conditional when calculating object size

This commit is contained in:
Joel Dice 2007-07-01 15:47:26 -06:00
parent 38cea04322
commit f698d347ac

View File

@ -492,15 +492,11 @@ collect(Machine* m, Heap::CollectionType type)
p = m->heap->follow(mask(p)); p = m->heap->follow(mask(p));
object class_ = m->heap->follow(objectClass(t, p)); object class_ = m->heap->follow(objectClass(t, p));
unsigned n = divide(classFixedSize(t, class_), BytesPerWord); return divide(classFixedSize(t, class_), BytesPerWord)
+ divide(classArrayElementSize(t, class_)
if (classArrayElementSize(t, class_)) {
n += divide(classArrayElementSize(t, class_)
* cast<uint32_t>(p, classFixedSize(t, class_) - 4), * cast<uint32_t>(p, classFixedSize(t, class_) - 4),
BytesPerWord); BytesPerWord);
} }
return n;
}
virtual void walk(void* p, Heap::Walker* w) { virtual void walk(void* p, Heap::Walker* w) {
Thread* t = m->rootThread; Thread* t = m->rootThread;
@ -764,17 +760,12 @@ objectSize(Thread* t, object o)
{ {
object class_ = objectClass(t, o); object class_ = objectClass(t, o);
unsigned n = divide(classFixedSize(t, class_), BytesPerWord); return divide(classFixedSize(t, class_), BytesPerWord)
+ divide(classArrayElementSize(t, class_)
if (classArrayElementSize(t, class_)) {
n += divide(classArrayElementSize(t, class_)
* cast<uint32_t>(o, classFixedSize(t, class_) - 4), * cast<uint32_t>(o, classFixedSize(t, class_) - 4),
BytesPerWord); BytesPerWord);
} }
return n;
}
object object
makeByteArray(Thread* t, const char* format, va_list a) makeByteArray(Thread* t, const char* format, va_list a)
{ {