Mercurial > hg > graal-compiler
comparison src/cpu/sparc/vm/cppInterpreter_sparc.cpp @ 17980:0bf37f737702
8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
Summary: make compiled code bang the stack by the worst case size of the interpreter frame at deoptimization points.
Reviewed-by: twisti, kvn
author | roland |
---|---|
date | Tue, 01 Apr 2014 09:36:49 +0200 |
parents | 2100bf712e2a |
children |
comparison
equal
deleted
inserted
replaced
17978:ad51f24671c2 | 17980:0bf37f737702 |
---|---|
2099 // Save space for one monitor to get into the interpreted method in case | 2099 // Save space for one monitor to get into the interpreted method in case |
2100 // the method is synchronized | 2100 // the method is synchronized |
2101 int monitor_size = method->is_synchronized() ? | 2101 int monitor_size = method->is_synchronized() ? |
2102 1*frame::interpreter_frame_monitor_size() : 0; | 2102 1*frame::interpreter_frame_monitor_size() : 0; |
2103 return size_activation_helper(method->max_locals(), method->max_stack(), | 2103 return size_activation_helper(method->max_locals(), method->max_stack(), |
2104 monitor_size) + call_stub_size; | 2104 monitor_size) + call_stub_size; |
2105 } | 2105 } |
2106 | 2106 |
2107 void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill, | 2107 void BytecodeInterpreter::layout_interpreterState(interpreterState to_fill, |
2108 frame* caller, | 2108 frame* caller, |
2109 frame* current, | 2109 frame* current, |
2183 | 2183 |
2184 void BytecodeInterpreter::pd_layout_interpreterState(interpreterState istate, address last_Java_pc, intptr_t* last_Java_fp) { | 2184 void BytecodeInterpreter::pd_layout_interpreterState(interpreterState istate, address last_Java_pc, intptr_t* last_Java_fp) { |
2185 istate->_last_Java_pc = (intptr_t*) last_Java_pc; | 2185 istate->_last_Java_pc = (intptr_t*) last_Java_pc; |
2186 } | 2186 } |
2187 | 2187 |
2188 | 2188 static int frame_size_helper(int max_stack, |
2189 int AbstractInterpreter::layout_activation(Method* method, | 2189 int moncount, |
2190 int tempcount, // Number of slots on java expression stack in use | 2190 int callee_param_size, |
2191 int popframe_extra_args, | 2191 int callee_locals_size, |
2192 int moncount, // Number of active monitors | 2192 bool is_top_frame, |
2193 int caller_actual_parameters, | 2193 int& monitor_size, |
2194 int callee_param_size, | 2194 int& full_frame_words) { |
2195 int callee_locals_size, | 2195 int extra_locals_size = callee_locals_size - callee_param_size; |
2196 frame* caller, | 2196 monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize; |
2197 frame* interpreter_frame, | 2197 full_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size); |
2198 bool is_top_frame, | 2198 int short_frame_words = size_activation_helper(extra_locals_size, max_stack, monitor_size); |
2199 bool is_bottom_frame) { | 2199 int frame_words = is_top_frame ? full_frame_words : short_frame_words; |
2200 | 2200 |
2201 assert(popframe_extra_args == 0, "NEED TO FIX"); | 2201 return frame_words; |
2202 // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state() | 2202 } |
2203 // does as far as allocating an interpreter frame. | 2203 |
2204 // If interpreter_frame!=NULL, set up the method, locals, and monitors. | 2204 int AbstractInterpreter::size_activation(int max_stack, |
2205 // The frame interpreter_frame, if not NULL, is guaranteed to be the right size, | 2205 int tempcount, |
2206 // as determined by a previous call to this method. | 2206 int extra_args, |
2207 // It is also guaranteed to be walkable even though it is in a skeletal state | 2207 int moncount, |
2208 int callee_param_size, | |
2209 int callee_locals_size, | |
2210 bool is_top_frame) { | |
2211 assert(extra_args == 0, "NEED TO FIX"); | |
2208 // NOTE: return size is in words not bytes | 2212 // NOTE: return size is in words not bytes |
2209 // NOTE: tempcount is the current size of the java expression stack. For top most | |
2210 // frames we will allocate a full sized expression stack and not the curback | |
2211 // version that non-top frames have. | |
2212 | |
2213 // Calculate the amount our frame will be adjust by the callee. For top frame | 2213 // Calculate the amount our frame will be adjust by the callee. For top frame |
2214 // this is zero. | 2214 // this is zero. |
2215 | 2215 |
2216 // NOTE: ia64 seems to do this wrong (or at least backwards) in that it | 2216 // NOTE: ia64 seems to do this wrong (or at least backwards) in that it |
2217 // calculates the extra locals based on itself. Not what the callee does | 2217 // calculates the extra locals based on itself. Not what the callee does |
2218 // to it. So it ignores last_frame_adjust value. Seems suspicious as far | 2218 // to it. So it ignores last_frame_adjust value. Seems suspicious as far |
2219 // as getting sender_sp correct. | 2219 // as getting sender_sp correct. |
2220 | 2220 |
2221 int extra_locals_size = callee_locals_size - callee_param_size; | 2221 int unused_monitor_size = 0; |
2222 int monitor_size = (sizeof(BasicObjectLock) * moncount) / wordSize; | 2222 int unused_full_frame_words = 0; |
2223 int full_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size); | 2223 return frame_size_helper(max_stack, moncount, callee_param_size, callee_locals_size, is_top_frame, |
2224 int short_frame_words = size_activation_helper(extra_locals_size, method->max_stack(), monitor_size); | 2224 unused_monitor_size, unused_full_frame_words); |
2225 int frame_words = is_top_frame ? full_frame_words : short_frame_words; | 2225 } |
2226 | 2226 void AbstractInterpreter::layout_activation(Method* method, |
2227 int tempcount, // Number of slots on java expression stack in use | |
2228 int popframe_extra_args, | |
2229 int moncount, // Number of active monitors | |
2230 int caller_actual_parameters, | |
2231 int callee_param_size, | |
2232 int callee_locals_size, | |
2233 frame* caller, | |
2234 frame* interpreter_frame, | |
2235 bool is_top_frame, | |
2236 bool is_bottom_frame) { | |
2237 assert(popframe_extra_args == 0, "NEED TO FIX"); | |
2238 // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state() | |
2239 // does as far as allocating an interpreter frame. | |
2240 // Set up the method, locals, and monitors. | |
2241 // The frame interpreter_frame is guaranteed to be the right size, | |
2242 // as determined by a previous call to the size_activation() method. | |
2243 // It is also guaranteed to be walkable even though it is in a skeletal state | |
2244 // NOTE: tempcount is the current size of the java expression stack. For top most | |
2245 // frames we will allocate a full sized expression stack and not the curback | |
2246 // version that non-top frames have. | |
2247 | |
2248 int monitor_size = 0; | |
2249 int full_frame_words = 0; | |
2250 int frame_words = frame_size_helper(method->max_stack(), moncount, callee_param_size, callee_locals_size, | |
2251 is_top_frame, monitor_size, full_frame_words); | |
2227 | 2252 |
2228 /* | 2253 /* |
2229 if we actually have a frame to layout we must now fill in all the pieces. This means both | 2254 We must now fill in all the pieces of the frame. This means both |
2230 the interpreterState and the registers. | 2255 the interpreterState and the registers. |
2231 */ | 2256 */ |
2232 if (interpreter_frame != NULL) { | 2257 |
2233 | 2258 // MUCHO HACK |
2234 // MUCHO HACK | 2259 |
2235 | 2260 intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words); |
2236 intptr_t* frame_bottom = interpreter_frame->sp() - (full_frame_words - frame_words); | 2261 // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode. |
2237 // 'interpreter_frame->sp()' is unbiased while 'frame_bottom' must be a biased value in 64bit mode. | 2262 assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation"); |
2238 assert(((intptr_t)frame_bottom & 0xf) == 0, "SP biased in layout_activation"); | 2263 frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS); |
2239 frame_bottom = (intptr_t*)((intptr_t)frame_bottom - STACK_BIAS); | 2264 |
2240 | 2265 /* Now fillin the interpreterState object */ |
2241 /* Now fillin the interpreterState object */ | 2266 |
2242 | 2267 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter)); |
2243 interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter)); | 2268 |
2244 | 2269 |
2245 | 2270 intptr_t* locals; |
2246 intptr_t* locals; | 2271 |
2247 | 2272 // Calculate the postion of locals[0]. This is painful because of |
2248 // Calculate the postion of locals[0]. This is painful because of | 2273 // stack alignment (same as ia64). The problem is that we can |
2249 // stack alignment (same as ia64). The problem is that we can | 2274 // not compute the location of locals from fp(). fp() will account |
2250 // not compute the location of locals from fp(). fp() will account | 2275 // for the extra locals but it also accounts for aligning the stack |
2251 // for the extra locals but it also accounts for aligning the stack | 2276 // and we can't determine if the locals[0] was misaligned but max_locals |
2252 // and we can't determine if the locals[0] was misaligned but max_locals | 2277 // was enough to have the |
2253 // was enough to have the | 2278 // calculate postion of locals. fp already accounts for extra locals. |
2254 // calculate postion of locals. fp already accounts for extra locals. | 2279 // +2 for the static long no_params() issue. |
2255 // +2 for the static long no_params() issue. | 2280 |
2256 | 2281 if (caller->is_interpreted_frame()) { |
2257 if (caller->is_interpreted_frame()) { | 2282 // locals must agree with the caller because it will be used to set the |
2258 // locals must agree with the caller because it will be used to set the | 2283 // caller's tos when we return. |
2259 // caller's tos when we return. | 2284 interpreterState prev = caller->get_interpreterState(); |
2260 interpreterState prev = caller->get_interpreterState(); | 2285 // stack() is prepushed. |
2261 // stack() is prepushed. | 2286 locals = prev->stack() + method->size_of_parameters(); |
2262 locals = prev->stack() + method->size_of_parameters(); | 2287 } else { |
2288 // Lay out locals block in the caller adjacent to the register window save area. | |
2289 // | |
2290 // Compiled frames do not allocate a varargs area which is why this if | |
2291 // statement is needed. | |
2292 // | |
2293 intptr_t* fp = interpreter_frame->fp(); | |
2294 int local_words = method->max_locals() * Interpreter::stackElementWords; | |
2295 | |
2296 if (caller->is_compiled_frame()) { | |
2297 locals = fp + frame::register_save_words + local_words - 1; | |
2263 } else { | 2298 } else { |
2264 // Lay out locals block in the caller adjacent to the register window save area. | 2299 locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1; |
2265 // | |
2266 // Compiled frames do not allocate a varargs area which is why this if | |
2267 // statement is needed. | |
2268 // | |
2269 intptr_t* fp = interpreter_frame->fp(); | |
2270 int local_words = method->max_locals() * Interpreter::stackElementWords; | |
2271 | |
2272 if (caller->is_compiled_frame()) { | |
2273 locals = fp + frame::register_save_words + local_words - 1; | |
2274 } else { | |
2275 locals = fp + frame::memory_parameter_word_sp_offset + local_words - 1; | |
2276 } | |
2277 | |
2278 } | 2300 } |
2279 // END MUCHO HACK | 2301 |
2280 | 2302 } |
2281 intptr_t* monitor_base = (intptr_t*) cur_state; | 2303 // END MUCHO HACK |
2282 intptr_t* stack_base = monitor_base - monitor_size; | 2304 |
2283 /* +1 because stack is always prepushed */ | 2305 intptr_t* monitor_base = (intptr_t*) cur_state; |
2284 intptr_t* stack = stack_base - (tempcount + 1); | 2306 intptr_t* stack_base = monitor_base - monitor_size; |
2285 | 2307 /* +1 because stack is always prepushed */ |
2286 | 2308 intptr_t* stack = stack_base - (tempcount + 1); |
2287 BytecodeInterpreter::layout_interpreterState(cur_state, | 2309 |
2288 caller, | 2310 |
2289 interpreter_frame, | 2311 BytecodeInterpreter::layout_interpreterState(cur_state, |
2290 method, | 2312 caller, |
2291 locals, | 2313 interpreter_frame, |
2292 stack, | 2314 method, |
2293 stack_base, | 2315 locals, |
2294 monitor_base, | 2316 stack, |
2295 frame_bottom, | 2317 stack_base, |
2296 is_top_frame); | 2318 monitor_base, |
2297 | 2319 frame_bottom, |
2298 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp()); | 2320 is_top_frame); |
2299 | 2321 |
2300 } | 2322 BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp()); |
2301 return frame_words; | |
2302 } | 2323 } |
2303 | 2324 |
2304 #endif // CC_INTERP | 2325 #endif // CC_INTERP |