Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,17 @@ declare module "frida-java-bridge" {
*/
function deoptimizeBootImage(): void;

/**
* Deoptimizes a method / constructor in case hooked callee is not called
* because of inline.
*/
function deoptimizeMethod(method: Method): void;

/**
* Return whether a method is deoptimized.
*/
function isDeoptimized(method: Method): boolean;

const vm: VM;

/**
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
backtrace,
deoptimizeEverything,
deoptimizeBootImage,
deoptimizeMethod
deoptimizeMethod,
isDeoptimized
} from './lib/android.js';
import ClassFactory from './lib/class-factory.js';
import ClassModel from './lib/class-model.js';
Expand Down Expand Up @@ -524,6 +525,10 @@ class Runtime {
return deoptimizeMethod(vm, vm.getEnv(), method);
}

isDeoptimized (method) {
return isDeoptimized(method);
}

_checkAvailable () {
if (!this.available) {
throw new Error('Java API not available');
Expand Down
17 changes: 17 additions & 0 deletions lib/android.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ function _getApi () {
},
_ZN3art7Runtime19DeoptimizeBootImageEv: ['art::Runtime::DeoptimizeBootImage', 'void', ['pointer']],
_ZN3art15instrumentation15Instrumentation10DeoptimizeEPNS_9ArtMethodE: ['art::Instrumentation::Deoptimize', 'void', ['pointer', 'pointer']],
_ZN3art15instrumentation15Instrumentation13IsDeoptimizedEPNS_9ArtMethodE: ['art::Instrumentation::IsDeoptimized', 'bool', ['pointer', 'pointer']],

// Android >= 11
_ZN3art3jni12JniIdManager14DecodeMethodIdEP10_jmethodID: ['art::jni::JniIdManager::DecodeMethodId', 'pointer', ['pointer', 'pointer']],
Expand Down Expand Up @@ -368,6 +369,7 @@ function _getApi () {
'_ZN3art15instrumentation15Instrumentation20DeoptimizeEverythingEv',
'_ZN3art7Runtime19DeoptimizeBootImageEv',
'_ZN3art15instrumentation15Instrumentation10DeoptimizeEPNS_9ArtMethodE',
'_ZN3art15instrumentation15Instrumentation13IsDeoptimizedEPNS_9ArtMethodE',
'_ZN3art3Dbg9StartJdwpEv',
'_ZN3art3Dbg8GoActiveEv',
'_ZN3art3Dbg21RequestDeoptimizationERKNS_21DeoptimizationRequestE',
Expand Down Expand Up @@ -4057,6 +4059,21 @@ function requestDeoptimization (vm, env, kind, method) {
});
}

export function isDeoptimized (method) {
const api = getApi();

if (getAndroidApiLevel() < 24) {
throw new Error('This API is only available on Android >= 7.0');
}

const instrumentation = api.artInstrumentation;
if (instrumentation === null) {
throw new Error('Unable to find Instrumentation class in ART; please file a bug');
}

return !!api['art::Instrumentation::IsDeoptimized'](instrumentation, method);
}

class JdwpSession {
constructor () {
/*
Expand Down