src/cpu/sparc/vm/templateInterpreter_sparc.cpp

changeset 6723
0bf37f737702
parent 6558
2100bf712e2a
child 6876
710a3c8b516e
child 8368
32b682649973
     1.1 --- a/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
     1.2 +++ b/src/cpu/sparc/vm/templateInterpreter_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
     1.3 @@ -1564,37 +1564,23 @@
     1.4    int monitor_size    = method->is_synchronized() ?
     1.5                                  1*frame::interpreter_frame_monitor_size() : 0;
     1.6    return size_activation_helper(method->max_locals(), method->max_stack(),
     1.7 -                                 monitor_size) + call_stub_size;
     1.8 +                                monitor_size) + call_stub_size;
     1.9  }
    1.10  
    1.11 -int AbstractInterpreter::layout_activation(Method* method,
    1.12 -                                           int tempcount,
    1.13 -                                           int popframe_extra_args,
    1.14 -                                           int moncount,
    1.15 -                                           int caller_actual_parameters,
    1.16 -                                           int callee_param_count,
    1.17 -                                           int callee_local_count,
    1.18 -                                           frame* caller,
    1.19 -                                           frame* interpreter_frame,
    1.20 -                                           bool is_top_frame,
    1.21 -                                           bool is_bottom_frame) {
    1.22 +int AbstractInterpreter::size_activation(int max_stack,
    1.23 +                                         int temps,
    1.24 +                                         int extra_args,
    1.25 +                                         int monitors,
    1.26 +                                         int callee_params,
    1.27 +                                         int callee_locals,
    1.28 +                                         bool is_top_frame) {
    1.29    // Note: This calculation must exactly parallel the frame setup
    1.30    // in InterpreterGenerator::generate_fixed_frame.
    1.31 -  // If f!=NULL, set up the following variables:
    1.32 -  //   - Lmethod
    1.33 -  //   - Llocals
    1.34 -  //   - Lmonitors (to the indicated number of monitors)
    1.35 -  //   - Lesp (to the indicated number of temps)
    1.36 -  // The frame f (if not NULL) on entry is a description of the caller of the frame
    1.37 -  // we are about to layout. We are guaranteed that we will be able to fill in a
    1.38 -  // new interpreter frame as its callee (i.e. the stack space is allocated and
    1.39 -  // the amount was determined by an earlier call to this method with f == NULL).
    1.40 -  // On return f (if not NULL) while describe the interpreter frame we just layed out.
    1.41  
    1.42 -  int monitor_size           = moncount * frame::interpreter_frame_monitor_size();
    1.43 -  int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
    1.44 +  int monitor_size           = monitors * frame::interpreter_frame_monitor_size();
    1.45  
    1.46    assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
    1.47 +
    1.48    //
    1.49    // Note: if you look closely this appears to be doing something much different
    1.50    // than generate_fixed_frame. What is happening is this. On sparc we have to do
    1.51 @@ -1619,146 +1605,171 @@
    1.52    // there is no sense in messing working code.
    1.53    //
    1.54  
    1.55 -  int rounded_cls = round_to((callee_local_count - callee_param_count), WordsPerLong);
    1.56 +  int rounded_cls = round_to((callee_locals - callee_params), WordsPerLong);
    1.57    assert(rounded_cls == round_to(rounded_cls, WordsPerLong), "must align");
    1.58  
    1.59 -  int raw_frame_size = size_activation_helper(rounded_cls, method->max_stack(),
    1.60 -                                              monitor_size);
    1.61 +  int raw_frame_size = size_activation_helper(rounded_cls, max_stack, monitor_size);
    1.62  
    1.63 -  if (interpreter_frame != NULL) {
    1.64 -    // The skeleton frame must already look like an interpreter frame
    1.65 -    // even if not fully filled out.
    1.66 -    assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
    1.67 +  return raw_frame_size;
    1.68 +}
    1.69  
    1.70 -    intptr_t* fp = interpreter_frame->fp();
    1.71 +void AbstractInterpreter::layout_activation(Method* method,
    1.72 +                                            int tempcount,
    1.73 +                                            int popframe_extra_args,
    1.74 +                                            int moncount,
    1.75 +                                            int caller_actual_parameters,
    1.76 +                                            int callee_param_count,
    1.77 +                                            int callee_local_count,
    1.78 +                                            frame* caller,
    1.79 +                                            frame* interpreter_frame,
    1.80 +                                            bool is_top_frame,
    1.81 +                                            bool is_bottom_frame) {
    1.82 +  // Set up the following variables:
    1.83 +  //   - Lmethod
    1.84 +  //   - Llocals
    1.85 +  //   - Lmonitors (to the indicated number of monitors)
    1.86 +  //   - Lesp (to the indicated number of temps)
    1.87 +  // The frame caller on entry is a description of the caller of the
    1.88 +  // frame we are about to layout. We are guaranteed that we will be
    1.89 +  // able to fill in a new interpreter frame as its callee (i.e. the
    1.90 +  // stack space is allocated and the amount was determined by an
    1.91 +  // earlier call to the size_activation() method).  On return caller
    1.92 +  // while describe the interpreter frame we just layed out.
    1.93  
    1.94 -    JavaThread* thread = JavaThread::current();
    1.95 -    RegisterMap map(thread, false);
    1.96 -    // More verification that skeleton frame is properly walkable
    1.97 -    assert(fp == caller->sp(), "fp must match");
    1.98 +  // The skeleton frame must already look like an interpreter frame
    1.99 +  // even if not fully filled out.
   1.100 +  assert(interpreter_frame->is_interpreted_frame(), "Must be interpreted frame");
   1.101  
   1.102 -    intptr_t* montop     = fp - rounded_vm_local_words;
   1.103 +  int rounded_vm_local_words = round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
   1.104 +  int monitor_size           = moncount * frame::interpreter_frame_monitor_size();
   1.105 +  assert(monitor_size == round_to(monitor_size, WordsPerLong), "must align");
   1.106  
   1.107 -    // preallocate monitors (cf. __ add_monitor_to_stack)
   1.108 -    intptr_t* monitors = montop - monitor_size;
   1.109 +  intptr_t* fp = interpreter_frame->fp();
   1.110  
   1.111 -    // preallocate stack space
   1.112 -    intptr_t*  esp = monitors - 1 -
   1.113 -                     (tempcount * Interpreter::stackElementWords) -
   1.114 -                     popframe_extra_args;
   1.115 +  JavaThread* thread = JavaThread::current();
   1.116 +  RegisterMap map(thread, false);
   1.117 +  // More verification that skeleton frame is properly walkable
   1.118 +  assert(fp == caller->sp(), "fp must match");
   1.119  
   1.120 -    int local_words = method->max_locals() * Interpreter::stackElementWords;
   1.121 -    NEEDS_CLEANUP;
   1.122 -    intptr_t* locals;
   1.123 -    if (caller->is_interpreted_frame()) {
   1.124 -      // Can force the locals area to end up properly overlapping the top of the expression stack.
   1.125 -      intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
   1.126 -      // Note that this computation means we replace size_of_parameters() values from the caller
   1.127 -      // interpreter frame's expression stack with our argument locals
   1.128 -      int parm_words  = caller_actual_parameters * Interpreter::stackElementWords;
   1.129 -      locals = Lesp_ptr + parm_words;
   1.130 -      int delta = local_words - parm_words;
   1.131 -      int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
   1.132 -      *interpreter_frame->register_addr(I5_savedSP)    = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
   1.133 -      if (!is_bottom_frame) {
   1.134 -        // Llast_SP is set below for the current frame to SP (with the
   1.135 -        // extra space for the callee's locals). Here we adjust
   1.136 -        // Llast_SP for the caller's frame, removing the extra space
   1.137 -        // for the current method's locals.
   1.138 -        *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
   1.139 -      } else {
   1.140 -        assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
   1.141 -      }
   1.142 +  intptr_t* montop     = fp - rounded_vm_local_words;
   1.143 +
   1.144 +  // preallocate monitors (cf. __ add_monitor_to_stack)
   1.145 +  intptr_t* monitors = montop - monitor_size;
   1.146 +
   1.147 +  // preallocate stack space
   1.148 +  intptr_t*  esp = monitors - 1 -
   1.149 +    (tempcount * Interpreter::stackElementWords) -
   1.150 +    popframe_extra_args;
   1.151 +
   1.152 +  int local_words = method->max_locals() * Interpreter::stackElementWords;
   1.153 +  NEEDS_CLEANUP;
   1.154 +  intptr_t* locals;
   1.155 +  if (caller->is_interpreted_frame()) {
   1.156 +    // Can force the locals area to end up properly overlapping the top of the expression stack.
   1.157 +    intptr_t* Lesp_ptr = caller->interpreter_frame_tos_address() - 1;
   1.158 +    // Note that this computation means we replace size_of_parameters() values from the caller
   1.159 +    // interpreter frame's expression stack with our argument locals
   1.160 +    int parm_words  = caller_actual_parameters * Interpreter::stackElementWords;
   1.161 +    locals = Lesp_ptr + parm_words;
   1.162 +    int delta = local_words - parm_words;
   1.163 +    int computed_sp_adjustment = (delta > 0) ? round_to(delta, WordsPerLong) : 0;
   1.164 +    *interpreter_frame->register_addr(I5_savedSP)    = (intptr_t) (fp + computed_sp_adjustment) - STACK_BIAS;
   1.165 +    if (!is_bottom_frame) {
   1.166 +      // Llast_SP is set below for the current frame to SP (with the
   1.167 +      // extra space for the callee's locals). Here we adjust
   1.168 +      // Llast_SP for the caller's frame, removing the extra space
   1.169 +      // for the current method's locals.
   1.170 +      *caller->register_addr(Llast_SP) = *interpreter_frame->register_addr(I5_savedSP);
   1.171      } else {
   1.172 -      assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
   1.173 -      // Don't have Lesp available; lay out locals block in the caller
   1.174 -      // adjacent to the register window save area.
   1.175 -      //
   1.176 -      // Compiled frames do not allocate a varargs area which is why this if
   1.177 -      // statement is needed.
   1.178 -      //
   1.179 -      if (caller->is_compiled_frame()) {
   1.180 -        locals = fp + frame::register_save_words + local_words - 1;
   1.181 -      } else {
   1.182 -        locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
   1.183 -      }
   1.184 -      if (!caller->is_entry_frame()) {
   1.185 -        // Caller wants his own SP back
   1.186 -        int caller_frame_size = caller->cb()->frame_size();
   1.187 -        *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
   1.188 +      assert(*caller->register_addr(Llast_SP) >= *interpreter_frame->register_addr(I5_savedSP), "strange Llast_SP");
   1.189 +    }
   1.190 +  } else {
   1.191 +    assert(caller->is_compiled_frame() || caller->is_entry_frame(), "only possible cases");
   1.192 +    // Don't have Lesp available; lay out locals block in the caller
   1.193 +    // adjacent to the register window save area.
   1.194 +    //
   1.195 +    // Compiled frames do not allocate a varargs area which is why this if
   1.196 +    // statement is needed.
   1.197 +    //
   1.198 +    if (caller->is_compiled_frame()) {
   1.199 +      locals = fp + frame::register_save_words + local_words - 1;
   1.200 +    } else {
   1.201 +      locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
   1.202 +    }
   1.203 +    if (!caller->is_entry_frame()) {
   1.204 +      // Caller wants his own SP back
   1.205 +      int caller_frame_size = caller->cb()->frame_size();
   1.206 +      *interpreter_frame->register_addr(I5_savedSP) = (intptr_t)(caller->fp() - caller_frame_size) - STACK_BIAS;
   1.207 +    }
   1.208 +  }
   1.209 +  if (TraceDeoptimization) {
   1.210 +    if (caller->is_entry_frame()) {
   1.211 +      // make sure I5_savedSP and the entry frames notion of saved SP
   1.212 +      // agree.  This assertion duplicate a check in entry frame code
   1.213 +      // but catches the failure earlier.
   1.214 +      assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
   1.215 +             "would change callers SP");
   1.216 +    }
   1.217 +    if (caller->is_entry_frame()) {
   1.218 +      tty->print("entry ");
   1.219 +    }
   1.220 +    if (caller->is_compiled_frame()) {
   1.221 +      tty->print("compiled ");
   1.222 +      if (caller->is_deoptimized_frame()) {
   1.223 +        tty->print("(deopt) ");
   1.224        }
   1.225      }
   1.226 -    if (TraceDeoptimization) {
   1.227 -      if (caller->is_entry_frame()) {
   1.228 -        // make sure I5_savedSP and the entry frames notion of saved SP
   1.229 -        // agree.  This assertion duplicate a check in entry frame code
   1.230 -        // but catches the failure earlier.
   1.231 -        assert(*caller->register_addr(Lscratch) == *interpreter_frame->register_addr(I5_savedSP),
   1.232 -               "would change callers SP");
   1.233 -      }
   1.234 -      if (caller->is_entry_frame()) {
   1.235 -        tty->print("entry ");
   1.236 -      }
   1.237 -      if (caller->is_compiled_frame()) {
   1.238 -        tty->print("compiled ");
   1.239 -        if (caller->is_deoptimized_frame()) {
   1.240 -          tty->print("(deopt) ");
   1.241 -        }
   1.242 -      }
   1.243 -      if (caller->is_interpreted_frame()) {
   1.244 -        tty->print("interpreted ");
   1.245 -      }
   1.246 -      tty->print_cr("caller fp=0x%x sp=0x%x", caller->fp(), caller->sp());
   1.247 -      tty->print_cr("save area = 0x%x, 0x%x", caller->sp(), caller->sp() + 16);
   1.248 -      tty->print_cr("save area = 0x%x, 0x%x", caller->fp(), caller->fp() + 16);
   1.249 -      tty->print_cr("interpreter fp=0x%x sp=0x%x", interpreter_frame->fp(), interpreter_frame->sp());
   1.250 -      tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->sp(), interpreter_frame->sp() + 16);
   1.251 -      tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->fp(), interpreter_frame->fp() + 16);
   1.252 -      tty->print_cr("Llocals = 0x%x", locals);
   1.253 -      tty->print_cr("Lesp = 0x%x", esp);
   1.254 -      tty->print_cr("Lmonitors = 0x%x", monitors);
   1.255 +    if (caller->is_interpreted_frame()) {
   1.256 +      tty->print("interpreted ");
   1.257      }
   1.258 +    tty->print_cr("caller fp=0x%x sp=0x%x", caller->fp(), caller->sp());
   1.259 +    tty->print_cr("save area = 0x%x, 0x%x", caller->sp(), caller->sp() + 16);
   1.260 +    tty->print_cr("save area = 0x%x, 0x%x", caller->fp(), caller->fp() + 16);
   1.261 +    tty->print_cr("interpreter fp=0x%x sp=0x%x", interpreter_frame->fp(), interpreter_frame->sp());
   1.262 +    tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->sp(), interpreter_frame->sp() + 16);
   1.263 +    tty->print_cr("save area = 0x%x, 0x%x", interpreter_frame->fp(), interpreter_frame->fp() + 16);
   1.264 +    tty->print_cr("Llocals = 0x%x", locals);
   1.265 +    tty->print_cr("Lesp = 0x%x", esp);
   1.266 +    tty->print_cr("Lmonitors = 0x%x", monitors);
   1.267 +  }
   1.268  
   1.269 -    if (method->max_locals() > 0) {
   1.270 -      assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
   1.271 -      assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
   1.272 -      assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
   1.273 -      assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
   1.274 -    }
   1.275 +  if (method->max_locals() > 0) {
   1.276 +    assert(locals < caller->sp() || locals >= (caller->sp() + 16), "locals in save area");
   1.277 +    assert(locals < caller->fp() || locals > (caller->fp() + 16), "locals in save area");
   1.278 +    assert(locals < interpreter_frame->sp() || locals > (interpreter_frame->sp() + 16), "locals in save area");
   1.279 +    assert(locals < interpreter_frame->fp() || locals >= (interpreter_frame->fp() + 16), "locals in save area");
   1.280 +  }
   1.281  #ifdef _LP64
   1.282 -    assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
   1.283 +  assert(*interpreter_frame->register_addr(I5_savedSP) & 1, "must be odd");
   1.284  #endif
   1.285  
   1.286 -    *interpreter_frame->register_addr(Lmethod)     = (intptr_t) method;
   1.287 -    *interpreter_frame->register_addr(Llocals)     = (intptr_t) locals;
   1.288 -    *interpreter_frame->register_addr(Lmonitors)   = (intptr_t) monitors;
   1.289 -    *interpreter_frame->register_addr(Lesp)        = (intptr_t) esp;
   1.290 -    // Llast_SP will be same as SP as there is no adapter space
   1.291 -    *interpreter_frame->register_addr(Llast_SP)    = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
   1.292 -    *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
   1.293 +  *interpreter_frame->register_addr(Lmethod)     = (intptr_t) method;
   1.294 +  *interpreter_frame->register_addr(Llocals)     = (intptr_t) locals;
   1.295 +  *interpreter_frame->register_addr(Lmonitors)   = (intptr_t) monitors;
   1.296 +  *interpreter_frame->register_addr(Lesp)        = (intptr_t) esp;
   1.297 +  // Llast_SP will be same as SP as there is no adapter space
   1.298 +  *interpreter_frame->register_addr(Llast_SP)    = (intptr_t) interpreter_frame->sp() - STACK_BIAS;
   1.299 +  *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache();
   1.300  #ifdef FAST_DISPATCH
   1.301 -    *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
   1.302 +  *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table();
   1.303  #endif
   1.304  
   1.305  
   1.306  #ifdef ASSERT
   1.307 -    BasicObjectLock* mp = (BasicObjectLock*)monitors;
   1.308 +  BasicObjectLock* mp = (BasicObjectLock*)monitors;
   1.309  
   1.310 -    assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
   1.311 -    assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
   1.312 -    assert(interpreter_frame->interpreter_frame_monitor_end()   == mp, "monitor_end matches");
   1.313 -    assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
   1.314 -    assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
   1.315 +  assert(interpreter_frame->interpreter_frame_method() == method, "method matches");
   1.316 +  assert(interpreter_frame->interpreter_frame_local_at(9) == (intptr_t *)((intptr_t)locals - (9 * Interpreter::stackElementSize)), "locals match");
   1.317 +  assert(interpreter_frame->interpreter_frame_monitor_end()   == mp, "monitor_end matches");
   1.318 +  assert(((intptr_t *)interpreter_frame->interpreter_frame_monitor_begin()) == ((intptr_t *)mp)+monitor_size, "monitor_begin matches");
   1.319 +  assert(interpreter_frame->interpreter_frame_tos_address()-1 == esp, "esp matches");
   1.320  
   1.321 -    // check bounds
   1.322 -    intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
   1.323 -    intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
   1.324 -    assert(lo < monitors && montop <= hi, "monitors in bounds");
   1.325 -    assert(lo <= esp && esp < monitors, "esp in bounds");
   1.326 +  // check bounds
   1.327 +  intptr_t* lo = interpreter_frame->sp() + (frame::memory_parameter_word_sp_offset - 1);
   1.328 +  intptr_t* hi = interpreter_frame->fp() - rounded_vm_local_words;
   1.329 +  assert(lo < monitors && montop <= hi, "monitors in bounds");
   1.330 +  assert(lo <= esp && esp < monitors, "esp in bounds");
   1.331  #endif // ASSERT
   1.332 -  }
   1.333 -
   1.334 -  return raw_frame_size;
   1.335  }
   1.336  
   1.337  //----------------------------------------------------------------------------------------------------

mercurial