mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-18 10:50:23 +00:00
Merge
This commit is contained in:
commit
35acb940bf
@ -260,7 +260,7 @@ ifeq ($(USE_CLANG), true)
|
||||
WARNINGS_ARE_ERRORS += -Wno-empty-body
|
||||
endif
|
||||
|
||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
|
||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 -Wno-error=format-nonliteral
|
||||
|
||||
ifeq ($(USE_CLANG),)
|
||||
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
|
||||
@ -289,7 +289,7 @@ CFLAGS += -fno-strict-aliasing
|
||||
# The flags to use for an Optimized g++ build
|
||||
ifeq ($(OS_VENDOR), Darwin)
|
||||
# use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
|
||||
# <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
|
||||
# <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata>
|
||||
OPT_CFLAGS_DEFAULT ?= SIZE
|
||||
else
|
||||
OPT_CFLAGS_DEFAULT ?= SPEED
|
||||
|
||||
@ -214,7 +214,7 @@ ifeq ($(USE_CLANG), true)
|
||||
WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
|
||||
endif
|
||||
|
||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
|
||||
WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wno-error=format-nonliteral
|
||||
|
||||
ifeq ($(USE_CLANG),)
|
||||
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
|
||||
|
||||
@ -118,7 +118,7 @@ endif
|
||||
# Compiler warnings are treated as errors
|
||||
WARNINGS_ARE_ERRORS = -Werror
|
||||
# Enable these warnings. See 'info gcc' about details on these options
|
||||
WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
|
||||
WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 -Wno-error=format-nonliteral
|
||||
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
|
||||
# Special cases
|
||||
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
|
||||
|
||||
@ -1834,7 +1834,7 @@ void os::jvm_path(char *buf, jint buflen) {
|
||||
jrelib_p = buf + len;
|
||||
snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT);
|
||||
if (0 != access(buf, F_OK)) {
|
||||
snprintf(jrelib_p, buflen-len, "");
|
||||
snprintf(jrelib_p, buflen-len, "%s", "");
|
||||
}
|
||||
|
||||
// If the path exists within JAVA_HOME, add the JVM library name
|
||||
|
||||
@ -4348,8 +4348,23 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {
|
||||
|
||||
// Get needed field and method IDs
|
||||
directByteBufferConstructor = env->GetMethodID(directByteBufferClass, "<init>", "(JI)V");
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
directBufferSupportInitializeFailed = 1;
|
||||
return false;
|
||||
}
|
||||
directBufferAddressField = env->GetFieldID(bufferClass, "address", "J");
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
directBufferSupportInitializeFailed = 1;
|
||||
return false;
|
||||
}
|
||||
bufferCapacityField = env->GetFieldID(bufferClass, "capacity", "I");
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
directBufferSupportInitializeFailed = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((directByteBufferConstructor == NULL) ||
|
||||
(directBufferAddressField == NULL) ||
|
||||
|
||||
@ -858,6 +858,11 @@ static inline void throw_new(JNIEnv *env, const char *ename) {
|
||||
strcpy(buf, "java/lang/");
|
||||
strcat(buf, ename);
|
||||
jclass cls = env->FindClass(buf);
|
||||
if (env->ExceptionCheck()) {
|
||||
env->ExceptionClear();
|
||||
tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", buf);
|
||||
return;
|
||||
}
|
||||
char* msg = NULL;
|
||||
env->ThrowNew(cls, msg);
|
||||
}
|
||||
|
||||
@ -316,9 +316,10 @@ WB_END
|
||||
|
||||
WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
int result = 0;
|
||||
CHECK_JNI_EXCEPTION_(env, result);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
int result = 0;
|
||||
nmethod* code;
|
||||
if (is_osr) {
|
||||
int bci = InvocationEntryBci;
|
||||
@ -344,6 +345,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
|
||||
@ -355,6 +357,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
if (is_osr) {
|
||||
@ -366,6 +369,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
return mh->queued_for_compilation();
|
||||
@ -373,6 +377,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, CompLevel_none);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
|
||||
return (code != NULL ? code->comp_level() : CompLevel_none);
|
||||
@ -380,6 +385,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION(env);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
if (is_osr) {
|
||||
mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox");
|
||||
@ -390,6 +396,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, InvocationEntryBci);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false);
|
||||
return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci);
|
||||
@ -397,6 +404,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
bool result = mh->dont_inline();
|
||||
mh->set_dont_inline(value == JNI_TRUE);
|
||||
@ -414,6 +422,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
bool result = mh->force_inline();
|
||||
mh->set_force_inline(value == JNI_TRUE);
|
||||
@ -422,6 +431,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
@ -430,6 +440,7 @@ WB_END
|
||||
|
||||
WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method))
|
||||
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
|
||||
CHECK_JNI_EXCEPTION(env);
|
||||
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
|
||||
MutexLockerEx mu(Compile_lock);
|
||||
MethodData* mdo = mh->method_data();
|
||||
@ -616,14 +627,18 @@ JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass))
|
||||
bool result = true;
|
||||
// one by one registration natives for exception catching
|
||||
jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string());
|
||||
CHECK_JNI_EXCEPTION(env);
|
||||
for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) {
|
||||
if (env->RegisterNatives(wbclass, methods + i, 1) != 0) {
|
||||
result = false;
|
||||
if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) {
|
||||
// j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native
|
||||
// ignoring the exception
|
||||
tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature);
|
||||
jthrowable throwable_obj = env->ExceptionOccurred();
|
||||
if (throwable_obj != NULL) {
|
||||
env->ExceptionClear();
|
||||
if (env->IsInstanceOf(throwable_obj, exceptionKlass)) {
|
||||
// j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native
|
||||
// ignoring the exception
|
||||
tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature);
|
||||
}
|
||||
} else {
|
||||
// register is failed w/o exception or w/ unexpected exception
|
||||
tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered", methods[i].name, methods[i].signature);
|
||||
|
||||
@ -36,6 +36,22 @@
|
||||
#define WB_END JNI_END
|
||||
#define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL
|
||||
|
||||
#define CHECK_JNI_EXCEPTION_(env, value) \
|
||||
do { \
|
||||
if (env->ExceptionCheck()) { \
|
||||
env->ExceptionClear(); \
|
||||
return(value); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_JNI_EXCEPTION(env) \
|
||||
do { \
|
||||
if (env->ExceptionCheck()) { \
|
||||
env->ExceptionClear(); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
class WhiteBox : public AllStatic {
|
||||
private:
|
||||
static bool _used;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user