Skip to content

Commit 9ff01f7

Browse files
committed
Merge
2 parents f8c1d79 + 39b22d1 commit 9ff01f7

File tree

8 files changed

+148
-29
lines changed

8 files changed

+148
-29
lines changed

src/hotspot/share/opto/escape.cpp

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -723,8 +723,7 @@ void ConnectionGraph::add_to_congraph_unsafe_access(Node* n, uint opcode, Unique
723723
if (adr_type->isa_oopptr()
724724
|| ((opcode == Op_StoreP || opcode == Op_StoreN || opcode == Op_StoreNKlass)
725725
&& adr_type == TypeRawPtr::NOTNULL
726-
&& adr->in(AddPNode::Address)->is_Proj()
727-
&& adr->in(AddPNode::Address)->in(0)->is_Allocate())) {
726+
&& is_captured_store_address(adr))) {
728727
delayed_worklist->push(n); // Process it later.
729728
#ifdef ASSERT
730729
assert (adr->is_AddP(), "expecting an AddP");
@@ -771,8 +770,7 @@ bool ConnectionGraph::add_final_edges_unsafe_access(Node* n, uint opcode) {
771770
if (adr_type->isa_oopptr()
772771
|| ((opcode == Op_StoreP || opcode == Op_StoreN || opcode == Op_StoreNKlass)
773772
&& adr_type == TypeRawPtr::NOTNULL
774-
&& adr->in(AddPNode::Address)->is_Proj()
775-
&& adr->in(AddPNode::Address)->in(0)->is_Allocate())) {
773+
&& is_captured_store_address(adr))) {
776774
// Point Address to Value
777775
PointsToNode* adr_ptn = ptnode_adr(adr->_idx);
778776
assert(adr_ptn != NULL &&
@@ -1584,8 +1582,7 @@ int ConnectionGraph::find_init_values(JavaObjectNode* pta, PointsToNode* init_va
15841582
// Raw pointers are used for initializing stores so skip it
15851583
// since it should be recorded already
15861584
Node* base = get_addp_base(field->ideal_node());
1587-
assert(adr_type->isa_rawptr() && base->is_Proj() &&
1588-
(base->in(0) == alloc),"unexpected pointer type");
1585+
assert(adr_type->isa_rawptr() && is_captured_store_address(field->ideal_node()), "unexpected pointer type");
15891586
#endif
15901587
continue;
15911588
}
@@ -1916,8 +1913,7 @@ void ConnectionGraph::optimize_ideal_graph(GrowableArray<Node*>& ptr_cmp_worklis
19161913
Node *n = storestore_worklist.pop();
19171914
MemBarStoreStoreNode *storestore = n ->as_MemBarStoreStore();
19181915
Node *alloc = storestore->in(MemBarNode::Precedent)->in(0);
1919-
assert (alloc->is_Allocate(), "storestore should point to AllocateNode");
1920-
if (not_global_escape(alloc)) {
1916+
if (alloc->is_Allocate() && not_global_escape(alloc)) {
19211917
MemBarNode* mb = MemBarNode::make(C, Op_MemBarCPUOrder, Compile::AliasIdxBot);
19221918
mb->init_req(TypeFunc::Memory, storestore->in(TypeFunc::Memory));
19231919
mb->init_req(TypeFunc::Control, storestore->in(TypeFunc::Control));
@@ -2251,11 +2247,29 @@ bool FieldNode::has_base(JavaObjectNode* jobj) const {
22512247
}
22522248
#endif
22532249

2250+
bool ConnectionGraph::is_captured_store_address(Node* addp) {
2251+
// Handle simple case first.
2252+
assert(_igvn->type(addp)->isa_oopptr() == NULL, "should be raw access");
2253+
if (addp->in(AddPNode::Address)->is_Proj() && addp->in(AddPNode::Address)->in(0)->is_Allocate()) {
2254+
return true;
2255+
} else if (addp->in(AddPNode::Address)->is_Phi()) {
2256+
for (DUIterator_Fast imax, i = addp->fast_outs(imax); i < imax; i++) {
2257+
Node* addp_use = addp->fast_out(i);
2258+
if (addp_use->is_Store()) {
2259+
for (DUIterator_Fast jmax, j = addp_use->fast_outs(jmax); j < jmax; j++) {
2260+
if (addp_use->fast_out(j)->is_Initialize()) {
2261+
return true;
2262+
}
2263+
}
2264+
}
2265+
}
2266+
}
2267+
return false;
2268+
}
2269+
22542270
int ConnectionGraph::address_offset(Node* adr, PhaseTransform *phase) {
22552271
const Type *adr_type = phase->type(adr);
2256-
if (adr->is_AddP() && adr_type->isa_oopptr() == NULL &&
2257-
adr->in(AddPNode::Address)->is_Proj() &&
2258-
adr->in(AddPNode::Address)->in(0)->is_Allocate()) {
2272+
if (adr->is_AddP() && adr_type->isa_oopptr() == NULL && is_captured_store_address(adr)) {
22592273
// We are computing a raw address for a store captured by an Initialize
22602274
// compute an appropriate address type. AddP cases #3 and #5 (see below).
22612275
int offs = (int)phase->find_intptr_t_con(adr->in(AddPNode::Offset), Type::OffsetBot);
@@ -2358,7 +2372,7 @@ Node* ConnectionGraph::get_addp_base(Node *addp) {
23582372
assert(opcode == Op_ConP || opcode == Op_ThreadLocal ||
23592373
opcode == Op_CastX2P || uncast_base->is_DecodeNarrowPtr() ||
23602374
(uncast_base->is_Mem() && (uncast_base->bottom_type()->isa_rawptr() != NULL)) ||
2361-
(uncast_base->is_Proj() && uncast_base->in(0)->is_Allocate()), "sanity");
2375+
is_captured_store_address(addp), "sanity");
23622376
}
23632377
}
23642378
return base;
@@ -2974,7 +2988,10 @@ void ConnectionGraph::split_unique_types(GrowableArray<Node *> &alloc_worklist,
29742988
continue;
29752989
}
29762990
if (!n->is_CheckCastPP()) { // not unique CheckCastPP.
2977-
assert(!alloc->is_Allocate(), "allocation should have unique type");
2991+
// we could reach here for allocate case if one init is associated with many allocs.
2992+
if (alloc->is_Allocate()) {
2993+
alloc->as_Allocate()->_is_scalar_replaceable = false;
2994+
}
29782995
continue;
29792996
}
29802997

src/hotspot/share/opto/escape.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -512,6 +512,7 @@ class ConnectionGraph: public ResourceObj {
512512
// offset of a field reference
513513
int address_offset(Node* adr, PhaseTransform *phase);
514514

515+
bool is_captured_store_address(Node* addp);
515516

516517
// Propagate unique types created for unescaped allocated objects
517518
// through the graph

src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformEventType.java

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,34 @@ public final class PlatformEventType extends Type {
7575
this.stackTraceOffset = stackTraceOffset(name, isJDK);
7676
}
7777

78+
private static boolean isExceptionEvent(String name) {
79+
switch (name) {
80+
case Type.EVENT_NAME_PREFIX + "JavaErrorThrow" :
81+
case Type.EVENT_NAME_PREFIX + "JavaExceptionThrow" :
82+
return true;
83+
}
84+
return false;
85+
}
86+
87+
private static boolean isUsingHandler(String name) {
88+
switch (name) {
89+
case Type.EVENT_NAME_PREFIX + "SocketRead" :
90+
case Type.EVENT_NAME_PREFIX + "SocketWrite" :
91+
case Type.EVENT_NAME_PREFIX + "FileRead" :
92+
case Type.EVENT_NAME_PREFIX + "FileWrite" :
93+
case Type.EVENT_NAME_PREFIX + "FileForce" :
94+
return true;
95+
}
96+
return false;
97+
}
98+
7899
private static int stackTraceOffset(String name, boolean isJDK) {
79100
if (isJDK) {
80-
if (name.equals(Type.EVENT_NAME_PREFIX + "JavaExceptionThrow")) {
81-
return 5;
101+
if (isExceptionEvent(name)) {
102+
return 4;
82103
}
83-
if (name.equals(Type.EVENT_NAME_PREFIX + "JavaErrorThrow")) {
84-
return 5;
104+
if (isUsingHandler(name)) {
105+
return 3;
85106
}
86107
}
87108
return 4;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8242895
27+
* @summary full loop unroll before EA creates phis between allocs projs and init
28+
* @run main/othervm -Xbatch -XX:CompileCommand=dontinline,*DataA.m1 compiler.escapeAnalysis.TestIdealAllocShape
29+
*/
30+
31+
package compiler.escapeAnalysis;
32+
33+
public class TestIdealAllocShape {
34+
static volatile DataA f1;
35+
36+
static class DataA {
37+
DataA f1;
38+
DataA(DataA p1) {
39+
this.f1 = p1;
40+
}
41+
public void m1() {}
42+
}
43+
44+
public static DataA test1() {
45+
DataA l1 = new DataA(null);
46+
for (int i=0; i<2; i++) {
47+
try {
48+
return new DataA(l1); // l1 is a GlobalEscape. // control break.
49+
} catch (Exception e) {
50+
}
51+
}
52+
return null;
53+
}
54+
55+
public static DataA test2() {
56+
DataA l1 = new DataA(null);
57+
for (int i=0; i<2; i++) {
58+
try {
59+
f1 = new DataA(l1); // l1 is a GlobalEscape.
60+
break; // control break.
61+
} catch (Exception e) {
62+
}
63+
}
64+
synchronized(l1) { // elided sync
65+
l1.m1();
66+
}
67+
return null;
68+
}
69+
70+
public static void main(String argv[]) {
71+
72+
for (int i=0; i<20000; i++) {
73+
TestIdealAllocShape.test1();
74+
}
75+
76+
for (int i=0; i<20000; i++) {
77+
TestIdealAllocShape.test2();
78+
}
79+
}
80+
}

test/jdk/ProblemList.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ java/foreign/TestMismatch.java 8249684 macosx-all
570570
java/lang/StringCoding/CheckEncodings.sh 7008363 generic-all
571571
java/lang/ProcessHandle/InfoTest.java 8211847 aix-ppc64
572572
java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java 8151492 generic-all
573+
java/lang/invoke/LFCaching/LFGarbageCollectedTest.java 8078602 generic-all
573574

574575
############################################################################
575576

@@ -588,6 +589,7 @@ javax/management/monitor/DerivedGaugeMonitorTest.java 8042211 generic-al
588589
# jdk_io
589590

590591
java/io/pathNames/GeneralWin32.java 8180264 windows-all
592+
java/io/File/GetXSpace.java 6501010,8249703 windows-all,macosx-all
591593

592594
############################################################################
593595

test/jdk/java/io/File/GetXSpace.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
/**
2525
* @test
2626
* @bug 4057701 6286712 6364377
27-
* @ignore until 6492634 and 6501010 is fixed
2827
* @run build GetXSpace
2928
* @run shell GetXSpace.sh
3029
* @summary Basic functionality of File.get-X-Space methods.
@@ -135,7 +134,7 @@ private static ArrayList space(String f) throws IOException {
135134
ArrayList al = new ArrayList();
136135

137136
Process p = null;
138-
String cmd = "df -k" + (f == null ? "" : " " + f);
137+
String cmd = "df -k -P" + (f == null ? "" : " " + f);
139138
p = Runtime.getRuntime().exec(cmd);
140139
BufferedReader in = new BufferedReader
141140
(new InputStreamReader(p.getInputStream()));

test/jdk/java/io/File/GetXSpace.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# set platform-dependent variable
2727
OS=`uname -s`
2828
case "$OS" in
29-
Linux ) TMP=/tmp ;;
29+
Linux | Darwin ) TMP=/tmp ;;
3030
Windows_98 ) return ;;
3131
Windows* ) SID=`sid`; TMP="c:/temp" ;;
3232
* )
@@ -49,11 +49,11 @@ allow() {
4949
case "$OS" in
5050
Windows* ) chacl -g ${SID}:f $* ;;
5151
* ) chmod 777 $* ;;
52-
esac
52+
esac
5353
}
5454

5555
runTest() {
56-
${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES} GetXSpace $*
56+
${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTCLASSES} GetXSpace $*
5757
if [ $? -eq 0 ]
5858
then echo "Passed"
5959
else
@@ -64,17 +64,17 @@ runTest() {
6464

6565
# df output
6666
runTest
67-
67+
6868
# readable file in an unreadable directory
69-
mkdir ${TMP1}
69+
mkdir -p ${TMP1}
7070
touch ${TMP1}/foo
7171
deny ${TMP1}
7272
runTest ${TMP1}/foo
7373
allow ${TMP1}
7474
rm -rf ${TMP1}
7575

7676
if [ ${FAIL} -ne 0 ]
77-
then
77+
then
7878
echo ""
7979
echo "${FAIL} test(s) failed"
8080
exit 1

test/jdk/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
2626
* @bug 8046703
2727
* @key randomness
2828
* @library /lib/testlibrary /java/lang/invoke/common
29-
* @ignore 8078602
3029
* @summary Test verifies that lambda forms are garbage collected
3130
* @author kshefov
3231
* @build jdk.test.lib.TimeLimitedRunner

0 commit comments

Comments
 (0)