Skip to content

Commit

Permalink
Merge branch 'openjdk:master' into serialgc
Browse files Browse the repository at this point in the history
  • Loading branch information
LizBing authored Dec 1, 2023
2 parents fc6ce2d + 3087e14 commit 4a9c545
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 104 deletions.
45 changes: 33 additions & 12 deletions src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2600,6 +2600,13 @@ void LIR_Assembler::emit_compare_and_swap(LIR_OpCompareAndSwap* op) {
Unimplemented();
}

// There might be a volatile load before this Unsafe CAS.
if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ sync();
} else {
__ lwsync();
}

if (is_64bit) {
__ cmpxchgd(BOOL_RESULT, /*current_value=*/R0, cmp_value, new_value, addr,
MacroAssembler::MemBarNone,
Expand Down Expand Up @@ -2961,9 +2968,24 @@ void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr
assert(addr->disp() == 0 && addr->index()->is_illegal(), "use leal!");
const Register Rptr = addr->base()->as_pointer_register(),
Rtmp = tmp->as_register();
Register Rco = noreg;
if (UseCompressedOops && data->is_oop()) {
Rco = __ encode_heap_oop(Rtmp, data->as_register());
Register Robj = noreg;
if (data->is_oop()) {
if (UseCompressedOops) {
Robj = __ encode_heap_oop(Rtmp, data->as_register());
} else {
Robj = data->as_register();
if (Robj == dest->as_register()) { // May happen with ZGC.
__ mr(Rtmp, Robj);
Robj = Rtmp;
}
}
}

// There might be a volatile load before this Unsafe OP.
if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ sync();
} else {
__ lwsync();
}

Label Lretry;
Expand All @@ -2983,18 +3005,11 @@ void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr
} else if (data->is_oop()) {
assert(code == lir_xchg, "xadd for oops");
const Register Rold = dest->as_register();
assert_different_registers(Rptr, Rold, Robj);
if (UseCompressedOops) {
assert_different_registers(Rptr, Rold, Rco);
__ lwarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
__ stwcx_(Rco, Rptr);
__ stwcx_(Robj, Rptr);
} else {
Register Robj = data->as_register();
assert_different_registers(Rptr, Rold, Rtmp);
assert_different_registers(Rptr, Robj, Rtmp);
if (Robj == Rold) { // May happen with ZGC.
__ mr(Rtmp, Robj);
Robj = Rtmp;
}
__ ldarx(Rold, Rptr, MacroAssembler::cmpxchgx_hint_atomic_update());
__ stdcx_(Robj, Rptr);
}
Expand Down Expand Up @@ -3022,6 +3037,12 @@ void LIR_Assembler::atomic_op(LIR_Code code, LIR_Opr src, LIR_Opr data, LIR_Opr
if (UseCompressedOops && data->is_oop()) {
__ decode_heap_oop(dest->as_register());
}

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ isync();
} else {
__ sync();
}
}


Expand Down
35 changes: 0 additions & 35 deletions src/hotspot/cpu/ppc/c1_LIRGenerator_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,6 @@ LIR_Opr LIRGenerator::atomic_cmpxchg(BasicType type, LIR_Opr addr, LIRItem& cmp_
cmp_value.load_item();
new_value.load_item();

// Volatile load may be followed by Unsafe CAS.
if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar();
} else {
__ membar_release();
}

if (is_reference_type(type)) {
if (UseCompressedOops) {
t1 = new_register(T_OBJECT);
Expand All @@ -670,21 +663,7 @@ LIR_Opr LIRGenerator::atomic_xchg(BasicType type, LIR_Opr addr, LIRItem& value)
LIR_Opr tmp = FrameMap::R0_opr;

value.load_item();

// Volatile load may be followed by Unsafe CAS.
if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar();
} else {
__ membar_release();
}

__ xchg(addr, value.result(), result, tmp);

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar_acquire();
} else {
__ membar();
}
return result;
}

Expand All @@ -694,21 +673,7 @@ LIR_Opr LIRGenerator::atomic_add(BasicType type, LIR_Opr addr, LIRItem& value) {
LIR_Opr tmp = FrameMap::R0_opr;

value.load_item();

// Volatile load may be followed by Unsafe CAS.
if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar(); // To be safe. Unsafe semantics are unclear.
} else {
__ membar_release();
}

__ xadd(addr, value.result(), result, tmp);

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar_acquire();
} else {
__ membar();
}
return result;
}

Expand Down
45 changes: 15 additions & 30 deletions src/hotspot/cpu/ppc/gc/shenandoah/c1/shenandoahBarrierSetC1_ppc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
* Copyright (c) 2012, 2021 SAP SE. All rights reserved.
* Copyright (c) 2018, 2023, Red Hat, Inc. All rights reserved.
* Copyright (c) 2012, 2023 SAP SE. 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 @@ -53,8 +53,13 @@ void LIR_OpShenandoahCompareAndSwap::emit_code(LIR_Assembler *masm) {
__ encode_heap_oop(new_val, new_val);
}

// Due to the memory barriers emitted in ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved,
// there is no need to specify stronger memory semantics.
// There might be a volatile load before this Unsafe CAS.
if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ sync();
} else {
__ lwsync();
}

ShenandoahBarrierSet::assembler()->cmpxchg_oop(masm->masm(), addr, cmp_val, new_val, tmp1, tmp2,
false, result);

Expand All @@ -63,6 +68,12 @@ void LIR_OpShenandoahCompareAndSwap::emit_code(LIR_Assembler *masm) {
__ decode_heap_oop(new_val);
}

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ isync();
} else {
__ sync();
}

__ block_comment("} LIR_OpShenandoahCompareAndSwap (shenandaohgc)");
}

Expand All @@ -80,14 +91,6 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess &access, LI
if (access.is_oop()) {
LIRGenerator* gen = access.gen();

if (ShenandoahCASBarrier) {
if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar();
} else {
__ membar_release();
}
}

if (ShenandoahSATBBarrier) {
pre_barrier(gen, access.access_emit_info(), access.decorators(), access.resolved_addr(),
LIR_OprFact::illegalOpr);
Expand All @@ -104,12 +107,6 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess &access, LI

__ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar_acquire();
} else {
__ membar();
}

return result;
}
}
Expand All @@ -125,12 +122,6 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess &access, LIRIt
value.load_item();
LIR_Opr value_opr = value.result();

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar();
} else {
__ membar_release();
}

if (access.is_oop()) {
value_opr = iu_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
}
Expand All @@ -152,11 +143,5 @@ LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess &access, LIRIt
}
}

if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
__ membar_acquire();
} else {
__ membar();
}

return result;
}
5 changes: 3 additions & 2 deletions src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,12 @@ void ZBarrierSetAssembler::store_barrier_medium(MacroAssembler* masm,
}
__ ld(R0, in_bytes(ZThreadLocalData::store_good_mask_offset()), R16_thread);
__ cmpxchgd(CCR0, tmp, (intptr_t)0, R0, ref_base,
MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update());
MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(),
noreg, need_restore ? nullptr : &slow_path);
if (need_restore) {
__ subf(ref_base, ind_or_offs, ref_base);
__ bne(CCR0, slow_path);
}
__ bne(CCR0, slow_path);
} else {
// A non-atomic relocatable object won't get to the medium fast path due to a
// raw null in the young generation. We only get here because the field is bad.
Expand Down
10 changes: 5 additions & 5 deletions src/java.base/share/classes/java/lang/Class.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,21 @@
* a class or interface is hidden has no bearing on the characteristics
* exposed by the methods of class {@code Class}.
*
* <h2><a id=implicitClasses>Implicit Classes</a></h2>
* <h2><a id=implicitClasses>Implicitly Declared Classes</a></h2>
*
* Conventionally, a Java compiler, starting from a source file for an
* implicit class, say {@code HelloWorld.java}, creates a
* implicitly declared class, say {@code HelloWorld.java}, creates a
* similarly-named {@code class} file, {@code HelloWorld.class}, where
* the class stored in that {@code class} file is named {@code
* "HelloWorld"}, matching the base names of the source and {@code
* class} files.
*
* For the {@code Class} object of an implicit class {@code
* For the {@code Class} object of an implicitly declared class {@code
* HelloWorld}, the methods to get the {@linkplain #getName name} and
* {@linkplain #getTypeName type name} return results
* equal to {@code "HelloWorld"}. The {@linkplain #getSimpleName
* simple name} of such an implicit class is {@code "HelloWorld"} and the
* {@linkplain #getCanonicalName canonical name} is {@code "HelloWorld"}.
* simple name} of such an implicitly declared class is {@code "HelloWorld"} and
* the {@linkplain #getCanonicalName canonical name} is {@code "HelloWorld"}.
*
* @param <T> the type of the class modeled by this {@code Class}
* object. For example, the type of {@code String.class} is {@code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public enum Feature {
STRING_TEMPLATES,
@JEP(number=445, title="Unnamed Classes and Instance Main Methods", status="Deprecated")
UNNAMED_CLASSES,
@JEP(number=463, title="Implicit Classes and Instance Main Methods", status="Preview")
@JEP(number=463, title="Implicitly Declared Classes and Instance Main Methods", status="Preview")
IMPLICIT_CLASSES,
@JEP(number=446, title="Scoped Values", status="Preview")
SCOPED_VALUES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public interface Filer {
* classes, the name argument is used to provide the leading component of the
* name used for the output file. For example {@code filer.createSourceFile("Foo")}
* to create an implicitly declared class hosted in {@code Foo.java}. All
* implicit classes must be in an unnamed package.
* implicitly declared classes must be in an unnamed package.
*
* @apiNote To use a particular {@linkplain
* java.nio.charset.Charset charset} to encode the contents of the
Expand Down Expand Up @@ -266,7 +266,7 @@ JavaFileObject createSourceFile(CharSequence name,
* classes, the name argument is used to provide the leading component of the
* name used for the output file. For example {@code filer.createSourceFile("Foo")}
* to create an implicitly declared class hosted in {@code Foo.java}. All
* implicit classes must be in an unnamed package.
* implicitly declared classes must be in an unnamed package.
*
* @apiNote To avoid subsequent errors, the contents of the class
* file should be compatible with the {@linkplain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static EnumSet<Flag> asFlagSet(long flags) {
*/
public static final int HASINIT = 1<<18;

/** Class is a implicit top level class.
/** Class is an implicitly declared top level class.
*/
public static final int IMPLICIT_CLASS = 1<<19;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ public void setRecordComponents(List<RecordComponent> recordComponents) {
@DefinedBy(Api.LANGUAGE_MODEL)
public NestingKind getNestingKind() {
apiComplete();
if (owner.kind == PCK) // Handles implicit classes as well
if (owner.kind == PCK) // Handles implicitly declared classes as well
return NestingKind.TOP_LEVEL;
else if (name.isEmpty())
return NestingKind.ANONYMOUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4186,11 +4186,11 @@ public void visitBindingPattern(JCBindingPattern tree) {
if (chk.checkUnique(tree.var.pos(), v, env.info.scope)) {
chk.checkTransparentVar(tree.var.pos(), v, env.info.scope);
}
if (tree.var.vartype != null) {
annotate.annotateLater(tree.var.mods.annotations, env, v, tree.pos());
annotate.annotateLater(tree.var.mods.annotations, env, v, tree.pos());
if (!tree.var.isImplicitlyTyped()) {
annotate.queueScanTreeAndTypeAnnotate(tree.var.vartype, env, v, tree.var.pos());
annotate.flush();
}
annotate.flush();
chk.validate(tree.var.vartype, env, true);
result = tree.type;
if (v.isUnnamedVariable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3982,11 +3982,11 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
defs.appendList(semiList.toList());
boolean isTopLevelMethodOrField = false;

// Do to a significant number of existing negative tests
// Due to a significant number of existing negative tests
// this code speculatively tests to see if a top level method
// or field can parse. If the method or field can parse then
// it is parsed. Otherwise, parsing continues as though
// implicit classes did not exist and error reporting
// implicitly declared classes did not exist and error reporting
// is the same as in the past.
if (Feature.IMPLICIT_CLASSES.allowedInSource(source) && !isDeclaration()) {
final JCModifiers finalMods = mods;
Expand Down Expand Up @@ -4014,7 +4014,7 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
firstTypeDecl = false;
}
}
List<JCTree> topLevelDefs = isImplicitClass ? constructImplictClass(defs.toList()) : defs.toList();
List<JCTree> topLevelDefs = isImplicitClass ? constructImplicitClass(defs.toList()) : defs.toList();
JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(topLevelDefs);
if (!consumedToplevelDoc)
attach(toplevel, firstToken.docComment());
Expand All @@ -4029,8 +4029,8 @@ public JCTree.JCCompilationUnit parseCompilationUnit() {
return toplevel;
}

// Restructure top level to be an implicit class.
private List<JCTree> constructImplictClass(List<JCTree> origDefs) {
// Restructure top level to be an implicitly declared class.
private List<JCTree> constructImplicitClass(List<JCTree> origDefs) {
ListBuffer<JCTree> topDefs = new ListBuffer<>();
ListBuffer<JCTree> defs = new ListBuffer<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ compiler.err.bad.file.name=\
bad file name: {0}

compiler.err.implicit.class.should.not.have.package.declaration=\
implicit class should not have package declaration
implicitly declared class should not have package declaration

compiler.err.implicit.class.does.not.have.main.method=\
implicit class does not have main method in the form of void main() or void main(String[] args)
implicitly declared class does not have main method in the form of void main() or void main(String[] args)

# 0: name, 1: name
compiler.err.same.binary.name=\
Expand Down Expand Up @@ -3219,7 +3219,7 @@ compiler.misc.feature.unconditional.patterns.in.instanceof=\
unconditional patterns in instanceof

compiler.misc.feature.implicit.classes=\
implicit classes
implicitly declared classes

compiler.misc.feature.super.init=\
statements before super()
Expand Down
Loading

0 comments on commit 4a9c545

Please sign in to comment.