1.1 --- a/src/share/vm/c1/c1_Instruction.cpp Wed Mar 20 17:04:45 2013 -0700 1.2 +++ b/src/share/vm/c1/c1_Instruction.cpp Thu Mar 21 09:27:54 2013 +0100 1.3 @@ -34,6 +34,15 @@ 1.4 // Implementation of Instruction 1.5 1.6 1.7 +int Instruction::dominator_depth() { 1.8 + int result = -1; 1.9 + if (block()) { 1.10 + result = block()->dominator_depth(); 1.11 + } 1.12 + assert(result != -1 || this->as_Local(), "Only locals have dominator depth -1"); 1.13 + return result; 1.14 +} 1.15 + 1.16 Instruction::Condition Instruction::mirror(Condition cond) { 1.17 switch (cond) { 1.18 case eql: return eql; 1.19 @@ -42,6 +51,8 @@ 1.20 case leq: return geq; 1.21 case gtr: return lss; 1.22 case geq: return leq; 1.23 + case aeq: return beq; 1.24 + case beq: return aeq; 1.25 } 1.26 ShouldNotReachHere(); 1.27 return eql; 1.28 @@ -56,6 +67,8 @@ 1.29 case leq: return gtr; 1.30 case gtr: return leq; 1.31 case geq: return lss; 1.32 + case aeq: assert(false, "Above equal cannot be negated"); 1.33 + case beq: assert(false, "Below equal cannot be negated"); 1.34 } 1.35 ShouldNotReachHere(); 1.36 return eql; 1.37 @@ -70,10 +83,10 @@ 1.38 } 1.39 } 1.40 1.41 - 1.42 -Instruction* Instruction::prev(BlockBegin* block) { 1.43 +// Prev without need to have BlockBegin 1.44 +Instruction* Instruction::prev() { 1.45 Instruction* p = NULL; 1.46 - Instruction* q = block; 1.47 + Instruction* q = block(); 1.48 while (q != this) { 1.49 assert(q != NULL, "this is not in the block's instruction list"); 1.50 p = q; q = q->next(); 1.51 @@ -122,15 +135,24 @@ 1.52 1.53 // perform constant and interval tests on index value 1.54 bool AccessIndexed::compute_needs_range_check() { 1.55 - Constant* clength = length()->as_Constant(); 1.56 - Constant* cindex = index()->as_Constant(); 1.57 - if (clength && cindex) { 1.58 - IntConstant* l = clength->type()->as_IntConstant(); 1.59 - IntConstant* i = cindex->type()->as_IntConstant(); 1.60 - if (l && i && i->value() < l->value() && i->value() >= 0) { 1.61 - return false; 1.62 + 1.63 + if (length()) { 1.64 + 1.65 + Constant* clength = length()->as_Constant(); 1.66 + Constant* cindex = index()->as_Constant(); 1.67 + if (clength && cindex) { 1.68 + IntConstant* l = clength->type()->as_IntConstant(); 1.69 + IntConstant* i = cindex->type()->as_IntConstant(); 1.70 + if (l && i && i->value() < l->value() && i->value() >= 0) { 1.71 + return false; 1.72 + } 1.73 } 1.74 } 1.75 + 1.76 + if (!this->check_flag(NeedsRangeCheckFlag)) { 1.77 + return false; 1.78 + } 1.79 + 1.80 return true; 1.81 } 1.82 1.83 @@ -631,19 +653,25 @@ 1.84 // of the inserted block, without recomputing the values of the other blocks 1.85 // in the CFG. Therefore the value of "depth_first_number" in BlockBegin becomes meaningless. 1.86 BlockBegin* BlockBegin::insert_block_between(BlockBegin* sux) { 1.87 - BlockBegin* new_sux = new BlockBegin(end()->state()->bci()); 1.88 + int bci = sux->bci(); 1.89 + // critical edge splitting may introduce a goto after a if and array 1.90 + // bound check elimination may insert a predicate between the if and 1.91 + // goto. The bci of the goto can't be the one of the if otherwise 1.92 + // the state and bci are inconsistent and a deoptimization triggered 1.93 + // by the predicate would lead to incorrect execution/a crash. 1.94 + BlockBegin* new_sux = new BlockBegin(bci); 1.95 1.96 // mark this block (special treatment when block order is computed) 1.97 new_sux->set(critical_edge_split_flag); 1.98 1.99 // This goto is not a safepoint. 1.100 Goto* e = new Goto(sux, false); 1.101 - new_sux->set_next(e, end()->state()->bci()); 1.102 + new_sux->set_next(e, bci); 1.103 new_sux->set_end(e); 1.104 // setup states 1.105 ValueStack* s = end()->state(); 1.106 - new_sux->set_state(s->copy()); 1.107 - e->set_state(s->copy()); 1.108 + new_sux->set_state(s->copy(s->kind(), bci)); 1.109 + e->set_state(s->copy(s->kind(), bci)); 1.110 assert(new_sux->state()->locals_size() == s->locals_size(), "local size mismatch!"); 1.111 assert(new_sux->state()->stack_size() == s->stack_size(), "stack size mismatch!"); 1.112 assert(new_sux->state()->locks_size() == s->locks_size(), "locks size mismatch!"); 1.113 @@ -960,15 +988,14 @@ 1.114 BlockList* sux = NULL; 1.115 if (begin != NULL) { 1.116 sux = begin->successors(); 1.117 - } else if (_begin != NULL) { 1.118 + } else if (this->begin() != NULL) { 1.119 // copy our sux list 1.120 - BlockList* sux = new BlockList(_begin->number_of_sux()); 1.121 - for (int i = 0; i < _begin->number_of_sux(); i++) { 1.122 - sux->append(_begin->sux_at(i)); 1.123 + BlockList* sux = new BlockList(this->begin()->number_of_sux()); 1.124 + for (int i = 0; i < this->begin()->number_of_sux(); i++) { 1.125 + sux->append(this->begin()->sux_at(i)); 1.126 } 1.127 } 1.128 _sux = sux; 1.129 - _begin = begin; 1.130 } 1.131 1.132 1.133 @@ -1008,7 +1035,38 @@ 1.134 } 1.135 } 1.136 1.137 +#ifdef ASSERT 1.138 +// Constructor of Assert 1.139 +Assert::Assert(Value x, Condition cond, bool unordered_is_true, Value y) : Instruction(illegalType) 1.140 + , _x(x) 1.141 + , _cond(cond) 1.142 + , _y(y) 1.143 +{ 1.144 + set_flag(UnorderedIsTrueFlag, unordered_is_true); 1.145 + assert(x->type()->tag() == y->type()->tag(), "types must match"); 1.146 + pin(); 1.147 1.148 + stringStream strStream; 1.149 + Compilation::current()->method()->print_name(&strStream); 1.150 + 1.151 + stringStream strStream1; 1.152 + InstructionPrinter ip1(1, &strStream1); 1.153 + ip1.print_instr(x); 1.154 + 1.155 + stringStream strStream2; 1.156 + InstructionPrinter ip2(1, &strStream2); 1.157 + ip2.print_instr(y); 1.158 + 1.159 + stringStream ss; 1.160 + ss.print("Assertion %s %s %s in method %s", strStream1.as_string(), ip2.cond_name(cond), strStream2.as_string(), strStream.as_string()); 1.161 + 1.162 + _message = ss.as_string(); 1.163 +} 1.164 +#endif 1.165 + 1.166 +void RangeCheckPredicate::check_state() { 1.167 + assert(state()->kind() != ValueStack::EmptyExceptionState && state()->kind() != ValueStack::ExceptionState, "will deopt with empty state"); 1.168 +} 1.169 1.170 void ProfileInvoke::state_values_do(ValueVisitor* f) { 1.171 if (state() != NULL) state()->values_do(f);