src/share/vm/c1/c1_Instruction.cpp

changeset 2174
f02a8bbe6ed4
parent 2138
d5d065957597
child 2254
42a10fc37986
     1.1 --- a/src/share/vm/c1/c1_Instruction.cpp	Wed Sep 22 23:51:03 2010 -0700
     1.2 +++ b/src/share/vm/c1/c1_Instruction.cpp	Tue Dec 29 19:08:54 2009 +0100
     1.3 @@ -29,13 +29,6 @@
     1.4  // Implementation of Instruction
     1.5  
     1.6  
     1.7 -#ifdef ASSERT
     1.8 -void Instruction::create_hi_word() {
     1.9 -  assert(type()->is_double_word() && _hi_word == NULL, "only double word has high word");
    1.10 -  _hi_word = new HiWord(this);
    1.11 -}
    1.12 -#endif
    1.13 -
    1.14  Instruction::Condition Instruction::mirror(Condition cond) {
    1.15    switch (cond) {
    1.16      case eql: return eql;
    1.17 @@ -63,6 +56,15 @@
    1.18    return eql;
    1.19  }
    1.20  
    1.21 +void Instruction::update_exception_state(ValueStack* state) {
    1.22 +  if (state != NULL && (state->kind() == ValueStack::EmptyExceptionState || state->kind() == ValueStack::ExceptionState)) {
    1.23 +    assert(state->kind() == ValueStack::EmptyExceptionState || Compilation::current()->env()->jvmti_can_access_local_variables(), "unexpected state kind");
    1.24 +    _exception_state = state;
    1.25 +  } else {
    1.26 +    _exception_state = NULL;
    1.27 +  }
    1.28 +}
    1.29 +
    1.30  
    1.31  Instruction* Instruction::prev(BlockBegin* block) {
    1.32    Instruction* p = NULL;
    1.33 @@ -75,7 +77,24 @@
    1.34  }
    1.35  
    1.36  
    1.37 +void Instruction::state_values_do(ValueVisitor* f) {
    1.38 +  if (state_before() != NULL) {
    1.39 +    state_before()->values_do(f);
    1.40 +  }
    1.41 +  if (exception_state() != NULL){
    1.42 +    exception_state()->values_do(f);
    1.43 +  }
    1.44 +}
    1.45 +
    1.46 +
    1.47  #ifndef PRODUCT
    1.48 +void Instruction::check_state(ValueStack* state) {
    1.49 +  if (state != NULL) {
    1.50 +    state->verify();
    1.51 +  }
    1.52 +}
    1.53 +
    1.54 +
    1.55  void Instruction::print() {
    1.56    InstructionPrinter ip;
    1.57    print(ip);
    1.58 @@ -190,35 +209,6 @@
    1.59    return NULL;
    1.60  }
    1.61  
    1.62 -
    1.63 -void ArithmeticOp::other_values_do(ValueVisitor* f) {
    1.64 -  if (lock_stack() != NULL) lock_stack()->values_do(f);
    1.65 -}
    1.66 -
    1.67 -void NullCheck::other_values_do(ValueVisitor* f) {
    1.68 -  lock_stack()->values_do(f);
    1.69 -}
    1.70 -
    1.71 -void AccessArray::other_values_do(ValueVisitor* f) {
    1.72 -  if (lock_stack() != NULL) lock_stack()->values_do(f);
    1.73 -}
    1.74 -
    1.75 -
    1.76 -// Implementation of AccessField
    1.77 -
    1.78 -void AccessField::other_values_do(ValueVisitor* f) {
    1.79 -  if (state_before() != NULL) state_before()->values_do(f);
    1.80 -  if (lock_stack() != NULL) lock_stack()->values_do(f);
    1.81 -}
    1.82 -
    1.83 -
    1.84 -// Implementation of StoreIndexed
    1.85 -
    1.86 -IRScope* StoreIndexed::scope() const {
    1.87 -  return lock_stack()->scope();
    1.88 -}
    1.89 -
    1.90 -
    1.91  // Implementation of ArithmeticOp
    1.92  
    1.93  bool ArithmeticOp::is_commutative() const {
    1.94 @@ -266,13 +256,6 @@
    1.95  }
    1.96  
    1.97  
    1.98 -// Implementation of CompareOp
    1.99 -
   1.100 -void CompareOp::other_values_do(ValueVisitor* f) {
   1.101 -  if (state_before() != NULL) state_before()->values_do(f);
   1.102 -}
   1.103 -
   1.104 -
   1.105  // Implementation of IfOp
   1.106  
   1.107  bool IfOp::is_commutative() const {
   1.108 @@ -301,6 +284,7 @@
   1.109  
   1.110  
   1.111  void StateSplit::state_values_do(ValueVisitor* f) {
   1.112 +  Instruction::state_values_do(f);
   1.113    if (state() != NULL) state()->values_do(f);
   1.114  }
   1.115  
   1.116 @@ -316,30 +300,17 @@
   1.117  }
   1.118  
   1.119  
   1.120 -void MonitorEnter::state_values_do(ValueVisitor* f) {
   1.121 -  StateSplit::state_values_do(f);
   1.122 -  _lock_stack_before->values_do(f);
   1.123 -}
   1.124 -
   1.125 -
   1.126 -void Intrinsic::state_values_do(ValueVisitor* f) {
   1.127 -  StateSplit::state_values_do(f);
   1.128 -  if (lock_stack() != NULL) lock_stack()->values_do(f);
   1.129 -}
   1.130 -
   1.131 -
   1.132  // Implementation of Invoke
   1.133  
   1.134  
   1.135  Invoke::Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
   1.136                 int vtable_index, ciMethod* target, ValueStack* state_before)
   1.137 -  : StateSplit(result_type)
   1.138 +  : StateSplit(result_type, state_before)
   1.139    , _code(code)
   1.140    , _recv(recv)
   1.141    , _args(args)
   1.142    , _vtable_index(vtable_index)
   1.143    , _target(target)
   1.144 -  , _state_before(state_before)
   1.145  {
   1.146    set_flag(TargetIsLoadedFlag,   target->is_loaded());
   1.147    set_flag(TargetIsFinalFlag,    target_is_loaded() && target->is_final_method());
   1.148 @@ -376,7 +347,7 @@
   1.149  
   1.150  // Implementation of Contant
   1.151  intx Constant::hash() const {
   1.152 -  if (_state == NULL) {
   1.153 +  if (state_before() == NULL) {
   1.154      switch (type()->tag()) {
   1.155      case intTag:
   1.156        return HASH2(name(), type()->as_IntConstant()->value());
   1.157 @@ -499,25 +470,6 @@
   1.158  }
   1.159  
   1.160  
   1.161 -void Constant::other_values_do(ValueVisitor* f) {
   1.162 -  if (state() != NULL) state()->values_do(f);
   1.163 -}
   1.164 -
   1.165 -
   1.166 -// Implementation of NewArray
   1.167 -
   1.168 -void NewArray::other_values_do(ValueVisitor* f) {
   1.169 -  if (state_before() != NULL) state_before()->values_do(f);
   1.170 -}
   1.171 -
   1.172 -
   1.173 -// Implementation of TypeCheck
   1.174 -
   1.175 -void TypeCheck::other_values_do(ValueVisitor* f) {
   1.176 -  if (state_before() != NULL) state_before()->values_do(f);
   1.177 -}
   1.178 -
   1.179 -
   1.180  // Implementation of BlockBegin
   1.181  
   1.182  void BlockBegin::set_end(BlockEnd* end) {
   1.183 @@ -604,23 +556,14 @@
   1.184  // of the inserted block, without recomputing the values of the other blocks
   1.185  // in the CFG. Therefore the value of "depth_first_number" in BlockBegin becomes meaningless.
   1.186  BlockBegin* BlockBegin::insert_block_between(BlockBegin* sux) {
   1.187 -  // Try to make the bci close to a block with a single pred or sux,
   1.188 -  // since this make the block layout algorithm work better.
   1.189 -  int bci = -1;
   1.190 -  if (sux->number_of_preds() == 1) {
   1.191 -    bci = sux->bci();
   1.192 -  } else {
   1.193 -    bci = end()->bci();
   1.194 -  }
   1.195 -
   1.196 -  BlockBegin* new_sux = new BlockBegin(bci);
   1.197 +  BlockBegin* new_sux = new BlockBegin(-99);
   1.198  
   1.199    // mark this block (special treatment when block order is computed)
   1.200    new_sux->set(critical_edge_split_flag);
   1.201  
   1.202    // This goto is not a safepoint.
   1.203    Goto* e = new Goto(sux, false);
   1.204 -  new_sux->set_next(e, bci);
   1.205 +  new_sux->set_next(e, end()->state()->bci());
   1.206    new_sux->set_end(e);
   1.207    // setup states
   1.208    ValueStack* s = end()->state();
   1.209 @@ -763,7 +706,7 @@
   1.210      }
   1.211  
   1.212      // copy state because it is altered
   1.213 -    new_state = new_state->copy();
   1.214 +    new_state = new_state->copy(ValueStack::BlockBeginState, bci());
   1.215  
   1.216      // Use method liveness to invalidate dead locals
   1.217      MethodLivenessResult liveness = new_state->scope()->method()->liveness_at_bci(bci());
   1.218 @@ -800,19 +743,9 @@
   1.219      // initialize state of block
   1.220      set_state(new_state);
   1.221  
   1.222 -  } else if (existing_state->is_same_across_scopes(new_state)) {
   1.223 +  } else if (existing_state->is_same(new_state)) {
   1.224      TRACE_PHI(tty->print_cr("exisiting state found"));
   1.225  
   1.226 -    // Inlining may cause the local state not to match up, so walk up
   1.227 -    // the new state until we get to the same scope as the
   1.228 -    // existing and then start processing from there.
   1.229 -    while (existing_state->scope() != new_state->scope()) {
   1.230 -      new_state = new_state->caller_state();
   1.231 -      assert(new_state != NULL, "could not match up scopes");
   1.232 -
   1.233 -      assert(false, "check if this is necessary");
   1.234 -    }
   1.235 -
   1.236      assert(existing_state->scope() == new_state->scope(), "not matching");
   1.237      assert(existing_state->locals_size() == new_state->locals_size(), "not matching");
   1.238      assert(existing_state->stack_size() == new_state->stack_size(), "not matching");
   1.239 @@ -969,11 +902,6 @@
   1.240  }
   1.241  
   1.242  
   1.243 -void BlockEnd::other_values_do(ValueVisitor* f) {
   1.244 -  if (state_before() != NULL) state_before()->values_do(f);
   1.245 -}
   1.246 -
   1.247 -
   1.248  // Implementation of Phi
   1.249  
   1.250  // Normal phi functions take their operands from the last instruction of the
   1.251 @@ -1006,11 +934,6 @@
   1.252  }
   1.253  
   1.254  
   1.255 -// Implementation of Throw
   1.256 -
   1.257 -void Throw::state_values_do(ValueVisitor* f) {
   1.258 -  BlockEnd::state_values_do(f);
   1.259 -}
   1.260  
   1.261  void ProfileInvoke::state_values_do(ValueVisitor* f) {
   1.262    if (state() != NULL) state()->values_do(f);

mercurial