--- a/hotspot/src/share/vm/adlc/output_c.cpp Fri Jan 29 09:27:22 2010 -0800
+++ b/hotspot/src/share/vm/adlc/output_c.cpp Fri Jan 29 22:51:41 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2010 Sun Microsystems, 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
@@ -1496,7 +1496,7 @@
unsigned i;
// Generate Expand function header
- fprintf(fp,"MachNode *%sNode::Expand(State *state, Node_List &proj_list) {\n", node->_ident);
+ fprintf(fp,"MachNode *%sNode::Expand(State *state, Node_List &proj_list, Node* mem) {\n", node->_ident);
fprintf(fp,"Compile* C = Compile::current();\n");
// Generate expand code
if( node->expands() ) {
@@ -1546,15 +1546,16 @@
// Build a mapping from operand index to input edges
fprintf(fp," unsigned idx0 = oper_input_base();\n");
- // The order in which inputs are added to a node is very
+ // The order in which the memory input is added to a node is very
// strange. Store nodes get a memory input before Expand is
- // called and all other nodes get it afterwards so
- // oper_input_base is wrong during expansion. This code adjusts
- // is so that expansion will work correctly.
- bool missing_memory_edge = node->_matrule->needs_ideal_memory_edge(_globalNames) &&
- node->is_ideal_store() == Form::none;
- if (missing_memory_edge) {
- fprintf(fp," idx0--; // Adjust base because memory edge hasn't been inserted yet\n");
+ // called and other nodes get it afterwards or before depending on
+ // match order so oper_input_base is wrong during expansion. This
+ // code adjusts it so that expansion will work correctly.
+ int has_memory_edge = node->_matrule->needs_ideal_memory_edge(_globalNames);
+ if (has_memory_edge) {
+ fprintf(fp," if (mem == (Node*)1) {\n");
+ fprintf(fp," idx0--; // Adjust base because memory edge hasn't been inserted yet\n");
+ fprintf(fp," }\n");
}
for( i = 0; i < node->num_opnds(); i++ ) {
@@ -1611,9 +1612,11 @@
int node_mem_op = node->memory_operand(_globalNames);
assert( node_mem_op != InstructForm::NO_MEMORY_OPERAND,
"expand rule member needs memory but top-level inst doesn't have any" );
- if (!missing_memory_edge) {
+ if (has_memory_edge) {
// Copy memory edge
- fprintf(fp," n%d->add_req(_in[1]);\t// Add memory edge\n", cnt);
+ fprintf(fp," if (mem != (Node*)1) {\n");
+ fprintf(fp," n%d->add_req(_in[1]);\t// Add memory edge\n", cnt);
+ fprintf(fp," }\n");
}
}
@@ -1689,7 +1692,7 @@
} // done iterating over a new instruction's operands
// Invoke Expand() for the newly created instruction.
- fprintf(fp," result = n%d->Expand( state, proj_list );\n", cnt);
+ fprintf(fp," result = n%d->Expand( state, proj_list, mem );\n", cnt);
assert( !new_inst->expands(), "Do not have complete support for recursive expansion");
} // done iterating over new instructions
fprintf(fp,"\n");
--- a/hotspot/src/share/vm/adlc/output_h.cpp Fri Jan 29 09:27:22 2010 -0800
+++ b/hotspot/src/share/vm/adlc/output_h.cpp Fri Jan 29 22:51:41 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1998-2010 Sun Microsystems, 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
@@ -1754,7 +1754,7 @@
instr->has_temps() ||
instr->_matrule != NULL &&
instr->num_opnds() != instr->num_unique_opnds() ) {
- fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list);\n");
+ fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n");
}
if (instr->is_pinned(_globalNames)) {
--- a/hotspot/src/share/vm/opto/machnode.hpp Fri Jan 29 09:27:22 2010 -0800
+++ b/hotspot/src/share/vm/opto/machnode.hpp Fri Jan 29 22:51:41 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, 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
@@ -232,7 +232,7 @@
// Expand method for MachNode, replaces nodes representing pseudo
// instructions with a set of nodes which represent real machine
// instructions and compute the same value.
- virtual MachNode *Expand( State *, Node_List &proj_list ) { return this; }
+ virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; }
// Bottom_type call; value comes from operand0
virtual const class Type *bottom_type() const { return _opnds[0]->type(); }
--- a/hotspot/src/share/vm/opto/matcher.cpp Fri Jan 29 09:27:22 2010 -0800
+++ b/hotspot/src/share/vm/opto/matcher.cpp Fri Jan 29 22:51:41 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 1997-2010 Sun Microsystems, 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
@@ -1580,7 +1580,7 @@
uint num_proj = _proj_list.size();
// Perform any 1-to-many expansions required
- MachNode *ex = mach->Expand(s,_proj_list);
+ MachNode *ex = mach->Expand(s,_proj_list, mem);
if( ex != mach ) {
assert(ex->ideal_reg() == mach->ideal_reg(), "ideal types should match");
if( ex->in(1)->is_Con() )
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/6916644/Test6916644.java Fri Jan 29 22:51:41 2010 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2010 Sun Microsystems, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ */
+
+/**
+ * @test
+ * @bug 6916644
+ * @summary C2 compiler crash on x86
+ *
+ * @run main/othervm -Xcomp -XX:CompileOnly=Test6916644.test Test6916644
+ */
+
+public class Test6916644 {
+ static int result;
+ static int i1;
+ static int i2;
+
+ static public void test(double d) {
+ result = (d <= 0.0D) ? i1 : i2;
+ }
+
+ public static void main(String[] args) {
+ for (int i = 0; i < 100000; i++) {
+ // use an alternating value so the test doesn't always go
+ // the same direction. Otherwise we won't transform it
+ // into a cmove.
+ test(i & 1);
+ }
+ }
+}