提交 4f23f9fc 编写于 作者: N never

6916644: C2 compiler crash on x86

Reviewed-by: kvn, twisti
上级 360cba23
/* /*
* 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. * 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
...@@ -1496,7 +1496,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { ...@@ -1496,7 +1496,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
unsigned i; unsigned i;
// Generate Expand function header // 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"); fprintf(fp,"Compile* C = Compile::current();\n");
// Generate expand code // Generate expand code
if( node->expands() ) { if( node->expands() ) {
...@@ -1546,15 +1546,16 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { ...@@ -1546,15 +1546,16 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
// Build a mapping from operand index to input edges // Build a mapping from operand index to input edges
fprintf(fp," unsigned idx0 = oper_input_base();\n"); 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 // strange. Store nodes get a memory input before Expand is
// called and all other nodes get it afterwards so // called and other nodes get it afterwards or before depending on
// oper_input_base is wrong during expansion. This code adjusts // match order so oper_input_base is wrong during expansion. This
// is so that expansion will work correctly. // code adjusts it so that expansion will work correctly.
bool missing_memory_edge = node->_matrule->needs_ideal_memory_edge(_globalNames) && int has_memory_edge = node->_matrule->needs_ideal_memory_edge(_globalNames);
node->is_ideal_store() == Form::none; if (has_memory_edge) {
if (missing_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," idx0--; // Adjust base because memory edge hasn't been inserted yet\n");
fprintf(fp," }\n");
} }
for( i = 0; i < node->num_opnds(); i++ ) { for( i = 0; i < node->num_opnds(); i++ ) {
...@@ -1611,9 +1612,11 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { ...@@ -1611,9 +1612,11 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
int node_mem_op = node->memory_operand(_globalNames); int node_mem_op = node->memory_operand(_globalNames);
assert( node_mem_op != InstructForm::NO_MEMORY_OPERAND, assert( node_mem_op != InstructForm::NO_MEMORY_OPERAND,
"expand rule member needs memory but top-level inst doesn't have any" ); "expand rule member needs memory but top-level inst doesn't have any" );
if (!missing_memory_edge) { if (has_memory_edge) {
// Copy 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 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { ...@@ -1689,7 +1692,7 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) {
} // done iterating over a new instruction's operands } // done iterating over a new instruction's operands
// Invoke Expand() for the newly created instruction. // 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"); assert( !new_inst->expands(), "Do not have complete support for recursive expansion");
} // done iterating over new instructions } // done iterating over new instructions
fprintf(fp,"\n"); fprintf(fp,"\n");
......
/* /*
* 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. * 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
...@@ -1754,7 +1754,7 @@ void ArchDesc::declareClasses(FILE *fp) { ...@@ -1754,7 +1754,7 @@ void ArchDesc::declareClasses(FILE *fp) {
instr->has_temps() || instr->has_temps() ||
instr->_matrule != NULL && instr->_matrule != NULL &&
instr->num_opnds() != instr->num_unique_opnds() ) { 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)) { if (instr->is_pinned(_globalNames)) {
......
/* /*
* 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. * 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
...@@ -232,7 +232,7 @@ public: ...@@ -232,7 +232,7 @@ public:
// Expand method for MachNode, replaces nodes representing pseudo // Expand method for MachNode, replaces nodes representing pseudo
// instructions with a set of nodes which represent real machine // instructions with a set of nodes which represent real machine
// instructions and compute the same value. // 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 // Bottom_type call; value comes from operand0
virtual const class Type *bottom_type() const { return _opnds[0]->type(); } virtual const class Type *bottom_type() const { return _opnds[0]->type(); }
......
/* /*
* 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. * 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
...@@ -1580,7 +1580,7 @@ MachNode *Matcher::ReduceInst( State *s, int rule, Node *&mem ) { ...@@ -1580,7 +1580,7 @@ MachNode *Matcher::ReduceInst( State *s, int rule, Node *&mem ) {
uint num_proj = _proj_list.size(); uint num_proj = _proj_list.size();
// Perform any 1-to-many expansions required // 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 ) { if( ex != mach ) {
assert(ex->ideal_reg() == mach->ideal_reg(), "ideal types should match"); assert(ex->ideal_reg() == mach->ideal_reg(), "ideal types should match");
if( ex->in(1)->is_Con() ) if( ex->in(1)->is_Con() )
......
/*
* 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);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册