1.1 --- a/src/share/vm/adlc/output_c.cpp Tue Oct 21 11:23:52 2008 -0700 1.2 +++ b/src/share/vm/adlc/output_c.cpp Tue Oct 28 09:31:30 2008 -0700 1.3 @@ -1619,6 +1619,7 @@ 1.4 } 1.5 1.6 // Iterate over the new instruction's operands 1.7 + int prev_pos = -1; 1.8 for( expand_instr->reset(); (opid = expand_instr->iter()) != NULL; ) { 1.9 // Use 'parameter' at current position in list of new instruction's formals 1.10 // instead of 'opid' when looking up info internal to new_inst 1.11 @@ -1642,6 +1643,18 @@ 1.12 // ins = (InstructForm *) _globalNames[new_id]; 1.13 exp_pos = node->operand_position_format(opid); 1.14 assert(exp_pos != -1, "Bad expand rule"); 1.15 + if (prev_pos > exp_pos && expand_instruction->_matrule != NULL) { 1.16 + // For the add_req calls below to work correctly they need 1.17 + // to added in the same order that a match would add them. 1.18 + // This means that they would need to be in the order of 1.19 + // the components list instead of the formal parameters. 1.20 + // This is a sort of hidden invariant that previously 1.21 + // wasn't checked and could lead to incorrectly 1.22 + // constructed nodes. 1.23 + syntax_err(node->_linenum, "For expand in %s to work, parameter declaration order in %s must follow matchrule\n", 1.24 + node->_ident, new_inst->_ident); 1.25 + } 1.26 + prev_pos = exp_pos; 1.27 1.28 new_pos = new_inst->operand_position(parameter,Component::USE); 1.29 if (new_pos != -1) { 1.30 @@ -2306,7 +2319,12 @@ 1.31 _processing_noninput = false; 1.32 // A replacement variable, originally '$' 1.33 if ( Opcode::as_opcode_type(rep_var) != Opcode::NOT_AN_OPCODE ) { 1.34 - _inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(rep_var) ); 1.35 + if (!_inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(rep_var) )) { 1.36 + // Missing opcode 1.37 + _AD.syntax_err( _inst._linenum, 1.38 + "Missing $%s opcode definition in %s, used by encoding %s\n", 1.39 + rep_var, _inst._ident, _encoding._name); 1.40 + } 1.41 } 1.42 else { 1.43 // Lookup its position in parameter list 1.44 @@ -2348,7 +2366,13 @@ 1.45 else if( Opcode::as_opcode_type(inst_rep_var) != Opcode::NOT_AN_OPCODE ) { 1.46 // else check if "primary", "secondary", "tertiary" 1.47 assert( _constant_status == LITERAL_ACCESSED, "Must be processing a literal constant parameter"); 1.48 - _inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(inst_rep_var) ); 1.49 + if (!_inst._opcode->print_opcode(_fp, Opcode::as_opcode_type(inst_rep_var) )) { 1.50 + // Missing opcode 1.51 + _AD.syntax_err( _inst._linenum, 1.52 + "Missing $%s opcode definition in %s\n", 1.53 + rep_var, _inst._ident); 1.54 + 1.55 + } 1.56 _constant_status = LITERAL_OUTPUT; 1.57 } 1.58 else if((_AD.get_registers() != NULL ) && (_AD.get_registers()->getRegDef(inst_rep_var) != NULL)) {