src/cpu/sparc/vm/cppInterpreter_sparc.cpp

changeset 6723
0bf37f737702
parent 6558
2100bf712e2a
child 6876
710a3c8b516e
child 8368
32b682649973
     1.1 --- a/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Mon Jun 09 15:42:31 2014 -0700
     1.2 +++ b/src/cpu/sparc/vm/cppInterpreter_sparc.cpp	Tue Apr 01 09:36:49 2014 +0200
     1.3 @@ -2101,7 +2101,7 @@
     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  void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill,
    1.12 @@ -2185,31 +2185,31 @@
    1.13    istate->_last_Java_pc = (intptr_t*) last_Java_pc;
    1.14  }
    1.15  
    1.16 +static int frame_size_helper(int max_stack,
    1.17 +                             int moncount,
    1.18 +                             int callee_param_size,
    1.19 +                             int callee_locals_size,
    1.20 +                             bool is_top_frame,
    1.21 +                             int& monitor_size,
    1.22 +                             int& full_frame_words) {
    1.23 +  int extra_locals_size = callee_locals_size - callee_param_size;
    1.24 +  monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
    1.25 +  full_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
    1.26 +  int short_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size);
    1.27 +  int frame_words = is_top_frame ? full_frame_words : short_frame_words;
    1.28  
    1.29 -int AbstractInterpreter::layout_activation(Method* method,
    1.30 -                                           int tempcount, // Number of slots on java expression stack in use
    1.31 -                                           int popframe_extra_args,
    1.32 -                                           int moncount,  // Number of active monitors
    1.33 -                                           int caller_actual_parameters,
    1.34 -                                           int callee_param_size,
    1.35 -                                           int callee_locals_size,
    1.36 -                                           frame* caller,
    1.37 -                                           frame* interpreter_frame,
    1.38 -                                           bool is_top_frame,
    1.39 -                                           bool is_bottom_frame) {
    1.40 +  return frame_words;
    1.41 +}
    1.42  
    1.43 -  assert(popframe_extra_args == 0, "NEED TO FIX");
    1.44 -  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
    1.45 -  // does as far as allocating an interpreter frame.
    1.46 -  // If interpreter_frame!=NULL, set up the method, locals, and monitors.
    1.47 -  // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
    1.48 -  // as determined by a previous call to this method.
    1.49 -  // It is also guaranteed to be walkable even though it is in a skeletal state
    1.50 +int AbstractInterpreter::size_activation(int max_stack,
    1.51 +                                         int tempcount,
    1.52 +                                         int extra_args,
    1.53 +                                         int moncount,
    1.54 +                                         int callee_param_size,
    1.55 +                                         int callee_locals_size,
    1.56 +                                         bool is_top_frame) {
    1.57 +  assert(extra_args == 0, "NEED TO FIX");
    1.58    // NOTE: return size is in words not bytes
    1.59 -  // NOTE: tempcount is the current size of the java expression stack. For top most
    1.60 -  //       frames we will allocate a full sized expression stack and not the curback
    1.61 -  //       version that non-top frames have.
    1.62 -
    1.63    // Calculate the amount our frame will be adjust by the callee. For top frame
    1.64    // this is zero.
    1.65  
    1.66 @@ -2218,87 +2218,108 @@
    1.67    // to it. So it ignores last_frame_adjust value. Seems suspicious as far
    1.68    // as getting sender_sp correct.
    1.69  
    1.70 -  int extra_locals_size = callee_locals_size - callee_param_size;
    1.71 -  int monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize;
    1.72 -  int full_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
    1.73 -  int short_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size);
    1.74 -  int frame_words = is_top_frame ? full_frame_words : short_frame_words;
    1.75 +  int unused_monitor_size = 0;
    1.76 +  int unused_full_frame_words = 0;
    1.77 +  return frame_size_helper(max_stack, moncount, callee_param_size, callee_locals_size, is_top_frame,
    1.78 +                           unused_monitor_size, unused_full_frame_words);
    1.79 +}
    1.80 +void AbstractInterpreter::layout_activation(Method* method,
    1.81 +                                            int tempcount, // Number of slots on java expression stack in use
    1.82 +                                            int popframe_extra_args,
    1.83 +                                            int moncount,  // Number of active monitors
    1.84 +                                            int caller_actual_parameters,
    1.85 +                                            int callee_param_size,
    1.86 +                                            int callee_locals_size,
    1.87 +                                            frame* caller,
    1.88 +                                            frame* interpreter_frame,
    1.89 +                                            bool is_top_frame,
    1.90 +                                            bool is_bottom_frame) {
    1.91 +  assert(popframe_extra_args == 0, "NEED TO FIX");
    1.92 +  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
    1.93 +  // does as far as allocating an interpreter frame.
    1.94 +  // Set up the method, locals, and monitors.
    1.95 +  // The frame interpreter_frame is guaranteed to be the right size,
    1.96 +  // as determined by a previous call to the size_activation() method.
    1.97 +  // It is also guaranteed to be walkable even though it is in a skeletal state
    1.98 +  // NOTE: tempcount is the current size of the java expression stack. For top most
    1.99 +  //       frames we will allocate a full sized expression stack and not the curback
   1.100 +  //       version that non-top frames have.
   1.101  
   1.102 +  int monitor_size = 0;
   1.103 +  int full_frame_words = 0;
   1.104 +  int frame_words = frame_size_helper(method->max_stack(), moncount, callee_param_size, callee_locals_size,
   1.105 +                                      is_top_frame, monitor_size, full_frame_words);
   1.106  
   1.107    /*
   1.108 -    if we actually have a frame to layout we must now fill in all the pieces. This means both
   1.109 +    We must now fill in all the pieces of the frame. This means both
   1.110      the interpreterState and the registers.
   1.111    */
   1.112 -  if (interpreter_frame != NULL) {
   1.113  
   1.114 -    // MUCHO HACK
   1.115 +  // MUCHO HACK
   1.116  
   1.117 -    intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
   1.118 -    // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
   1.119 -    assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
   1.120 -    frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
   1.121 +  intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words);
   1.122 +  // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode.
   1.123 +  assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation");
   1.124 +  frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS);
   1.125  
   1.126 -    /* Now fillin the interpreterState object */
   1.127 +  /* Now fillin the interpreterState object */
   1.128  
   1.129 -    interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() -  sizeof(BytecodeInterpreter));
   1.130 +  interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() -  sizeof(BytecodeInterpreter));
   1.131  
   1.132  
   1.133 -    intptr_t* locals;
   1.134 +  intptr_t* locals;
   1.135  
   1.136 -    // Calculate the postion of locals[0]. This is painful because of
   1.137 -    // stack alignment (same as ia64). The problem is that we can
   1.138 -    // not compute the location of locals from fp(). fp() will account
   1.139 -    // for the extra locals but it also accounts for aligning the stack
   1.140 -    // and we can't determine if the locals[0] was misaligned but max_locals
   1.141 -    // was enough to have the
   1.142 -    // calculate postion of locals. fp already accounts for extra locals.
   1.143 -    // +2 for the static long no_params() issue.
   1.144 +  // Calculate the postion of locals[0]. This is painful because of
   1.145 +  // stack alignment (same as ia64). The problem is that we can
   1.146 +  // not compute the location of locals from fp(). fp() will account
   1.147 +  // for the extra locals but it also accounts for aligning the stack
   1.148 +  // and we can't determine if the locals[0] was misaligned but max_locals
   1.149 +  // was enough to have the
   1.150 +  // calculate postion of locals. fp already accounts for extra locals.
   1.151 +  // +2 for the static long no_params() issue.
   1.152  
   1.153 -    if (caller->is_interpreted_frame()) {
   1.154 -      // locals must agree with the caller because it will be used to set the
   1.155 -      // caller's tos when we return.
   1.156 -      interpreterState prev  = caller->get_interpreterState();
   1.157 -      // stack() is prepushed.
   1.158 -      locals = prev->stack() + method->size_of_parameters();
   1.159 +  if (caller->is_interpreted_frame()) {
   1.160 +    // locals must agree with the caller because it will be used to set the
   1.161 +    // caller's tos when we return.
   1.162 +    interpreterState prev  = caller->get_interpreterState();
   1.163 +    // stack() is prepushed.
   1.164 +    locals = prev->stack() + method->size_of_parameters();
   1.165 +  } else {
   1.166 +    // Lay out locals block in the caller adjacent to the register window save area.
   1.167 +    //
   1.168 +    // Compiled frames do not allocate a varargs area which is why this if
   1.169 +    // statement is needed.
   1.170 +    //
   1.171 +    intptr_t* fp = interpreter_frame->fp();
   1.172 +    int local_words = method->max_locals() * Interpreter::stackElementWords;
   1.173 +
   1.174 +    if (caller->is_compiled_frame()) {
   1.175 +      locals = fp + frame::register_save_words + local_words - 1;
   1.176      } else {
   1.177 -      // Lay out locals block in the caller adjacent to the register window save area.
   1.178 -      //
   1.179 -      // Compiled frames do not allocate a varargs area which is why this if
   1.180 -      // statement is needed.
   1.181 -      //
   1.182 -      intptr_t* fp = interpreter_frame->fp();
   1.183 -      int local_words = method->max_locals() * Interpreter::stackElementWords;
   1.184 -
   1.185 -      if (caller->is_compiled_frame()) {
   1.186 -        locals = fp + frame::register_save_words + local_words - 1;
   1.187 -      } else {
   1.188 -        locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
   1.189 -      }
   1.190 -
   1.191 +      locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1;
   1.192      }
   1.193 -    // END MUCHO HACK
   1.194 -
   1.195 -    intptr_t* monitor_base = (intptr_t*) cur_state;
   1.196 -    intptr_t* stack_base =  monitor_base - monitor_size;
   1.197 -    /* +1 because stack is always prepushed */
   1.198 -    intptr_t* stack = stack_base - (tempcount + 1);
   1.199 -
   1.200 -
   1.201 -    BytecodeInterpreter::layout_interpreterState(cur_state,
   1.202 -                                          caller,
   1.203 -                                          interpreter_frame,
   1.204 -                                          method,
   1.205 -                                          locals,
   1.206 -                                          stack,
   1.207 -                                          stack_base,
   1.208 -                                          monitor_base,
   1.209 -                                          frame_bottom,
   1.210 -                                          is_top_frame);
   1.211 -
   1.212 -    BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
   1.213  
   1.214    }
   1.215 -  return frame_words;
   1.216 +  // END MUCHO HACK
   1.217 +
   1.218 +  intptr_t* monitor_base = (intptr_t*) cur_state;
   1.219 +  intptr_t* stack_base =  monitor_base - monitor_size;
   1.220 +  /* +1 because stack is always prepushed */
   1.221 +  intptr_t* stack = stack_base - (tempcount + 1);
   1.222 +
   1.223 +
   1.224 +  BytecodeInterpreter::layout_interpreterState(cur_state,
   1.225 +                                               caller,
   1.226 +                                               interpreter_frame,
   1.227 +                                               method,
   1.228 +                                               locals,
   1.229 +                                               stack,
   1.230 +                                               stack_base,
   1.231 +                                               monitor_base,
   1.232 +                                               frame_bottom,
   1.233 +                                               is_top_frame);
   1.234 +
   1.235 +  BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
   1.236  }
   1.237  
   1.238  #endif // CC_INTERP

mercurial