src/cpu/x86/vm/cppInterpreter_x86.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/cpu/x86/vm

src/cpu/x86/vm/cppInterpreter_x86.cpp

Print this page
rev 6132 : 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:
rev 6133 : [mq]: newstackbang-reviews


2325     prev->_result._to_call._callee = method;
2326     if (*prev->_bcp == Bytecodes::_invokeinterface) {
2327       prev->_result._to_call._bcp_advance = 5;
2328     } else {
2329       prev->_result._to_call._bcp_advance = 3;
2330     }
2331   }
2332   to_fill->_oop_temp = NULL;
2333   to_fill->_stack_base = stack_base;
2334   // Need +1 here because stack_base points to the word just above the first expr stack entry
2335   // and stack_limit is supposed to point to the word just below the last expr stack entry.
2336   // See generate_compute_interpreter_state.
2337   to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
2338   to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
2339 
2340   to_fill->_self_link = to_fill;
2341   assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base,
2342          "Stack top out of range");
2343 }
2344 
2345 int AbstractInterpreter::layout_activation(Method* method,
2346                                            int tempcount,  //
2347                                            int popframe_extra_args,
2348                                            int moncount,
2349                                            int caller_actual_parameters,
2350                                            int callee_param_count,
2351                                            int callee_locals,
2352                                            frame* caller,
2353                                            frame* interpreter_frame,
2354                                            bool is_top_frame,
2355                                            bool is_bottom_frame) {



2356 






















2357   assert(popframe_extra_args == 0, "FIX ME");
2358   // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
2359   // does as far as allocating an interpreter frame.
2360   // If interpreter_frame!=NULL, set up the method, locals, and monitors.
2361   // The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
2362   // as determined by a previous call to this method.
2363   // It is also guaranteed to be walkable even though it is in a skeletal state
2364   // NOTE: return size is in words not bytes
2365   // NOTE: tempcount is the current size of the java expression stack. For top most
2366   //       frames we will allocate a full sized expression stack and not the curback
2367   //       version that non-top frames have.
2368 
2369   // Calculate the amount our frame will be adjust by the callee. For top frame
2370   // this is zero.
2371 
2372   // NOTE: ia64 seems to do this wrong (or at least backwards) in that it
2373   // calculates the extra locals based on itself. Not what the callee does
2374   // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2375   // as getting sender_sp correct.
2376 
2377   int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
2378   int monitor_size = sizeof(BasicObjectLock) * moncount;
2379 
2380   // First calculate the frame size without any java expression stack
2381   int short_frame_size = size_activation_helper(extra_locals_size,
2382                                                 monitor_size);
2383 
2384   // Now with full size expression stack
2385   int full_frame_size = short_frame_size + method->max_stack() * BytesPerWord;









2386 
2387   // and now with only live portion of the expression stack
2388   short_frame_size = short_frame_size + tempcount * BytesPerWord;








2389 
2390   // the size the activation is right now. Only top frame is full size
2391   int frame_size = (is_top_frame ? full_frame_size : short_frame_size);


2392 
2393   if (interpreter_frame != NULL) {
2394 #ifdef ASSERT
2395     assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
2396 #endif
2397 
2398     // MUCHO HACK
2399 
2400     intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
2401 
2402     /* Now fillin the interpreterState object */
2403 
2404     // The state object is the first thing on the frame and easily located
2405 
2406     interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2407 
2408 
2409     // Find the locals pointer. This is rather simple on x86 because there is no
2410     // confusing rounding at the callee to account for. We can trivially locate
2411     // our locals based on the current fp().
2412     // Note: the + 2 is for handling the "static long no_params() method" issue.
2413     // (too bad I don't really remember that issue well...)


2436     }
2437 
2438     intptr_t* monitor_base = (intptr_t*) cur_state;
2439     intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
2440     /* +1 because stack is always prepushed */
2441     intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
2442 
2443 
2444     BytecodeInterpreter::layout_interpreterState(cur_state,
2445                                           caller,
2446                                           interpreter_frame,
2447                                           method,
2448                                           locals,
2449                                           stack,
2450                                           stack_base,
2451                                           monitor_base,
2452                                           frame_bottom,
2453                                           is_top_frame);
2454 
2455     // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());
2456   }
2457   return frame_size/BytesPerWord;
2458 }
2459 
2460 bool AbstractInterpreter::can_be_compiled(methodHandle m) {
2461   switch (method_kind(m)) {
2462     case Interpreter::java_lang_math_sin     : // fall thru
2463     case Interpreter::java_lang_math_cos     : // fall thru
2464     case Interpreter::java_lang_math_tan     : // fall thru
2465     case Interpreter::java_lang_math_abs     : // fall thru
2466     case Interpreter::java_lang_math_log     : // fall thru
2467     case Interpreter::java_lang_math_log10   : // fall thru
2468     case Interpreter::java_lang_math_sqrt    : // fall thru
2469     case Interpreter::java_lang_math_pow     : // fall thru
2470     case Interpreter::java_lang_math_exp     :
2471       return false;
2472     default:
2473       return true;
2474   }
2475 }
2476 
2477 


2325     prev->_result._to_call._callee = method;
2326     if (*prev->_bcp == Bytecodes::_invokeinterface) {
2327       prev->_result._to_call._bcp_advance = 5;
2328     } else {
2329       prev->_result._to_call._bcp_advance = 3;
2330     }
2331   }
2332   to_fill->_oop_temp = NULL;
2333   to_fill->_stack_base = stack_base;
2334   // Need +1 here because stack_base points to the word just above the first expr stack entry
2335   // and stack_limit is supposed to point to the word just below the last expr stack entry.
2336   // See generate_compute_interpreter_state.
2337   to_fill->_stack_limit = stack_base - (method->max_stack() + 1);
2338   to_fill->_monitor_base = (BasicObjectLock*) monitor_base;
2339 
2340   to_fill->_self_link = to_fill;
2341   assert(stack >= to_fill->_stack_limit && stack < to_fill->_stack_base,
2342          "Stack top out of range");
2343 }
2344 
2345 
2346 static int frame_size_helper(int max_stack,
2347                              int tempcount,
2348                              int moncount,

2349                              int callee_param_count,
2350                              int callee_locals,


2351                              bool is_top_frame,
2352                              int& monitor_size,
2353                              int& full_frame_size) {
2354   int extra_locals_size = (callee_locals - callee_param_count) * BytesPerWord;
2355   monitor_size = sizeof(BasicObjectLock) * moncount;
2356 
2357   // First calculate the frame size without any java expression stack
2358   int short_frame_size = size_activation_helper(extra_locals_size,
2359                                                 monitor_size);
2360 
2361   // Now with full size expression stack
2362   full_frame_size = short_frame_size + max_stack * BytesPerWord;
2363 
2364   // and now with only live portion of the expression stack
2365   short_frame_size = short_frame_size + tempcount * BytesPerWord;
2366 
2367   // the size the activation is right now. Only top frame is full size
2368   int frame_size = (is_top_frame ? full_frame_size : short_frame_size);
2369   return frame_size;
2370 }
2371 
2372 int AbstractInterpreter::size_activation(int max_stack,
2373                                          int tempcount,
2374                                          int popframe_extra_args,
2375                                          int moncount,
2376                                          int callee_param_count,
2377                                          int callee_locals,
2378                                          bool is_top_frame) {
2379   assert(popframe_extra_args == 0, "FIX ME");






2380   // NOTE: return size is in words not bytes



2381 
2382   // Calculate the amount our frame will be adjust by the callee. For top frame
2383   // this is zero.
2384 
2385   // NOTE: ia64 seems to do this wrong (or at least backwards) in that it
2386   // calculates the extra locals based on itself. Not what the callee does
2387   // to it. So it ignores last_frame_adjust value. Seems suspicious as far
2388   // as getting sender_sp correct.
2389 
2390   int unused_monitor_size = 0;
2391   int unused_full_frame_size = 0;
2392   return frame_size_helper(max_stack, tempcount, moncount, callee_param_count, callee_locals,
2393                            is_top_frame, unused_monitor_size, unused_full_frame_size)/BytesPerWord;
2394 }

2395 
2396 void AbstractInterpreter::layout_activation(Method* method,
2397                                             int tempcount,  //
2398                                             int popframe_extra_args,
2399                                             int moncount,
2400                                             int caller_actual_parameters,
2401                                             int callee_param_count,
2402                                             int callee_locals,
2403                                             frame* caller,
2404                                             frame* interpreter_frame,
2405                                             bool is_top_frame,
2406                                             bool is_bottom_frame) {
2407 
2408   assert(popframe_extra_args == 0, "FIX ME");
2409   // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state()
2410   // does as far as allocating an interpreter frame.
2411   // Set up the method, locals, and monitors.
2412   // The frame interpreter_frame is guaranteed to be the right size,
2413   // as determined by a previous call to the size_activation() method.
2414   // It is also guaranteed to be walkable even though it is in a skeletal state
2415   // NOTE: tempcount is the current size of the java expression stack. For top most
2416   //       frames we will allocate a full sized expression stack and not the curback
2417   //       version that non-top frames have.
2418 
2419   int monitor_size = 0;
2420   int full_frame_size = 0;
2421   int frame_size = frame_size_helper(method->max_stack(), tempcount, moncount, callee_param_count, callee_locals,
2422                                      is_top_frame, monitor_size, full_frame_size);
2423 

2424 #ifdef ASSERT
2425   assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
2426 #endif
2427 
2428   // MUCHO HACK
2429 
2430   intptr_t* frame_bottom = (intptr_t*) ((intptr_t)interpreter_frame->sp() - (full_frame_size - frame_size));
2431 
2432   /* Now fillin the interpreterState object */
2433 
2434   // The state object is the first thing on the frame and easily located
2435 
2436   interpreterState cur_state = (interpreterState) ((intptr_t)interpreter_frame->fp() - sizeof(BytecodeInterpreter));
2437 
2438 
2439   // Find the locals pointer. This is rather simple on x86 because there is no
2440   // confusing rounding at the callee to account for. We can trivially locate
2441   // our locals based on the current fp().
2442   // Note: the + 2 is for handling the "static long no_params() method" issue.
2443   // (too bad I don't really remember that issue well...)


2466   }
2467 
2468   intptr_t* monitor_base = (intptr_t*) cur_state;
2469   intptr_t* stack_base = (intptr_t*) ((intptr_t) monitor_base - monitor_size);
2470   /* +1 because stack is always prepushed */
2471   intptr_t* stack = (intptr_t*) ((intptr_t) stack_base - (tempcount + 1) * BytesPerWord);
2472 
2473 
2474   BytecodeInterpreter::layout_interpreterState(cur_state,
2475                                                caller,
2476                                                interpreter_frame,
2477                                                method,
2478                                                locals,
2479                                                stack,
2480                                                stack_base,
2481                                                monitor_base,
2482                                                frame_bottom,
2483                                                is_top_frame);
2484 
2485   // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp());


2486 }
2487 
2488 bool AbstractInterpreter::can_be_compiled(methodHandle m) {
2489   switch (method_kind(m)) {
2490     case Interpreter::java_lang_math_sin     : // fall thru
2491     case Interpreter::java_lang_math_cos     : // fall thru
2492     case Interpreter::java_lang_math_tan     : // fall thru
2493     case Interpreter::java_lang_math_abs     : // fall thru
2494     case Interpreter::java_lang_math_log     : // fall thru
2495     case Interpreter::java_lang_math_log10   : // fall thru
2496     case Interpreter::java_lang_math_sqrt    : // fall thru
2497     case Interpreter::java_lang_math_pow     : // fall thru
2498     case Interpreter::java_lang_math_exp     :
2499       return false;
2500     default:
2501       return true;
2502   }
2503 }
2504 
2505 
src/cpu/x86/vm/cppInterpreter_x86.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File