1386 1387 // Performance measurements show the 1word and 2word variants to be almost equivalent, 1388 // with very light advantages for the 1word variant. We chose the 1word variant for 1389 // code compactness. 1390 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3); 1391 1392 // Restore caller sp for c2i case and return. 1393 __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. 1394 __ blr(); 1395 1396 // Generate a vanilla native entry as the slow path. 1397 BLOCK_COMMENT("} CRC32_updateBytes(Buffer)"); 1398 BIND(slow_path); 1399 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1); 1400 return start; 1401 } 1402 1403 return NULL; 1404 } 1405 1406 // These should never be compiled since the interpreter will prefer 1407 // the compiled version to the intrinsic version. 1408 bool AbstractInterpreter::can_be_compiled(methodHandle m) { 1409 return !math_entry_available(method_kind(m)); 1410 } 1411 1412 // How much stack a method activation needs in stack slots. 1413 // We must calc this exactly like in generate_fixed_frame. 1414 // Note: This returns the conservative size assuming maximum alignment. 1415 int AbstractInterpreter::size_top_interpreter_activation(Method* method) { 1416 const int max_alignment_size = 2; 1417 const int abi_scratch = frame::abi_reg_args_size; 1418 return method->max_locals() + method->max_stack() + 1419 frame::interpreter_frame_monitor_size() + max_alignment_size + abi_scratch; 1420 } 1421 1422 // Returns number of stackElementWords needed for the interpreter frame with the 1423 // given sections. 1424 // This overestimates the stack by one slot in case of alignments. 1425 int AbstractInterpreter::size_activation(int max_stack, 1426 int temps, 1427 int extra_args, 1428 int monitors, 1429 int callee_params, 1430 int callee_locals, 1431 bool is_top_frame) { 1432 // Note: This calculation must exactly parallel the frame setup 1433 // in InterpreterGenerator::generate_fixed_frame. 1434 assert(Interpreter::stackElementWords == 1, "sanity"); 1435 const int max_alignment_space = StackAlignmentInBytes / Interpreter::stackElementSize; 1436 const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) : 1437 (frame::abi_minframe_size / Interpreter::stackElementSize); 1438 const int size = 1439 max_stack + 1440 (callee_locals - callee_params) + 1441 monitors * frame::interpreter_frame_monitor_size() + 1442 max_alignment_space + 1443 abi_scratch + 1444 frame::ijava_state_size / Interpreter::stackElementSize; 1445 1446 // Fixed size of an interpreter frame, align to 16-byte. 1447 return (size & -2); 1448 } 1449 1450 // Fills a sceletal interpreter frame generated during deoptimizations. 1451 // 1452 // Parameters: 1453 // 1454 // interpreter_frame != NULL: 1455 // set up the method, locals, and monitors. 1456 // The frame interpreter_frame, if not NULL, is guaranteed to be the 1457 // right size, as determined by a previous call to this method. 1458 // It is also guaranteed to be walkable even though it is in a skeletal state 1459 // 1460 // is_top_frame == true: 1461 // We're processing the *oldest* interpreter frame! 1462 // 1463 // pop_frame_extra_args: 1464 // If this is != 0 we are returning to a deoptimized frame by popping 1465 // off the callee frame. We want to re-execute the call that called the 1466 // callee interpreted, but since the return to the interpreter would pop 1467 // the arguments off advance the esp by dummy popframe_extra_args slots. 1468 // Popping off those will establish the stack layout as it was before the call. 1469 // 1470 void AbstractInterpreter::layout_activation(Method* method, 1471 int tempcount, 1472 int popframe_extra_args, 1473 int moncount, 1474 int caller_actual_parameters, 1475 int callee_param_count, 1476 int callee_locals_count, 1477 frame* caller, 1478 frame* interpreter_frame, 1479 bool is_top_frame, 1480 bool is_bottom_frame) { 1481 1482 const int abi_scratch = is_top_frame ? (frame::abi_reg_args_size / Interpreter::stackElementSize) : 1483 (frame::abi_minframe_size / Interpreter::stackElementSize); 1484 1485 intptr_t* locals_base = (caller->is_interpreted_frame()) ? 1486 caller->interpreter_frame_esp() + caller_actual_parameters : 1487 caller->sp() + method->max_locals() - 1 + (frame::abi_minframe_size / Interpreter::stackElementSize) ; 1488 1489 intptr_t* monitor_base = caller->sp() - frame::ijava_state_size / Interpreter::stackElementSize ; 1490 intptr_t* monitor = monitor_base - (moncount * frame::interpreter_frame_monitor_size()); 1491 intptr_t* esp_base = monitor - 1; 1492 intptr_t* esp = esp_base - tempcount - popframe_extra_args; 1493 intptr_t* sp = (intptr_t *) (((intptr_t) (esp_base - callee_locals_count + callee_param_count - method->max_stack()- abi_scratch)) & -StackAlignmentInBytes); 1494 intptr_t* sender_sp = caller->sp() + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize; 1495 intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize; 1496 1497 interpreter_frame->interpreter_frame_set_method(method); 1498 interpreter_frame->interpreter_frame_set_locals(locals_base); 1499 interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache()); 1500 interpreter_frame->interpreter_frame_set_esp(esp); 1501 interpreter_frame->interpreter_frame_set_monitor_end((BasicObjectLock *)monitor); 1502 interpreter_frame->interpreter_frame_set_top_frame_sp(top_frame_sp); 1503 if (!is_bottom_frame) { 1504 interpreter_frame->interpreter_frame_set_sender_sp(sender_sp); 1505 } 1506 } 1507 1508 // ============================================================================= 1509 // Exceptions 1510 1511 void TemplateInterpreterGenerator::generate_throw_exception() { 1512 Register Rexception = R17_tos, 1513 Rcontinuation = R3_RET; 1514 1515 // -------------------------------------------------------------------------- 1516 // Entry point if an method returns with a pending exception (rethrow). 1517 Interpreter::_rethrow_exception_entry = __ pc(); 1518 { 1519 __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp. 1520 __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1); 1521 __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0); 1522 1523 // Compiled code destroys templateTableBase, reload. 1524 __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1); 1525 } 1526 1527 // Entry point if a interpreted method throws an exception (throw). | 1386 1387 // Performance measurements show the 1word and 2word variants to be almost equivalent, 1388 // with very light advantages for the 1word variant. We chose the 1word variant for 1389 // code compactness. 1390 __ kernel_crc32_1word(crc, data, dataLen, table, t0, t1, t2, t3, tc0, tc1, tc2, tc3); 1391 1392 // Restore caller sp for c2i case and return. 1393 __ mr(R1_SP, R21_sender_SP); // Cut the stack back to where the caller started. 1394 __ blr(); 1395 1396 // Generate a vanilla native entry as the slow path. 1397 BLOCK_COMMENT("} CRC32_updateBytes(Buffer)"); 1398 BIND(slow_path); 1399 __ jump_to_entry(Interpreter::entry_for_kind(Interpreter::native), R11_scratch1); 1400 return start; 1401 } 1402 1403 return NULL; 1404 } 1405 1406 // ============================================================================= 1407 // Exceptions 1408 1409 void TemplateInterpreterGenerator::generate_throw_exception() { 1410 Register Rexception = R17_tos, 1411 Rcontinuation = R3_RET; 1412 1413 // -------------------------------------------------------------------------- 1414 // Entry point if an method returns with a pending exception (rethrow). 1415 Interpreter::_rethrow_exception_entry = __ pc(); 1416 { 1417 __ restore_interpreter_state(R11_scratch1); // Sets R11_scratch1 = fp. 1418 __ ld(R12_scratch2, _ijava_state_neg(top_frame_sp), R11_scratch1); 1419 __ resize_frame_absolute(R12_scratch2, R11_scratch1, R0); 1420 1421 // Compiled code destroys templateTableBase, reload. 1422 __ load_const_optimized(R25_templateTableBase, (address)Interpreter::dispatch_table((TosState)0), R11_scratch1); 1423 } 1424 1425 // Entry point if a interpreted method throws an exception (throw). |