Skip to content

Commit

Permalink
Merge branch 'master' into goetz_backport_8304761
Browse files Browse the repository at this point in the history
  • Loading branch information
GoeLin committed Apr 3, 2024
2 parents 814c5f9 + 7a9e984 commit 8c545a8
Show file tree
Hide file tree
Showing 12 changed files with 248 additions and 293 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/classfile/classLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,7 +1141,7 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR

const char* const class_name = name->as_C_string();

EventMark m("loading class %s", class_name);
EventMarkClassLoading m("Loading class %s", class_name);

const char* const file_name = file_name_for_class_name(class_name,
name->utf8_length());
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/utilities/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ StringEventLog* Events::_vm_operations = NULL;
ExceptionsEventLog* Events::_exceptions = NULL;
StringEventLog* Events::_redefinitions = NULL;
UnloadingEventLog* Events::_class_unloading = NULL;
StringEventLog* Events::_class_loading = NULL;
StringEventLog* Events::_deopt_messages = NULL;
StringEventLog* Events::_dll_messages = NULL;

Expand Down Expand Up @@ -97,6 +98,7 @@ void Events::init() {
_exceptions = new ExceptionsEventLog("Internal exceptions", "exc");
_redefinitions = new StringEventLog("Classes redefined", "redef");
_class_unloading = new UnloadingEventLog("Classes unloaded", "unload");
_class_loading = new StringEventLog("Classes loaded", "load");
_deopt_messages = new StringEventLog("Deoptimization events", "deopt");
_dll_messages = new StringEventLog("Dll operation events", "dll");
}
Expand Down
17 changes: 17 additions & 0 deletions src/hotspot/share/utilities/events.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ class Events : AllStatic {

// Class unloading events
static UnloadingEventLog* _class_unloading;

// Class loading events
static StringEventLog* _class_loading;
public:

// Print all event logs; limit number of events per event log to be printed with max
Expand All @@ -263,6 +266,8 @@ class Events : AllStatic {

static void log_class_unloading(Thread* thread, InstanceKlass* ik);

static void log_class_loading(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);

static void log_deopt_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);

static void log_dll_message(Thread* thread, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
Expand Down Expand Up @@ -319,6 +324,15 @@ inline void Events::log_class_unloading(Thread* thread, InstanceKlass* ik) {
}
}

inline void Events::log_class_loading(Thread* thread, const char* format, ...) {
if (LogEvents && _class_loading != NULL) {
va_list ap;
va_start(ap, format);
_class_loading->logv(thread, format, ap);
va_end(ap);
}
}

inline void Events::log_deopt_message(Thread* thread, const char* format, ...) {
if (LogEvents && _deopt_messages != NULL) {
va_list ap;
Expand Down Expand Up @@ -487,4 +501,7 @@ typedef EventMarkWithLogFunction<Events::log> EventMark;
// These end up in the vm_operation log.
typedef EventMarkWithLogFunction<Events::log_vm_operation> EventMarkVMOperation;

// These end up in the class loading log.
typedef EventMarkWithLogFunction<Events::log_class_loading> EventMarkClassLoading;

#endif // SHARE_UTILITIES_EVENTS_HPP
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,8 @@ protected void engineSetPadding(String padding)
// no native padding support; use our own padding impl
paddingObj = new PKCS5Padding(blockSize);
padBuffer = new byte[blockSize];
char[] tokenLabel = token.tokenInfo.label;
// NSS requires block-sized updates in multi-part operations.
reqBlockUpdates = ((tokenLabel[0] == 'N' && tokenLabel[1] == 'S'
&& tokenLabel[2] == 'S') ? true : false);
reqBlockUpdates = P11Util.isNSS(token);
}
} else {
throw new NoSuchPaddingException("Unsupported padding " + padding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ abstract class P11Key implements Key, Length {
this.tokenObject = tokenObject;
this.sensitive = sensitive;
this.extractable = extractable;
char[] tokenLabel = this.token.tokenInfo.label;
isNSS = (tokenLabel[0] == 'N' && tokenLabel[1] == 'S'
&& tokenLabel[2] == 'S');
isNSS = P11Util.isNSS(this.token);
boolean extractKeyInfo = (!DISABLE_NATIVE_KEYS_EXTRACTION && isNSS &&
extractable && !tokenObject);
this.keyIDHolder = new NativeKeyHolder(this, keyID, session,
Expand Down Expand Up @@ -395,8 +393,9 @@ static PrivateKey privateKey(Session session, long keyID, String algorithm,
new CK_ATTRIBUTE(CKA_EXTRACTABLE),
});

boolean keySensitive = (attrs[0].getBoolean() ||
attrs[1].getBoolean() || !attrs[2].getBoolean());
boolean keySensitive =
(attrs[0].getBoolean() && P11Util.isNSS(session.token)) ||
attrs[1].getBoolean() || !attrs[2].getBoolean();

switch (algorithm) {
case "RSA":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ private P11Util() {
// empty
}

static boolean isNSS(Token token) {
char[] tokenLabel = token.tokenInfo.label;
if (tokenLabel != null && tokenLabel.length >= 3) {
return (tokenLabel[0] == 'N' && tokenLabel[1] == 'S'
&& tokenLabel[2] == 'S');
}
return false;
}

static Provider getSunProvider() {
Provider p = sun;
if (p == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class DigestSanityTestBase {
private static final int MSG_SIZE = 1024;
private static final int OFFSET = 0;
private static final int ITERATIONS = 10000;
private static final int WARMUP_ITERATIONS = 1;
private static final int WARMUP_ITERATIONS = WHITE_BOX.getIntxVMFlag("Tier4InvocationThreshold").intValue() + 50;
private static final String PROVIDER = "SUN";

private final BooleanSupplier predicate;
Expand Down
86 changes: 51 additions & 35 deletions test/jdk/java/math/BigInteger/BigIntegerTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2023, 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 @@ -1222,6 +1222,17 @@ public static void serialize() throws Exception {
*
*/
public static void main(String[] args) throws Exception {
// subset zero indicates to run all subsets
int subset = Integer.valueOf(System.getProperty("subset",
String.valueOf(1 + random.nextInt(3))));
if (subset < 0 || subset > 3) {
throw new RuntimeException("Unknown subset " + subset);
}
if (subset == 0)
System.out.println("Testing all subsets");
else
System.out.println("Testing subset " + subset);

// Some variables for sizing test numbers in bits
int order1 = ORDER_MEDIUM;
int order2 = ORDER_SMALL;
Expand All @@ -1237,52 +1248,57 @@ public static void main(String[] args) throws Exception {
if (args.length >3)
order4 = (int)((Integer.parseInt(args[3]))* 3.333);

constructor();

prime();
nextProbablePrime();
if (subset == 0 || subset == 1) {
constructor();

arithmetic(order1); // small numbers
arithmetic(order3); // Karatsuba range
arithmetic(order4); // Toom-Cook / Burnikel-Ziegler range
prime();
nextProbablePrime();

divideAndRemainder(order1); // small numbers
divideAndRemainder(order3); // Karatsuba range
divideAndRemainder(order4); // Toom-Cook / Burnikel-Ziegler range
arithmetic(order1); // small numbers
arithmetic(order3); // Karatsuba range
arithmetic(order4); // Toom-Cook / Burnikel-Ziegler range

pow(order1);
pow(order3);
pow(order4);
divideAndRemainder(order1); // small numbers
divideAndRemainder(order3); // Karatsuba range
divideAndRemainder(order4); // Toom-Cook / Burnikel-Ziegler range

square(ORDER_MEDIUM);
square(ORDER_KARATSUBA_SQUARE);
square(ORDER_TOOM_COOK_SQUARE);
pow(order1);
pow(order3);
pow(order4);

squareRoot();
squareRootAndRemainder();
square(ORDER_MEDIUM);
square(ORDER_KARATSUBA_SQUARE);
square(ORDER_TOOM_COOK_SQUARE);

bitCount();
bitLength();
bitOps(order1);
bitwise(order1);
squareRoot();
squareRootAndRemainder();

shift(order1);
bitCount();
bitLength();
bitOps(order1);
bitwise(order1);

byteArrayConv(order1);
shift(order1);

modInv(order1); // small numbers
modInv(order3); // Karatsuba range
modInv(order4); // Toom-Cook / Burnikel-Ziegler range
byteArrayConv(order1);

modExp(order1, order2);
modExp2(order1);
modInv(order1); // small numbers
modInv(order3); // Karatsuba range
}
if (subset == 0 || subset == 2) {
modInv(order4); // Toom-Cook / Burnikel-Ziegler range

stringConv();
serialize();
modExp(order1, order2);
modExp2(order1);
}
if (subset == 0 || subset == 3) {
stringConv();
serialize();

multiplyLarge();
squareLarge();
divideLarge();
multiplyLarge();
squareLarge();
divideLarge();
}

if (failure)
throw new RuntimeException("Failure in BigIntegerTest.");
Expand Down
11 changes: 10 additions & 1 deletion test/jdk/java/math/BigInteger/LargeValueExceptions.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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 @@ -30,6 +30,8 @@
*/
import java.math.BigInteger;
import static java.math.BigInteger.ONE;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

//
Expand Down Expand Up @@ -62,6 +64,13 @@ public class LargeValueExceptions {
// Half BigInteger.MAX_MAG_LENGTH
private static final int MAX_INTS_HALF = MAX_INTS / 2;

// Print the run time of each sub-test in milliseconds
@AfterMethod
public void getRunTime(ITestResult tr) {
long time = tr.getEndMillis() - tr.getStartMillis();
System.out.printf("Run time: %d ms%n", time);
}

// --- squaring ---

// Largest no overflow determined by examining data lengths alone.
Expand Down
Loading

0 comments on commit 8c545a8

Please sign in to comment.