Commit f0abd619 authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

Keep code flags calculation local to disl.c

parent 6bd4ba6d
......@@ -16,8 +16,53 @@
#include "bytecode.h"
#include "classparser.h"
/*
* Flags representing code options, derived from the values generated from Java.
*/
enum code_flags {
CF_CREATE_BYPASS = ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS,
CF_DYNAMIC_BYPASS = ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS,
CF_SPLIT_METHODS = ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS,
CF_CATCH_EXCEPTIONS = ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS,
};
/**
* Agent configuration.
*/
static const struct config * agent_config;
/*
* Code option flags that control the instrumentation.
*/
static volatile jint agent_code_flags;
static jint
__calc_code_flags (const struct config * config, bool jvm_is_booting) {
jint result = 0;
//
// If bypass is desired, always create bypass code while the JVM is
// bootstrapping. If dynamic bypass is desired, create bypass code as
// well as code to control it dynamically.
//
if (config->bypass_mode > BYPASS_MODE_DISABLED) {
result |= jvm_is_booting ? CF_CREATE_BYPASS : 0;
if (config->bypass_mode > BYPASS_MODE_BOOTSTRAP) {
result |= (CF_CREATE_BYPASS | CF_DYNAMIC_BYPASS);
}
}
result |= config->split_methods ? CF_SPLIT_METHODS : 0;
result |= config->catch_exceptions ? CF_CATCH_EXCEPTIONS : 0;
return (result);
}
/*
* Flag indicating that the VM has been started, which
* allows calling any JNI function.
......@@ -179,7 +224,7 @@ disl_init (const struct config * config, jvmtiEnv * jvmti) {
jvm_is_initialized = false;
agent_config = config;
agent_code_flags = calc_code_flags (config, true);
agent_code_flags = __calc_code_flags (config, true /* jvm_is_booting */);
send_instrumentation (config);
......@@ -192,27 +237,6 @@ disl_finish () {
// Empty for now.
}
static jint
calc_code_flags (const struct config * config, bool jvm_is_booting) {
jint result = 0;
//
// If bypass is desired, always create bypass code while the JVM is
// bootstrapping. If dynamic bypass is desired, create bypass code as
// well as code to control it dynamically.
//
if (config->bypass_mode > BYPASS_MODE_DISABLED) {
result |= jvm_is_booting ? CF_CREATE_BYPASS : 0;
if (config->bypass_mode > BYPASS_MODE_BOOTSTRAP) {
result |= (CF_CREATE_BYPASS | CF_DYNAMIC_BYPASS);
}
}
result |= config->split_methods ? CF_SPLIT_METHODS : 0;
result |= config->catch_exceptions ? CF_CATCH_EXCEPTIONS : 0;
return result;
}
static inline const char *
__safe (const char * class_name) {
......@@ -579,7 +603,7 @@ disl_jvmti_callback_vm_init (jvmtiEnv * jvmti, JNIEnv * jni, jthread thread) {
// Update flags to reflect that the VM has stopped booting.
//
jvm_is_initialized = true;
agent_code_flags = calc_code_flags (agent_config, false);
agent_code_flags = __calc_code_flags(agent_config, false /* jvm_is_booting */);
struct thread_info info = INIT_THREAD_INFO;
disl_rdexec {
......
......@@ -7,31 +7,13 @@
#define _DISL_H
#include <jvmti.h>
#include "codeflags.h"
#include "../common.h"
#include "../config.h"
/*
* Flags representing code options, derived from the values generated from Java.
*/
enum code_flags {
CF_CREATE_BYPASS = ch_usi_dag_disl_CodeOption_Flag_CREATE_BYPASS,
CF_DYNAMIC_BYPASS = ch_usi_dag_disl_CodeOption_Flag_DYNAMIC_BYPASS,
CF_SPLIT_METHODS = ch_usi_dag_disl_CodeOption_Flag_SPLIT_METHODS,
CF_CATCH_EXCEPTIONS = ch_usi_dag_disl_CodeOption_Flag_CATCH_EXCEPTIONS,
};
/*
* Code option flags that control the instrumentation.
*/
volatile jint agent_code_flags;
void disl_init (const struct config * config, jvmtiEnv * jvmti);
void disl_finish ();
jint
calc_code_flags(const struct config * config, bool jvm_is_booting);
// ****************************************************************************
// JVMTI EVENTS
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment