91 __ jump_to (thrower);
92 __ delayed()->nop();
93 return entry;
94 }
95
96 address TemplateInterpreterGenerator::generate_ClassCastException_handler() {
97 address entry = __ pc();
98 // expression stack must be empty before entering the VM if an exception
99 // happened
100 __ empty_expression_stack();
101 // load exception object
102 __ call_VM(Oexception,
103 CAST_FROM_FN_PTR(address,
104 InterpreterRuntime::throw_ClassCastException),
105 Otos_i);
106 __ should_not_reach_here();
107 return entry;
108 }
109
110
111 address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler(const char* name) {
112 address entry = __ pc();
113 // expression stack must be empty before entering the VM if an exception happened
114 __ empty_expression_stack();
115 // convention: expect aberrant index in register G3_scratch, then shuffle the
116 // index to G4_scratch for the VM call
117 __ mov(G3_scratch, G4_scratch);
118 __ set((intptr_t)name, G3_scratch);
119 __ call_VM(Oexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException), G3_scratch, G4_scratch);
120 __ should_not_reach_here();
121 return entry;
122 }
123
124
125 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
126 address entry = __ pc();
127 // expression stack must be empty before entering the VM if an exception happened
128 __ empty_expression_stack();
129 __ call_VM(Oexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError));
130 __ should_not_reach_here();
431 // Llocals : locals pointer
432 // Lmonitors : monitor pointer
433 // LcpoolCache: constant pool cache
434 //
435 // 4) Initialize the non-argument locals if necessary:
436 // Non-argument locals may need to be initialized to NULL
437 // for GC to work. If the oop-map information is accurate
438 // (in the absence of the JSR problem), no initialization
439 // is necessary.
440 //
441 // (gri - 2/25/2000)
442
443
444 const Address size_of_parameters(G5_method, 0, in_bytes(methodOopDesc::size_of_parameters_offset()));
445 const Address size_of_locals (G5_method, 0, in_bytes(methodOopDesc::size_of_locals_offset()));
446 const Address max_stack (G5_method, 0, in_bytes(methodOopDesc::max_stack_offset()));
447 int rounded_vm_local_words = round_to( frame::interpreter_frame_vm_local_words, WordsPerLong );
448
449 const int extra_space =
450 rounded_vm_local_words + // frame local scratch space
451 frame::memory_parameter_word_sp_offset + // register save area
452 (native_call ? frame::interpreter_frame_extra_outgoing_argument_words : 0);
453
454 const Register Glocals_size = G3;
455 const Register Otmp1 = O3;
456 const Register Otmp2 = O4;
457 // Lscratch can't be used as a temporary because the call_stub uses
458 // it to assert that the stack frame was setup correctly.
459
460 __ lduh( size_of_parameters, Glocals_size);
461
462 // Gargs points to first local + BytesPerWord
463 // Set the saved SP after the register window save
464 //
465 assert_different_registers(Gargs, Glocals_size, Gframe_size, O5_savedSP);
466 __ sll(Glocals_size, Interpreter::logStackElementSize(), Otmp1);
467 __ add(Gargs, Otmp1, Gargs);
468
469 if (native_call) {
470 __ calc_mem_param_words( Glocals_size, Gframe_size );
1428 // | |
1429
1430 static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
1431
1432 // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
1433 // expression stack, the callee will have callee_extra_locals (so we can account for
1434 // frame extension) and monitor_size for monitors. Basically we need to calculate
1435 // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
1436 //
1437 //
1438 // The big complicating thing here is that we must ensure that the stack stays properly
1439 // aligned. This would be even uglier if monitor size wasn't modulo what the stack
1440 // needs to be aligned for). We are given that the sp (fp) is already aligned by
1441 // the caller so we must ensure that it is properly aligned for our callee.
1442 //
1443 const int rounded_vm_local_words =
1444 round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
1445 // callee_locals and max_stack are counts, not the size in frame.
1446 const int locals_size =
1447 round_to(callee_extra_locals * Interpreter::stackElementWords(), WordsPerLong);
1448 const int max_stack_words = max_stack * Interpreter::stackElementWords();
1449 return (round_to((max_stack_words
1450 + rounded_vm_local_words
1451 + frame::memory_parameter_word_sp_offset), WordsPerLong)
1452 // already rounded
1453 + locals_size + monitor_size);
1454 }
1455
1456 // How much stack a method top interpreter activation needs in words.
1457 int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
1458
1459 // See call_stub code
1460 int call_stub_size = round_to(7 + frame::memory_parameter_word_sp_offset,
1461 WordsPerLong); // 7 + register save area
1462
1463 // Save space for one monitor to get into the interpreted method in case
1464 // the method is synchronized
1465 int monitor_size = method->is_synchronized() ?
1466 1*frame::interpreter_frame_monitor_size() : 0;
1467 return size_activation_helper(method->max_locals(), method->max_stack(),
1468 monitor_size) + call_stub_size;
|
91 __ jump_to (thrower);
92 __ delayed()->nop();
93 return entry;
94 }
95
96 address TemplateInterpreterGenerator::generate_ClassCastException_handler() {
97 address entry = __ pc();
98 // expression stack must be empty before entering the VM if an exception
99 // happened
100 __ empty_expression_stack();
101 // load exception object
102 __ call_VM(Oexception,
103 CAST_FROM_FN_PTR(address,
104 InterpreterRuntime::throw_ClassCastException),
105 Otos_i);
106 __ should_not_reach_here();
107 return entry;
108 }
109
110
111 #ifdef ASSERT
112 address last_WrongMethodType_caller;
113 #endif //ASSERT
114
115 // Arguments are: required type in G5_method_type, and
116 // failing object (or NULL) in G3_method_handle.
117 // In the debug build, the caller should put his own PC in G1.
118 address TemplateInterpreterGenerator::generate_WrongMethodType_handler() {
119 address entry = __ pc();
120 #ifdef ASSERT
121 Address last_caller_addr(O3, (address)&last_WrongMethodType_caller);
122 __ sethi(last_caller_addr);
123 __ st_ptr(G1, last_caller_addr);
124 #endif //ASSERT
125 // expression stack must be empty before entering the VM if an exception
126 // happened
127 __ empty_expression_stack();
128 // load exception object
129 __ call_VM(Oexception,
130 CAST_FROM_FN_PTR(address,
131 InterpreterRuntime::throw_WrongMethodTypeException),
132 G5_method_type, // required
133 G3_method_handle); // actual
134 __ should_not_reach_here();
135 return entry;
136 }
137
138
139 address TemplateInterpreterGenerator::generate_ArrayIndexOutOfBounds_handler(const char* name) {
140 address entry = __ pc();
141 // expression stack must be empty before entering the VM if an exception happened
142 __ empty_expression_stack();
143 // convention: expect aberrant index in register G3_scratch, then shuffle the
144 // index to G4_scratch for the VM call
145 __ mov(G3_scratch, G4_scratch);
146 __ set((intptr_t)name, G3_scratch);
147 __ call_VM(Oexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException), G3_scratch, G4_scratch);
148 __ should_not_reach_here();
149 return entry;
150 }
151
152
153 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
154 address entry = __ pc();
155 // expression stack must be empty before entering the VM if an exception happened
156 __ empty_expression_stack();
157 __ call_VM(Oexception, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_StackOverflowError));
158 __ should_not_reach_here();
459 // Llocals : locals pointer
460 // Lmonitors : monitor pointer
461 // LcpoolCache: constant pool cache
462 //
463 // 4) Initialize the non-argument locals if necessary:
464 // Non-argument locals may need to be initialized to NULL
465 // for GC to work. If the oop-map information is accurate
466 // (in the absence of the JSR problem), no initialization
467 // is necessary.
468 //
469 // (gri - 2/25/2000)
470
471
472 const Address size_of_parameters(G5_method, 0, in_bytes(methodOopDesc::size_of_parameters_offset()));
473 const Address size_of_locals (G5_method, 0, in_bytes(methodOopDesc::size_of_locals_offset()));
474 const Address max_stack (G5_method, 0, in_bytes(methodOopDesc::max_stack_offset()));
475 int rounded_vm_local_words = round_to( frame::interpreter_frame_vm_local_words, WordsPerLong );
476
477 const int extra_space =
478 rounded_vm_local_words + // frame local scratch space
479 methodOopDesc::extra_stack() + // extra push slot for MH insertion
480 frame::memory_parameter_word_sp_offset + // register save area
481 (native_call ? frame::interpreter_frame_extra_outgoing_argument_words : 0);
482
483 const Register Glocals_size = G3;
484 const Register Otmp1 = O3;
485 const Register Otmp2 = O4;
486 // Lscratch can't be used as a temporary because the call_stub uses
487 // it to assert that the stack frame was setup correctly.
488
489 __ lduh( size_of_parameters, Glocals_size);
490
491 // Gargs points to first local + BytesPerWord
492 // Set the saved SP after the register window save
493 //
494 assert_different_registers(Gargs, Glocals_size, Gframe_size, O5_savedSP);
495 __ sll(Glocals_size, Interpreter::logStackElementSize(), Otmp1);
496 __ add(Gargs, Otmp1, Gargs);
497
498 if (native_call) {
499 __ calc_mem_param_words( Glocals_size, Gframe_size );
1457 // | |
1458
1459 static int size_activation_helper(int callee_extra_locals, int max_stack, int monitor_size) {
1460
1461 // Figure out the size of an interpreter frame (in words) given that we have a fully allocated
1462 // expression stack, the callee will have callee_extra_locals (so we can account for
1463 // frame extension) and monitor_size for monitors. Basically we need to calculate
1464 // this exactly like generate_fixed_frame/generate_compute_interpreter_state.
1465 //
1466 //
1467 // The big complicating thing here is that we must ensure that the stack stays properly
1468 // aligned. This would be even uglier if monitor size wasn't modulo what the stack
1469 // needs to be aligned for). We are given that the sp (fp) is already aligned by
1470 // the caller so we must ensure that it is properly aligned for our callee.
1471 //
1472 const int rounded_vm_local_words =
1473 round_to(frame::interpreter_frame_vm_local_words,WordsPerLong);
1474 // callee_locals and max_stack are counts, not the size in frame.
1475 const int locals_size =
1476 round_to(callee_extra_locals * Interpreter::stackElementWords(), WordsPerLong);
1477 const int extra_stack = methodOopDesc::extra_stack();
1478 const int max_stack_words = (max_stack + extra_stack) * Interpreter::stackElementWords();
1479 return (round_to((max_stack_words
1480 + rounded_vm_local_words
1481 + frame::memory_parameter_word_sp_offset), WordsPerLong)
1482 // already rounded
1483 + locals_size + monitor_size);
1484 }
1485
1486 // How much stack a method top interpreter activation needs in words.
1487 int AbstractInterpreter::size_top_interpreter_activation(methodOop method) {
1488
1489 // See call_stub code
1490 int call_stub_size = round_to(7 + frame::memory_parameter_word_sp_offset,
1491 WordsPerLong); // 7 + register save area
1492
1493 // Save space for one monitor to get into the interpreted method in case
1494 // the method is synchronized
1495 int monitor_size = method->is_synchronized() ?
1496 1*frame::interpreter_frame_monitor_size() : 0;
1497 return size_activation_helper(method->max_locals(), method->max_stack(),
1498 monitor_size) + call_stub_size;
|