Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
JesperIRL committed Jul 7, 2020
2 parents db2d4e8 + e87c864 commit c782d0e
Show file tree
Hide file tree
Showing 15 changed files with 428 additions and 339 deletions.
17 changes: 15 additions & 2 deletions src/hotspot/share/jfr/periodic/jfrPeriodic.cpp
Expand Up @@ -54,6 +54,7 @@
#include "runtime/arguments.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/globals.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/os_perf.hpp"
#include "runtime/thread.inline.hpp"
Expand Down Expand Up @@ -174,7 +175,13 @@ TRACE_REQUEST_FUNC(CPULoad) {
double u = 0; // user time
double s = 0; // kernel time
double t = 0; // total time
int ret_val = JfrOSInterface::cpu_loads_process(&u, &s, &t);
int ret_val = OS_ERR;
{
// Can take some time on certain platforms, especially under heavy load.
// Transition to native to avoid unnecessary stalls for pending safepoint synchronizations.
ThreadToNativeFromVM transition((JavaThread*)Thread::current());
ret_val = JfrOSInterface::cpu_loads_process(&u, &s, &t);
}
if (ret_val == OS_ERR) {
log_debug(jfr, system)( "Unable to generate requestable event CPULoad");
return;
Expand Down Expand Up @@ -248,7 +255,13 @@ TRACE_REQUEST_FUNC(SystemProcess) {

TRACE_REQUEST_FUNC(ThreadContextSwitchRate) {
double rate = 0.0;
int ret_val = JfrOSInterface::context_switch_rate(&rate);
int ret_val = OS_ERR;
{
// Can take some time on certain platforms, especially under heavy load.
// Transition to native to avoid unnecessary stalls for pending safepoint synchronizations.
ThreadToNativeFromVM transition((JavaThread*)Thread::current());
ret_val = JfrOSInterface::context_switch_rate(&rate);
}
if (ret_val == OS_ERR) {
log_debug(jfr, system)( "Unable to generate requestable event ThreadContextSwitchRate");
return;
Expand Down
33 changes: 18 additions & 15 deletions src/java.base/share/classes/java/security/Provider.java
Expand Up @@ -868,7 +868,7 @@ private void check(String directive) {
// For backward compatibility, the registration ordering of
// SecureRandom (RNG) algorithms needs to be preserved for
// "new SecureRandom()" calls when this provider is used
private transient Set<Service> prngServices;
private transient Set<String> prngAlgos;

// Map<ServiceKey,Service>
// used for services added via legacy methods, init on demand
Expand Down Expand Up @@ -1089,7 +1089,7 @@ private void implClear() {
legacyChanged = false;
servicesChanged = false;
serviceSet = null;
prngServices = null;
prngAlgos = null;
super.clear();
putId();
}
Expand Down Expand Up @@ -1221,7 +1221,7 @@ private void parseLegacyPut(String name, String value) {
s.className = className;

if (type.equals("SecureRandom")) {
updateSecureRandomEntries(true, s);
updateSecureRandomEntries(true, s.algorithm);
}
} else { // attribute
// e.g. put("MessageDigest.SHA-1 ImplementedIn", "Software");
Expand Down Expand Up @@ -1383,25 +1383,25 @@ protected void putService(Service s) {
synchronized (this) {
putPropertyStrings(s);
if (type.equals("SecureRandom")) {
updateSecureRandomEntries(true, s);
updateSecureRandomEntries(true, s.algorithm);
}
}
}

private void updateSecureRandomEntries(boolean doAdd, Service s) {
// keep tracks of the registered secure random algos and store them in order
private void updateSecureRandomEntries(boolean doAdd, String s) {
Objects.requireNonNull(s);
if (doAdd) {
if (prngServices == null) {
prngServices = new LinkedHashSet<Service>();
if (prngAlgos == null) {
prngAlgos = new LinkedHashSet<String>();
}
prngServices.add(s);
prngAlgos.add(s);
} else {
prngServices.remove(s);
prngAlgos.remove(s);
}

if (debug != null) {
debug.println((doAdd? "Add":"Remove") + " SecureRandom algo " +
s.getAlgorithm());
debug.println((doAdd? "Add":"Remove") + " SecureRandom algo " + s);
}
}

Expand All @@ -1411,12 +1411,15 @@ synchronized Service getDefaultSecureRandomService() {
checkInitialized();

if (legacyChanged) {
prngServices = null;
prngAlgos = null;
ensureLegacyParsed();
}

if (prngServices != null && !prngServices.isEmpty()) {
return prngServices.iterator().next();
if (prngAlgos != null && !prngAlgos.isEmpty()) {
// IMPORTANT: use the Service obj returned by getService(...) call
// as providers may override putService(...)/getService(...) and
// return their own Service objects
return getService("SecureRandom", prngAlgos.iterator().next());
}

return null;
Expand Down Expand Up @@ -1516,7 +1519,7 @@ private void implRemoveService(Service s) {
synchronized (this) {
removePropertyStrings(s);
if (type.equals("SecureRandom")) {
updateSecureRandomEntries(false, s);
updateSecureRandomEntries(false, s.algorithm);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/hotspot/jtreg/ProblemList.txt
Expand Up @@ -143,7 +143,7 @@ vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/TestDescription.ja
vmTestbase/nsk/jvmti/scenarios/jni_interception/JI06/ji06t001/TestDescription.java 8219652 aix-ppc64
vmTestbase/nsk/jvmti/SetJNIFunctionTable/setjniftab001/TestDescription.java 8219652 aix-ppc64

vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8208243,8192647 generic-all
vmTestbase/gc/lock/jni/jnilock002/TestDescription.java 8192647 generic-all

vmTestbase/jit/escape/LockCoarsening/LockCoarsening001.java 8148743 generic-all
vmTestbase/jit/escape/LockCoarsening/LockCoarsening002.java 8208259 generic-all
Expand Down
Expand Up @@ -4,20 +4,21 @@
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Alibaba designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/* @test
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -37,40 +37,42 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jboolean JNICALL Java_nsk_share_gc_lock_jni_BooleanArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);

jsize size, i;
jbooleanArray arr;
jboolean *pa;
jboolean hash = JNI_TRUE;
time_t start_time, current_time;
jsize size, i;
jbooleanArray arr;
jboolean *pa;
jboolean hash = JNI_TRUE;
time_t start_time, current_time;

if (objFieldId == NULL) {
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jbooleanArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
if (objFieldId == NULL) {
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jbooleanArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);

size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jboolean*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
} else {
hash = JNI_FALSE;
}
mssleep((long) sleepTime);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (difftime(current_time, start_time) < enterTime) {
hash = JNI_TRUE;
pa = (jboolean*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i) {
hash ^= pa[i];
}
} else {
jni_env->FatalError("GetPrimitiveArrayCritical returned NULL");
}
mssleep((long) sleepTime);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,40 +36,42 @@ static jfieldID objFieldId = NULL;
*/
JNIEXPORT jbyte JNICALL Java_nsk_share_gc_lock_jni_ByteArrayCriticalLocker_criticalNative
(JNIEnv *jni_env, jobject o, jlong enterTime, jlong sleepTime) {
ExceptionCheckingJniEnvPtr ec_jni(jni_env);
ExceptionCheckingJniEnvPtr ec_jni(jni_env);

jsize size, i;
jbyteArray arr;
jbyte *pa;
jbyte hash = 0;
time_t start_time, current_time;
jsize size, i;
jbyteArray arr;
jbyte *pa;
jbyte hash = 0;
time_t start_time, current_time;

if (objFieldId == NULL) {
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jbyteArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);
if (objFieldId == NULL) {
jclass klass = ec_jni->GetObjectClass(o, TRACE_JNI_CALL);
objFieldId = ec_jni->GetFieldID(klass, "obj", "Ljava/lang/Object;", TRACE_JNI_CALL);
}
arr = (jbyteArray) ec_jni->GetObjectField(o, objFieldId, TRACE_JNI_CALL);
ec_jni->SetObjectField(o, objFieldId, NULL, TRACE_JNI_CALL);

size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (current_time - start_time < enterTime) {
pa = (jbyte*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i)
hash ^= pa[i];
} else {
hash = 0;
}
mssleep((long) sleepTime);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
size = ec_jni->GetArrayLength(arr, TRACE_JNI_CALL);
start_time = time(NULL);
enterTime /= 1000;
current_time = 0;
while (difftime(current_time, start_time) < enterTime) {
hash = 0;
pa = (jbyte*) ec_jni->GetPrimitiveArrayCritical(arr, NULL, TRACE_JNI_CALL);
if (pa != NULL) {
for (i = 0; i < size; ++i) {
hash ^= pa[i];
}
} else {
jni_env->FatalError("GetPrimitiveArrayCritical returned NULL");
}
mssleep((long) sleepTime);
ec_jni->ReleasePrimitiveArrayCritical(arr, pa, 0, TRACE_JNI_CALL);
mssleep((long) sleepTime);
current_time = time(NULL);
}
ec_jni->SetObjectField(o, objFieldId, arr, TRACE_JNI_CALL);
return hash;
}

}

0 comments on commit c782d0e

Please sign in to comment.