Skip to content

Commit a028480

Browse files
authored
Merge branch 'openjdk:master' into backport-sendaoYan-fe29cad5-master
2 parents e4994d9 + 46fc523 commit a028480

File tree

408 files changed

+4984
-6829
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

408 files changed

+4984
-6829
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ jobs:
237237
uses: ./.github/workflows/build-macos.yml
238238
with:
239239
platform: macos-x64
240-
runs-on: 'macos-13'
241-
xcode-toolset-version: '14.3.1'
240+
runs-on: 'macos-15-intel'
241+
xcode-toolset-version: '16.4'
242242
configure-arguments: ${{ github.event.inputs.configure-arguments }}
243243
make-arguments: ${{ github.event.inputs.make-arguments }}
244244
if: needs.prepare.outputs.macos-x64 == 'true'
@@ -249,8 +249,8 @@ jobs:
249249
uses: ./.github/workflows/build-macos.yml
250250
with:
251251
platform: macos-aarch64
252-
runs-on: 'macos-14'
253-
xcode-toolset-version: '15.4'
252+
runs-on: 'macos-15'
253+
xcode-toolset-version: '16.4'
254254
configure-arguments: ${{ github.event.inputs.configure-arguments }}
255255
make-arguments: ${{ github.event.inputs.make-arguments }}
256256
if: needs.prepare.outputs.macos-aarch64 == 'true'
@@ -319,8 +319,8 @@ jobs:
319319
with:
320320
platform: macos-aarch64
321321
bootjdk-platform: macos-aarch64
322-
runs-on: macos-14
323-
xcode-toolset-version: '15.4'
322+
runs-on: macos-15
323+
xcode-toolset-version: '16.4'
324324

325325
test-windows-x64:
326326
name: windows-x64

make/autoconf/flags-cflags.m4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
625625
TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced -fno-exceptions \
626626
-qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect"
627627
elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
628-
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:preprocessor -Zc:strictStrings -permissive- -MP"
629-
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:preprocessor -Zc:strictStrings -Zc:wchar_t-"
628+
TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:preprocessor -Zc:throwingNew -permissive- -MP"
629+
TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:preprocessor -Zc:throwingNew -permissive- -Zc:wchar_t-"
630630
fi
631631
632632
# CFLAGS C language level for JDK sources (hotspot only uses C++)

src/hotspot/cpu/ppc/interp_masm_ppc.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ class InterpreterMacroAssembler: public MacroAssembler {
126126

127127
void get_cache_index_at_bcp(Register Rdst, int bcp_offset, size_t index_size);
128128

129-
void get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size = sizeof(u2));
129+
void get_cache_and_index_at_bcp(Register cache, int bcp_offset, size_t index_size = sizeof(u2),
130+
bool for_fast_bytecode = false);
130131
void load_resolved_indy_entry(Register cache, Register index);
131132

132133
void get_u4(Register Rdst, Register Rsrc, int offset, signedOrNot is_signed);

src/hotspot/cpu/ppc/interp_masm_ppc_64.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,18 @@ void InterpreterMacroAssembler::get_cache_index_at_bcp(Register Rdst, int bcp_of
451451
}
452452

453453
void InterpreterMacroAssembler::get_cache_and_index_at_bcp(Register cache, int bcp_offset,
454-
size_t index_size) {
454+
size_t index_size, bool for_fast_bytecode) {
455455
get_cache_index_at_bcp(cache, bcp_offset, index_size);
456456
sldi(cache, cache, exact_log2(in_words(ConstantPoolCacheEntry::size()) * BytesPerWord));
457457
add(cache, R27_constPoolCache, cache);
458+
459+
if (for_fast_bytecode) {
460+
// Prevent speculative loading from ConstantPoolCacheEntry as it can miss the info written by another thread.
461+
// TemplateTable::patch_bytecode uses release-store.
462+
// We reached here via control dependency (Bytecode dispatch has used the rewritten Bytecode).
463+
// So, we can use control-isync based ordering.
464+
isync();
465+
}
458466
}
459467

460468
// Load 4-byte signed or unsigned integer in Java format (that is, big-endian format)

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ void TemplateTable::patch_bytecode(Bytecodes::Code new_bc, Register Rnew_bc, Reg
147147
__ bind(L_fast_patch);
148148
}
149149

150-
// Patch bytecode.
150+
// Patch bytecode with release store to coordinate with ConstantPoolCacheEntry
151+
// loads in fast bytecode codelets.
152+
__ release();
151153
__ stb(Rnew_bc, 0, R14_bcp);
152154

153155
__ bind(L_patch_done);
@@ -311,6 +313,7 @@ void TemplateTable::fast_aldc(LdcType type) {
311313
// We are resolved if the resolved reference cache entry contains a
312314
// non-null object (CallSite, etc.)
313315
__ get_cache_index_at_bcp(R31, 1, index_size); // Load index.
316+
// Only rewritten during link time. So, no need for memory barriers for accessing resolved info.
314317
__ load_resolved_reference_at_index(R17_tos, R31, R11_scratch1, R12_scratch2, &is_null);
315318

316319
// Convert null sentinel to null
@@ -2377,7 +2380,7 @@ void TemplateTable::load_invoke_cp_cache_entry(int byte_no,
23772380
if (is_invokevfinal) {
23782381
assert(Ritable_index == noreg, "register not used");
23792382
// Already resolved.
2380-
__ get_cache_and_index_at_bcp(Rcache, 1);
2383+
__ get_cache_and_index_at_bcp(Rcache, 1, sizeof(u2), /* for_fast_bytecode */ true);
23812384
} else {
23822385
resolve_cache_and_index(byte_no, Rcache, /* temp */ Rmethod, sizeof(u2));
23832386
}
@@ -3084,7 +3087,7 @@ void TemplateTable::fast_storefield(TosState state) {
30843087
const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store).
30853088

30863089
// Constant pool already resolved => Load flags and offset of field.
3087-
__ get_cache_and_index_at_bcp(Rcache, 1);
3090+
__ get_cache_and_index_at_bcp(Rcache, 1, sizeof(u2), /* for_fast_bytecode */ true);
30883091
jvmti_post_field_mod(Rcache, Rscratch, false /* not static */);
30893092
load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12
30903093

@@ -3165,7 +3168,7 @@ void TemplateTable::fast_accessfield(TosState state) {
31653168
// R12_scratch2 used by load_field_cp_cache_entry
31663169

31673170
// Constant pool already resolved. Get the field offset.
3168-
__ get_cache_and_index_at_bcp(Rcache, 1);
3171+
__ get_cache_and_index_at_bcp(Rcache, 1, sizeof(u2), /* for_fast_bytecode */ true);
31693172
load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12
31703173

31713174
// JVMTI support
@@ -3304,7 +3307,7 @@ void TemplateTable::fast_xaccess(TosState state) {
33043307
__ ld(Rclass_or_obj, 0, R18_locals);
33053308

33063309
// Constant pool already resolved. Get the field offset.
3307-
__ get_cache_and_index_at_bcp(Rcache, 2);
3310+
__ get_cache_and_index_at_bcp(Rcache, 2, sizeof(u2), /* for_fast_bytecode */ true);
33083311
load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false); // Uses R11, R12
33093312

33103313
// JVMTI support not needed, since we switch back to single bytecode as soon as debugger attaches.

src/hotspot/share/classfile/verifier.cpp

Lines changed: 0 additions & 229 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,216 +2438,6 @@ void ClassVerifier::verify_field_instructions(RawBytecodeStream* bcs,
24382438
}
24392439
}
24402440

2441-
// Look at the method's handlers. If the bci is in the handler's try block
2442-
// then check if the handler_pc is already on the stack. If not, push it
2443-
// unless the handler has already been scanned.
2444-
void ClassVerifier::push_handlers(ExceptionTable* exhandlers,
2445-
GrowableArray<u4>* handler_list,
2446-
GrowableArray<u4>* handler_stack,
2447-
u4 bci) {
2448-
int exlength = exhandlers->length();
2449-
for(int x = 0; x < exlength; x++) {
2450-
if (bci >= exhandlers->start_pc(x) && bci < exhandlers->end_pc(x)) {
2451-
u4 exhandler_pc = exhandlers->handler_pc(x);
2452-
if (!handler_list->contains(exhandler_pc)) {
2453-
handler_stack->append_if_missing(exhandler_pc);
2454-
handler_list->append(exhandler_pc);
2455-
}
2456-
}
2457-
}
2458-
}
2459-
2460-
// Return TRUE if all code paths starting with start_bc_offset end in
2461-
// bytecode athrow or loop.
2462-
bool ClassVerifier::ends_in_athrow(u4 start_bc_offset) {
2463-
ResourceMark rm;
2464-
// Create bytecode stream.
2465-
RawBytecodeStream bcs(method());
2466-
u4 code_length = method()->code_size();
2467-
bcs.set_start(start_bc_offset);
2468-
u4 target;
2469-
// Create stack for storing bytecode start offsets for if* and *switch.
2470-
GrowableArray<u4>* bci_stack = new GrowableArray<u4>(30);
2471-
// Create stack for handlers for try blocks containing this handler.
2472-
GrowableArray<u4>* handler_stack = new GrowableArray<u4>(30);
2473-
// Create list of handlers that have been pushed onto the handler_stack
2474-
// so that handlers embedded inside of their own TRY blocks only get
2475-
// scanned once.
2476-
GrowableArray<u4>* handler_list = new GrowableArray<u4>(30);
2477-
// Create list of visited branch opcodes (goto* and if*).
2478-
GrowableArray<u4>* visited_branches = new GrowableArray<u4>(30);
2479-
ExceptionTable exhandlers(_method());
2480-
2481-
while (true) {
2482-
if (bcs.is_last_bytecode()) {
2483-
// if no more starting offsets to parse or if at the end of the
2484-
// method then return false.
2485-
if ((bci_stack->is_empty()) || ((u4)bcs.end_bci() == code_length))
2486-
return false;
2487-
// Pop a bytecode starting offset and scan from there.
2488-
bcs.set_start(bci_stack->pop());
2489-
}
2490-
Bytecodes::Code opcode = bcs.raw_next();
2491-
u4 bci = bcs.bci();
2492-
2493-
// If the bytecode is in a TRY block, push its handlers so they
2494-
// will get parsed.
2495-
push_handlers(&exhandlers, handler_list, handler_stack, bci);
2496-
2497-
switch (opcode) {
2498-
case Bytecodes::_if_icmpeq:
2499-
case Bytecodes::_if_icmpne:
2500-
case Bytecodes::_if_icmplt:
2501-
case Bytecodes::_if_icmpge:
2502-
case Bytecodes::_if_icmpgt:
2503-
case Bytecodes::_if_icmple:
2504-
case Bytecodes::_ifeq:
2505-
case Bytecodes::_ifne:
2506-
case Bytecodes::_iflt:
2507-
case Bytecodes::_ifge:
2508-
case Bytecodes::_ifgt:
2509-
case Bytecodes::_ifle:
2510-
case Bytecodes::_if_acmpeq:
2511-
case Bytecodes::_if_acmpne:
2512-
case Bytecodes::_ifnull:
2513-
case Bytecodes::_ifnonnull:
2514-
target = bcs.dest();
2515-
if (visited_branches->contains(bci)) {
2516-
if (bci_stack->is_empty()) {
2517-
if (handler_stack->is_empty()) {
2518-
return true;
2519-
} else {
2520-
// Parse the catch handlers for try blocks containing athrow.
2521-
bcs.set_start(handler_stack->pop());
2522-
}
2523-
} else {
2524-
// Pop a bytecode starting offset and scan from there.
2525-
bcs.set_start(bci_stack->pop());
2526-
}
2527-
} else {
2528-
if (target > bci) { // forward branch
2529-
if (target >= code_length) return false;
2530-
// Push the branch target onto the stack.
2531-
bci_stack->push(target);
2532-
// then, scan bytecodes starting with next.
2533-
bcs.set_start(bcs.next_bci());
2534-
} else { // backward branch
2535-
// Push bytecode offset following backward branch onto the stack.
2536-
bci_stack->push(bcs.next_bci());
2537-
// Check bytecodes starting with branch target.
2538-
bcs.set_start(target);
2539-
}
2540-
// Record target so we don't branch here again.
2541-
visited_branches->append(bci);
2542-
}
2543-
break;
2544-
2545-
case Bytecodes::_goto:
2546-
case Bytecodes::_goto_w: {
2547-
int offset = (opcode == Bytecodes::_goto ? bcs.get_offset_s2() : bcs.get_offset_s4());
2548-
int min_offset = -1 * max_method_code_size;
2549-
// Check offset for overflow
2550-
if (offset < min_offset || offset > max_method_code_size) return false;
2551-
2552-
target = bci + offset;
2553-
if (visited_branches->contains(bci)) {
2554-
if (bci_stack->is_empty()) {
2555-
if (handler_stack->is_empty()) {
2556-
return true;
2557-
} else {
2558-
// Parse the catch handlers for try blocks containing athrow.
2559-
bcs.set_start(handler_stack->pop());
2560-
}
2561-
} else {
2562-
// Been here before, pop new starting offset from stack.
2563-
bcs.set_start(bci_stack->pop());
2564-
}
2565-
} else {
2566-
if (target >= code_length) return false;
2567-
// Continue scanning from the target onward.
2568-
bcs.set_start(target);
2569-
// Record target so we don't branch here again.
2570-
visited_branches->append(bci);
2571-
}
2572-
break;
2573-
}
2574-
2575-
// Check that all switch alternatives end in 'athrow' bytecodes. Since it
2576-
// is difficult to determine where each switch alternative ends, parse
2577-
// each switch alternative until either hit a 'return', 'athrow', or reach
2578-
// the end of the method's bytecodes. This is gross but should be okay
2579-
// because:
2580-
// 1. tableswitch and lookupswitch byte codes in handlers for ctor explicit
2581-
// constructor invocations should be rare.
2582-
// 2. if each switch alternative ends in an athrow then the parsing should be
2583-
// short. If there is no athrow then it is bogus code, anyway.
2584-
case Bytecodes::_lookupswitch:
2585-
case Bytecodes::_tableswitch:
2586-
{
2587-
address aligned_bcp = align_up(bcs.bcp() + 1, jintSize);
2588-
u4 default_offset = Bytes::get_Java_u4(aligned_bcp) + bci;
2589-
int keys, delta;
2590-
if (opcode == Bytecodes::_tableswitch) {
2591-
jint low = (jint)Bytes::get_Java_u4(aligned_bcp + jintSize);
2592-
jint high = (jint)Bytes::get_Java_u4(aligned_bcp + 2*jintSize);
2593-
// This is invalid, but let the regular bytecode verifier
2594-
// report this because the user will get a better error message.
2595-
if (low > high) return true;
2596-
keys = high - low + 1;
2597-
delta = 1;
2598-
} else {
2599-
keys = (int)Bytes::get_Java_u4(aligned_bcp + jintSize);
2600-
delta = 2;
2601-
}
2602-
// Invalid, let the regular bytecode verifier deal with it.
2603-
if (keys < 0) return true;
2604-
2605-
// Push the offset of the next bytecode onto the stack.
2606-
bci_stack->push(bcs.next_bci());
2607-
2608-
// Push the switch alternatives onto the stack.
2609-
for (int i = 0; i < keys; i++) {
2610-
int min_offset = -1 * max_method_code_size;
2611-
int offset = (jint)Bytes::get_Java_u4(aligned_bcp+(3+i*delta)*jintSize);
2612-
if (offset < min_offset || offset > max_method_code_size) return false;
2613-
u4 target = bci + offset;
2614-
if (target > code_length) return false;
2615-
bci_stack->push(target);
2616-
}
2617-
2618-
// Start bytecode parsing for the switch at the default alternative.
2619-
if (default_offset > code_length) return false;
2620-
bcs.set_start(default_offset);
2621-
break;
2622-
}
2623-
2624-
case Bytecodes::_return:
2625-
return false;
2626-
2627-
case Bytecodes::_athrow:
2628-
{
2629-
if (bci_stack->is_empty()) {
2630-
if (handler_stack->is_empty()) {
2631-
return true;
2632-
} else {
2633-
// Parse the catch handlers for try blocks containing athrow.
2634-
bcs.set_start(handler_stack->pop());
2635-
}
2636-
} else {
2637-
// Pop a bytecode offset and starting scanning from there.
2638-
bcs.set_start(bci_stack->pop());
2639-
}
2640-
}
2641-
break;
2642-
2643-
default:
2644-
;
2645-
} // end switch
2646-
} // end while loop
2647-
2648-
return false;
2649-
}
2650-
26512441
void ClassVerifier::verify_invoke_init(
26522442
RawBytecodeStream* bcs, u2 ref_class_index, VerificationType ref_class_type,
26532443
StackMapFrame* current_frame, u4 code_length, bool in_try_block,
@@ -2672,25 +2462,6 @@ void ClassVerifier::verify_invoke_init(
26722462
// sure that all catch clause paths end in a throw. Otherwise, this can
26732463
// result in returning an incomplete object.
26742464
if (in_try_block) {
2675-
ExceptionTable exhandlers(_method());
2676-
int exlength = exhandlers.length();
2677-
for(int i = 0; i < exlength; i++) {
2678-
u2 start_pc = exhandlers.start_pc(i);
2679-
u2 end_pc = exhandlers.end_pc(i);
2680-
2681-
if (bci >= start_pc && bci < end_pc) {
2682-
if (!ends_in_athrow(exhandlers.handler_pc(i))) {
2683-
verify_error(ErrorContext::bad_code(bci),
2684-
"Bad <init> method call from after the start of a try block");
2685-
return;
2686-
} else if (log_is_enabled(Debug, verification)) {
2687-
ResourceMark rm(THREAD);
2688-
log_debug(verification)("Survived call to ends_in_athrow(): %s",
2689-
current_class()->name()->as_C_string());
2690-
}
2691-
}
2692-
}
2693-
26942465
// Check the exception handler target stackmaps with the locals from the
26952466
// incoming stackmap (before initialize_object() changes them to outgoing
26962467
// state).

src/hotspot/share/classfile/verifier.hpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 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
@@ -335,17 +335,6 @@ class ClassVerifier : public StackObj {
335335
bool* this_uninit, const constantPoolHandle& cp, StackMapTable* stackmap_table,
336336
TRAPS);
337337

338-
// Used by ends_in_athrow() to push all handlers that contain bci onto the
339-
// handler_stack, if the handler has not already been pushed on the stack.
340-
void push_handlers(ExceptionTable* exhandlers,
341-
GrowableArray<u4>* handler_list,
342-
GrowableArray<u4>* handler_stack,
343-
u4 bci);
344-
345-
// Returns true if all paths starting with start_bc_offset end in athrow
346-
// bytecode or loop.
347-
bool ends_in_athrow(u4 start_bc_offset);
348-
349338
void verify_invoke_instructions(
350339
RawBytecodeStream* bcs, u4 code_length, StackMapFrame* current_frame,
351340
bool in_try_block, bool* this_uninit, VerificationType return_type,

0 commit comments

Comments
 (0)