Skip to content

Commit

Permalink
Merge branch 'master' into goetz_backport_8276227
Browse files Browse the repository at this point in the history
  • Loading branch information
GoeLin committed Mar 29, 2024
2 parents 3a3124b + ba77d0b commit 5324de4
Show file tree
Hide file tree
Showing 136 changed files with 828 additions and 991 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ const char *ciEnv::replay_name(ciKlass* k) const {
// Look up the location descriptor for the given class and return it as a string.
// Returns the class name as a fallback if no location is found.
const char *ciEnv::replay_name(const InstanceKlass* ik) const {
// JDK-8271911 is not in JDK 17, so we fall back to using the class name below.
const char* name = nullptr; // dyno_name(ik);
if (name != nullptr) {
return name;
Expand Down
25 changes: 15 additions & 10 deletions test/hotspot/gtest/runtime/test_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ struct NUMASwitcher {

// ...re-reserve the middle stripes. This should work unless release silently failed.
address p2 = (address)os::attempt_reserve_memory_at((char*)p_middle_stripes, middle_stripe_len);

ASSERT_EQ(p2, p_middle_stripes);

PRINT_MAPPINGS("C");

// Clean up. Release all mappings.
Expand Down Expand Up @@ -544,26 +546,29 @@ TEST_VM(os, release_bad_ranges) {
TEST_VM(os, release_one_mapping_multi_commits) {
// Test that we can release an area consisting of interleaved
// committed and uncommitted regions:
const size_t stripe_len = 4 * M;
const int num_stripes = 4;
const size_t stripe_len = os::vm_allocation_granularity();
const int num_stripes = 6;
const size_t total_range_len = stripe_len * num_stripes;

// reserve address space...
address p = reserve_one_commit_multiple(num_stripes, stripe_len);
ASSERT_NE(p, (address)NULL);
PRINT_MAPPINGS("A");
ASSERT_NE(p, (address)nullptr);

// .. release it...
ASSERT_TRUE(os::release_memory((char*)p, total_range_len));
// // make things even more difficult by trying to reserve at the border of the region
address border = p + num_stripes * stripe_len;
address p2 = (address)os::attempt_reserve_memory_at((char*)border, stripe_len);
PRINT_MAPPINGS("B");

// re-reserve it. This should work unless release failed.
address p2 = (address)os::attempt_reserve_memory_at((char*)p, total_range_len);
ASSERT_EQ(p2, p);
PRINT_MAPPINGS("C");
ASSERT_TRUE(p2 == nullptr || p2 == border);

ASSERT_TRUE(os::release_memory((char*)p, total_range_len));
PRINT_MAPPINGS("D");
PRINT_MAPPINGS("C");

if (p2 != nullptr) {
ASSERT_TRUE(os::release_memory((char*)p2, stripe_len));
PRINT_MAPPINGS("D");
}
}

static void test_show_mappings(address start, size_t size) {
Expand Down
7 changes: 5 additions & 2 deletions test/hotspot/jtreg/gtest/GTestResultParser.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, 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 @@ -57,7 +57,10 @@ public GTestResultParser(Path file) {
testCase = xmlReader.getAttributeValue("", "name");
break;
case "failure":
failedTests.add(testSuite + "::" + testCase);
String failedStr = testSuite + "::" + testCase;
if (!failedTests.contains(failedStr)) {
failedTests.add(failedStr);
}
break;
default:
// ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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 @@ -34,6 +34,7 @@
import java.util.List;
import java.util.Map;

import jdk.test.lib.JDWP;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
Expand Down Expand Up @@ -69,9 +70,6 @@ public static int run(String argv[], PrintStream out) {
}

private int runIt(String argv[], PrintStream out) {
String port;
String listenPort;
Process proc;
ArgumentHandler argHandler = new ArgumentHandler(argv);

// pass if "com.sun.jdi.SocketAttach" is not implemented
Expand All @@ -96,19 +94,17 @@ private int runIt(String argv[], PrintStream out) {
long timeout = argHandler.getWaitTime() * 60 * 1000;
attempts = (int)(timeout / delay);

port = argHandler.getTransportPort();
listenPort = argHandler.getTransportPort();

String java = argHandler.getLaunchExecPath()
+ " " + argHandler.getLaunchOptions();
String cmd = java +
" -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=" +
listenPort + " " + DEBUGEE_CLASS;
String cmd = java
+ " -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,address=0"
+ " " + DEBUGEE_CLASS;

Binder binder = new Binder(argHandler, log);
log.display("command: " + cmd);
Debugee debugee = binder.startLocalDebugee(cmd);
debugee.redirectOutput(log);
JDWP.ListenAddress listenAddress = debugee.redirectOutputAndDetectListeningAddress(log);
String port = listenAddress.address();

if ((vm = attachTarget(argHandler.getTestHost(), port)) == null) {
log.complain("TEST: Unable to attach the debugee VM");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2021, 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 @@ -34,6 +34,7 @@
import java.util.List;
import java.util.Map;

import jdk.test.lib.JDWP;
import nsk.share.*;
import nsk.share.jpda.*;
import nsk.share.jdi.*;
Expand Down Expand Up @@ -69,9 +70,6 @@ public static int run(String argv[], PrintStream out) {
}

private int runIt(String argv[], PrintStream out) {
String port;
String listenPort;
Process proc;
ArgumentHandler argHandler = new ArgumentHandler(argv);

// pass if "com.sun.jdi.SocketAttach" is not implemented
Expand All @@ -96,19 +94,17 @@ private int runIt(String argv[], PrintStream out) {
long timeout = argHandler.getWaitTime() * 60 * 1000;
attempts = (int)(timeout / delay);

port = argHandler.getTransportPort();
listenPort = argHandler.getTransportPort();

String java = argHandler.getLaunchExecPath()
+ " " + argHandler.getLaunchOptions();
String cmd = java +
" -Xdebug -Xnoagent -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" +
listenPort + " " + DEBUGEE_CLASS;
String cmd = java
+ " -Xdebug -Xnoagent -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0"
+ " " + DEBUGEE_CLASS;

Binder binder = new Binder(argHandler, log);
log.display("command: " + cmd);
Debugee debugee = binder.startLocalDebugee(cmd);
debugee.redirectOutput(log);
JDWP.ListenAddress listenAddress = debugee.redirectOutputAndDetectListeningAddress(log);
String port = listenAddress.address();

if ((vm = attachTarget(argHandler.getTestHost(), port)) == null) {
log.complain("TEST: Unable to attach the debugee VM");
Expand Down
62 changes: 23 additions & 39 deletions test/hotspot/jtreg/vmTestbase/nsk/share/IORedirector.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,17 @@
package nsk.share;

import java.io.*;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Consumer;

/**
* This class implements a thread transfering bytes from
* a given InputStream to a given OutputStream.
*/
public class IORedirector extends Thread {
private BufferedReader bin = null;
private PrintStream pout = null;
private Log log = null;

/**
* Few symbols to precede every text line being redirected.
*/
private String prefix = "";
private List<Consumer<String>> processors = new LinkedList<>();

/**
* Input and output streams must be specified.
Expand All @@ -54,10 +51,16 @@ private IORedirector() {
* @see #IORedirector(BufferedReader,Log,String)
*/
@Deprecated
public IORedirector(InputStream in, OutputStream out) {
public IORedirector(InputStream in, OutputStream out, String prefix) {
this();
bin = new BufferedReader(new InputStreamReader(in));
pout = new PrintStream(out);
PrintStream pout = new PrintStream(out);
addProcessor(s -> {
synchronized (pout) {
pout.println(prefix + s);
pout.flush();
}
});
}

/**
Expand All @@ -67,16 +70,16 @@ public IORedirector(InputStream in, OutputStream out) {
*/
public IORedirector(BufferedReader in, Log log, String prefix) {
this();
this.prefix = prefix;
this.bin = in;
this.log = log;
addProcessor(s -> log.println(prefix + s));
}

/**
* Set the prefix for redirected messages;
*/
public void setPrefix(String prefix) {
this.prefix = prefix;
public void addProcessor(Consumer<String> lineProcessor) {
processors.add(lineProcessor);
}

private void processLine(String line) {
processors.stream().forEach(processor -> processor.accept(line));
}

private boolean cancelled = false;
Expand Down Expand Up @@ -104,39 +107,20 @@ public void cancel () {
*/
public void run () {
started = true;
String logPrefix = "IORedirector-" + prefix;
if (bin == null || (pout == null && log == null))
if (bin == null || processors.isEmpty()) {
return;
}
try {
while (!cancelled) {
String line = bin.readLine();
if (line == null)
break; //EOF
String message = prefix + line;
if (log != null) {
// It's synchronized and auto-flushed:
log.println(message);
} else if (pout != null) {
synchronized (pout) {
pout.println(message);
pout.flush();
}
}
processLine(line);
}
} catch (IOException e) {
// e.printStackTrace(log.getOutStream());
String msg = "# WARNING: Caught IOException while redirecting output stream:\n\t" + e;
if (log != null) {
log.println(msg);
} else if (pout != null) {
synchronized (pout) {
pout.println(msg);
pout.flush();
}
} else {
System.err.println(msg);
System.err.flush();
}
processLine(msg);
};
stopped = true;
}
Expand Down
Loading

0 comments on commit 5324de4

Please sign in to comment.