Thu, 25 Oct 2018 13:42:08 +0200
Merge
1.1 --- a/src/share/vm/classfile/verificationType.cpp Thu Oct 25 04:34:20 2018 -0700 1.2 +++ b/src/share/vm/classfile/verificationType.cpp Thu Oct 25 13:42:08 2018 +0200 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -99,7 +99,7 @@ 1.11 VerificationType comp_from = from.get_component(context, CHECK_false); 1.12 if (!comp_this.is_bogus() && !comp_from.is_bogus()) { 1.13 return comp_this.is_assignable_from(comp_from, context, 1.14 - from_field_is_protected, CHECK_false); 1.15 + from_field_is_protected, THREAD); 1.16 } 1.17 } 1.18 return false;
2.1 --- a/src/share/vm/opto/cfgnode.cpp Thu Oct 25 04:34:20 2018 -0700 2.2 +++ b/src/share/vm/opto/cfgnode.cpp Thu Oct 25 13:42:08 2018 +0200 2.3 @@ -2016,6 +2016,7 @@ 2.4 uint ideal_reg = _type->ideal_reg(); 2.5 assert( ideal_reg != Node::NotAMachineReg, "invalid type at Phi" ); 2.6 if( ideal_reg == 0 ) return RegMask::Empty; 2.7 + assert(ideal_reg != Op_RegFlags, "flags register is not spillable"); 2.8 return *(Compile::current()->matcher()->idealreg2spillmask[ideal_reg]); 2.9 } 2.10
3.1 --- a/src/share/vm/opto/coalesce.cpp Thu Oct 25 04:34:20 2018 -0700 3.2 +++ b/src/share/vm/opto/coalesce.cpp Thu Oct 25 13:42:08 2018 +0200 3.3 @@ -25,6 +25,7 @@ 3.4 #include "precompiled.hpp" 3.5 #include "memory/allocation.inline.hpp" 3.6 #include "opto/block.hpp" 3.7 +#include "opto/c2compiler.hpp" 3.8 #include "opto/cfgnode.hpp" 3.9 #include "opto/chaitin.hpp" 3.10 #include "opto/coalesce.hpp" 3.11 @@ -292,7 +293,18 @@ 3.12 // Copy any flags as well 3.13 _phc.clone_projs(pred, pred->end_idx(), m, copy, _phc._lrg_map); 3.14 } else { 3.15 - const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()]; 3.16 + int ireg = m->ideal_reg(); 3.17 + if (ireg == 0 || ireg == Op_RegFlags) { 3.18 + if (C->subsume_loads()) { 3.19 + C->record_failure(C2Compiler::retry_no_subsuming_loads()); 3.20 + } else { 3.21 + assert(false, err_msg("attempted to spill a non-spillable item: %d: %s, ireg = %d", 3.22 + m->_idx, m->Name(), ireg)); 3.23 + C->record_method_not_compilable("attempted to spill a non-spillable item"); 3.24 + } 3.25 + return; 3.26 + } 3.27 + const RegMask *rm = C->matcher()->idealreg2spillmask[ireg]; 3.28 copy = new (C) MachSpillCopyNode(m, *rm, *rm); 3.29 // Find a good place to insert. Kinda tricky, use a subroutine 3.30 insert_copy_with_overlap(pred,copy,phi_name,src_name); 3.31 @@ -326,7 +338,14 @@ 3.32 b->insert_node(copy, l++); 3.33 l += _phc.clone_projs(b, l, m, copy, _phc._lrg_map); 3.34 } else { 3.35 - const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()]; 3.36 + int ireg = m->ideal_reg(); 3.37 + if (ireg == 0 || ireg == Op_RegFlags) { 3.38 + assert(false, err_msg("attempted to spill a non-spillable item: %d: %s, ireg = %d", 3.39 + m->_idx, m->Name(), ireg)); 3.40 + C->record_method_not_compilable("attempted to spill a non-spillable item"); 3.41 + return; 3.42 + } 3.43 + const RegMask *rm = C->matcher()->idealreg2spillmask[ireg]; 3.44 copy = new (C) MachSpillCopyNode(m, *rm, *rm); 3.45 // Insert the copy in the basic block, just before us 3.46 b->insert_node(copy, l++); 3.47 @@ -373,7 +392,14 @@ 3.48 if( k < b->_num_succs ) 3.49 continue; // Live out; do not pre-split 3.50 // Split the lrg at this use 3.51 - const RegMask *rm = C->matcher()->idealreg2spillmask[inp->ideal_reg()]; 3.52 + int ireg = inp->ideal_reg(); 3.53 + if (ireg == 0 || ireg == Op_RegFlags) { 3.54 + assert(false, err_msg("attempted to spill a non-spillable item: %d: %s, ireg = %d", 3.55 + inp->_idx, inp->Name(), ireg)); 3.56 + C->record_method_not_compilable("attempted to spill a non-spillable item"); 3.57 + return; 3.58 + } 3.59 + const RegMask *rm = C->matcher()->idealreg2spillmask[ireg]; 3.60 Node *copy = new (C) MachSpillCopyNode( inp, *rm, *rm ); 3.61 // Insert the copy in the use-def chain 3.62 n->set_req(inpidx, copy );
4.1 --- a/src/share/vm/opto/machnode.cpp Thu Oct 25 04:34:20 2018 -0700 4.2 +++ b/src/share/vm/opto/machnode.cpp Thu Oct 25 13:42:08 2018 +0200 4.3 @@ -619,6 +619,7 @@ 4.4 } 4.5 4.6 // Values outside the domain represent debug info 4.7 + assert(in(idx)->ideal_reg() != Op_RegFlags, "flags register is not spillable"); 4.8 return *Compile::current()->matcher()->idealreg2spillmask[in(idx)->ideal_reg()]; 4.9 } 4.10
5.1 --- a/src/share/vm/opto/matcher.cpp Thu Oct 25 04:34:20 2018 -0700 5.2 +++ b/src/share/vm/opto/matcher.cpp Thu Oct 25 13:42:08 2018 +0200 5.3 @@ -95,6 +95,7 @@ 5.4 idealreg2spillmask [Op_VecD] = NULL; 5.5 idealreg2spillmask [Op_VecX] = NULL; 5.6 idealreg2spillmask [Op_VecY] = NULL; 5.7 + idealreg2spillmask [Op_RegFlags] = NULL; 5.8 5.9 idealreg2debugmask [Op_RegI] = NULL; 5.10 idealreg2debugmask [Op_RegN] = NULL; 5.11 @@ -106,6 +107,7 @@ 5.12 idealreg2debugmask [Op_VecD] = NULL; 5.13 idealreg2debugmask [Op_VecX] = NULL; 5.14 idealreg2debugmask [Op_VecY] = NULL; 5.15 + idealreg2debugmask [Op_RegFlags] = NULL; 5.16 5.17 idealreg2mhdebugmask[Op_RegI] = NULL; 5.18 idealreg2mhdebugmask[Op_RegN] = NULL; 5.19 @@ -117,6 +119,7 @@ 5.20 idealreg2mhdebugmask[Op_VecD] = NULL; 5.21 idealreg2mhdebugmask[Op_VecX] = NULL; 5.22 idealreg2mhdebugmask[Op_VecY] = NULL; 5.23 + idealreg2mhdebugmask[Op_RegFlags] = NULL; 5.24 5.25 debug_only(_mem_node = NULL;) // Ideal memory node consumed by mach node 5.26 }
6.1 --- a/src/share/vm/utilities/exceptions.hpp Thu Oct 25 04:34:20 2018 -0700 6.2 +++ b/src/share/vm/utilities/exceptions.hpp Thu Oct 25 13:42:08 2018 +0200 6.3 @@ -201,7 +201,7 @@ 6.4 // 6.5 // CAUTION: make sure that the function call using a CHECK macro is not the only statement of a 6.6 // conditional branch w/o enclosing {} braces, since the CHECK macros expand into several state- 6.7 -// ments! 6.8 +// ments! Also make sure it is not used on a function call that is part of a return statement! 6.9 6.10 #define PENDING_EXCEPTION (((ThreadShadow*)THREAD)->pending_exception()) 6.11 #define HAS_PENDING_EXCEPTION (((ThreadShadow*)THREAD)->has_pending_exception())
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/compiler/c2/SubsumingLoadsCauseFlagSpill.java Thu Oct 25 13:42:08 2018 +0200 7.3 @@ -0,0 +1,72 @@ 7.4 +/* 7.5 + * Copyright (c) 2018, Red Hat, Inc. All rights reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7.23 + * or visit www.oracle.com if you need additional information or have any 7.24 + * questions. 7.25 + */ 7.26 + 7.27 +/** 7.28 + * @test 7.29 + * @bug 8209639 7.30 + * @summary assert failure in coalesce.cpp: attempted to spill a non-spillable item 7.31 + * 7.32 + * @run main/othervm -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,SubsumingLoadsCauseFlagSpill::not_inlined -Xmx1024m SubsumingLoadsCauseFlagSpill 7.33 + * 7.34 + */ 7.35 + 7.36 +public class SubsumingLoadsCauseFlagSpill { 7.37 + private static Object field; 7.38 + private static boolean do_throw; 7.39 + private static volatile boolean barrier; 7.40 + 7.41 + public static void main(String[] args) { 7.42 + for (int i = 0; i < 20_000; i++) { 7.43 + do_throw = true; 7.44 + field = null; 7.45 + test(0); 7.46 + do_throw = false; 7.47 + field = new Object(); 7.48 + test(0); 7.49 + } 7.50 + } 7.51 + 7.52 + private static float test(float f) { 7.53 + Object v = null; 7.54 + try { 7.55 + not_inlined(); 7.56 + v = field; 7.57 + } catch (MyException me) { 7.58 + v = field; 7.59 + barrier = true; 7.60 + } 7.61 + if (v == null) { 7.62 + return f * f; 7.63 + } 7.64 + return f; 7.65 + } 7.66 + 7.67 + private static void not_inlined() throws MyException{ 7.68 + if (do_throw) { 7.69 + throw new MyException(); 7.70 + } 7.71 + } 7.72 + 7.73 + private static class MyException extends Throwable { 7.74 + } 7.75 +}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/compiler/gcbarriers/TestMembarDependencies.java Thu Oct 25 13:42:08 2018 +0200 8.3 @@ -0,0 +1,98 @@ 8.4 +/* 8.5 + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 + * 8.8 + * This code is free software; you can redistribute it and/or modify it 8.9 + * under the terms of the GNU General Public License version 2 only, as 8.10 + * published by the Free Software Foundation. 8.11 + * 8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 + * version 2 for more details (a copy is included in the LICENSE file that 8.16 + * accompanied this code). 8.17 + * 8.18 + * You should have received a copy of the GNU General Public License version 8.19 + * 2 along with this work; if not, write to the Free Software Foundation, 8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 + * 8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 + * or visit www.oracle.com if you need additional information or have any 8.24 + * questions. 8.25 + */ 8.26 + 8.27 +/* 8.28 + * @test TestMembarDependencies 8.29 + * @bug 8172850 8.30 + * @summary Tests correct scheduling of memory loads around MembarVolatile emitted by GC barriers. 8.31 + * @library /testlibrary 8.32 + * @run driver compiler.membars.TestMembarDependencies 8.33 + */ 8.34 + 8.35 +package compiler.membars; 8.36 + 8.37 +import com.oracle.java.testlibrary.*; 8.38 + 8.39 +public class TestMembarDependencies { 8.40 + private static TestMembarDependencies f1; 8.41 + private static TestMembarDependencies f2; 8.42 + 8.43 + public static void main(String args[]) throws Throwable { 8.44 + if (args.length == 0) { 8.45 + // For debugging, add "-XX:+TraceOptoPipelining" 8.46 + OutputAnalyzer oa = ProcessTools.executeTestJvm("-XX:+IgnoreUnrecognizedVMOptions", 8.47 + "-XX:-TieredCompilation", "-XX:-BackgroundCompilation", "-XX:+PrintOpto", 8.48 + "-XX:CompileCommand=compileonly,compiler.membars.TestMembarDependencies::test*", 8.49 + "-XX:CompileCommand=dontinline,compiler.membars.TestMembarDependencies::test_m1", 8.50 + TestMembarDependencies.class.getName(), "run"); 8.51 + // C2 should not crash or bail out from compilation 8.52 + oa.shouldHaveExitValue(0); 8.53 + oa.shouldNotMatch("Bailout: Recompile without subsuming loads"); 8.54 + System.out.println(oa.getOutput()); 8.55 + } else { 8.56 + f2 = new TestMembarDependencies(); 8.57 + // Trigger compilation of test1 and test2 8.58 + for (int i = 0; i < 10_000; ++i) { 8.59 + f2.test1(f2); 8.60 + f2.test2(f2); 8.61 + } 8.62 + } 8.63 + } 8.64 + 8.65 + public void test_m1() { } 8.66 + public void test_m2() { } 8.67 + 8.68 + public void test1(TestMembarDependencies obj) { 8.69 + // Try/catch/finally is used to create a CFG block without a test + jmpCon 8.70 + // allowing GCM to schedule the testN_mem_reg0 instruction into that block. 8.71 + try { 8.72 + // Method call defines memory state that is then 8.73 + // used by subsequent instructions/blocks (see below). 8.74 + test_m1(); 8.75 + } catch (Exception e) { 8.76 + 8.77 + } finally { 8.78 + // Oop write to field emits a GC post-barrier with a MembarVolatile 8.79 + // which has a wide memory effect (kills all memory). This creates an 8.80 + // anti-dependency on all surrounding memory loads. 8.81 + f1 = obj; 8.82 + } 8.83 + // The empty method m2 is inlined but the null check of f2 remains. It is encoded 8.84 + // as CmpN(LoadN(MEM), NULL) where MEM is the memory after the call to test_m1(). 8.85 + // This is matched to testN_mem_reg0 on x86 which is scheduled before the barrier 8.86 + // in the try/catch block due to the anti-dependency on the MembarVolatile. 8.87 + // C2 crashes in the register allocator when trying to spill the flag register 8.88 + // to keep the result of the testN instruction live from the try/catch block 8.89 + // until it is here. 8.90 + f2.test_m2(); 8.91 + } 8.92 + 8.93 + public void test2(TestMembarDependencies obj) { 8.94 + // Same as test1 but without try/catch/finally. 8.95 + // This causes C2 to bail out in block local scheduling because testN_mem_reg0 is 8.96 + // scheduled into a block that already contains another test + jmpCon instruction. 8.97 + test_m1(); 8.98 + f1 = obj; 8.99 + f2.test_m2(); 8.100 + } 8.101 +}