src/cpu/sparc/vm/templateInterpreter_sparc.cpp

Print this page
rev 4376 : 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
Summary: ConstMethod::max_stack() doesn't account for JSR 292 appendix.
Reviewed-by:


 482   //    Lesp       : expression stack pointer
 483   //    Lbcp       : bytecode pointer
 484   //    Lmethod    : method
 485   //    Llocals    : locals pointer
 486   //    Lmonitors  : monitor pointer
 487   //    LcpoolCache: constant pool cache
 488   //
 489   // 4) Initialize the non-argument locals if necessary:
 490   //    Non-argument locals may need to be initialized to NULL
 491   //    for GC to work. If the oop-map information is accurate
 492   //    (in the absence of the JSR problem), no initialization
 493   //    is necessary.
 494   //
 495   // (gri - 2/25/2000)
 496 
 497 
 498   int rounded_vm_local_words = round_to( frame::interpreter_frame_vm_local_words, WordsPerLong );
 499 
 500   const int extra_space =
 501     rounded_vm_local_words +                   // frame local scratch space
 502     //6815692//Method::extra_stack_words() +       // extra push slots for MH adapters
 503     frame::memory_parameter_word_sp_offset +   // register save area
 504     (native_call ? frame::interpreter_frame_extra_outgoing_argument_words : 0);
 505 
 506   const Register Glocals_size = G3;
 507   const Register RconstMethod = Glocals_size;
 508   const Register Otmp1 = O3;
 509   const Register Otmp2 = O4;
 510   // Lscratch can't be used as a temporary because the call_stub uses
 511   // it to assert that the stack frame was setup correctly.
 512   const Address constMethod       (G5_method, Method::const_offset());
 513   const Address size_of_parameters(RconstMethod, ConstMethod::size_of_parameters_offset());
 514 
 515   __ ld_ptr( constMethod, RconstMethod );
 516   __ lduh( size_of_parameters, Glocals_size);
 517 
 518   // Gargs points to first local + BytesPerWord
 519   // Set the saved SP after the register window save
 520   //
 521   assert_different_registers(Gargs, Glocals_size, Gframe_size, O5_savedSP);
 522   __ sll(Glocals_size, Interpreter::logStackElementSize, Otmp1);


1533 static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
1534 
1535   // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
1536   // expression stack, the callee will have callee_extra_locals (so we can account for
1537   // frame extension) and monitor_size for monitors. Basically we need to calculate
1538   // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
1539   //
1540   //
1541   // The big complicating thing here is that we must ensure that the stack stays properly
1542   // aligned. This would be even uglier if monitor size wasn't modulo what the stack
1543   // needs to be aligned for). We are given that the sp (fp) is already aligned by
1544   // the caller so we must ensure that it is properly aligned for our callee.
1545   //
1546   const int rounded_vm_local_words =
1547        round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
1548   // callee_locals and max_stack are counts, not the size in frame.
1549   const int locals_size =
1550        round_to(callee_extra_locals * Interpreter::stackElementWords, WordsPerLong);
1551   const int max_stack_words = max_stack * Interpreter::stackElementWords;
1552   return (round_to((max_stack_words
1553                    //6815692//+ Method::extra_stack_words()
1554                    + rounded_vm_local_words
1555                    + frame::memory_parameter_word_sp_offset), WordsPerLong)
1556                    // already rounded
1557                    + locals_size + monitor_size);
1558 }
1559 
1560 // How much stack a method top interpreter activation needs in words.
1561 int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
1562 
1563   // See call_stub code
1564   int call_stub_size  = round_to(7 + frame::memory_parameter_word_sp_offset,
1565                                  WordsPerLong);    // 7 + register save area
1566 
1567   // Save space for one monitor to get into the interpreted method in case
1568   // the method is synchronized
1569   int monitor_size    = method->is_synchronized() ?
1570                                 1*frame::interpreter_frame_monitor_size() : 0;
1571   return size_activation_helper(method->max_locals(), method->max_stack(),
1572                                  monitor_size) + call_stub_size;
1573 }




 482   //    Lesp       : expression stack pointer
 483   //    Lbcp       : bytecode pointer
 484   //    Lmethod    : method
 485   //    Llocals    : locals pointer
 486   //    Lmonitors  : monitor pointer
 487   //    LcpoolCache: constant pool cache
 488   //
 489   // 4) Initialize the non-argument locals if necessary:
 490   //    Non-argument locals may need to be initialized to NULL
 491   //    for GC to work. If the oop-map information is accurate
 492   //    (in the absence of the JSR problem), no initialization
 493   //    is necessary.
 494   //
 495   // (gri - 2/25/2000)
 496 
 497 
 498   int rounded_vm_local_words = round_to( frame::interpreter_frame_vm_local_words, WordsPerLong );
 499 
 500   const int extra_space =
 501     rounded_vm_local_words +                   // frame local scratch space

 502     frame::memory_parameter_word_sp_offset +   // register save area
 503     (native_call ? frame::interpreter_frame_extra_outgoing_argument_words : 0);
 504 
 505   const Register Glocals_size = G3;
 506   const Register RconstMethod = Glocals_size;
 507   const Register Otmp1 = O3;
 508   const Register Otmp2 = O4;
 509   // Lscratch can't be used as a temporary because the call_stub uses
 510   // it to assert that the stack frame was setup correctly.
 511   const Address constMethod       (G5_method, Method::const_offset());
 512   const Address size_of_parameters(RconstMethod, ConstMethod::size_of_parameters_offset());
 513 
 514   __ ld_ptr( constMethod, RconstMethod );
 515   __ lduh( size_of_parameters, Glocals_size);
 516 
 517   // Gargs points to first local + BytesPerWord
 518   // Set the saved SP after the register window save
 519   //
 520   assert_different_registers(Gargs, Glocals_size, Gframe_size, O5_savedSP);
 521   __ sll(Glocals_size, Interpreter::logStackElementSize, Otmp1);


1532 static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
1533 
1534   // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
1535   // expression stack, the callee will have callee_extra_locals (so we can account for
1536   // frame extension) and monitor_size for monitors. Basically we need to calculate
1537   // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
1538   //
1539   //
1540   // The big complicating thing here is that we must ensure that the stack stays properly
1541   // aligned. This would be even uglier if monitor size wasn't modulo what the stack
1542   // needs to be aligned for). We are given that the sp (fp) is already aligned by
1543   // the caller so we must ensure that it is properly aligned for our callee.
1544   //
1545   const int rounded_vm_local_words =
1546        round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
1547   // callee_locals and max_stack are counts, not the size in frame.
1548   const int locals_size =
1549        round_to(callee_extra_locals * Interpreter::stackElementWords, WordsPerLong);
1550   const int max_stack_words = max_stack * Interpreter::stackElementWords;
1551   return (round_to((max_stack_words

1552                    + rounded_vm_local_words
1553                    + frame::memory_parameter_word_sp_offset), WordsPerLong)
1554                    // already rounded
1555                    + locals_size + monitor_size);
1556 }
1557 
1558 // How much stack a method top interpreter activation needs in words.
1559 int AbstractInterpreter::size_top_interpreter_activation(Method* method) {
1560 
1561   // See call_stub code
1562   int call_stub_size  = round_to(7 + frame::memory_parameter_word_sp_offset,
1563                                  WordsPerLong);    // 7 + register save area
1564 
1565   // Save space for one monitor to get into the interpreted method in case
1566   // the method is synchronized
1567   int monitor_size    = method->is_synchronized() ?
1568                                 1*frame::interpreter_frame_monitor_size() : 0;
1569   return size_activation_helper(method->max_locals(), method->max_stack(),
1570                                  monitor_size) + call_stub_size;
1571 }