Skip to content

Commit

Permalink
Merge branch 'upstream-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Datadog Syncup Service committed Nov 27, 2023
2 parents d70d859 + a40d8d9 commit cea75b5
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/hotspot/share/code/icBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void ICStub::print() {

void InlineCacheBuffer::initialize() {
if (_buffer != nullptr) return; // already initialized
_buffer = new StubQueue(new ICStubInterface, 10*K, InlineCacheBuffer_lock, "InlineCacheBuffer");
_buffer = new StubQueue(new ICStubInterface, checked_cast<int>(InlineCacheBufferSize), InlineCacheBuffer_lock, "InlineCacheBuffer");
assert (_buffer != nullptr, "cannot allocate InlineCacheBuffer");
}

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/share/code/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ void StubQueue::verify() {
guarantee(0 <= _queue_begin && _queue_begin < _buffer_limit, "_queue_begin out of bounds");
guarantee(0 <= _queue_end && _queue_end <= _buffer_limit, "_queue_end out of bounds");
// verify alignment
guarantee(_buffer_size % stub_alignment() == 0, "_buffer_size not aligned");
guarantee(_buffer_limit % stub_alignment() == 0, "_buffer_limit not aligned");
guarantee(_queue_begin % stub_alignment() == 0, "_queue_begin not aligned");
guarantee(_queue_end % stub_alignment() == 0, "_queue_end not aligned");
// verify buffer limit/size relationship
Expand Down
5 changes: 5 additions & 0 deletions src/hotspot/share/compiler/compilerDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ bool CompilerConfig::check_args_consistency(bool status) {
"Invalid NonNMethodCodeHeapSize=%dK. Must be at least %uK.\n", NonNMethodCodeHeapSize/K,
min_code_cache_size/K);
status = false;
} else if (InlineCacheBufferSize > NonNMethodCodeHeapSize / 2) {
jio_fprintf(defaultStream::error_stream(),
"Invalid InlineCacheBufferSize=" SIZE_FORMAT "K. Must be less than or equal to " SIZE_FORMAT "K.\n",
InlineCacheBufferSize/K, NonNMethodCodeHeapSize/2/K);
status = false;
}

#ifdef _LP64
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ const int ObjectAlignmentInBytes = 8;
product(bool, UseInlineCaches, true, \
"Use Inline Caches for virtual calls ") \
\
product(size_t, InlineCacheBufferSize, 10*K, EXPERIMENTAL, \
"InlineCacheBuffer size") \
\
product(bool, InlineArrayCopy, true, DIAGNOSTIC, \
"Inline arraycopy native that is known to be part of " \
"base library DLL") \
Expand Down
3 changes: 0 additions & 3 deletions src/hotspot/share/runtime/lockStack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ class LockStack {
// Pushes an oop on this lock-stack.
inline void push(oop o);

// Pops an oop from this lock-stack.
inline oop pop();

// Removes an oop from an arbitrary location of this lock-stack.
inline void remove(oop o);

Expand Down
13 changes: 0 additions & 13 deletions src/hotspot/share/runtime/lockStack.inline.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ inline void LockStack::push(oop o) {
verify("post-push");
}

inline oop LockStack::pop() {
verify("pre-pop");
assert(to_index(_top) > 0, "underflow, probably unbalanced push/pop");
_top -= oopSize;
oop o = _base[to_index(_top)];
#ifdef ASSERT
_base[to_index(_top)] = nullptr;
#endif
assert(!contains(o), "entries must be unique: " PTR_FORMAT, p2i(o));
verify("post-pop");
return o;
}

inline void LockStack::remove(oop o) {
verify("pre-remove");
assert(contains(o), "entry must be present: " PTR_FORMAT, p2i(o));
Expand Down
8 changes: 1 addition & 7 deletions src/hotspot/share/runtime/synchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,13 +599,7 @@ void ObjectSynchronizer::exit(oop object, BasicLock* lock, JavaThread* current)
// The ObjectMonitor* can't be async deflated until ownership is
// dropped inside exit() and the ObjectMonitor* must be !is_busy().
ObjectMonitor* monitor = inflate(current, object, inflate_cause_vm_internal);
if (LockingMode == LM_LIGHTWEIGHT && monitor->is_owner_anonymous()) {
// It must be owned by us. Pop lock object from lock stack.
LockStack& lock_stack = current->lock_stack();
oop popped = lock_stack.pop();
assert(popped == object, "must be owned by this thread");
monitor->set_owner_from_anonymous(current);
}
assert(!monitor->is_owner_anonymous(), "must not be");
monitor->exit(current);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,7 @@ Type toArray() {
}

Type getComponent() {
if (sym.isArray()) {
if (isArray()) {
var comp = sym.componentType();
if (comp.isPrimitive()) {
return switch (comp.descriptorString().charAt(0)) {
Expand Down
11 changes: 11 additions & 0 deletions src/java.desktop/share/classes/javax/swing/text/html/CSS.java
Original file line number Diff line number Diff line change
Expand Up @@ -2965,6 +2965,17 @@ ImageIcon getImage(URL base) {
}
return image;
}

@Override
public int hashCode() {
return Objects.hashCode(svalue);
}

@Override
public boolean equals(Object val) {
return val instanceof CSS.BackgroundImage img
&& Objects.equals(svalue, img.svalue);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class MultiExchange<T> implements Cancelable {
);

private final List<HeaderFilter> filters;
ResponseTimerEvent responseTimerEvent;
volatile ResponseTimerEvent responseTimerEvent;
volatile boolean cancelled;
AtomicReference<CancellationException> interrupted = new AtomicReference<>();
final PushGroup<T> pushGroup;
Expand Down Expand Up @@ -231,6 +231,7 @@ public Optional<Duration> remainingConnectTimeout() {
private void cancelTimer() {
if (responseTimerEvent != null) {
client.cancelTimer(responseTimerEvent);
responseTimerEvent = null;
}
}

Expand Down Expand Up @@ -457,6 +458,7 @@ private CompletableFuture<Response> responseAsyncImpl() {
}
return completedFuture(response);
} else {
cancelTimer();
this.response =
new HttpResponseImpl<>(currentreq, response, this.response, null, exch);
Exchange<T> oldExch = exch;
Expand Down
2 changes: 1 addition & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ java/beans/XMLEncoder/Test6570354.java 8015593 macosx-all
java/lang/ProcessHandle/InfoTest.java 8211847 aix-ppc64
java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java 8151492 generic-all
java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-all
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-x64
java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 8249079 linux-all
java/lang/invoke/RicochetTest.java 8251969 generic-all

############################################################################
Expand Down
176 changes: 176 additions & 0 deletions test/jdk/java/net/httpclient/RedirectTimeoutTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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
* 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
* @bug 8304701
* @summary Verifies that for a redirected request, the given HttpClient
* will clear and start a new response timer instead of throwing
* an HttpTimeoutException during the redirected request.
* @library /test/lib /test/jdk/java/net/httpclient/lib
* @build jdk.test.lib.net.SimpleSSLContext
* @run testng/othervm -Djdk.httpclient.HttpClient.log=errors,trace -Djdk.internal.httpclient.debug=false RedirectTimeoutTest
*/

import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestExchange;
import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestHandler;
import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestResponseHeaders;
import jdk.httpclient.test.lib.common.HttpServerAdapters.HttpTestServer;
import org.testng.TestException;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpClient.Version;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpTimeoutException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.time.Instant;

import static java.net.http.HttpClient.Redirect.ALWAYS;
import static java.net.http.HttpClient.Version.HTTP_1_1;
import static java.net.http.HttpClient.Version.HTTP_2;
import static jdk.test.lib.Utils.adjustTimeout;

public class RedirectTimeoutTest {

static HttpTestServer h1TestServer, h2TestServer;
static URI h1Uri, h1RedirectUri, h2Uri, h2RedirectUri, h2WarmupUri, testRedirectURI;
private static final long TIMEOUT_MILLIS = 3000L; // 3s
private static final long SLEEP_TIME = 1500L; // 1.5s
public static final int ITERATIONS = 4;
private static final PrintStream out = System.out;

@BeforeTest
public void setup() throws IOException {
h1TestServer = HttpTestServer.create(HTTP_1_1);
h2TestServer = HttpTestServer.create(HTTP_2);
h1Uri = URI.create("http://" + h1TestServer.serverAuthority() + "/h1_test");
h1RedirectUri = URI.create("http://" + h1TestServer.serverAuthority() + "/h1_redirect");
h2Uri = URI.create("http://" + h2TestServer.serverAuthority() + "/h2_test");
h2RedirectUri = URI.create("http://" + h2TestServer.serverAuthority() + "/h2_redirect");
h2WarmupUri = URI.create("http://" + h2TestServer.serverAuthority() + "/h2_warmup");
h1TestServer.addHandler(new GetHandler(), "/h1_test");
h1TestServer.addHandler(new RedirectHandler(), "/h1_redirect");
h2TestServer.addHandler(new GetHandler(), "/h2_test");
h2TestServer.addHandler(new RedirectHandler(), "/h2_redirect");
h2TestServer.addHandler(new Http2Warmup(), "/h2_warmup");
h1TestServer.start();
h2TestServer.start();
}

@AfterTest
public void teardown() {
h1TestServer.stop();
h2TestServer.stop();
}

@DataProvider(name = "testData")
public Object[][] testData() {
return new Object[][] {
{ HTTP_1_1, h1Uri, h1RedirectUri },
{ HTTP_2, h2Uri, h2RedirectUri }
};
}

@Test(dataProvider = "testData")
public void test(Version version, URI uri, URI redirectURI) throws InterruptedException {
out.println("Testing for " + version);
testRedirectURI = redirectURI;
HttpClient.Builder clientBuilder = HttpClient.newBuilder().followRedirects(ALWAYS);
HttpRequest request = HttpRequest.newBuilder().uri(uri)
.GET()
.version(version)
.timeout(Duration.ofMillis(adjustTimeout(TIMEOUT_MILLIS)))
.build();

try (HttpClient client = clientBuilder.build()) {
if (version.equals(HTTP_2))
client.send(HttpRequest.newBuilder(h2WarmupUri).HEAD().build(), HttpResponse.BodyHandlers.discarding());
/*
With TIMEOUT_MILLIS set to 1500ms and the server's RedirectHandler sleeping for 750ms before responding
to each request, 4 iterations will take a guaranteed minimum time of 3000ms which will ensure that any
uncancelled/uncleared timers will fire within the test window.
*/
for (int i = 0; i < ITERATIONS; i++) {
out.println(Instant.now() + ": Client: Sending request #" + (i + 1));
client.send(request, HttpResponse.BodyHandlers.ofString());
out.println("Request complete");
}
} catch (IOException e) {
if (e.getClass() == HttpTimeoutException.class) {
e.printStackTrace(System.out);
throw new TestException("Timeout from original HttpRequest expired on redirect when it should have been cancelled.");
} else {
throw new RuntimeException(e);
}
}
}

public static class Http2Warmup implements HttpTestHandler {

@Override
public void handle(HttpTestExchange t) throws IOException {
t.sendResponseHeaders(200, 0);
}
}

public static class GetHandler implements HttpTestHandler {

@Override
public void handle(HttpTestExchange exchange) throws IOException {
out.println(Instant.now() + ": Server: Get Handler Called");
HttpTestResponseHeaders responseHeaders = exchange.getResponseHeaders();
responseHeaders.addHeader("Location", testRedirectURI.toString());
exchange.sendResponseHeaders(302, 0);
}
}

public static class RedirectHandler implements HttpTestHandler {

@Override
public void handle(HttpTestExchange exchange) throws IOException {
out.println(Instant.now() + ": Server: Redirect Handler Called");
byte[] data = "Test".getBytes(StandardCharsets.UTF_8);
try {
Thread.sleep(adjustTimeout(SLEEP_TIME));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
exchange.sendResponseHeaders(200, data.length);
try (OutputStream os = exchange.getResponseBody()) {
os.write(data);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

/*
* @test
* @bug 7083187
* @bug 7083187 8318113
* @summary Verifies if CSS.CSSValue attribute is same
* @run main CSSAttributeEqualityBug
*/
Expand Down Expand Up @@ -72,6 +72,9 @@ public class CSSAttributeEqualityBug {
"background-position: 1em 2em",

"border-width: medium",

"background-image: none",
"background-image: url(image.png)",
};

/**
Expand All @@ -86,6 +89,8 @@ public class CSSAttributeEqualityBug {
{"margin-top: 42px", "margin-top: 22px"},
{"margin-top: 42px", "margin-top: 42pt"},
{"margin-top: 100%", "margin-top: 50%"},

{"background-image: none", "background-image: url(image.png)"},
};

private static final String[][] EQUALS_WITH_SPACE = {
Expand Down
15 changes: 13 additions & 2 deletions test/jdk/jdk/classfile/StackMapsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/*
* @test
* @summary Testing Classfile stack maps generator.
* @bug 8305990 8320222
* @bug 8305990 8320222 8320618
* @build testdata.*
* @run junit StackMapsTest
*/
Expand All @@ -43,7 +43,6 @@
import java.lang.constant.ClassDesc;
import java.lang.constant.ConstantDescs;
import java.lang.constant.MethodTypeDesc;
import java.util.List;
import java.lang.reflect.AccessFlag;

/**
Expand Down Expand Up @@ -237,6 +236,18 @@ void testClassVersions() throws Exception {
.verify(null));
}

@Test
void testInvalidAALOADStack() {
Classfile.of().build(ClassDesc.of("Test"), clb
-> clb.withMethodBody("test", ConstantDescs.MTD_void, 0, cob
-> cob.bipush(10)
.anewarray(ConstantDescs.CD_Object)
.lconst_1() //long on stack caused NPE, see 8320618
.aaload()
.astore(2)
.return_()));
}

private static final FileSystem JRT = FileSystems.getFileSystem(URI.create("jrt:/"));

private static void testTransformedStackMaps(String classPath, Classfile.Option... options) throws Exception {
Expand Down

0 comments on commit cea75b5

Please sign in to comment.