diff options
author | Andy McFadden <fadden@android.com> | 2009-07-16 18:11:22 -0700 |
---|---|---|
committer | Andy McFadden <fadden@android.com> | 2009-07-31 13:18:56 -0700 |
commit | 734155efc18543eab20b763f9a315ab1a44240ac (patch) | |
tree | d8243b4f35ccf73f1de1b721b9005ebcc6f77da1 /vm/ReferenceTable.c | |
parent | 51b9e5c27aa5d5c399f93f2df2b2ca1674b0858d (diff) | |
download | android_dalvik-734155efc18543eab20b763f9a315ab1a44240ac.tar.gz android_dalvik-734155efc18543eab20b763f9a315ab1a44240ac.tar.bz2 android_dalvik-734155efc18543eab20b763f9a315ab1a44240ac.zip |
Indirect reference table implementation.
This change introduces the "indirect" reference table, which will be
replacing ReferenceTable for local and global JNI references. The key
difference is that, instead of handing raw Object pointers to JNI, we
will be giving them a magic value that can be converted back to an
Object. The goal is to avoid having to pin every object that native
code is aware of.
The code is not actually used anywhere yet.
Also bundled up here:
- added detail to a log message
- fixed a string format issue in the internal assert() definition
- very minor optimization in "remove" function in ReferenceTable
- quiet a gcc complaint
- only include the hash table regression test in builds that invoke it
Diffstat (limited to 'vm/ReferenceTable.c')
-rw-r--r-- | vm/ReferenceTable.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/vm/ReferenceTable.c b/vm/ReferenceTable.c index c748222a7..089f2f287 100644 --- a/vm/ReferenceTable.c +++ b/vm/ReferenceTable.c @@ -58,11 +58,15 @@ bool dvmAddToReferenceTable(ReferenceTable* pRef, Object* obj) assert(dvmIsValidObject(obj)); assert(obj != NULL); 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)\n", pRef->maxEntries); + return false; + } - if (pRef->nextEntry == pRef->table + pRef->maxEntries) { - LOGW("ReferenceTable overflow (max=%d)\n", pRef->maxEntries); - return false; - } else if (pRef->nextEntry == pRef->table + pRef->allocEntries) { Object** newTable; int newSize; |