src/cpu/x86/vm/cppInterpreter_x86.cpp

changeset 6723
0bf37f737702
parent 6558
2100bf712e2a
child 6876
710a3c8b516e
child 8368
32b682649973
     1.1 --- a/src/cpu/x86/vm/cppInterpreter_x86.cpp	Mon Jun 09 15:42:31 2014 -0700
     1.2 +++ b/src/cpu/x86/vm/cppInterpreter_x86.cpp	Tue Apr 01 09:36:49 2014 +0200
     1.3 @@ -2336,29 +2336,42 @@
     1.4           "Stack top out of range");
     1.5  }
     1.6  
     1.7 -int AbstractInterpreter::layout_activation(Method* method,
     1.8 -                                           int tempcount,  //
     1.9 -                                           int popframe_extra_args,
    1.10 -                                           int moncount,
    1.11 -                                           int caller_actual_parameters,
    1.12 -                                           int callee_param_count,
    1.13 -                                           int callee_locals,
    1.14 -                                           frame* caller,
    1.15 -                                           frame* interpreter_frame,
    1.16 -                                           bool is_top_frame,
    1.17 -                                           bool is_bottom_frame) {
    1.18 -
    1.19 -  assert(popframe_extra_args == 0, "FIX ME");
    1.20 -  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
    1.21 -  // does as far as allocating an interpreter frame.
    1.22 -  // If interpreter_frame!=NULL, set up the method, locals, and monitors.
    1.23 -  // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
    1.24 -  // as determined by a previous call to this method.
    1.25 -  // It is also guaranteed to be walkable even though it is in a skeletal state
    1.26 +
    1.27 +static int frame_size_helper(int max_stack,
    1.28 +                             int tempcount,
    1.29 +                             int moncount,
    1.30 +                             int callee_param_count,
    1.31 +                             int callee_locals,
    1.32 +                             bool is_top_frame,
    1.33 +                             int& monitor_size,
    1.34 +                             int& full_frame_size) {
    1.35 +  int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
    1.36 +  monitor_size = sizeof(BasicObjectLock) * moncount;
    1.37 +
    1.38 +  // First calculate the frame size without any java expression stack
    1.39 +  int short_frame_size = size_activation_helper(extra_locals_size,
    1.40 +                                                monitor_size);
    1.41 +
    1.42 +  // Now with full size expression stack
    1.43 +  full_frame_size = short_frame_size + max_stack * BytesPerWord;
    1.44 +
    1.45 +  // and now with only live portion of the expression stack
    1.46 +  short_frame_size = short_frame_size + tempcount * BytesPerWord;
    1.47 +
    1.48 +  // the size the activation is right now. Only top frame is full size
    1.49 +  int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
    1.50 +  return frame_size;
    1.51 +}
    1.52 +
    1.53 +int AbstractInterpreter::size_activation(int max_stack,
    1.54 +                                         int tempcount,
    1.55 +                                         int extra_args,
    1.56 +                                         int moncount,
    1.57 +                                         int callee_param_count,
    1.58 +                                         int callee_locals,
    1.59 +                                         bool is_top_frame) {
    1.60 +  assert(extra_args == 0, "FIX ME");
    1.61    // NOTE: return size is in words not bytes
    1.62 -  // NOTE: tempcount is the current size of the java expression stack. For top most
    1.63 -  //       frames we will allocate a full sized expression stack and not the curback
    1.64 -  //       version that non-top frames have.
    1.65  
    1.66    // Calculate the amount our frame will be adjust by the callee. For top frame
    1.67    // this is zero.
    1.68 @@ -2368,87 +2381,102 @@
    1.69    // to it. So it ignores last_frame_adjust value. Seems suspicious as far
    1.70    // as getting sender_sp correct.
    1.71  
    1.72 -  int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
    1.73 -  int monitor_size = sizeof(BasicObjectLock) * moncount;
    1.74 -
    1.75 -  // First calculate the frame size without any java expression stack
    1.76 -  int short_frame_size = size_activation_helper(extra_locals_size,
    1.77 -                                                monitor_size);
    1.78 -
    1.79 -  // Now with full size expression stack
    1.80 -  int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord;
    1.81 -
    1.82 -  // and now with only live portion of the expression stack
    1.83 -  short_frame_size = short_frame_size + tempcount * BytesPerWord;
    1.84 -
    1.85 -  // the size the activation is right now. Only top frame is full size
    1.86 -  int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
    1.87 -
    1.88 -  if (interpreter_frame != NULL) {
    1.89 +  int unused_monitor_size = 0;
    1.90 +  int unused_full_frame_size = 0;
    1.91 +  return frame_size_helper(max_stack, tempcount, moncount, callee_param_count, callee_locals,
    1.92 +                           is_top_frame, unused_monitor_size, unused_full_frame_size)/BytesPerWord;
    1.93 +}
    1.94 +
    1.95 +void AbstractInterpreter::layout_activation(Method* method,
    1.96 +                                            int tempcount,  //
    1.97 +                                            int popframe_extra_args,
    1.98 +                                            int moncount,
    1.99 +                                            int caller_actual_parameters,
   1.100 +                                            int callee_param_count,
   1.101 +                                            int callee_locals,
   1.102 +                                            frame* caller,
   1.103 +                                            frame* interpreter_frame,
   1.104 +                                            bool is_top_frame,
   1.105 +                                            bool is_bottom_frame) {
   1.106 +
   1.107 +  assert(popframe_extra_args == 0, "FIX ME");
   1.108 +  // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
   1.109 +  // does as far as allocating an interpreter frame.
   1.110 +  // Set up the method, locals, and monitors.
   1.111 +  // The frame interpreter_frame is guaranteed to be the right size,
   1.112 +  // as determined by a previous call to the size_activation() method.
   1.113 +  // It is also guaranteed to be walkable even though it is in a skeletal state
   1.114 +  // NOTE: tempcount is the current size of the java expression stack. For top most
   1.115 +  //       frames we will allocate a full sized expression stack and not the curback
   1.116 +  //       version that non-top frames have.
   1.117 +
   1.118 +  int monitor_size = 0;
   1.119 +  int full_frame_size = 0;
   1.120 +  int frame_size = frame_size_helper(method->max_stack(), tempcount, moncount, callee_param_count, callee_locals,
   1.121 +                                     is_top_frame, monitor_size, full_frame_size);
   1.122 +
   1.123  #ifdef ASSERT
   1.124 -    assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
   1.125 +  assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
   1.126  #endif
   1.127  
   1.128 -    // MUCHO HACK
   1.129 -
   1.130 -    intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
   1.131 -
   1.132 -    /* Now fillin the interpreterState object */
   1.133 -
   1.134 -    // The state object is the first thing on the frame and easily located
   1.135 -
   1.136 -    interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
   1.137 -
   1.138 -
   1.139 -    // Find the locals pointer. This is rather simple on x86 because there is no
   1.140 -    // confusing rounding at the callee to account for. We can trivially locate
   1.141 -    // our locals based on the current fp().
   1.142 -    // Note: the + 2 is for handling the "static long no_params() method" issue.
   1.143 -    // (too bad I don't really remember that issue well...)
   1.144 -
   1.145 -    intptr_t* locals;
   1.146 -    // If the caller is interpreted we need to make sure that locals points to the first
   1.147 -    // argument that the caller passed and not in an area where the stack might have been extended.
   1.148 -    // because the stack to stack to converter needs a proper locals value in order to remove the
   1.149 -    // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
   1.150 -    // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
   1.151 -    // adjust the stack?? HMMM QQQ
   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 -      // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
   1.160 -      if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
   1.161 -        // os::breakpoint();
   1.162 -      }
   1.163 -    } else {
   1.164 -      // this is where a c2i would have placed locals (except for the +2)
   1.165 -      locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
   1.166 +  // MUCHO HACK
   1.167 +
   1.168 +  intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
   1.169 +
   1.170 +  /* Now fillin the interpreterState object */
   1.171 +
   1.172 +  // The state object is the first thing on the frame and easily located
   1.173 +
   1.174 +  interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
   1.175 +
   1.176 +
   1.177 +  // Find the locals pointer. This is rather simple on x86 because there is no
   1.178 +  // confusing rounding at the callee to account for. We can trivially locate
   1.179 +  // our locals based on the current fp().
   1.180 +  // Note: the + 2 is for handling the "static long no_params() method" issue.
   1.181 +  // (too bad I don't really remember that issue well...)
   1.182 +
   1.183 +  intptr_t* locals;
   1.184 +  // If the caller is interpreted we need to make sure that locals points to the first
   1.185 +  // argument that the caller passed and not in an area where the stack might have been extended.
   1.186 +  // because the stack to stack to converter needs a proper locals value in order to remove the
   1.187 +  // arguments from the caller and place the result in the proper location. Hmm maybe it'd be
   1.188 +  // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code
   1.189 +  // adjust the stack?? HMMM QQQ
   1.190 +  //
   1.191 +  if (caller->is_interpreted_frame()) {
   1.192 +    // locals must agree with the caller because it will be used to set the
   1.193 +    // caller's tos when we return.
   1.194 +    interpreterState prev  = caller->get_interpreterState();
   1.195 +    // stack() is prepushed.
   1.196 +    locals = prev->stack() + method->size_of_parameters();
   1.197 +    // locals = caller->unextended_sp() + (method->size_of_parameters() - 1);
   1.198 +    if (locals != interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2) {
   1.199 +      // os::breakpoint();
   1.200      }
   1.201 -
   1.202 -    intptr_t* monitor_base = (intptr_t*) cur_state;
   1.203 -    intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
   1.204 -    /* +1 because stack is always prepushed */
   1.205 -    intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
   1.206 -
   1.207 -
   1.208 -    BytecodeInterpreter::layout_interpreterState(cur_state,
   1.209 -                                          caller,
   1.210 -                                          interpreter_frame,
   1.211 -                                          method,
   1.212 -                                          locals,
   1.213 -                                          stack,
   1.214 -                                          stack_base,
   1.215 -                                          monitor_base,
   1.216 -                                          frame_bottom,
   1.217 -                                          is_top_frame);
   1.218 -
   1.219 -    // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
   1.220 +  } else {
   1.221 +    // this is where a c2i would have placed locals (except for the +2)
   1.222 +    locals = interpreter_frame->fp() + frame::sender_sp_offset + (method->max_locals() - 1) + 2;
   1.223    }
   1.224 -  return frame_size/BytesPerWord;
   1.225 +
   1.226 +  intptr_t* monitor_base = (intptr_t*) cur_state;
   1.227 +  intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
   1.228 +  /* +1 because stack is always prepushed */
   1.229 +  intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
   1.230 +
   1.231 +
   1.232 +  BytecodeInterpreter::layout_interpreterState(cur_state,
   1.233 +                                               caller,
   1.234 +                                               interpreter_frame,
   1.235 +                                               method,
   1.236 +                                               locals,
   1.237 +                                               stack,
   1.238 +                                               stack_base,
   1.239 +                                               monitor_base,
   1.240 +                                               frame_bottom,
   1.241 +                                               is_top_frame);
   1.242 +
   1.243 +  // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
   1.244  }
   1.245  
   1.246  #endif // CC_INTERP (all)

mercurial