1332 // We must calc this exactly like in generate_fixed_frame. |
1332 // We must calc this exactly like in generate_fixed_frame. |
1333 // Note: This returns the conservative size assuming maximum alignment. |
1333 // Note: This returns the conservative size assuming maximum alignment. |
1334 int AbstractInterpreter::size_top_interpreter_activation(Method* method) { |
1334 int AbstractInterpreter::size_top_interpreter_activation(Method* method) { |
1335 const int max_alignment_size = 2; |
1335 const int max_alignment_size = 2; |
1336 const int abi_scratch = frame::abi_reg_args_size; |
1336 const int abi_scratch = frame::abi_reg_args_size; |
1337 return method->max_locals() + method->max_stack() + frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch; |
1337 return method->max_locals() + method->max_stack() + |
1338 } |
1338 frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch; |
1339 |
1339 } |
1340 // Fills a sceletal interpreter frame generated during deoptimizations |
1340 |
1341 // and returns the frame size in slots. |
1341 // Returns number of stackElementWords needed for the interpreter frame with the |
|
1342 // given sections. |
|
1343 // This overestimates the stack by one slot in case of alignments. |
|
1344 int AbstractInterpreter::size_activation(int max_stack, |
|
1345 int temps, |
|
1346 int extra_args, |
|
1347 int monitors, |
|
1348 int callee_params, |
|
1349 int callee_locals, |
|
1350 bool is_top_frame) { |
|
1351 // Note: This calculation must exactly parallel the frame setup |
|
1352 // in AbstractInterpreterGenerator::generate_method_entry. |
|
1353 assert(Interpreter::stackElementWords == 1, "sanity"); |
|
1354 const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize; |
|
1355 const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) : |
|
1356 (frame::abi_minframe_size / Interpreter::stackElementSize); |
|
1357 const int size = |
|
1358 max_stack + |
|
1359 (callee_locals - callee_params) + |
|
1360 monitors * frame::interpreter_frame_monitor_size() + |
|
1361 max_alignment_space + |
|
1362 abi_scratch + |
|
1363 frame::ijava_state_size / Interpreter::stackElementSize; |
|
1364 |
|
1365 // Fixed size of an interpreter frame, align to 16-byte. |
|
1366 return (size & -2); |
|
1367 } |
|
1368 |
|
1369 // Fills a sceletal interpreter frame generated during deoptimizations. |
1342 // |
1370 // |
1343 // Parameters: |
1371 // Parameters: |
1344 // |
|
1345 // interpreter_frame == NULL: |
|
1346 // Only calculate the size of an interpreter activation, no actual layout. |
|
1347 // Note: This calculation must exactly parallel the frame setup |
|
1348 // in TemplateInterpreter::generate_normal_entry. But it does not |
|
1349 // account for the SP alignment, that might further enhance the |
|
1350 // frame size, depending on FP. |
|
1351 // |
1372 // |
1352 // interpreter_frame != NULL: |
1373 // interpreter_frame != NULL: |
1353 // set up the method, locals, and monitors. |
1374 // set up the method, locals, and monitors. |
1354 // The frame interpreter_frame, if not NULL, is guaranteed to be the |
1375 // The frame interpreter_frame, if not NULL, is guaranteed to be the |
1355 // right size, as determined by a previous call to this method. |
1376 // right size, as determined by a previous call to this method. |
1363 // off the callee frame. We want to re-execute the call that called the |
1384 // off the callee frame. We want to re-execute the call that called the |
1364 // callee interpreted, but since the return to the interpreter would pop |
1385 // callee interpreted, but since the return to the interpreter would pop |
1365 // the arguments off advance the esp by dummy popframe_extra_args slots. |
1386 // the arguments off advance the esp by dummy popframe_extra_args slots. |
1366 // Popping off those will establish the stack layout as it was before the call. |
1387 // Popping off those will establish the stack layout as it was before the call. |
1367 // |
1388 // |
1368 int AbstractInterpreter::layout_activation(Method* method, |
1389 void AbstractInterpreter::layout_activation(Method* method, |
1369 int tempcount, |
1390 int tempcount, |
1370 int popframe_extra_args, |
1391 int popframe_extra_args, |
1371 int moncount, |
1392 int moncount, |
1372 int caller_actual_parameters, |
1393 int caller_actual_parameters, |
1373 int callee_param_count, |
1394 int callee_param_count, |
1374 int callee_locals, |
1395 int callee_locals_count, |
1375 frame* caller, |
1396 frame* caller, |
1376 frame* interpreter_frame, |
1397 frame* interpreter_frame, |
1377 bool is_top_frame, |
1398 bool is_top_frame, |
1378 bool is_bottom_frame) { |
1399 bool is_bottom_frame) { |
1379 |
1400 |
1380 const int max_alignment_space = 2; |
|
1381 const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) : |
1401 const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) : |
1382 (frame::abi_minframe_size / Interpreter::stackElementSize) ; |
1402 (frame::abi_minframe_size / Interpreter::stackElementSize); |
1383 const int conservative_framesize_in_slots = |
1403 |
1384 method->max_stack() + callee_locals - callee_param_count + |
1404 intptr_t* locals_base = (caller->is_interpreted_frame()) ? |
1385 (moncount * frame::interpreter_frame_monitor_size()) + max_alignment_space + |
1405 caller->interpreter_frame_esp() + caller_actual_parameters : |
1386 abi_scratch + frame::ijava_state_size / Interpreter::stackElementSize; |
1406 caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ; |
1387 |
1407 |
1388 assert(!is_top_frame || conservative_framesize_in_slots * 8 > frame::abi_reg_args_size + frame::ijava_state_size, "frame too small"); |
1408 intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ; |
1389 |
1409 intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size()); |
1390 if (interpreter_frame == NULL) { |
1410 intptr_t* esp_base = monitor - 1; |
1391 // Since we don't know the exact alignment, we return the conservative size. |
1411 intptr_t* esp = esp_base - tempcount - popframe_extra_args; |
1392 return (conservative_framesize_in_slots & -2); |
1412 intptr_t* sp = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes); |
1393 } else { |
1413 intptr_t* sender_sp = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize; |
1394 // Now we know our caller, calc the exact frame layout and size. |
1414 intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize; |
1395 intptr_t* locals_base = (caller->is_interpreted_frame()) ? |
1415 |
1396 caller->interpreter_frame_esp() + caller_actual_parameters : |
1416 interpreter_frame->interpreter_frame_set_method(method); |
1397 caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ; |
1417 interpreter_frame->interpreter_frame_set_locals(locals_base); |
1398 |
1418 interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache()); |
1399 intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ; |
1419 interpreter_frame->interpreter_frame_set_esp(esp); |
1400 intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size()); |
1420 interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor); |
1401 intptr_t* esp_base = monitor - 1; |
1421 interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp); |
1402 intptr_t* esp = esp_base - tempcount - popframe_extra_args; |
1422 if (!is_bottom_frame) { |
1403 intptr_t* sp = (intptr_t *) (((intptr_t) (esp_base- callee_locals + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes); |
1423 interpreter_frame->interpreter_frame_set_sender_sp(sender_sp); |
1404 intptr_t* sender_sp = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize; |
|
1405 intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize; |
|
1406 |
|
1407 interpreter_frame->interpreter_frame_set_method(method); |
|
1408 interpreter_frame->interpreter_frame_set_locals(locals_base); |
|
1409 interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache()); |
|
1410 interpreter_frame->interpreter_frame_set_esp(esp); |
|
1411 interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor); |
|
1412 interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp); |
|
1413 if (!is_bottom_frame) { |
|
1414 interpreter_frame->interpreter_frame_set_sender_sp(sender_sp); |
|
1415 } |
|
1416 |
|
1417 int framesize_in_slots = caller->sp() - sp; |
|
1418 assert(!is_top_frame ||framesize_in_slots >= (frame::abi_reg_args_size / Interpreter::stackElementSize) + frame::ijava_state_size / Interpreter::stackElementSize, "frame too small"); |
|
1419 assert(framesize_in_slots <= conservative_framesize_in_slots, "exact frame size must be smaller than the convervative size!"); |
|
1420 return framesize_in_slots; |
|
1421 } |
1424 } |
1422 } |
1425 } |
1423 |
1426 |
1424 // ============================================================================= |
1427 // ============================================================================= |
1425 // Exceptions |
1428 // Exceptions |