From dddca764c2db86ea25c48ee410c444accac1f883 Mon Sep 17 00:00:00 2001 From: mbricchi Date: Thu, 11 Jul 2024 17:49:03 +0200 Subject: [PATCH 1/2] android: Handle the CMC GC strategy Fixes #323. --- lib/android.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/android.js b/lib/android.js index 27e20961..41816b38 100644 --- a/lib/android.js +++ b/lib/android.js @@ -1890,6 +1890,11 @@ function ensureArtKnowsHowToHandleReplacementMethods (vm) { if (exportName !== null) { Interceptor.attach(Module.getExportByName('libart.so', exportName), artController.hooks.Gc.copyingPhase); + + const collectorCMC = Module.findExportByName('libart.so', '_ZN3art2gc9collector11MarkCompact15CompactionPhaseEv'); + if (collectorCMC !== null) { + Interceptor.attach(collectorCMC, artController.hooks.Gc.copyingPhase); + } } } From 29ad811247c2105847d8a4592474b98199b9943e Mon Sep 17 00:00:00 2001 From: mbricchi Date: Sat, 13 Jul 2024 00:01:58 +0200 Subject: [PATCH 2/2] android: Fix Java.choose() on Android >= 14 --- lib/android.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/android.js b/lib/android.js index 41816b38..06b2adc8 100644 --- a/lib/android.js +++ b/lib/android.js @@ -591,8 +591,9 @@ function _getArtRuntimeSpec (api) { * gc::Heap* heap_; <-- we need to find this * std::unique_ptr jit_arena_pool_; <----- API level >= 24 * std::unique_ptr arena_pool_; __ - * std::unique_ptr low_4gb_arena_pool_; <--|__ API level >= 23 + * std::unique_ptr low_4gb_arena_pool_/linear_alloc_arena_pool_; <--|__ API level >= 23 * std::unique_ptr linear_alloc_; \_ + * std::atomic startup_linear_alloc_;<----- API level >= 34 * size_t max_spins_before_thin_lock_inflation_; * MonitorList* monitor_list_; * MonitorPool* monitor_pool_; @@ -644,7 +645,9 @@ function _getArtRuntimeSpec (api) { const threadListOffset = internTableOffset - pointerSize; let heapOffset; - if (apiLevel >= 24) { + if (apiLevel >= 34) { + heapOffset = threadListOffset - (9 * pointerSize); + } else if (apiLevel >= 24) { heapOffset = threadListOffset - (8 * pointerSize); } else if (apiLevel >= 23) { heapOffset = threadListOffset - (7 * pointerSize);