*/
bool dvmAddToReferenceTable(ReferenceTable* pRef, Object* obj)
{
- assert(dvmIsValidObject(obj));
assert(obj != NULL);
+ assert(dvmIsHeapAddress(obj));
assert(pRef->table != NULL);
assert(pRef->allocEntries <= pRef->maxEntries);
if (pRef->nextEntry == pRef->table + pRef->allocEntries) {
/* reached end of allocated space; did we hit buffer max? */
if (pRef->nextEntry == pRef->table + pRef->maxEntries) {
- LOGW("ReferenceTable overflow (max=%d)", pRef->maxEntries);
+ ALOGW("ReferenceTable overflow (max=%d)", pRef->maxEntries);
return false;
}
newTable = (Object**) realloc(pRef->table, newSize * sizeof(Object*));
if (newTable == NULL) {
- LOGE("Unable to expand ref table (from %d to %d %d-byte entries)",
+ ALOGE("Unable to expand ref table (from %d to %d %d-byte entries)",
pRef->allocEntries, newSize, sizeof(Object*));
return false;
}
if (moveCount != 0) {
/* remove from middle, slide the rest down */
memmove(ptr, ptr+1, moveCount * sizeof(Object*));
- //LOGV("LREF delete %p, shift %d down", obj, moveCount);
+ //ALOGV("LREF delete %p, shift %d down", obj, moveCount);
} else {
/* last entry, falls off the end */
- //LOGV("LREF delete %p from end", obj);
+ //ALOGV("LREF delete %p from end", obj);
}
return true;
static void logSummaryLine(const Object* obj, size_t elems, int identical, int equiv)
{
if (obj == NULL) {
- LOGW(" NULL reference (count=%d)", equiv);
+ ALOGW(" NULL reference (count=%d)", equiv);
return;
}
if (obj == kClearedJniWeakGlobal) {
- LOGW(" cleared jweak (count=%d)", equiv);
+ ALOGW(" cleared jweak (count=%d)", equiv);
return;
}
if (identical + equiv != 0) {
StringAppendF(&msg, " (%d unique instances)", equiv + 1);
}
- LOGW(" %s", msg.c_str());
+ ALOGW(" %s", msg.c_str());
}
/*
void dvmDumpReferenceTableContents(Object* const* refs, size_t count,
const char* descr)
{
- LOGW("%s reference table (%p) dump:", descr, refs);
+ ALOGW("%s reference table (%p) dump:", descr, refs);
if (count == 0) {
- LOGW(" (empty)");
+ ALOGW(" (empty)");
return;
}
if (first < 0) {
first = 0;
}
- LOGW(" Last %d entries (of %d):", (count - first), count);
+ ALOGW(" Last %d entries (of %d):", (count - first), count);
for (int idx = count - 1; idx >= first; --idx) {
const Object* ref = refs[idx];
if (ref == NULL) {
continue;
}
if (ref == kClearedJniWeakGlobal) {
- LOGW(" %5d: cleared jweak", idx);
+ ALOGW(" %5d: cleared jweak", idx);
continue;
}
if (ref->clazz == NULL) {
// should only be possible right after a plain dvmMalloc().
size_t size = dvmObjectSizeInHeap(ref);
- LOGW(" %5d: %p (raw) (%zd bytes)", idx, ref, size);
+ ALOGW(" %5d: %p (raw) (%zd bytes)", idx, ref, size);
continue;
}
}
free(s);
}
- LOGW(" %5d: %p %s%s", idx, ref, className.c_str(), extras.c_str());
+ ALOGW(" %5d: %p %s%s", idx, ref, className.c_str(), extras.c_str());
}
// Make a copy of the table, and sort it.
Object** tableCopy = (Object**)malloc(sizeof(Object*) * count);
if (tableCopy == NULL) {
- LOGE("Unable to copy table with %d elements", count);
+ ALOGE("Unable to copy table with %d elements", count);
return;
}
memcpy(tableCopy, refs, sizeof(Object*) * count);
}
// Dump a summary of the whole table.
- LOGW(" Summary:");
+ ALOGW(" Summary:");
size_t equiv, identical;
equiv = identical = 0;
size_t idx;