Implement shared counters for boot image / zygote methods.
Add a thread-local counter which the interpreter increments. When
hitting zero, the interpreter goes into the runtime and updates a map of
counters. If the counter for the particular method hits a threshold, we
JIT it.
Test: test.py
Test: imgdiag looking at boot.art
Bug: 162110941
Change-Id: I6493332eafc51856494ef20592ca83bc716c994e
diff --git a/libdexfile/dex/modifiers.h b/libdexfile/dex/modifiers.h
index f9cd8c8..72949b0 100644
--- a/libdexfile/dex/modifiers.h
+++ b/libdexfile/dex/modifiers.h
@@ -104,9 +104,9 @@
static constexpr uint32_t kAccPublicApi = 0x10000000; // field, method
static constexpr uint32_t kAccCorePlatformApi = 0x20000000; // field, method
-// Not currently used, except for intrinsic methods where these bits
-// are part of the intrinsic ordinal.
-static constexpr uint32_t kAccMayBeUnusedBits = 0x40000000;
+// For methods which we'd like to share memory between zygote and apps.
+// Uses an intrinsic bit but that's OK as intrinsics are always in the boot image.
+static constexpr uint32_t kAccMemorySharedMethod = 0x40000000;
// Set by the compiler driver when compiling boot classes with instrinsic methods.
static constexpr uint32_t kAccIntrinsic = 0x80000000; // method (runtime)
@@ -125,7 +125,7 @@
// which overlap are not valid when kAccIntrinsic is set.
static constexpr uint32_t kAccIntrinsicBits = kAccHiddenapiBits |
kAccSingleImplementation | kAccMustCountLocks | kAccCompileDontBother | kAccCopied |
- kAccPreviouslyWarm | kAccMayBeUnusedBits;
+ kAccPreviouslyWarm | kAccMemorySharedMethod;
// Valid (meaningful) bits for a field.
static constexpr uint32_t kAccValidFieldFlags = kAccPublic | kAccPrivate | kAccProtected |