Add ability to switch to index ids late.
In order to support some debugging features we need to have JNI code
mostly running with jmethodIDs and jfieldIDs as opaque indexes
disconnected from any underlying art data-structure pointers. For
performance though we want to continue to use data-structure pointers
as these IDs when debugging is not needed. To support both
possibilities this adds support for changing from a 'swapablePointer'
to either 'pointer' or 'indicies' regime at runtime.
The SwapablePointer regime still uses pointers as the ids but creates
the data-structures needed to ensure that we can (1) detect that the
methods have pointer-type IDs and (2) we can change some
WellKnownClass internal IDs from one to the other.
Currently one must select this mode explicitly using
'-Xopaque-jni-ids:swapable'. Depending on when the final jni-id-type
is selected a small amount of extra memory is used. Currently manual
testing of turning the default id-type to swapable and changing to
pointer immediately after zygote-fork shows a additional 40-90 kb of
shared zygote-heap memory.
Test: ./test.py --host
Test: m libfieldcounts; \
./tools/jvmti-agents/field-counts/count-fields.py 'Ljava/lang/Class;.extData:Ldalvik/system/ClassExt;' 'Ldalvik/system/ClassExt;.jmethodIDs:Ljava/lang/Object;' 'Ldalvik/system/ClassExt;.staticJfieldIDs:Ljava/lang/Object;' 'Ldalvik/system/ClassExt;.instanceJfieldIDs:Ljava/lang/Object;' -p `adb shell pidof com.android.deskclock`;
Examine output
Bug: 134162467
Change-Id: I1885b10056d5dcc65dad5ae4f858ddc12ba79403
diff --git a/test/knownfailures.json b/test/knownfailures.json
index bd32647..85eec1b 100644
--- a/test/knownfailures.json
+++ b/test/knownfailures.json
@@ -1114,7 +1114,10 @@
"1001-app-image-regions",
"1339-dead-reference-safe",
"1951-monitor-enter-no-suspend",
- "1957-error-ext"],
+ "1957-error-ext",
+ "1972-jni-id-swap-indices",
+ "1973-jni-id-swap-pointer"
+ ],
"variant": "jvm",
"description": ["Doesn't run on RI."]
},