Skip to content

Commit

Permalink
Tweak style and refactor slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Jul 16, 2024
1 parent 33bc5c5 commit 689d8c1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ function _getArtRuntimeSpec (api) {

const apiLevel = getAndroidApiLevel();
const codename = getAndroidCodename();
const isApiLevel34OrApexEquivalent = Module.findExportByName('libart.so', '_ZN3art7AppInfo29GetPrimaryApkReferenceProfileEv') !== null;

let spec = null;

Expand Down Expand Up @@ -645,7 +646,7 @@ function _getArtRuntimeSpec (api) {
const threadListOffset = internTableOffset - pointerSize;

let heapOffset;
if (Module.findExportByName('libart.so', '_ZN3art7AppInfo29GetPrimaryApkReferenceProfileEv') !== null) { // with apex updates apiLevel!=libart version
if (isApiLevel34OrApexEquivalent) {
heapOffset = threadListOffset - (9 * pointerSize);
} else if (apiLevel >= 24) {
heapOffset = threadListOffset - (8 * pointerSize);
Expand Down Expand Up @@ -1887,21 +1888,20 @@ function ensureArtKnowsHowToHandleReplacementMethods (vm) {

const apiLevel = getAndroidApiLevel();

let exportName = null;
const api = getApi();
const mayUseCollector = (apiLevel > 28)
? new NativeFunction(Module.getExportByName('libart.so', '_ZNK3art2gc4Heap15MayUseCollectorENS0_13CollectorTypeE'), 'bool', ['pointer', 'int'])

Check failure on line 1892 in lib/android.js

View workflow job for this annotation

GitHub Actions / eslint

Expected indentation of 4 spaces but found 6
: () => false;

Check failure on line 1893 in lib/android.js

View workflow job for this annotation

GitHub Actions / eslint

Expected indentation of 4 spaces but found 6
const kCollectorTypeCMC = 3;
const mayUseCollector = new NativeFunction(Module.findExportByName('libart.so', '_ZNK3art2gc4Heap15MayUseCollectorENS0_13CollectorTypeE'), 'int', ['pointer', 'int']);

if (mayUseCollector !== null && apiLevel > 28 && mayUseCollector(api.artHeap, kCollectorTypeCMC)) {
exportName = '_ZN3art6Thread15RunFlipFunctionEPS0_b';
Interceptor.attach(Module.getExportByName('libart.so', exportName), artController.hooks.Gc.runFlip);
if (mayUseCollector(getApi().artHeap, kCollectorTypeCMC)) {
Interceptor.attach(Module.getExportByName('libart.so', '_ZN3art6Thread15RunFlipFunctionEPS0_b'), artController.hooks.Gc.runFlip);
} else {
let exportName = null;
if (apiLevel > 28) {
exportName = '_ZN3art2gc9collector17ConcurrentCopying12CopyingPhaseEv';
} else if (apiLevel > 22) {
exportName = '_ZN3art2gc9collector17ConcurrentCopying12MarkingPhaseEv';
}

if (exportName !== null) {
Interceptor.attach(Module.getExportByName('libart.so', exportName), artController.hooks.Gc.copyingPhase);
}
Expand Down

0 comments on commit 689d8c1

Please sign in to comment.