src/cpu/sparc/vm/cppInterpreter_sparc.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot-dvm Sdiff src/cpu/sparc/vm

src/cpu/sparc/vm/cppInterpreter_sparc.cpp

Print this page
rev 522 : [mq]: meth.patch


1000   // On return
1001   // "state" is a pointer to the newly allocated  state object. We must allocate and initialize
1002   // a new interpretState object and the method expression stack.
1003 
1004   assert_different_registers(state, prev_state);
1005   assert_different_registers(prev_state, G3_scratch);
1006   const Register Gtmp = G3_scratch;
1007   const Address constants         (G5_method, 0, in_bytes(methodOopDesc::constants_offset()));
1008   const Address access_flags      (G5_method, 0, in_bytes(methodOopDesc::access_flags_offset()));
1009   const Address size_of_parameters(G5_method, 0, in_bytes(methodOopDesc::size_of_parameters_offset()));
1010   const Address max_stack         (G5_method, 0, in_bytes(methodOopDesc::max_stack_offset()));
1011   const Address size_of_locals    (G5_method, 0, in_bytes(methodOopDesc::size_of_locals_offset()));
1012 
1013   // slop factor is two extra slots on the expression stack so that
1014   // we always have room to store a result when returning from a call without parameters
1015   // that returns a result.
1016 
1017   const int slop_factor = 2*wordSize;
1018 
1019   const int fixed_size = ((sizeof(BytecodeInterpreter) + slop_factor) >> LogBytesPerWord) + // what is the slop factor?

1020                          frame::memory_parameter_word_sp_offset +  // register save area + param window
1021                          (native ?  frame::interpreter_frame_extra_outgoing_argument_words : 0); // JNI, class
1022 
1023   // XXX G5_method valid
1024 
1025   // Now compute new frame size
1026 
1027   if (native) {
1028     __ lduh( size_of_parameters, Gtmp );
1029     __ calc_mem_param_words(Gtmp, Gtmp);     // space for native call parameters passed on the stack in words
1030   } else {
1031     __ lduh(max_stack, Gtmp);                // Full size expression stack
1032   }
1033   __ add(Gtmp, fixed_size, Gtmp);           // plus the fixed portion
1034 
1035   __ neg(Gtmp);                               // negative space for stack/parameters in words
1036   __ and3(Gtmp, -WordsPerLong, Gtmp);        // make multiple of 2 (SP must be 2-word aligned)
1037   __ sll(Gtmp, LogBytesPerWord, Gtmp);       // negative space for frame in bytes
1038 
1039   // Need to do stack size check here before we fault on large frames


1146     __ breakpoint_trap(Assembler::zero);
1147   #endif // ASSERT
1148 
1149     const int entry_size            = frame::interpreter_frame_monitor_size() * wordSize;
1150     __ sub(SP, entry_size, SP);                         // account for initial monitor
1151     __ sub(O2, entry_size, O2);                        // initial monitor
1152     __ st_ptr(O1, O2, BasicObjectLock::obj_offset_in_bytes()); // and allocate it for interpreter use
1153     __ bind(done);
1154   }
1155 
1156   // Remember initial frame bottom
1157 
1158   __ st_ptr(SP, XXX_STATE(_frame_bottom));
1159 
1160   __ st_ptr(O2, XXX_STATE(_stack_base));
1161 
1162   __ sub(O2, wordSize, O2);                    // prepush
1163   __ st_ptr(O2, XXX_STATE(_stack));                // PREPUSH
1164 
1165   __ lduh(max_stack, O3);                      // Full size expression stack


1166   __ sll(O3, LogBytesPerWord, O3);
1167   __ sub(O2, O3, O3);
1168 //  __ sub(O3, wordSize, O3);                    // so prepush doesn't look out of bounds
1169   __ st_ptr(O3, XXX_STATE(_stack_limit));
1170 
1171   if (!native) {
1172     //
1173     // Code to initialize locals
1174     //
1175     Register init_value = noreg;    // will be G0 if we must clear locals
1176     // Now zero locals
1177     if (true /* zerolocals */ || ClearInterpreterLocals) {
1178       // explicitly initialize locals
1179       init_value = G0;
1180     } else {
1181     #ifdef ASSERT
1182       // initialize locals to a garbage pattern for better debugging
1183       init_value = O3;
1184       __ set( 0x0F0F0F0F, init_value );
1185     #endif // ASSERT


2000 static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
2001 
2002   // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
2003   // expression stack, the callee will have callee_extra_locals (so we can account for
2004   // frame extension) and monitor_size for monitors. Basically we need to calculate
2005   // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
2006   //
2007   //
2008   // The big complicating thing here is that we must ensure that the stack stays properly
2009   // aligned. This would be even uglier if monitor size wasn't modulo what the stack
2010   // needs to be aligned for). We are given that the sp (fp) is already aligned by
2011   // the caller so we must ensure that it is properly aligned for our callee.
2012   //
2013   // Ths c++ interpreter always makes sure that we have a enough extra space on the
2014   // stack at all times to deal with the "stack long no_params()" method issue. This
2015   // is "slop_factor" here.
2016   const int slop_factor = 2;
2017 
2018   const int fixed_size = sizeof(BytecodeInterpreter)/wordSize +           // interpreter state object
2019                          frame::memory_parameter_word_sp_offset;   // register save area + param window

2020   return (round_to(max_stack +

2021                    slop_factor +
2022                    fixed_size +
2023                    monitor_size +
2024                    (callee_extra_locals * Interpreter::stackElementWords()), WordsPerLong));
2025 
2026 }
2027 
2028 int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
2029 
2030   // See call_stub code
2031   int call_stub_size  = round_to(7 + frame::memory_parameter_word_sp_offset,
2032                                  WordsPerLong);    // 7 + register save area
2033 
2034   // Save space for one monitor to get into the interpreted method in case
2035   // the method is synchronized
2036   int monitor_size    = method->is_synchronized() ?
2037                                 1*frame::interpreter_frame_monitor_size() : 0;
2038   return size_activation_helper(method->max_locals(), method->max_stack(),
2039                                  monitor_size) + call_stub_size;
2040 }


2087   // skeletal already places a useful value here and this doesn't account
2088   // for alignment so don't bother.
2089   // *current->register_addr(I5_savedSP) =     (intptr_t) locals - (method->size_of_parameters() - 1);
2090 
2091   if (caller->is_interpreted_frame()) {
2092     interpreterState prev  = caller->get_interpreterState();
2093     to_fill->_prev_link = prev;
2094     // Make the prev callee look proper
2095     prev->_result._to_call._callee = method;
2096     if (*prev->_bcp == Bytecodes::_invokeinterface) {
2097       prev->_result._to_call._bcp_advance = 5;
2098     } else {
2099       prev->_result._to_call._bcp_advance = 3;
2100     }
2101   }
2102   to_fill->_oop_temp = NULL;
2103   to_fill->_stack_base = stack_base;
2104   // Need +1 here because stack_base points to the word just above the first expr stack entry
2105   // and stack_limit is supposed to point to the word just below the last expr stack entry.
2106   // See generate_compute_interpreter_state.
2107   to_fill->_stack_limit = stack_base - (method->max_stack() + 1);

2108   to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
2109 
2110   // sparc specific
2111   to_fill->_frame_bottom = frame_bottom;
2112   to_fill->_self_link = to_fill;
2113 #ifdef ASSERT
2114   to_fill->_native_fresult = 123456.789;
2115   to_fill->_native_lresult = CONST64(0xdeadcafedeafcafe);
2116 #endif
2117 }
2118 
2119 void BytecodeInterpreter::pd_layout_interpreterState(interpreterState istate, address last_Java_pc, intptr_t* last_Java_fp) {
2120   istate->_last_Java_pc = (intptr_t*) last_Java_pc;
2121 }
2122 
2123 
2124 int AbstractInterpreter::layout_activation(methodOop method,
2125                                            int tempcount, // Number of slots on java expression stack in use
2126                                            int popframe_extra_args,
2127                                            int moncount,  // Number of active monitors




1000   // On return
1001   // "state" is a pointer to the newly allocated  state object. We must allocate and initialize
1002   // a new interpretState object and the method expression stack.
1003 
1004   assert_different_registers(state, prev_state);
1005   assert_different_registers(prev_state, G3_scratch);
1006   const Register Gtmp = G3_scratch;
1007   const Address constants         (G5_method, 0, in_bytes(methodOopDesc::constants_offset()));
1008   const Address access_flags      (G5_method, 0, in_bytes(methodOopDesc::access_flags_offset()));
1009   const Address size_of_parameters(G5_method, 0, in_bytes(methodOopDesc::size_of_parameters_offset()));
1010   const Address max_stack         (G5_method, 0, in_bytes(methodOopDesc::max_stack_offset()));
1011   const Address size_of_locals    (G5_method, 0, in_bytes(methodOopDesc::size_of_locals_offset()));
1012 
1013   // slop factor is two extra slots on the expression stack so that
1014   // we always have room to store a result when returning from a call without parameters
1015   // that returns a result.
1016 
1017   const int slop_factor = 2*wordSize;
1018 
1019   const int fixed_size = ((sizeof(BytecodeInterpreter) + slop_factor) >> LogBytesPerWord) + // what is the slop factor?
1020                          methodOopDesc::extra_stack() +  // extra push slot for MH insertion
1021                          frame::memory_parameter_word_sp_offset +  // register save area + param window
1022                          (native ?  frame::interpreter_frame_extra_outgoing_argument_words : 0); // JNI, class
1023 
1024   // XXX G5_method valid
1025 
1026   // Now compute new frame size
1027 
1028   if (native) {
1029     __ lduh( size_of_parameters, Gtmp );
1030     __ calc_mem_param_words(Gtmp, Gtmp);     // space for native call parameters passed on the stack in words
1031   } else {
1032     __ lduh(max_stack, Gtmp);                // Full size expression stack
1033   }
1034   __ add(Gtmp, fixed_size, Gtmp);           // plus the fixed portion
1035 
1036   __ neg(Gtmp);                               // negative space for stack/parameters in words
1037   __ and3(Gtmp, -WordsPerLong, Gtmp);        // make multiple of 2 (SP must be 2-word aligned)
1038   __ sll(Gtmp, LogBytesPerWord, Gtmp);       // negative space for frame in bytes
1039 
1040   // Need to do stack size check here before we fault on large frames


1147     __ breakpoint_trap(Assembler::zero);
1148   #endif // ASSERT
1149 
1150     const int entry_size            = frame::interpreter_frame_monitor_size() * wordSize;
1151     __ sub(SP, entry_size, SP);                         // account for initial monitor
1152     __ sub(O2, entry_size, O2);                        // initial monitor
1153     __ st_ptr(O1, O2, BasicObjectLock::obj_offset_in_bytes()); // and allocate it for interpreter use
1154     __ bind(done);
1155   }
1156 
1157   // Remember initial frame bottom
1158 
1159   __ st_ptr(SP, XXX_STATE(_frame_bottom));
1160 
1161   __ st_ptr(O2, XXX_STATE(_stack_base));
1162 
1163   __ sub(O2, wordSize, O2);                    // prepush
1164   __ st_ptr(O2, XXX_STATE(_stack));                // PREPUSH
1165 
1166   __ lduh(max_stack, O3);                      // Full size expression stack
1167   if (MethodHandle)
1168     __ inc(O3, methodOopDesc::extra_stack());
1169   __ sll(O3, LogBytesPerWord, O3);
1170   __ sub(O2, O3, O3);
1171 //  __ sub(O3, wordSize, O3);                    // so prepush doesn't look out of bounds
1172   __ st_ptr(O3, XXX_STATE(_stack_limit));
1173 
1174   if (!native) {
1175     //
1176     // Code to initialize locals
1177     //
1178     Register init_value = noreg;    // will be G0 if we must clear locals
1179     // Now zero locals
1180     if (true /* zerolocals */ || ClearInterpreterLocals) {
1181       // explicitly initialize locals
1182       init_value = G0;
1183     } else {
1184     #ifdef ASSERT
1185       // initialize locals to a garbage pattern for better debugging
1186       init_value = O3;
1187       __ set( 0x0F0F0F0F, init_value );
1188     #endif // ASSERT


2003 static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
2004 
2005   // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
2006   // expression stack, the callee will have callee_extra_locals (so we can account for
2007   // frame extension) and monitor_size for monitors. Basically we need to calculate
2008   // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
2009   //
2010   //
2011   // The big complicating thing here is that we must ensure that the stack stays properly
2012   // aligned. This would be even uglier if monitor size wasn't modulo what the stack
2013   // needs to be aligned for). We are given that the sp (fp) is already aligned by
2014   // the caller so we must ensure that it is properly aligned for our callee.
2015   //
2016   // Ths c++ interpreter always makes sure that we have a enough extra space on the
2017   // stack at all times to deal with the "stack long no_params()" method issue. This
2018   // is "slop_factor" here.
2019   const int slop_factor = 2;
2020 
2021   const int fixed_size = sizeof(BytecodeInterpreter)/wordSize +           // interpreter state object
2022                          frame::memory_parameter_word_sp_offset;   // register save area + param window
2023   const int extra_stack = methodOopDesc::extra_stack();
2024     return (round_to(max_stack +
2025                    extra_stack +
2026                    slop_factor +
2027                    fixed_size +
2028                    monitor_size +
2029                    (callee_extra_locals * Interpreter::stackElementWords()), WordsPerLong));
2030 
2031 }
2032 
2033 int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
2034 
2035   // See call_stub code
2036   int call_stub_size  = round_to(7 + frame::memory_parameter_word_sp_offset,
2037                                  WordsPerLong);    // 7 + register save area
2038 
2039   // Save space for one monitor to get into the interpreted method in case
2040   // the method is synchronized
2041   int monitor_size    = method->is_synchronized() ?
2042                                 1*frame::interpreter_frame_monitor_size() : 0;
2043   return size_activation_helper(method->max_locals(), method->max_stack(),
2044                                  monitor_size) + call_stub_size;
2045 }


2092   // skeletal already places a useful value here and this doesn't account
2093   // for alignment so don't bother.
2094   // *current->register_addr(I5_savedSP) =     (intptr_t) locals - (method->size_of_parameters() - 1);
2095 
2096   if (caller->is_interpreted_frame()) {
2097     interpreterState prev  = caller->get_interpreterState();
2098     to_fill->_prev_link = prev;
2099     // Make the prev callee look proper
2100     prev->_result._to_call._callee = method;
2101     if (*prev->_bcp == Bytecodes::_invokeinterface) {
2102       prev->_result._to_call._bcp_advance = 5;
2103     } else {
2104       prev->_result._to_call._bcp_advance = 3;
2105     }
2106   }
2107   to_fill->_oop_temp = NULL;
2108   to_fill->_stack_base = stack_base;
2109   // Need +1 here because stack_base points to the word just above the first expr stack entry
2110   // and stack_limit is supposed to point to the word just below the last expr stack entry.
2111   // See generate_compute_interpreter_state.
2112   int extra_stack = methodOopDesc::extra_stack();
2113   to_fill->_stack_limit = stack_base - (method->max_stack() + 1 + extra_stack);
2114   to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
2115 
2116   // sparc specific
2117   to_fill->_frame_bottom = frame_bottom;
2118   to_fill->_self_link = to_fill;
2119 #ifdef ASSERT
2120   to_fill->_native_fresult = 123456.789;
2121   to_fill->_native_lresult = CONST64(0xdeadcafedeafcafe);
2122 #endif
2123 }
2124 
2125 void BytecodeInterpreter::pd_layout_interpreterState(interpreterState istate, address last_Java_pc, intptr_t* last_Java_fp) {
2126   istate->_last_Java_pc = (intptr_t*) last_Java_pc;
2127 }
2128 
2129 
2130 int AbstractInterpreter::layout_activation(methodOop method,
2131                                            int tempcount, // Number of slots on java expression stack in use
2132                                            int popframe_extra_args,
2133                                            int moncount,  // Number of active monitors


src/cpu/sparc/vm/cppInterpreter_sparc.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File