Skip to content

Commit 2f7806f

Browse files
author
Doug Simon
committed
8355034: [JVMCI] assert(static_cast<int>(_jvmci_data_size) == align_up(compiler->is_jvmci() ? jvmci_data->size() : 0, oopSize)) failed: failed: 104 != 16777320
Reviewed-by: never, yzheng, cslucas
1 parent a55ccd2 commit 2f7806f

File tree

4 files changed

+83
-3
lines changed

4 files changed

+83
-3
lines changed

src/hotspot/share/code/nmethod.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
// Cast from int value to narrow type
113113
#define CHECKED_CAST(result, T, thing) \
114114
result = static_cast<T>(thing); \
115-
assert(static_cast<int>(result) == thing, "failed: %d != %d", static_cast<int>(result), thing);
115+
guarantee(static_cast<int>(result) == thing, "failed: %d != %d", static_cast<int>(result), thing);
116116

117117
//---------------------------------------------------------------------------------
118118
// NMethod statistics

src/hotspot/share/jvmci/jvmciCodeInstaller.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,13 @@ JVMCI::CodeInstallResult CodeInstaller::install(JVMCICompiler* compiler,
825825
// Since this compilation didn't pass through the broker it wasn't logged yet.
826826
if (PrintCompilation) {
827827
ttyLocker ttyl;
828-
CompileTask::print(tty, nm, "(hosted JVMCI compilation)");
828+
if (name != nullptr) {
829+
stringStream st;
830+
st.print_cr("(hosted JVMCI compilation: %s)", name);
831+
CompileTask::print(tty, nm, st.as_string());
832+
} else {
833+
CompileTask::print(tty, nm, "(hosted JVMCI compilation)");
834+
}
829835
}
830836
}
831837

src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/InstalledCode.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,24 @@ public class InstalledCode {
4646

4747
protected final String name;
4848

49+
/**
50+
* The maximum length of an InstalledCode name. This name is typically installed into
51+
* the code cache so it should have a reasonable limit.
52+
*/
53+
public static final int MAX_NAME_LENGTH = 2048;
54+
55+
/**
56+
* @param name the name to be associated with the installed code. Can be null and
57+
* must be no longer than {@link #MAX_NAME_LENGTH}.
58+
*
59+
* @throws IllegalArgumentException if {@code name.length >} {@link #MAX_NAME_LENGTH}
60+
*/
4961
public InstalledCode(String name) {
62+
if (name != null && name.length() > MAX_NAME_LENGTH) {
63+
String msg = String.format("name length (%d) is greater than %d (name[0:%s] = %s)",
64+
name.length(), MAX_NAME_LENGTH, MAX_NAME_LENGTH, name.substring(0, MAX_NAME_LENGTH));
65+
throw new IllegalArgumentException(msg);
66+
}
5067
this.name = name;
5168
}
5269

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test 8355034
26+
* @requires vm.jvmci
27+
* @modules jdk.internal.vm.ci/jdk.vm.ci.code
28+
* @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.InstalledCodeTest
29+
*/
30+
31+
package jdk.vm.ci.code.test;
32+
33+
import jdk.vm.ci.code.InstalledCode;
34+
import org.junit.Assert;
35+
import org.junit.Test;
36+
37+
public class InstalledCodeTest {
38+
39+
@Test
40+
public void testNullName() {
41+
new InstalledCode(null);
42+
}
43+
44+
@Test
45+
public void testTooLongName() {
46+
String longName = new String(new char[InstalledCode.MAX_NAME_LENGTH]).replace('\0', 'A');
47+
new InstalledCode(longName);
48+
try {
49+
String tooLongName = longName + "X";
50+
new InstalledCode(tooLongName);
51+
} catch (IllegalArgumentException iae) {
52+
// Threw IllegalArgumentException as expected.
53+
return;
54+
}
55+
Assert.fail("expected IllegalArgumentException");
56+
}
57+
}

0 commit comments

Comments
 (0)