src/share/vm/c1/c1_LinearScan.cpp

changeset 2174
f02a8bbe6ed4
parent 2171
87b64980e2f1
child 2314
f95d63e2154a
     1.1 --- a/src/share/vm/c1/c1_LinearScan.cpp	Wed Sep 22 23:51:03 2010 -0700
     1.2 +++ b/src/share/vm/c1/c1_LinearScan.cpp	Tue Dec 29 19:08:54 2009 +0100
     1.3 @@ -2274,8 +2274,8 @@
     1.4  }
     1.5  
     1.6  void check_stack_depth(CodeEmitInfo* info, int stack_end) {
     1.7 -  if (info->bci() != SynchronizationEntryBCI && !info->scope()->method()->is_native()) {
     1.8 -    Bytecodes::Code code = info->scope()->method()->java_code_at_bci(info->bci());
     1.9 +  if (info->stack()->bci() != SynchronizationEntryBCI && !info->scope()->method()->is_native()) {
    1.10 +    Bytecodes::Code code = info->scope()->method()->java_code_at_bci(info->stack()->bci());
    1.11      switch (code) {
    1.12        case Bytecodes::_ifnull    : // fall through
    1.13        case Bytecodes::_ifnonnull : // fall through
    1.14 @@ -2379,7 +2379,7 @@
    1.15  
    1.16    // add oops from lock stack
    1.17    assert(info->stack() != NULL, "CodeEmitInfo must always have a stack");
    1.18 -  int locks_count = info->stack()->locks_size();
    1.19 +  int locks_count = info->stack()->total_locks_size();
    1.20    for (int i = 0; i < locks_count; i++) {
    1.21      map->set_oop(frame_map()->monitor_object_regname(i));
    1.22    }
    1.23 @@ -2762,19 +2762,13 @@
    1.24  }
    1.25  
    1.26  
    1.27 -IRScopeDebugInfo* LinearScan::compute_debug_info_for_scope(int op_id, IRScope* cur_scope, ValueStack* cur_state, ValueStack* innermost_state, int cur_bci, int stack_end, int locks_end) {
    1.28 +IRScopeDebugInfo* LinearScan::compute_debug_info_for_scope(int op_id, IRScope* cur_scope, ValueStack* cur_state, ValueStack* innermost_state) {
    1.29    IRScopeDebugInfo* caller_debug_info = NULL;
    1.30 -  int stack_begin, locks_begin;
    1.31 -
    1.32 -  ValueStack* caller_state = cur_scope->caller_state();
    1.33 +
    1.34 +  ValueStack* caller_state = cur_state->caller_state();
    1.35    if (caller_state != NULL) {
    1.36      // process recursively to compute outermost scope first
    1.37 -    stack_begin = caller_state->stack_size();
    1.38 -    locks_begin = caller_state->locks_size();
    1.39 -    caller_debug_info = compute_debug_info_for_scope(op_id, cur_scope->caller(), caller_state, innermost_state, cur_scope->caller_bci(), stack_begin, locks_begin);
    1.40 -  } else {
    1.41 -    stack_begin = 0;
    1.42 -    locks_begin = 0;
    1.43 +    caller_debug_info = compute_debug_info_for_scope(op_id, cur_scope->caller(), caller_state, innermost_state);
    1.44    }
    1.45  
    1.46    // initialize these to null.
    1.47 @@ -2785,7 +2779,7 @@
    1.48    GrowableArray<MonitorValue*>* monitors    = NULL;
    1.49  
    1.50    // describe local variable values
    1.51 -  int nof_locals = cur_scope->method()->max_locals();
    1.52 +  int nof_locals = cur_state->locals_size();
    1.53    if (nof_locals > 0) {
    1.54      locals = new GrowableArray<ScopeValue*>(nof_locals);
    1.55  
    1.56 @@ -2800,45 +2794,41 @@
    1.57      }
    1.58      assert(locals->length() == cur_scope->method()->max_locals(), "wrong number of locals");
    1.59      assert(locals->length() == cur_state->locals_size(), "wrong number of locals");
    1.60 -  }
    1.61 -
    1.62 +  } else if (cur_scope->method()->max_locals() > 0) {
    1.63 +    assert(cur_state->kind() == ValueStack::EmptyExceptionState, "should be");
    1.64 +    nof_locals = cur_scope->method()->max_locals();
    1.65 +    locals = new GrowableArray<ScopeValue*>(nof_locals);
    1.66 +    for(int i = 0; i < nof_locals; i++) {
    1.67 +      locals->append(&_illegal_value);
    1.68 +    }
    1.69 +  }
    1.70  
    1.71    // describe expression stack
    1.72 -  //
    1.73 -  // When we inline methods containing exception handlers, the
    1.74 -  // "lock_stacks" are changed to preserve expression stack values
    1.75 -  // in caller scopes when exception handlers are present. This
    1.76 -  // can cause callee stacks to be smaller than caller stacks.
    1.77 -  if (stack_end > innermost_state->stack_size()) {
    1.78 -    stack_end = innermost_state->stack_size();
    1.79 -  }
    1.80 -
    1.81 -
    1.82 -
    1.83 -  int nof_stack = stack_end - stack_begin;
    1.84 +  int nof_stack = cur_state->stack_size();
    1.85    if (nof_stack > 0) {
    1.86      expressions = new GrowableArray<ScopeValue*>(nof_stack);
    1.87  
    1.88 -    int pos = stack_begin;
    1.89 -    while (pos < stack_end) {
    1.90 -      Value expression = innermost_state->stack_at_inc(pos);
    1.91 +    int pos = 0;
    1.92 +    while (pos < nof_stack) {
    1.93 +      Value expression = cur_state->stack_at_inc(pos);
    1.94        append_scope_value(op_id, expression, expressions);
    1.95  
    1.96 -      assert(expressions->length() + stack_begin == pos, "must match");
    1.97 -    }
    1.98 +      assert(expressions->length() == pos, "must match");
    1.99 +    }
   1.100 +    assert(expressions->length() == cur_state->stack_size(), "wrong number of stack entries");
   1.101    }
   1.102  
   1.103    // describe monitors
   1.104 -  assert(locks_begin <= locks_end, "error in scope iteration");
   1.105 -  int nof_locks = locks_end - locks_begin;
   1.106 +  int nof_locks = cur_state->locks_size();
   1.107    if (nof_locks > 0) {
   1.108 +    int lock_offset = cur_state->caller_state() != NULL ? cur_state->caller_state()->total_locks_size() : 0;
   1.109      monitors = new GrowableArray<MonitorValue*>(nof_locks);
   1.110 -    for (int i = locks_begin; i < locks_end; i++) {
   1.111 -      monitors->append(location_for_monitor_index(i));
   1.112 -    }
   1.113 -  }
   1.114 -
   1.115 -  return new IRScopeDebugInfo(cur_scope, cur_bci, locals, expressions, monitors, caller_debug_info);
   1.116 +    for (int i = 0; i < nof_locks; i++) {
   1.117 +      monitors->append(location_for_monitor_index(lock_offset + i));
   1.118 +    }
   1.119 +  }
   1.120 +
   1.121 +  return new IRScopeDebugInfo(cur_scope, cur_state->bci(), locals, expressions, monitors, caller_debug_info);
   1.122  }
   1.123  
   1.124  
   1.125 @@ -2850,17 +2840,14 @@
   1.126  
   1.127    assert(innermost_scope != NULL && innermost_state != NULL, "why is it missing?");
   1.128  
   1.129 -  int stack_end = innermost_state->stack_size();
   1.130 -  int locks_end = innermost_state->locks_size();
   1.131 -
   1.132 -  DEBUG_ONLY(check_stack_depth(info, stack_end));
   1.133 +  DEBUG_ONLY(check_stack_depth(info, innermost_state->stack_size()));
   1.134  
   1.135    if (info->_scope_debug_info == NULL) {
   1.136      // compute debug information
   1.137 -    info->_scope_debug_info = compute_debug_info_for_scope(op_id, innermost_scope, innermost_state, innermost_state, info->bci(), stack_end, locks_end);
   1.138 +    info->_scope_debug_info = compute_debug_info_for_scope(op_id, innermost_scope, innermost_state, innermost_state);
   1.139    } else {
   1.140      // debug information already set. Check that it is correct from the current point of view
   1.141 -    DEBUG_ONLY(assert_equal(info->_scope_debug_info, compute_debug_info_for_scope(op_id, innermost_scope, innermost_state, innermost_state, info->bci(), stack_end, locks_end)));
   1.142 +    DEBUG_ONLY(assert_equal(info->_scope_debug_info, compute_debug_info_for_scope(op_id, innermost_scope, innermost_state, innermost_state)));
   1.143    }
   1.144  }
   1.145  

mercurial