This commit is contained in:
Jesper Wilhelmsson 2021-07-01 01:01:34 +00:00
commit 9def3b068e
29 changed files with 370 additions and 116 deletions

View file

@ -2413,6 +2413,11 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType
return false; return false;
} }
break; break;
case Op_VectorMaskCmp:
if (vlen < 2 || bit_size < 64) {
return false;
}
break;
default: default:
break; break;
} }

View file

@ -3768,9 +3768,8 @@ void TemplateTable::_new() {
// Get instance_size in InstanceKlass (scaled to a count of bytes). // Get instance_size in InstanceKlass (scaled to a count of bytes).
Register Rsize = offset; Register Rsize = offset;
const int mask = 1 << Klass::_lh_instance_slow_path_bit;
__ z_llgf(Rsize, Address(iklass, Klass::layout_helper_offset())); __ z_llgf(Rsize, Address(iklass, Klass::layout_helper_offset()));
__ z_tmll(Rsize, mask); __ z_tmll(Rsize, Klass::_lh_instance_slow_path_bit);
__ z_btrue(slow_case); __ z_btrue(slow_case);
// Allocate the instance // Allocate the instance

View file

@ -1427,7 +1427,7 @@ void C2_MacroAssembler::evscatter(BasicType typ, Register base, XMMRegister idx,
} }
} }
void C2_MacroAssembler::load_vector_mask(XMMRegister dst, XMMRegister src, int vlen_in_bytes, BasicType elem_bt) { void C2_MacroAssembler::load_vector_mask(XMMRegister dst, XMMRegister src, int vlen_in_bytes, BasicType elem_bt, bool is_legacy) {
if (vlen_in_bytes <= 16) { if (vlen_in_bytes <= 16) {
pxor (dst, dst); pxor (dst, dst);
psubb(dst, src); psubb(dst, src);
@ -1442,10 +1442,12 @@ void C2_MacroAssembler::load_vector_mask(XMMRegister dst, XMMRegister src, int v
default: assert(false, "%s", type2name(elem_bt)); default: assert(false, "%s", type2name(elem_bt));
} }
} else { } else {
assert(!is_legacy || !is_subword_type(elem_bt) || vlen_in_bytes < 64, "");
int vlen_enc = vector_length_encoding(vlen_in_bytes); int vlen_enc = vector_length_encoding(vlen_in_bytes);
vpxor (dst, dst, dst, vlen_enc); vpxor (dst, dst, dst, vlen_enc);
vpsubb(dst, dst, src, vlen_enc); vpsubb(dst, dst, src, is_legacy ? AVX_256bit : vlen_enc);
switch (elem_bt) { switch (elem_bt) {
case T_BYTE: /* nothing to do */ break; case T_BYTE: /* nothing to do */ break;
case T_SHORT: vpmovsxbw(dst, dst, vlen_enc); break; case T_SHORT: vpmovsxbw(dst, dst, vlen_enc); break;
@ -1461,7 +1463,11 @@ void C2_MacroAssembler::load_vector_mask(XMMRegister dst, XMMRegister src, int v
void C2_MacroAssembler::load_iota_indices(XMMRegister dst, Register scratch, int vlen_in_bytes) { void C2_MacroAssembler::load_iota_indices(XMMRegister dst, Register scratch, int vlen_in_bytes) {
ExternalAddress addr(StubRoutines::x86::vector_iota_indices()); ExternalAddress addr(StubRoutines::x86::vector_iota_indices());
if (vlen_in_bytes <= 16) { if (vlen_in_bytes == 4) {
movdl(dst, addr);
} else if (vlen_in_bytes == 8) {
movq(dst, addr);
} else if (vlen_in_bytes == 16) {
movdqu(dst, addr, scratch); movdqu(dst, addr, scratch);
} else if (vlen_in_bytes == 32) { } else if (vlen_in_bytes == 32) {
vmovdqu(dst, addr, scratch); vmovdqu(dst, addr, scratch);
@ -1470,6 +1476,7 @@ void C2_MacroAssembler::load_iota_indices(XMMRegister dst, Register scratch, int
evmovdqub(dst, k0, addr, false /*merge*/, Assembler::AVX_512bit, scratch); evmovdqub(dst, k0, addr, false /*merge*/, Assembler::AVX_512bit, scratch);
} }
} }
// Reductions for vectors of bytes, shorts, ints, longs, floats, and doubles. // Reductions for vectors of bytes, shorts, ints, longs, floats, and doubles.
void C2_MacroAssembler::reduce_operation_128(BasicType typ, int opcode, XMMRegister dst, XMMRegister src) { void C2_MacroAssembler::reduce_operation_128(BasicType typ, int opcode, XMMRegister dst, XMMRegister src) {

View file

@ -141,7 +141,7 @@ public:
void evpcmp(BasicType typ, KRegister kdmask, KRegister ksmask, XMMRegister src1, XMMRegister src2, int comparison, int vector_len); void evpcmp(BasicType typ, KRegister kdmask, KRegister ksmask, XMMRegister src1, XMMRegister src2, int comparison, int vector_len);
void evpblend(BasicType typ, XMMRegister dst, KRegister kmask, XMMRegister src1, XMMRegister src2, bool merge, int vector_len); void evpblend(BasicType typ, XMMRegister dst, KRegister kmask, XMMRegister src1, XMMRegister src2, bool merge, int vector_len);
void load_vector_mask(XMMRegister dst, XMMRegister src, int vlen_in_bytes, BasicType elem_bt); void load_vector_mask(XMMRegister dst, XMMRegister src, int vlen_in_bytes, BasicType elem_bt, bool is_legacy);
void load_iota_indices(XMMRegister dst, Register scratch, int vlen_in_bytes); void load_iota_indices(XMMRegister dst, Register scratch, int vlen_in_bytes);
// vector compare // vector compare

View file

@ -1835,6 +1835,11 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType
return false; return false;
} }
break; break;
case Op_VectorMaskCmp:
if (vlen < 2 || size_in_bits < 32) {
return false;
}
break;
} }
return true; // Per default match rules are supported. return true; // Per default match rules are supported.
} }
@ -6906,7 +6911,7 @@ instruct evcmpFD(vec dst, vec src1, vec src2, immI8 cond, rRegP scratch, kReg kt
instruct vcmp(legVec dst, legVec src1, legVec src2, immI8 cond, rRegP scratch) %{ instruct vcmp(legVec dst, legVec src1, legVec src2, immI8 cond, rRegP scratch) %{
predicate((UseAVX <= 2 || !VM_Version::supports_avx512vl()) && predicate((UseAVX <= 2 || !VM_Version::supports_avx512vl()) &&
!is_unsigned_booltest_pred(n->in(2)->get_int()) && !is_unsigned_booltest_pred(n->in(2)->get_int()) &&
vector_length_in_bytes(n->in(1)->in(1)) >= 8 && // src1 vector_length_in_bytes(n->in(1)->in(1)) >= 4 && // src1
vector_length_in_bytes(n->in(1)->in(1)) <= 32 && // src1 vector_length_in_bytes(n->in(1)->in(1)) <= 32 && // src1
is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1 is_integral_type(vector_element_basic_type(n->in(1)->in(1)))); // src1
match(Set dst (VectorMaskCmp (Binary src1 src2) cond)); match(Set dst (VectorMaskCmp (Binary src1 src2) cond));
@ -7442,7 +7447,8 @@ instruct cmpvptest_anytrue_evex(rFlagsReg cr, legVec src1, legVec src2, immI_0 z
//------------------------------------- LoadMask -------------------------------------------- //------------------------------------- LoadMask --------------------------------------------
instruct loadMask(vec dst, vec src) %{ instruct loadMask(legVec dst, legVec src) %{
predicate(!VM_Version::supports_avx512vlbw());
match(Set dst (VectorLoadMask src)); match(Set dst (VectorLoadMask src));
effect(TEMP dst); effect(TEMP dst);
format %{ "vector_loadmask_byte $dst,$src\n\t" %} format %{ "vector_loadmask_byte $dst,$src\n\t" %}
@ -7450,7 +7456,21 @@ instruct loadMask(vec dst, vec src) %{
int vlen_in_bytes = vector_length_in_bytes(this); int vlen_in_bytes = vector_length_in_bytes(this);
BasicType elem_bt = vector_element_basic_type(this); BasicType elem_bt = vector_element_basic_type(this);
__ load_vector_mask($dst$$XMMRegister, $src$$XMMRegister, vlen_in_bytes, elem_bt); __ load_vector_mask($dst$$XMMRegister, $src$$XMMRegister, vlen_in_bytes, elem_bt, true);
%}
ins_pipe( pipe_slow );
%}
instruct loadMask_evex(vec dst, vec src) %{
predicate(VM_Version::supports_avx512vlbw());
match(Set dst (VectorLoadMask src));
effect(TEMP dst);
format %{ "vector_loadmask_byte $dst,$src\n\t" %}
ins_encode %{
int vlen_in_bytes = vector_length_in_bytes(this);
BasicType elem_bt = vector_element_basic_type(this);
__ load_vector_mask($dst$$XMMRegister, $src$$XMMRegister, vlen_in_bytes, elem_bt, false);
%} %}
ins_pipe( pipe_slow ); ins_pipe( pipe_slow );
%} %}

View file

@ -87,7 +87,7 @@ void ParallelArguments::initialize() {
} }
if (FLAG_IS_DEFAULT(ParallelRefProcEnabled) && ParallelGCThreads > 1) { if (FLAG_IS_DEFAULT(ParallelRefProcEnabled) && ParallelGCThreads > 1) {
//FLAG_SET_DEFAULT(ParallelRefProcEnabled, true); FLAG_SET_DEFAULT(ParallelRefProcEnabled, true);
} }
} }

View file

@ -71,12 +71,7 @@ class PromotionFailedInfo : public CopyFailedInfo {
void register_copy_failure(size_t size) { void register_copy_failure(size_t size) {
CopyFailedInfo::register_copy_failure(size); CopyFailedInfo::register_copy_failure(size);
if (_thread_trace_id == 0) {
_thread_trace_id = JFR_THREAD_ID(Thread::current()); _thread_trace_id = JFR_THREAD_ID(Thread::current());
} else {
assert(JFR_THREAD_ID(Thread::current()) == _thread_trace_id,
"The PromotionFailedInfo should be thread local.");
}
} }
void reset() { void reset() {

View file

@ -411,9 +411,6 @@ bool LibraryCallKit::inline_vector_shuffle_iota() {
int num_elem = vlen->get_con(); int num_elem = vlen->get_con();
BasicType elem_bt = T_BYTE; BasicType elem_bt = T_BYTE;
if (num_elem < 4)
return false;
if (!arch_supports_vector(VectorNode::replicate_opcode(elem_bt), num_elem, elem_bt, VecMaskNotUsed)) { if (!arch_supports_vector(VectorNode::replicate_opcode(elem_bt), num_elem, elem_bt, VecMaskNotUsed)) {
return false; return false;
} }

View file

@ -928,6 +928,7 @@ void ThreadSafepointState::handle_polling_page_exception() {
if( nm->is_at_poll_return(real_return_addr) ) { if( nm->is_at_poll_return(real_return_addr) ) {
// See if return type is an oop. // See if return type is an oop.
bool return_oop = nm->method()->is_returning_oop(); bool return_oop = nm->method()->is_returning_oop();
HandleMark hm(self);
Handle return_value; Handle return_value;
if (return_oop) { if (return_oop) {
// The oop result has been saved on the stack together with all // The oop result has been saved on the stack together with all

View file

@ -43,6 +43,8 @@ import jdk.internal.vm.annotation.IntrinsicCandidate;
* <p> In order to ensure that a reclaimable object remains so, the referent of * <p> In order to ensure that a reclaimable object remains so, the referent of
* a phantom reference may not be retrieved: The {@code get} method of a * a phantom reference may not be retrieved: The {@code get} method of a
* phantom reference always returns {@code null}. * phantom reference always returns {@code null}.
* The {@link #refersTo(Object) refersTo} method can be used to test
* whether some object is the referent of a phantom reference.
* *
* @author Mark Reinhold * @author Mark Reinhold
* @since 1.2 * @since 1.2
@ -75,9 +77,7 @@ public class PhantomReference<T> extends Reference<T> {
* is registered with the given queue. * is registered with the given queue.
* *
* <p> It is possible to create a phantom reference with a {@code null} * <p> It is possible to create a phantom reference with a {@code null}
* queue, but such a reference is completely useless: Its {@code get} * queue. Such a reference will never be enqueued.
* method will always return {@code null} and, since it does not have a queue,
* it will never be enqueued.
* *
* @param referent the object the new phantom reference will refer to * @param referent the object the new phantom reference will refer to
* @param q the queue with which the reference is to be registered, * @param q the queue with which the reference is to be registered,

View file

@ -455,9 +455,11 @@ import sun.util.locale.provider.TimeZoneNameUtility;
* *
* <p>For the backward compatible behavior, the system property * <p>For the backward compatible behavior, the system property
* {@systemProperty java.locale.useOldISOCodes} reverts the behavior * {@systemProperty java.locale.useOldISOCodes} reverts the behavior
* back to prior to Java SE 17 one. If the system property is set * back to that of before Java SE 17. If the system property is set to
* to {@code true}, those three current language codes are mapped to their * {@code true}, those three current language codes are mapped to their
* backward compatible forms. * backward compatible forms. The property is only read at Java runtime
* startup and subsequent calls to {@code System.setProperty()} will
* have no effect.
* *
* <p>The APIs added in 1.7 map between the old and new language codes, * <p>The APIs added in 1.7 map between the old and new language codes,
* maintaining the mapped codes internal to Locale (so that * maintaining the mapped codes internal to Locale (so that

View file

@ -169,6 +169,8 @@ public class Attr extends JCTree.Visitor {
allowStaticInterfaceMethods = Feature.STATIC_INTERFACE_METHODS.allowedInSource(source); allowStaticInterfaceMethods = Feature.STATIC_INTERFACE_METHODS.allowedInSource(source);
allowReifiableTypesInInstanceof = Feature.REIFIABLE_TYPES_INSTANCEOF.allowedInSource(source); allowReifiableTypesInInstanceof = Feature.REIFIABLE_TYPES_INSTANCEOF.allowedInSource(source);
allowRecords = Feature.RECORDS.allowedInSource(source); allowRecords = Feature.RECORDS.allowedInSource(source);
allowPatternSwitch = (preview.isEnabled() || !preview.isPreview(Feature.PATTERN_SWITCH)) &&
Feature.PATTERN_SWITCH.allowedInSource(source);
sourceName = source.name; sourceName = source.name;
useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
@ -209,6 +211,10 @@ public class Attr extends JCTree.Visitor {
*/ */
private final boolean allowRecords; private final boolean allowRecords;
/** Are patterns in switch allowed
*/
private final boolean allowPatternSwitch;
/** /**
* Switch: warn about use of variable before declaration? * Switch: warn about use of variable before declaration?
* RFE: 6425594 * RFE: 6425594
@ -1724,14 +1730,22 @@ public class Attr extends JCTree.Visitor {
rs.basicLogResolveHelper = prevResolveHelper; rs.basicLogResolveHelper = prevResolveHelper;
} }
} else { } else {
Type pattype = attribExpr(expr, switchEnv, seltype); ResultInfo valTypInfo = new ResultInfo(KindSelector.VAL_TYP,
!seltype.hasTag(ERROR) ? seltype
: Type.noType);
Type pattype = attribTree(expr, switchEnv, valTypInfo);
if (!pattype.hasTag(ERROR)) { if (!pattype.hasTag(ERROR)) {
if (!stringSwitch && !types.isAssignable(seltype, syms.intType)) {
log.error(pat.pos(), Errors.ConstantLabelNotCompatible(pattype, seltype));
}
if (pattype.constValue() == null) { if (pattype.constValue() == null) {
Symbol s = TreeInfo.symbol(expr);
if (s != null && s.kind == TYP && allowPatternSwitch) {
log.error(expr.pos(),
Errors.PatternExpected);
} else {
log.error(expr.pos(), log.error(expr.pos(),
(stringSwitch ? Errors.StringConstReq : Errors.ConstExprReq)); (stringSwitch ? Errors.StringConstReq : Errors.ConstExprReq));
}
} else if (!stringSwitch && !types.isAssignable(seltype, syms.intType)) {
log.error(pat.pos(), Errors.ConstantLabelNotCompatible(pattype, seltype));
} else if (!labels.add(pattype.constValue())) { } else if (!labels.add(pattype.constValue())) {
log.error(c.pos(), Errors.DuplicateCaseLabel); log.error(c.pos(), Errors.DuplicateCaseLabel);
} else { } else {

View file

@ -1375,8 +1375,7 @@ public class Gen extends JCTree.Visitor {
if (switchEnv.info.cont != null) { if (switchEnv.info.cont != null) {
Assert.check(patternSwitch); Assert.check(patternSwitch);
code.resolve(switchEnv.info.cont); code.resolve(switchEnv.info.cont, switchStart);
code.resolve(code.branch(goto_), switchStart);
} }
// Resolve all breaks. // Resolve all breaks.

View file

@ -1189,6 +1189,9 @@ compiler.err.static.imp.only.classes.and.interfaces=\
compiler.err.string.const.req=\ compiler.err.string.const.req=\
constant string expression required constant string expression required
compiler.err.pattern.expected=\
type pattern expected
# 0: symbol, 1: fragment # 0: symbol, 1: fragment
compiler.err.cannot.generate.class=\ compiler.err.cannot.generate.class=\
error while generating class {0}\n\ error while generating class {0}\n\

View file

@ -350,14 +350,12 @@ ul.see-list-long li:not(:last-child):after {
/* /*
* Styles for tables. * Styles for tables.
*/ */
.summary-table { .summary-table, .details-table {
width:100%; width:100%;
border-spacing:0; border-spacing:0;
border-left:1px solid #EEE; border-left:1px solid #EEE;
border-right:1px solid #EEE; border-right:1px solid #EEE;
border-bottom:1px solid #EEE; border-bottom:1px solid #EEE;
}
.summary-table {
padding:0; padding:0;
} }
.caption { .caption {
@ -445,7 +443,7 @@ div.table-tabs > button.table-tab {
grid-template-columns: minmax(15%, max-content) minmax(15%, auto); grid-template-columns: minmax(15%, max-content) minmax(15%, auto);
} }
} }
.summary-table > div { .summary-table > div, .details-table > div {
text-align:left; text-align:left;
padding: 8px 3px 3px 7px; padding: 8px 3px 3px 7px;
} }

View file

@ -32,3 +32,5 @@ compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java 8268033 generic-x64
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all
vmTestbase/vm/mlvm/mixed/stress/regression/b6969574/INDIFY_Test.java 8265295 linux-x64,windows-x64 vmTestbase/vm/mlvm/mixed/stress/regression/b6969574/INDIFY_Test.java 8265295 linux-x64,windows-x64
vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t002/TestDescription.java 8245680 windows-x64

View file

@ -72,7 +72,9 @@ public class MultiCommand extends AbstractTestBase {
Executable exec = Utils.getRandomElement(METHODS).first; Executable exec = Utils.getRandomElement(METHODS).first;
MethodDescriptor md; MethodDescriptor md;
if (validOnly) {
// Command.quiet discards the method descriptor - can never fail on the method descriptor
if (validOnly || cmd == Command.QUIET) {
md = AbstractTestBase.getValidMethodDescriptor(exec); md = AbstractTestBase.getValidMethodDescriptor(exec);
} else { } else {
md = AbstractTestBase.METHOD_GEN.generateRandomDescriptor(exec); md = AbstractTestBase.METHOD_GEN.generateRandomDescriptor(exec);

View file

@ -0,0 +1,58 @@
/*
* Copyright (c) 2021, Huawei Technologies Co. Ltd. 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.
*
* 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.
*/
package compiler.vectorapi;
import jdk.incubator.vector.IntVector;
import jdk.incubator.vector.VectorSpecies;
import jdk.incubator.vector.VectorShuffle;
/*
* @test
* @bug 8265907
* @modules jdk.incubator.vector
* @run main/othervm compiler.vectorapi.TestVectorShuffleIota
*/
public class TestVectorShuffleIota {
static final VectorSpecies<Integer> SPECIESi = IntVector.SPECIES_128;
static final int INVOC_COUNT = 50000;
static int[] ai = {87, 65, 78, 71};
static void testShuffleI() {
IntVector iv = (IntVector) VectorShuffle.iota(SPECIESi, 0, 2, false).toVector();
iv.intoArray(ai, 0);
}
public static void main(String[] args) {
for (int i = 0; i < INVOC_COUNT; i++) {
testShuffleI();
}
for (int i = 0; i < ai.length; i++) {
System.out.print(ai[i] + ", ");
}
System.out.println();
}
}

View file

@ -51,7 +51,7 @@ public class TestParallelRefProc {
} }
if (GC.Parallel.isSupported()) { if (GC.Parallel.isSupported()) {
noneGCSupported = false; noneGCSupported = false;
testFlag(new String[] { "-XX:+UseParallelGC" }, false); testFlag(new String[] { "-XX:+UseParallelGC" }, true);
} }
if (GC.G1.isSupported()) { if (GC.G1.isSupported()) {
noneGCSupported = false; noneGCSupported = false;

View file

@ -24,38 +24,70 @@
/* /*
* @test * @test
* @modules java.base/jdk.internal.misc
* *
* @summary converted from VM Testbase vm/mlvm/anonloader/stress/oome/metaspace. * @summary converted from VM Testbase vm/mlvm/anonloader/stress/oome/metaspace.
* VM Testbase keywords: [feature_mlvm, nonconcurrent] * VM Testbase keywords: [feature_mlvm, nonconcurrent]
* *
* @library /test/lib * @library /vmTestbase
* /test/lib
* *
* @run driver vm.mlvm.anonloader.stress.oome.metaspace.Test * @comment build test class and indify classes
* @build vm.mlvm.anonloader.stress.oome.metaspace.Test
* @run driver vm.mlvm.share.IndifiedClassesBuilder
*
* @run main/othervm -XX:MaxRAMPercentage=25 -XX:-UseGCOverheadLimit -XX:MetaspaceSize=10m
* -XX:MaxMetaspaceSize=20m vm.mlvm.anonloader.stress.oome.metaspace.Test
*/ */
package vm.mlvm.anonloader.stress.oome.metaspace; package vm.mlvm.anonloader.stress.oome.metaspace;
import jdk.test.lib.process.OutputAnalyzer; import java.lang.invoke.MethodHandles;
import jdk.test.lib.process.ProcessTools; import java.lang.invoke.MethodHandles.Lookup;
import java.util.List;
import java.io.IOException;
public class Test { import vm.mlvm.anonloader.share.AnonkTestee01;
import vm.mlvm.share.MlvmOOMTest;
import vm.mlvm.share.MlvmTestExecutor;
import vm.mlvm.share.Env;
import vm.share.FileUtils;
public static void main(String[] args) throws Exception { /**
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( * This test loads classes using defineHiddenClass and stores them,
"-Xshare:off", "-XX:MaxMetaspaceSize=512k", "-version"); * expecting Metaspace OOME.
*
OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); */
public class Test extends MlvmOOMTest {
analyzer.shouldNotHaveExitValue(0); @Override
protected void checkOOME(OutOfMemoryError oome) {
if (!analyzer.getStdout().contains("OutOfMemoryError")) { String message = oome.getMessage();
throw new RuntimeException("TEST FAIL : no OOME"); if (!"Metaspace".equals(message) && !"Compressed class space".equals(message)) {
} throw new RuntimeException("TEST FAIL : wrong OOME", oome);
if (!analyzer.getStdout().contains("Metaspace") &&
!analyzer.getStdout().contains("Compressed class space")) {
throw new RuntimeException("TEST FAIL : wrong OOME");
} }
} }
@Override
protected void eatMemory(List<Object> list) {
byte[] classBytes = null;
try {
classBytes = FileUtils.readClass(AnonkTestee01.class.getName());
} catch (IOException e) {
Env.throwAsUncheckedException(e);
}
try {
while (true) {
Lookup lookup = MethodHandles.lookup();
Lookup ank_lookup = MethodHandles.privateLookupIn(AnonkTestee01.class, lookup);
Class<?> c = ank_lookup.defineHiddenClass(classBytes, true).lookupClass();
list.add(c.newInstance());
}
} catch (InstantiationException | IllegalAccessException e) {
Env.throwAsUncheckedException(e);
}
}
public static void main(String[] args) {
MlvmTestExecutor.launch(args);
}
} }

View file

@ -580,7 +580,7 @@ com/sun/management/OperatingSystemMXBean/GetSystemCpuLoad.java 8030957 aix-all
java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java 8247426 generic-all java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java 8247426 generic-all
sun/management/jdp/JdpDefaultsTest.java 8241865 macosx-all sun/management/jdp/JdpDefaultsTest.java 8241865 linux-aarch64,macosx-all
sun/management/jdp/JdpJmxRemoteDynamicPortTest.java 8241865 macosx-all sun/management/jdp/JdpJmxRemoteDynamicPortTest.java 8241865 macosx-all
sun/management/jdp/JdpSpecificAddressTest.java 8241865 macosx-all sun/management/jdp/JdpSpecificAddressTest.java 8241865 macosx-all

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -37,7 +37,6 @@
import java.io.File; import java.io.File;
import java.util.Map; import java.util.Map;
import jdk.test.lib.Platform; import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.OutputAnalyzer;
import java.io.IOException; import java.io.IOException;
@ -50,17 +49,15 @@ public class CallerAccessTest {
ProcessBuilder pb = new ProcessBuilder(launcher.toString()); ProcessBuilder pb = new ProcessBuilder(launcher.toString());
Map<String, String> env = pb.environment(); Map<String, String> env = pb.environment();
String libName = Platform.isWindows() ? "bin" : "lib"; String libDir = Platform.libDir().toString();
Path libPath = Paths.get(Utils.TEST_JDK).resolve(libName); String vmDir = Platform.jvmLibDir().toString();
String libDir = libPath.toAbsolutePath().toString();
String serverDir = libPath.resolve("server").toAbsolutePath().toString();
// set up shared library path // set up shared library path
String sharedLibraryPathEnvName = Platform.sharedLibraryPathVariableName(); String sharedLibraryPathEnvName = Platform.sharedLibraryPathVariableName();
env.compute(sharedLibraryPathEnvName, env.compute(sharedLibraryPathEnvName,
(k, v) -> (v == null) ? libDir : v + File.pathSeparator + libDir); (k, v) -> (v == null) ? libDir : v + File.pathSeparator + libDir);
env.compute(sharedLibraryPathEnvName, env.compute(sharedLibraryPathEnvName,
(k, v) -> (v == null) ? serverDir : v + File.pathSeparator + serverDir); (k, v) -> (v == null) ? vmDir : v + File.pathSeparator + vmDir);
System.out.println("Launching: " + launcher + " shared library path: " + System.out.println("Launching: " + launcher + " shared library path: " +
env.get(sharedLibraryPathEnvName)); env.get(sharedLibraryPathEnvName));

View file

@ -120,7 +120,7 @@ public class CheckStylesheetClasses {
"modifiers", "permits", "return-type"); "modifiers", "permits", "return-type");
// misc: these are defined in HtmlStyle, and used by the doclet // misc: these are defined in HtmlStyle, and used by the doclet
removeAll(htmlStyleNames, "col-plain", "details-table", "external-link", removeAll(htmlStyleNames, "col-plain", "external-link",
"hierarchy", "index", "package-uses", "packages", "permits-note", "hierarchy", "index", "package-uses", "packages", "permits-note",
"serialized-package-container", "source-container"); "serialized-package-container", "source-container");

View file

@ -140,7 +140,7 @@ public class TestStylesheet extends JavadocTester {
overflow: auto; overflow: auto;
}""", }""",
""" """
.summary-table > div { .summary-table > div, .details-table > div {
text-align:left; text-align:left;
padding: 8px 3px 3px 7px; padding: 8px 3px 3px 7px;
}""", }""",

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* 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.
*/
// key: compiler.err.pattern.expected
// key: compiler.note.preview.filename
// key: compiler.note.preview.recompile
// options: --enable-preview -source ${jdk.version}
class PatternSwitch {
private void doSwitch(Object o) {
switch (o) {
case String: break;
default: break;
}
}
}

View file

@ -0,0 +1,42 @@
SwitchErrors.java:35:31: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.pattern.switch)
SwitchErrors.java:34:18: compiler.err.constant.label.not.compatible: java.lang.String, java.lang.Object
SwitchErrors.java:40:18: compiler.err.constant.label.not.compatible: int, java.lang.Object
SwitchErrors.java:46:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
SwitchErrors.java:47:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.CharSequence)
SwitchErrors.java:52:18: compiler.err.preview.feature.disabled: (compiler.misc.feature.case.null)
SwitchErrors.java:53:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, int)
SwitchErrors.java:54:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.CharSequence)
SwitchErrors.java:60:20: compiler.err.total.pattern.and.default
SwitchErrors.java:66:13: compiler.err.pattern.dominated
SwitchErrors.java:72:18: compiler.err.total.pattern.and.default
SwitchErrors.java:78:18: compiler.err.duplicate.total.pattern
SwitchErrors.java:84:20: compiler.err.duplicate.default.label
SwitchErrors.java:90:20: compiler.err.duplicate.default.label
SwitchErrors.java:101:13: compiler.err.duplicate.case.label
SwitchErrors.java:106:13: compiler.err.duplicate.case.label
SwitchErrors.java:111:28: compiler.err.flows.through.to.pattern
SwitchErrors.java:117:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:124:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:131:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:136:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
SwitchErrors.java:142:18: compiler.err.instanceof.reifiable.not.safe: java.util.List, java.util.List<java.lang.Integer>
SwitchErrors.java:148:18: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, SwitchErrors, null)
SwitchErrors.java:155:18: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array)
SwitchErrors.java:172:27: compiler.err.flows.through.to.pattern
SwitchErrors.java:178:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:184:13: compiler.err.pattern.dominated
SwitchErrors.java:196:18: compiler.err.const.expr.req
SwitchErrors.java:202:76: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null)
SwitchErrors.java:208:71: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null)
SwitchErrors.java:33:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:39:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:45:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:51:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:99:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:105:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:110:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:115:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:121:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:128:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:188:9: compiler.err.not.exhaustive.statement
41 errors

View file

@ -26,6 +26,7 @@
* @bug 8262891 * @bug 8262891
* @summary Verify errors related to pattern switches. * @summary Verify errors related to pattern switches.
* @compile/fail/ref=SwitchErrors.out --enable-preview -source ${jdk.version} -XDrawDiagnostics -XDshould-stop.at=FLOW SwitchErrors.java * @compile/fail/ref=SwitchErrors.out --enable-preview -source ${jdk.version} -XDrawDiagnostics -XDshould-stop.at=FLOW SwitchErrors.java
* @compile/fail/ref=SwitchErrors-no-preview.out -XDrawDiagnostics -XDshould-stop.at=FLOW SwitchErrors.java
*/ */
public class SwitchErrors { public class SwitchErrors {
void incompatibleSelectorObjectString(Object o) { void incompatibleSelectorObjectString(Object o) {
@ -190,6 +191,12 @@ public class SwitchErrors {
} }
sealed class SealedNonAbstract permits A {} sealed class SealedNonAbstract permits A {}
final class A extends SealedNonAbstract {} final class A extends SealedNonAbstract {}
void errorRecoveryNoPattern1(Object o) {
switch (o) {
case String: break;
case Object obj: break;
}
}
Object guardWithMatchingStatement(Object o1, Object o2) { Object guardWithMatchingStatement(Object o1, Object o2) {
switch (o1) { switch (o1) {
case String s && s.isEmpty() || o2 instanceof Number n: return n; case String s && s.isEmpty() || o2 instanceof Number n: return n;

View file

@ -1,46 +1,47 @@
SwitchErrors.java:33:18: compiler.err.constant.label.not.compatible: java.lang.String, java.lang.Object SwitchErrors.java:34:18: compiler.err.constant.label.not.compatible: java.lang.String, java.lang.Object
SwitchErrors.java:39:18: compiler.err.constant.label.not.compatible: int, java.lang.Object SwitchErrors.java:40:18: compiler.err.constant.label.not.compatible: int, java.lang.Object
SwitchErrors.java:45:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer) SwitchErrors.java:46:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
SwitchErrors.java:46:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.CharSequence) SwitchErrors.java:47:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.CharSequence)
SwitchErrors.java:51:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, int) SwitchErrors.java:52:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: compiler.misc.type.null, int)
SwitchErrors.java:52:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, int) SwitchErrors.java:53:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, int)
SwitchErrors.java:53:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.CharSequence) SwitchErrors.java:54:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: int, java.lang.CharSequence)
SwitchErrors.java:59:20: compiler.err.total.pattern.and.default SwitchErrors.java:60:20: compiler.err.total.pattern.and.default
SwitchErrors.java:65:13: compiler.err.pattern.dominated SwitchErrors.java:66:13: compiler.err.pattern.dominated
SwitchErrors.java:65:24: compiler.err.total.pattern.and.default SwitchErrors.java:66:24: compiler.err.total.pattern.and.default
SwitchErrors.java:71:18: compiler.err.total.pattern.and.default SwitchErrors.java:72:18: compiler.err.total.pattern.and.default
SwitchErrors.java:77:18: compiler.err.duplicate.total.pattern SwitchErrors.java:78:18: compiler.err.duplicate.total.pattern
SwitchErrors.java:83:20: compiler.err.duplicate.default.label SwitchErrors.java:84:20: compiler.err.duplicate.default.label
SwitchErrors.java:89:20: compiler.err.duplicate.default.label SwitchErrors.java:90:20: compiler.err.duplicate.default.label
SwitchErrors.java:94:27: compiler.err.duplicate.default.label SwitchErrors.java:95:27: compiler.err.duplicate.default.label
SwitchErrors.java:100:13: compiler.err.duplicate.case.label SwitchErrors.java:101:13: compiler.err.duplicate.case.label
SwitchErrors.java:105:13: compiler.err.duplicate.case.label SwitchErrors.java:106:13: compiler.err.duplicate.case.label
SwitchErrors.java:110:28: compiler.err.flows.through.to.pattern SwitchErrors.java:111:28: compiler.err.flows.through.to.pattern
SwitchErrors.java:116:18: compiler.err.flows.through.to.pattern SwitchErrors.java:117:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:123:18: compiler.err.flows.through.to.pattern SwitchErrors.java:124:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:130:18: compiler.err.flows.through.to.pattern SwitchErrors.java:131:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:135:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer) SwitchErrors.java:136:18: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer)
SwitchErrors.java:141:18: compiler.err.instanceof.reifiable.not.safe: java.util.List, java.util.List<java.lang.Integer> SwitchErrors.java:142:18: compiler.err.instanceof.reifiable.not.safe: java.util.List, java.util.List<java.lang.Integer>
SwitchErrors.java:147:18: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, SwitchErrors, null) SwitchErrors.java:148:18: compiler.err.cant.resolve.location: kindname.class, Undefined, , , (compiler.misc.location: kindname.class, SwitchErrors, null)
SwitchErrors.java:154:18: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array) SwitchErrors.java:155:18: compiler.err.type.found.req: int, (compiler.misc.type.req.class.array)
SwitchErrors.java:160:28: compiler.err.flows.through.from.pattern SwitchErrors.java:161:28: compiler.err.flows.through.from.pattern
SwitchErrors.java:166:18: compiler.err.flows.through.from.pattern SwitchErrors.java:167:18: compiler.err.flows.through.from.pattern
SwitchErrors.java:171:27: compiler.err.flows.through.to.pattern SwitchErrors.java:172:27: compiler.err.flows.through.to.pattern
SwitchErrors.java:177:18: compiler.err.flows.through.to.pattern SwitchErrors.java:178:18: compiler.err.flows.through.to.pattern
SwitchErrors.java:183:13: compiler.err.pattern.dominated SwitchErrors.java:184:13: compiler.err.pattern.dominated
SwitchErrors.java:195:76: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null) SwitchErrors.java:196:18: compiler.err.pattern.expected
SwitchErrors.java:201:71: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null) SwitchErrors.java:202:76: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null)
SwitchErrors.java:32:9: compiler.err.not.exhaustive.statement SwitchErrors.java:208:71: compiler.err.cant.resolve.location: kindname.variable, n, , , (compiler.misc.location: kindname.class, SwitchErrors, null)
SwitchErrors.java:38:9: compiler.err.not.exhaustive.statement SwitchErrors.java:33:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:44:9: compiler.err.not.exhaustive.statement SwitchErrors.java:39:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:50:9: compiler.err.not.exhaustive.statement SwitchErrors.java:45:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:98:9: compiler.err.not.exhaustive.statement SwitchErrors.java:51:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:104:9: compiler.err.not.exhaustive.statement SwitchErrors.java:99:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:109:9: compiler.err.not.exhaustive.statement SwitchErrors.java:105:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:114:9: compiler.err.not.exhaustive.statement SwitchErrors.java:110:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:120:9: compiler.err.not.exhaustive.statement SwitchErrors.java:115:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:127:9: compiler.err.not.exhaustive.statement SwitchErrors.java:121:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:187:9: compiler.err.not.exhaustive.statement SwitchErrors.java:128:9: compiler.err.not.exhaustive.statement
SwitchErrors.java:188:9: compiler.err.not.exhaustive.statement
- compiler.note.preview.filename: SwitchErrors.java, DEFAULT - compiler.note.preview.filename: SwitchErrors.java, DEFAULT
- compiler.note.preview.recompile - compiler.note.preview.recompile
43 errors 44 errors

View file

@ -27,7 +27,7 @@ import java.util.function.Function;
/* /*
* @test * @test
* @bug 8262891 8268333 * @bug 8262891 8268333 8268896
* @summary Check behavior of pattern switches. * @summary Check behavior of pattern switches.
* @compile --enable-preview -source ${jdk.version} Switches.java * @compile --enable-preview -source ${jdk.version} Switches.java
* @run main/othervm --enable-preview Switches * @run main/othervm --enable-preview Switches
@ -60,6 +60,8 @@ public class Switches {
runEnumTest(this::testIntegerWithGuardsExpression1); runEnumTest(this::testIntegerWithGuardsExpression1);
runStringWithConstant(this::testStringWithConstant); runStringWithConstant(this::testStringWithConstant);
runStringWithConstant(this::testStringWithConstantExpression); runStringWithConstant(this::testStringWithConstantExpression);
runFallThrough(this::testFallThroughStatement);
runFallThrough(this::testFallThroughExpression);
npeTest(this::npeTestStatement); npeTest(this::npeTestStatement);
npeTest(this::npeTestExpression); npeTest(this::npeTestExpression);
exhaustiveStatementSane(""); exhaustiveStatementSane("");
@ -104,6 +106,10 @@ public class Switches {
assertEquals(-1, mapper.apply(null)); assertEquals(-1, mapper.apply(null));
} }
void runFallThrough(Function<Integer, Integer> mapper) {
assertEquals(2, mapper.apply(1));
}
void npeTest(Consumer<I> testCase) { void npeTest(Consumer<I> testCase) {
try { try {
testCase.accept(null); testCase.accept(null);
@ -272,7 +278,7 @@ public class Switches {
String testStringWithGuards1(E e) { String testStringWithGuards1(E e) {
switch (e != null ? e.name() : null) { switch (e != null ? e.name() : null) {
case "A": return "a"; case "A": return "a";
case "B": return "b"; case Switches.ConstantClassClash: return "b";
case String x && "C".equals(x): return "C"; case String x && "C".equals(x): return "C";
case "C": return "broken"; case "C": return "broken";
case null, String x: return String.valueOf(x); case null, String x: return String.valueOf(x);
@ -282,7 +288,7 @@ public class Switches {
String testStringWithGuardsExpression1(E e) { String testStringWithGuardsExpression1(E e) {
return switch (e != null ? e.name() : null) { return switch (e != null ? e.name() : null) {
case "A" -> "a"; case "A" -> "a";
case "B" -> "b"; case ConstantClassClash -> "b";
case String x && "C".equals(x) -> "C"; case String x && "C".equals(x) -> "C";
case "C" -> "broken"; case "C" -> "broken";
case null, String x -> String.valueOf(x); case null, String x -> String.valueOf(x);
@ -309,6 +315,31 @@ public class Switches {
}; };
} }
Integer testFallThroughStatement(Integer i) {
int r = 0;
switch (i) {
case Integer o && o != null:
r = 1;
default:
r = 2;
}
return r;
}
Integer testFallThroughExpression(Integer i) {
int r = switch (i) {
case Integer o && o != null:
r = 1;
default:
r = 2;
yield r;
};
return r;
}
void npeTestStatement(I i) { void npeTestStatement(I i) {
switch (i) { switch (i) {
case A a -> {} case A a -> {}
@ -335,6 +366,12 @@ public class Switches {
} }
} }
//verify that for cases like:
//case ConstantClassClash ->
//ConstantClassClash is interpreted as a field, not as a class
private static final String ConstantClassClash = "B";
private static class ConstantClassClash {}
sealed interface I {} sealed interface I {}
final class A implements I {} final class A implements I {}
final class B implements I {} final class B implements I {}