This commit is contained in:
Jesper Wilhelmsson 2021-07-02 01:07:50 +00:00
commit b0e186792e
25 changed files with 912 additions and 133 deletions

View file

@ -11481,7 +11481,7 @@ instruct MoveL2D_reg_reg_sse(regD dst, eRegL src, regD tmp) %{
// Small ClearArray non-AVX512.
instruct rep_stos(eCXRegI cnt, eDIRegP base, regD tmp, eAXRegI zero, Universe dummy, eFlagsReg cr) %{
predicate(!((ClearArrayNode*)n)->is_large() &&
(UseAVX <= 2 || !VM_Version::supports_avx512vlbw()));
(UseAVX <= 2));
match(Set dummy (ClearArray cnt base));
effect(USE_KILL cnt, USE_KILL base, TEMP tmp, KILL zero, KILL cr);
@ -11542,7 +11542,7 @@ instruct rep_stos(eCXRegI cnt, eDIRegP base, regD tmp, eAXRegI zero, Universe du
// Small ClearArray AVX512 non-constant length.
instruct rep_stos_evex(eCXRegI cnt, eDIRegP base, regD tmp, kReg ktmp, eAXRegI zero, Universe dummy, eFlagsReg cr) %{
predicate(!((ClearArrayNode*)n)->is_large() &&
UseAVX > 2 && VM_Version::supports_avx512vlbw() &&
UseAVX > 2 &&
!n->in(2)->bottom_type()->is_int()->is_con());
match(Set dummy (ClearArray cnt base));
effect(USE_KILL cnt, USE_KILL base, TEMP tmp, TEMP ktmp, KILL zero, KILL cr);

View file

@ -11044,7 +11044,7 @@ instruct rep_stos(rcx_RegL cnt, rdi_RegP base, regD tmp, rax_RegI zero,
Universe dummy, rFlagsReg cr)
%{
predicate(!((ClearArrayNode*)n)->is_large() &&
(UseAVX <= 2 || !VM_Version::supports_avx512vlbw()));
(UseAVX <= 2));
match(Set dummy (ClearArray cnt base));
effect(USE_KILL cnt, USE_KILL base, TEMP tmp, KILL zero, KILL cr);
@ -11105,7 +11105,7 @@ instruct rep_stos_evex(rcx_RegL cnt, rdi_RegP base, regD tmp, kReg ktmp, rax_Reg
Universe dummy, rFlagsReg cr)
%{
predicate(!((ClearArrayNode*)n)->is_large() &&
UseAVX > 2 && VM_Version::supports_avx512vlbw() &&
UseAVX > 2 &&
!n->in(2)->bottom_type()->is_long()->is_con());
match(Set dummy (ClearArray cnt base));
effect(USE_KILL cnt, USE_KILL base, TEMP tmp, TEMP ktmp, KILL zero, KILL cr);

View file

@ -1151,7 +1151,7 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod*
const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr();
const Type* sig_type = TypeOopPtr::make_from_klass(signature->accessing_klass());
if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
const Type* recv_type = arg_type->join_speculative(sig_type); // keep speculative part
const Type* recv_type = arg_type->filter_speculative(sig_type); // keep speculative part
Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, recv_type));
kit.set_argument(0, cast_obj);
}
@ -1164,7 +1164,7 @@ CallGenerator* CallGenerator::for_method_handle_inline(JVMState* jvms, ciMethod*
const TypeOopPtr* arg_type = arg->bottom_type()->isa_oopptr();
const Type* sig_type = TypeOopPtr::make_from_klass(t->as_klass());
if (arg_type != NULL && !arg_type->higher_equal(sig_type)) {
const Type* narrowed_arg_type = arg_type->join_speculative(sig_type); // keep speculative part
const Type* narrowed_arg_type = arg_type->filter_speculative(sig_type); // keep speculative part
Node* cast_obj = gvn.transform(new CheckCastPPNode(kit.control(), arg, narrowed_arg_type));
kit.set_argument(receiver_skip + j, cast_obj);
}

View file

@ -1011,6 +1011,33 @@ bool IfNode::fold_compares_helper(ProjNode* proj, ProjNode* success, ProjNode* f
adjusted_lim = igvn->transform(new SubINode(hi, lo));
}
hook->destruct(igvn);
int lo = igvn->type(adjusted_lim)->is_int()->_lo;
if (lo < 0) {
// If range check elimination applies to this comparison, it includes code to protect from overflows that may
// cause the main loop to be skipped entirely. Delay this transformation.
// Example:
// for (int i = 0; i < limit; i++) {
// if (i < max_jint && i > min_jint) {...
// }
// Comparisons folded as:
// i - min_jint - 1 <u -2
// when RC applies, main loop limit becomes:
// min(limit, max(-2 + min_jint + 1, min_jint))
// = min(limit, min_jint)
// = min_jint
if (!igvn->C->post_loop_opts_phase()) {
if (adjusted_val->outcnt() == 0) {
igvn->remove_dead_node(adjusted_val);
}
if (adjusted_lim->outcnt() == 0) {
igvn->remove_dead_node(adjusted_lim);
}
igvn->C->record_for_post_loop_opts_igvn(this);
return false;
}
}
Node* newcmp = igvn->transform(new CmpUNode(adjusted_val, adjusted_lim));
Node* newbool = igvn->transform(new BoolNode(newcmp, cond));

View file

@ -949,6 +949,9 @@ void PhaseIdealLoop::try_move_store_after_loop(Node* n) {
assert(get_loop(lca) == outer_loop, "safepoint in outer loop consume all memory state");
}
#endif
lca = place_outside_loop(lca, n_loop);
assert(!n_loop->is_member(get_loop(lca)), "control must not be back in the loop");
assert(get_loop(lca)->_nest < n_loop->_nest || lca->in(0)->Opcode() == Op_NeverBranch, "must not be moved into inner loop");
// Move store out of the loop
_igvn.replace_node(hook, n->in(MemNode::Memory));
@ -1147,7 +1150,9 @@ Node* PhaseIdealLoop::place_outside_loop(Node* useblock, IdealLoopTree* loop) co
// Pick control right outside the loop
for (;;) {
Node* dom = idom(useblock);
if (loop->is_member(get_loop(dom))) {
if (loop->is_member(get_loop(dom)) ||
// NeverBranch nodes are not assigned to the loop when constructed
(dom->Opcode() == Op_NeverBranch && loop->is_member(get_loop(dom->in(0))))) {
break;
}
useblock = dom;

View file

@ -144,7 +144,7 @@ public final class Normalizer {
/**
* Normalize a sequence of char values.
* The sequence will be normalized according to the specified normalization
* from.
* form.
* @param src The sequence of char values to normalize.
* @param form The normalization form; one of
* {@link java.text.Normalizer.Form#NFC},

View file

@ -80,6 +80,7 @@
- (void) blitTexture {
if (self.ctx == NULL || self.javaLayer == NULL || self.buffer == nil || self.ctx.device == nil) {
J2dTraceLn4(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: uninitialized (mtlc=%p, javaLayer=%p, buffer=%p, devide=%p)", self.ctx, self.javaLayer, self.buffer, ctx.device);
[self stopDisplayLink];
return;
}
@ -89,6 +90,7 @@
@autoreleasepool {
if ((self.buffer.width == 0) || (self.buffer.height == 0)) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: cannot create drawable of size 0");
[self stopDisplayLink];
return;
}
@ -99,17 +101,20 @@
if (src_h <= 0 || src_w <= 0) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: Invalid src width or height.");
[self stopDisplayLink];
return;
}
id<MTLCommandBuffer> commandBuf = [self.ctx createBlitCommandBuffer];
if (commandBuf == nil) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: commandBuf is null");
[self stopDisplayLink];
return;
}
id<CAMetalDrawable> mtlDrawable = [self nextDrawable];
if (mtlDrawable == nil) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer.blitTexture: nextDrawable is null)");
[self stopDisplayLink];
return;
}
self.nextDrawableCount++;
@ -277,6 +282,7 @@ Java_sun_java2d_metal_MTLLayer_blitTexture
MTLContext * ctx = layer.ctx;
if (layer == NULL || ctx == NULL) {
J2dTraceLn(J2D_TRACE_VERBOSE, "MTLLayer_blit : Layer or Context is null");
[layer stopDisplayLink];
return;
}

View file

@ -1577,6 +1577,10 @@ public class Flow {
public void visitClassDef(JCClassDecl tree) {
//skip
}
@Override
public void visitLambda(JCLambda tree) {
//skip
}
public boolean isAlive() {
return super.alive != Liveness.DEAD;
}

View file

@ -190,6 +190,7 @@ public class TransPatterns extends TreeTranslator {
syms.objectType
: tree.expr.type;
VarSymbol prevCurrentValue = currentValue;
bindingContext = new BasicBindingContext();
try {
JCExpression translatedExpr = translate(tree.expr);
Symbol exprSym = TreeInfo.symbol(translatedExpr);
@ -206,16 +207,20 @@ public class TransPatterns extends TreeTranslator {
}
Type principalType = principalType((JCPattern) tree.pattern);
result = makeBinary(Tag.AND,
JCExpression resultExpression=
makeBinary(Tag.AND,
makeTypeTest(make.Ident(currentValue), make.Type(principalType)),
(JCExpression) this.<JCTree>translate(tree.pattern));
if (currentValue != exprSym) {
result = make.at(tree.pos).LetExpr(make.VarDef(currentValue, translatedExpr),
(JCExpression)result).setType(syms.booleanType);
((LetExpr) result).needsCond = true;
resultExpression =
make.at(tree.pos).LetExpr(make.VarDef(currentValue, translatedExpr),
resultExpression).setType(syms.booleanType);
((LetExpr) resultExpression).needsCond = true;
}
result = bindingContext.decorateExpression(resultExpression);
} finally {
currentValue = prevCurrentValue;
bindingContext.pop();
}
} else {
super.visitTypeTest(tree);

View file

@ -27,6 +27,12 @@ module jdk.internal.vm.ci {
exports jdk.vm.ci.services to
jdk.internal.vm.compiler,
jdk.internal.vm.compiler.management;
exports jdk.vm.ci.runtime to
jdk.internal.vm.compiler,
jdk.internal.vm.compiler.management;
exports jdk.vm.ci.meta to jdk.internal.vm.compiler;
exports jdk.vm.ci.code to jdk.internal.vm.compiler;
exports jdk.vm.ci.hotspot to jdk.internal.vm.compiler;
uses jdk.vm.ci.services.JVMCIServiceLocator;
uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;

View file

@ -183,11 +183,6 @@ public class HtmlDocletWriter {
*/
protected boolean printedAnnotationHeading = false;
/**
* To check whether annotation field heading is printed or not.
*/
protected boolean printedAnnotationFieldHeading = false;
/**
* To check whether the repeated annotations is documented or not.
*/
@ -1647,13 +1642,41 @@ public class HtmlDocletWriter {
}
/**
* Return true if relative links should not be redirected.
* Returns true if relative links should be redirected.
*
* @return Return true if a relative link should not be redirected.
* @return true if a relative link should be redirected.
*/
private boolean shouldNotRedirectRelativeLinks() {
return this instanceof ClassWriter ||
this instanceof PackageSummaryWriter;
private boolean shouldRedirectRelativeLinks(Element element) {
if (element == null || utils.isOverviewElement(element)) {
// Can't redirect unless there is a valid source element.
return false;
}
// Retrieve the element of this writer if it is a "primary" writer for an element.
// Note: It would be nice to have getCurrentPageElement() return package and module elements
// in their respective writers, but other uses of the method are only interested in TypeElements.
Element currentPageElement = getCurrentPageElement();
if (currentPageElement == null) {
if (this instanceof PackageWriterImpl packageWriter) {
currentPageElement = packageWriter.packageElement;
} else if (this instanceof ModuleWriterImpl moduleWriter) {
currentPageElement = moduleWriter.mdle;
}
}
// Redirect link if the current writer is not the primary writer for the source element.
return currentPageElement == null
|| (currentPageElement != element
&& currentPageElement != utils.getEnclosingTypeElement(element));
}
/**
* Returns true if element lives in the same package as the type or package
* element of this writer.
*/
private boolean inSamePackage(Element element) {
Element currentPageElement = (this instanceof PackageWriterImpl packageWriter)
? packageWriter.packageElement : getCurrentPageElement();
return currentPageElement != null && !utils.isModule(element)
&& utils.containingPackage(currentPageElement) == utils.containingPackage(element);
}
/**
@ -1681,10 +1704,30 @@ public class HtmlDocletWriter {
*/
private String redirectRelativeLinks(Element element, TextTree tt) {
String text = tt.getBody();
if (element == null || utils.isOverviewElement(element) || shouldNotRedirectRelativeLinks()) {
if (!shouldRedirectRelativeLinks(element)) {
return text;
}
String lower = Utils.toLowerCase(text);
if (lower.startsWith("mailto:")
|| lower.startsWith("http:")
|| lower.startsWith("https:")
|| lower.startsWith("file:")) {
return text;
}
if (text.startsWith("#")) {
// Redirected fragment link: prepend HTML file name to make it work
if (utils.isModule(element)) {
text = "module-summary.html" + text;
} else if (utils.isPackage(element)) {
text = DocPaths.PACKAGE_SUMMARY.getPath() + text;
} else {
TypeElement typeElement = element instanceof TypeElement
? (TypeElement) element : utils.getEnclosingTypeElement(element);
text = docPaths.forName(typeElement).getPath() + text;
}
}
if (!inSamePackage(element)) {
DocPath redirectPathFromRoot = new SimpleElementVisitor14<DocPath, Void>() {
@Override
public DocPath visitType(TypeElement e, Void p) {
@ -1706,22 +1749,21 @@ public class HtmlDocletWriter {
return docPaths.forPackage(utils.containingPackage(e));
}
@Override
public DocPath visitModule(ModuleElement e, Void p) {
return DocPaths.forModule(e);
}
@Override
protected DocPath defaultAction(Element e, Void p) {
return null;
}
}.visit(element);
if (redirectPathFromRoot == null) {
return text;
}
String lower = Utils.toLowerCase(text);
if (!(lower.startsWith("mailto:")
|| lower.startsWith("http:")
|| lower.startsWith("https:")
|| lower.startsWith("file:"))) {
if (redirectPathFromRoot != null) {
text = "{@" + (new DocRootTaglet()).getName() + "}/"
+ redirectPathFromRoot.resolve(text).getPath();
text = replaceDocRootDir(text);
return replaceDocRootDir(text);
}
}
return text;
}

View file

@ -0,0 +1,80 @@
/*
* Copyright (c) 2021, Red Hat, Inc. 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.
*/
/**
* @test
* @bug 8269088
* @summary C2 fails with assert(!n->is_Store() && !n->is_LoadStore()) failed: no node with a side effect
*
* @requires vm.gc.Serial
* @run main/othervm -Xcomp -XX:CompileOnly=TestStoreSunkInInnerLoop -XX:CompileCommand=quiet -XX:+UseSerialGC -Xmx256m TestStoreSunkInInnerLoop
*
*/
public class TestStoreSunkInInnerLoop {
public static final int N = 400;
public static int iFld=-10622;
public static long lArrFld[]=new long[N];
public float fArrFld[][]=new float[N][N];
public void mainTest() {
int i8=-10584, i10=37284, i11=38, i13=-238, i14=-18473, i15=-53564;
boolean b1=false;
TestStoreSunkInInnerLoop.iFld -= TestStoreSunkInInnerLoop.iFld;
for (i8 = 224; i8 > 7; i8 -= 2) {
i10 = 1;
while (++i10 < 232) {
TestStoreSunkInInnerLoop.iFld += i8;
}
for (i11 = 8; i11 < 232; ++i11) {
if (b1) continue;
TestStoreSunkInInnerLoop.lArrFld[i11] += i10;
}
}
i13 = 1;
do {
switch ((i13 % 2) + 126) {
case 126:
for (i14 = 102; i14 > 2; i14 -= 3) {
fArrFld[i13][(-126 >>> 1) % N] -= i15;
}
break;
case 127:
i15 = (i13 % i10);
break;
default:
}
} while (++i13 < 247);
}
public static void main(String[] strArr) {
TestStoreSunkInInnerLoop _instance = new TestStoreSunkInInnerLoop();
for (int i = 0; i < 10; i++ ) {
_instance.mainTest();
}
}
}

View file

@ -0,0 +1,61 @@
/*
* Copyright (c) 2021, Red Hat, Inc.. 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.
*/
/*
* @test
* @bug 8269285
* @summary Crash/miscompile in CallGenerator::for_method_handle_inline after JDK-8191998
* @requires vm.compMode == "Xmixed" & vm.flavor == "server"
*
* @run main/othervm
* -Xcomp -XX:CompileCommand=quiet -XX:CompileCommand=compileonly,compiler.types.TestMethodHandleSpeculation::main
* compiler.types.TestMethodHandleSpeculation
*/
package compiler.types;
import java.io.Serializable;
import java.util.Arrays;
import java.util.function.Supplier;
public class TestMethodHandleSpeculation {
public static void main(String... args) {
byte[] serObj = {1};
MyClass<byte[]> obj = new MyClass<>();
for (int i = 0; i < 100_000; i++) {
boolean test = obj.test(serObj);
if (test) {
throw new IllegalStateException("Cannot be null");
}
}
}
static class MyClass<V extends Serializable> {
boolean test(V obj) {
Supplier<Boolean> supp = () -> (obj == null);
return supp.get();
}
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 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
@ -60,6 +60,7 @@
package gc.gctests.PhantomReference.phantom001;
import java.lang.ref.*;
import java.time.LocalTime;
import nsk.share.gc.*;
import nsk.share.gc.gp.*;
import nsk.share.gc.gp.string.InternedStringProducer;
@ -98,12 +99,43 @@ public class phantom001 extends ThreadedGCTest implements GarbageProducerAware,
int iteration;
private volatile boolean finalized;
private String addMessageContext(String message) {
return "T:" + Thread.currentThread().getId() +
" I:" + iteration +
" " + LocalTime.now().toString() +
": " + message;
}
private void info(String message) {
log.info(addMessageContext(message));
}
private void progress(String message) {
// Uncomment this to get more verbose logging.
// log.debug(addMessageContext(message));
}
private void fail(String message) {
log.error(addMessageContext("[FAILED] " + message));
setFailed(true);
}
private boolean shouldTerminate() {
return !getExecutionController().continueExecution();
}
private void eatMemory(int initialFactor) {
GarbageUtils.eatMemory(getExecutionController(),
garbageProducer,
initialFactor, 10, 0);
}
public void run() {
try {
log.info("iteration " + iteration);
int code = iteration % TYPES_COUNT;
info("start code " + code);
ReferenceQueue queue = new ReferenceQueue();
PhantomReference reference;
int code = iteration % TYPES_COUNT;
String type;
// Define a specific type for each thread to test
switch (code) {
@ -158,51 +190,66 @@ public class phantom001 extends ThreadedGCTest implements GarbageProducerAware,
}
int initialFactor = memoryStrategy.equals(MemoryStrategy.HIGH) ? 1 : (memoryStrategy.equals(MemoryStrategy.LOW) ? 10 : 2);
GarbageUtils.eatMemory(getExecutionController(), garbageProducer, initialFactor , 10, 0);
// If referent is finalizable, provoke GCs and wait for finalization.
if (type.equals("class")) {
while (!finalized && getExecutionController().continueExecution()) {
System.runFinalization(); //does not guarantee finalization, but increases the chance
progress("Waiting for finalization: " + type);
for (int checks = 0; !finalized && !shouldTerminate(); ++checks) {
// There are scenarios where one eatMemory() isn't enough,
// but 10 iterations really ought to be sufficient.
if (checks > 10) {
fail("Waiting for finalization: " + type);
return;
}
eatMemory(initialFactor);
// Give some time for finalizer to run.
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
GarbageUtils.eatMemory(getExecutionController(), garbageProducer, initialFactor , 10, 0);
}
}
//provoke gc once more to make finalized object phantom reachable
GarbageUtils.eatMemory(getExecutionController(), garbageProducer, initialFactor , 10, 0);
}
if (!getExecutionController().continueExecution()) {
// we were interrrupted by stresser. just exit...
// Provoke GCs and wait for reference to be enqueued.
progress("Waiting for enqueue: " + type);
Reference polled = queue.poll();
for (int checks = 0; polled == null && !shouldTerminate(); ++checks) {
// There are scenarios where one eatMemory() isn't enough,
// but 10 iterations really ought to be sufficient.
if (checks > 10) {
fail("Waiting for enqueue: " + type);
return;
}
Reference polledReference = null;
eatMemory(initialFactor);
// Give some time for reference to be enqueued.
try {
polledReference = queue.remove();
} catch (InterruptedException e) {
log.error("Unexpected InterruptedException during queue.remove().");
setFailed(true);
polled = queue.remove(100);
} catch (InterruptedException e) {}
}
// Check the reference and the queue
if (polled == null && shouldTerminate()) {
info("Terminated: " + type);
return;
}
// The polled reference must be equal to the one enqueued to
// the queue
if (polledReference != reference) {
log.error("The original reference is not equal to polled reference.");
setFailed(true);
if (polled != reference) {
fail("The original reference is not equal to polled reference.");
return;
}
// queue.poll() once again must return null now, since there is
// only one reference in the queue
polledReference = queue.poll();
if (polledReference != null) {
log.error("There are more than one references in the queue.");
setFailed(true);
if (queue.poll() != null) {
fail("There are more than one reference in the queue.");
return;
}
reference.clear();
progress("Finished: " + type);
} catch (OutOfMemoryError e) {
}
} finally {
iteration++;
}
}
class Referent {

View file

@ -46,7 +46,7 @@ import java.util.stream.IntStream;
public class TestResourceScope {
final static int N_THREADS = 10000;
final static int N_THREADS = 100;
@Test(dataProvider = "cleaners")
public void testConfined(Supplier<Cleaner> cleanerSupplier) {
@ -206,10 +206,6 @@ public class TestResourceScope {
}).start();
}
while (lockCount.get() == 0) {
waitSomeTime(); // make sure some thread gets scheduled
}
while (true) {
try {
scope.close();

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -23,7 +23,7 @@
/*
* @test
* @bug 4460354 8014636 8043186 8195805 8182765 8196202
* @bug 4460354 8014636 8043186 8195805 8182765 8196202 8262886
* @summary Test to make sure that relative paths are redirected in the
* output so that they are not broken.
* @library ../../lib
@ -46,77 +46,157 @@ public class TestRelativeLinks extends JavadocTester {
}
@Test
public void test() {
public void testRelativeLinks() {
javadoc("-d", "out",
"-use",
"-sourcepath", testSrc,
"pkg", "pkg2");
checkExit(Exit.ERROR);
checkOutput(Output.OUT, true,
"attribute not supported in HTML5: name");
"pkg", "pkg2", "pkg.sub");
checkExit(Exit.OK);
// These relative paths should stay relative because they appear
// in the right places.
checkOutput("pkg/C.html", true,
"""
<a href="relative-class-link.html">relative class link</a>""",
"""
<a href="#class-fragment">fragment class link</a>""",
"""
<a id="class-fragment">Class fragment</a>""",
"""
<a href="relative-field-link.html">relative field link</a>""",
"""
<a href="relative-method-link.html">relative method link</a>""",
"""
\s<a href="relative-multi-line-link.html">relative-multi-line-link</a>.""");
<a href="#method-fragment">fragment method link</a>""",
"""
<a href="relative-multi-line-link.html">relative-multi-line-link</a>""");
checkOutput("pkg/package-summary.html", true,
"""
<a href="relative-package-link.html">relative package link</a>""");
<a href="relative-package-link.html">relative package link</a>""",
"""
<a href="#package-fragment">package fragment link</a>""",
"""
<a id="package-fragment">Package fragment</a>""",
"""
<a href="relative-class-link.html">relative class link</a>""",
"""
<a href="C.html#class-fragment">fragment class link</a>""");
// subclass in same pacakge
checkOutput("pkg/D.html", true,
"""
<a href="relative-class-link.html">relative class link</a>""",
"""
<a href="C.html#class-fragment">fragment class link</a>""",
"""
<a href="relative-method-link.html">relative method link</a>""",
"""
<a href="C.html#method-fragment">fragment method link</a>""");
// These relative paths should be redirected because they are in different
// places.
// subclass in subpackage
checkOutput("pkg/sub/F.html", true,
"""
<a href="../../pkg/relative-class-link.html">relative class link</a>""",
"""
<a href="../../pkg/C.html#class-fragment">fragment class link</a>""",
"""
<a href="../../pkg/relative-method-link.html">relative method link</a>""",
"""
<a href="../../pkg/C.html#method-fragment">fragment method link</a>""");
// INDEX PAGE
checkOutput("index-all.html", true,
"""
<a href="./pkg/relative-class-link.html">relative class link</a>""",
"""
<a href="./pkg/C.html#class-fragment">fragment class link</a>""",
"""
<a href="./pkg/relative-field-link.html">relative field link</a>""",
"""
<a href="./pkg/relative-method-link.html">relative method link</a>""",
"""
<a href="./pkg/C.html#method-fragment">fragment method link</a>""",
"""
<a href="./pkg/relative-package-link.html">relative package link</a>""",
"""
\s<a href="./pkg/relative-multi-line-link.html">relative-multi-line-link</a>.""");
<a href="./pkg/relative-multi-line-link.html">relative-multi-line-link</a>""");
// This is not a relative path and should not be redirected.
checkOutput("index-all.html", true,
"""
<div class="block"><a name="masters"></a>""");
<div class="block"><a id="masters"></a>""");
checkOutput("index-all.html", false,
"""
<div class="block"><a name="./pkg/masters"></a>""");
<div class="block"><a id="./pkg/masters"></a>""");
// PACKAGE USE
checkOutput("pkg/package-use.html", true,
"""
<a href="../pkg/relative-package-link.html">relative package link</a>.""",
<a href="../pkg/relative-package-link.html">relative package link</a>""",
"""
<a href="../pkg/relative-class-link.html">relative class link</a>""");
<a href="../pkg/package-summary.html#package-fragment">package fragment link</a>""",
"""
<a href="../pkg/relative-class-link.html">relative class link</a>""",
"""
<a href="../pkg/C.html#class-fragment">fragment class link</a>""");
// CLASS_USE
checkOutput("pkg/class-use/C.html", true,
"""
<a href="../../pkg/relative-class-link.html">relative class link</a>""",
"""
<a href="../../pkg/C.html#class-fragment">fragment class link</a>""",
"""
<a href="../../pkg/relative-field-link.html">relative field link</a>""",
"""
<a href="../../pkg/relative-method-link.html">relative method link</a>""",
"""
<a href="../../pkg/C.html#method-fragment">fragment method link</a>""",
"""
<a href="../../pkg/relative-package-link.html">relative package link</a>""",
"""
\s<a href="../../pkg/relative-multi-line-link.html">relative-multi-line-link</a>.""");
<a href="../../pkg/relative-multi-line-link.html">relative-multi-line-link</a>""");
// PACKAGE OVERVIEW
checkOutput("index.html", true,
"""
<a href="./pkg/relative-package-link.html">relative package link</a>""");
// subpackage summary
checkOutput("pkg/sub/package-summary.html", true,
// related packages
"""
<a href="../../pkg/relative-package-link.html">relative package link</a>""",
"""
<a href="../../pkg/package-summary.html#package-fragment">package fragment link</a>""",
// subclass inheriting relative link doc
"""
<a href="../../pkg/relative-class-link.html">relative class link</a>""",
"""
<a href="../../pkg/C.html#class-fragment">fragment class link</a>""");
// sibling package summary
checkOutput("pkg2/package-summary.html", true,
"""
<a href="../pkg/relative-class-link.html">relative class link</a>""",
"""
<a href="../pkg/C.html#class-fragment">fragment class link</a>""");
}
@Override
public void checkLinks() {
// since the test uses explicit links to non-existent files,
// we create those files to avoid false positive errors from checkLinks
touch("pkg/relative-class-link.html");
touch("pkg/relative-field-link.html");
touch("pkg/relative-method-link.html");
touch("pkg/relative-package-link.html");
touch("pkg/relative-multi-line-link.html");
super.checkLinks();
}
private void touch(String file) {

View file

@ -0,0 +1,115 @@
/*
* 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.
*/
/*
* @test
* @bug 8262886
* @summary javadoc generates broken links with {@inheritDoc}
* @modules jdk.javadoc/jdk.javadoc.internal.api
* jdk.javadoc/jdk.javadoc.internal.tool
* jdk.compiler/com.sun.tools.javac.api
* jdk.compiler/com.sun.tools.javac.main
* @library ../../lib /tools/lib
* @build toolbox.ToolBox toolbox.ModuleBuilder javadoc.tester.*
* @run main TestRelativeModuleLinks
*/
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import javadoc.tester.JavadocTester;
import toolbox.ModuleBuilder;
import toolbox.ToolBox;
public class TestRelativeModuleLinks extends JavadocTester {
public final ToolBox tb;
public static void main(String... args) throws Exception {
TestRelativeModuleLinks tester = new TestRelativeModuleLinks();
tester.runTests(m -> new Object[] { Paths.get(m.getName()) });
}
public TestRelativeModuleLinks() {
tb = new ToolBox();
}
@Test
public void testRelativeModuleLinks(Path base) throws IOException {
Path src = base.resolve("src");
new ModuleBuilder(tb, "ma")
.classes("package pa; public class A {}")
.exports("pa")
.comment("""
<a href="doc-files/file.html">relative module link</a>,
<a href="#module-fragment">fragment module link</a>.
<a id="module-fragment">Module fragment</a>.""")
.write(src);
new ModuleBuilder(tb, "mb")
.classes("package pb; public class B {}")
.exports("pb")
.requiresTransitive("ma")
.write(src);
Path docFiles = src.resolve("ma").resolve("doc-files");
tb.writeFile(docFiles.resolve("file.html"),
"""
<html>
<head><title>Module HTML File</title></head>
<body><h1>Module HTML File</h1>
File content</body>
</html>
""");
javadoc("-d", base.resolve("api").toString(),
"-quiet",
"--module-source-path", src.toString(),
"--module", "ma,mb");
checkExit(Exit.OK);
// Main page
checkOutput("index.html", true,
"""
<div class="block"><a href="./ma/doc-files/file.html">relative module link</a>,
<a href="./ma/module-summary.html#module-fragment">fragment module link</a>.</div>""");
// Index page
checkOutput("index-all.html", true,
"""
<div class="block"><a href="./ma/doc-files/file.html">relative module link</a>,
<a href="./ma/module-summary.html#module-fragment">fragment module link</a>.</div>""");
// Own module page
checkOutput("ma/module-summary.html", true,
"""
<div class="block"><a href="doc-files/file.html">relative module link</a>,
<a href="#module-fragment">fragment module link</a>.
<a id="module-fragment">Module fragment</a>.</div>""");
// Other module page
checkOutput("mb/module-summary.html", true,
"""
<div class="block"><a href="../ma/doc-files/file.html">relative module link</a>,
<a href="../ma/module-summary.html#module-fragment">fragment module link</a>.</div>""");
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -24,8 +24,11 @@
package pkg;
/**
* Here is a relative link in a class:
* <a href="relative-class-link.html">relative class link</a>.
* Here are two relative links in a class:
* <a href="relative-class-link.html">relative class link</a>,
* <a href="#class-fragment">fragment class link</a>.
*
* <a id="class-fragment">Class fragment</a>.
*/
public class C {
@ -36,8 +39,9 @@ public class C {
public C field = null;
/**
* Here is a relative link in a method:
* <a href="relative-method-link.html">relative method link</a>.
* Here are two relative links in a method:
* <a href="relative-method-link.html">relative method link</a>,
* <a href="#method-fragment">fragment method link</a>.
*/
public C method() { return null;}
@ -45,11 +49,13 @@ public class C {
* Here is a relative link in a method:
* <a
* href="relative-multi-line-link.html">relative-multi-line-link</a>.
*
* <a id="method-fragment">Method fragment</a>.
*/
public C multipleLineTest() { return null;}
/**
* <a name="masters"></a>
* <a id="masters"></a>
* Something that goes holy cow. Second line.
*/
public static class WithAnAnchor{}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
* 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
@ -21,9 +21,21 @@
* questions.
*/
package pkg2;
package pkg;
/**
* Just a dummy class to force the overview page to generate.
* {@inheritDoc}
*
* A class that extends C and inherits some of its comments.
*/
public class Foo {}
public class D extends C {
/**
* {@inheritDoc}
*/
@Override
public D method() {
return null;
}
}

View file

@ -1,7 +1,10 @@
<html>
<body>
Here is a relative link in a package:
<a href="relative-package-link.html">relative package link</a>.
Here are two relative links in a package:
<a href="relative-package-link.html">relative package link</a>,
<a href="#package-fragment">package fragment link</a>.
<a id="package-fragment">Package fragment</a>.
</body>
</html>

View file

@ -0,0 +1,43 @@
/*
* 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.
*/
package pkg.sub;
import pkg.C;
/**
* {@inheritDoc}
*
* A class that extends C and inherits some of its comments.
*/
public class F extends C {
/**
* {@inheritDoc}
*/
@Override
public F method() {
return null;
}
}

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2003, 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.
*/
package pkg2;
import pkg.C;
/**
* {@inheritDoc}
*
* A class that extends pkg.C from onother package and inherits some of its comments.
*/
public class E extends C {
/**
* {@inheritDoc}
*/
@Override
public E method() {
return null;
}
}

View file

@ -0,0 +1,59 @@
/*
* Copyright (c) 2021, Alphabet LLC. 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.
*/
/* @test
* @bug 8268592
* @summary JDK-8262891 causes an NPE in Lint.augment
* @compile T8268592.java
*/
import java.util.Collection;
import java.util.function.Function;
import java.util.function.Supplier;
abstract class T {
abstract <T> T r(Function<String, Supplier<T>> x);
enum E {
ONE
}
abstract <T> Supplier<T> f(Function<T, Supplier<T>> x);
public void updateAcl(E e, Supplier<Void> v) {
r(
(String t) -> {
switch (e) {
case ONE:
return f(
a -> {
Collection<String> m = null;
return v;
});
default:
return v;
}
});
}
}

View file

@ -23,7 +23,7 @@
/*
* @test
* @bug 8262891
* @bug 8262891 8269354
* @summary Test parenthesized pattern
* @compile --enable-preview -source ${jdk.version} Parenthesized.java
* @run main/othervm --enable-preview Parenthesized
@ -46,6 +46,8 @@ public class Parenthesized {
if (o instanceof (String s && s.isEmpty())) {
System.err.println("OK: " + s);
}
boolean b1 = o instanceof (String s && s.isEmpty());
boolean b2 = o instanceof String s && s.isEmpty();
}
}

View file

@ -0,0 +1,137 @@
/*
* 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.
*/
package org.openjdk.bench.jdk.incubator.foreign;
import jdk.incubator.foreign.CLinker;
import jdk.incubator.foreign.MemoryAccess;
import jdk.incubator.foreign.MemoryAddress;
import jdk.incubator.foreign.MemorySegment;
import jdk.incubator.foreign.ResourceScope;
import jdk.incubator.vector.ByteVector;
import jdk.incubator.vector.IntVector;
import jdk.incubator.vector.VectorSpecies;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.AverageTime)
@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
@State(org.openjdk.jmh.annotations.Scope.Thread)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Fork(value = 1, jvmArgsAppend = {
"--add-modules=jdk.incubator.foreign",
"-Dforeign.restricted=permit",
"--enable-native-access", "ALL-UNNAMED"})
public class TestLoadBytes {
@Param("1024")
private int size;
private byte[] srcArray;
private ByteBuffer srcBufferNative;
private MemorySegment srcSegmentImplicit;
@Setup
public void setup() {
srcArray = new byte[size];
for (int i = 0; i < srcArray.length; i++) {
srcArray[i] = (byte) i;
}
srcBufferNative = ByteBuffer.allocateDirect(size);
srcSegmentImplicit = MemorySegment.allocateNative(size, ResourceScope.newImplicitScope());
}
@Benchmark
public int arrayScalar() {
int size = 0;
for (int i = 0; i < srcArray.length; i ++) {
var v = srcArray[i];
size += v;
}
return size;
}
@Benchmark
public int arrayScalarConst() {
int size = 0;
for (int i = 0; i < 1024; i ++) {
var v = srcArray[i];
size += v;
}
return size;
}
@Benchmark
public int bufferNativeScalar() {
int size = 0;
for (int i = 0; i < srcArray.length; i++) {
var v = srcBufferNative.get(i);
size += v;
}
return size;
}
@Benchmark
public int bufferNativeScalarConst() {
int size = 0;
for (int i = 0; i < 1024; i++) {
var v = srcBufferNative.get(i);
size += v;
}
return size;
}
@Benchmark
public int segmentNativeScalar() {
int size = 0;
for (int i = 0; i < srcArray.length; i++) {
var v = MemoryAccess.getByteAtOffset(srcSegmentImplicit, i);
size += v;
}
return size;
}
@Benchmark
public int segmentNativeScalarConst() {
int size = 0;
for (int i = 0; i < 1024; i++) {
var v = MemoryAccess.getByteAtOffset(srcSegmentImplicit, i);
size += v;
}
return size;
}
}