531 case Bytecodes::_ifnonnull:
532 case Bytecodes::_ifgt:
533 case Bytecodes::_ifge:
534 case Bytecodes::_if_icmpeq:
535 case Bytecodes::_if_icmpne:
536 case Bytecodes::_if_icmplt:
537 case Bytecodes::_if_icmpgt:
538 case Bytecodes::_if_icmple:
539 case Bytecodes::_if_icmpge:
540 case Bytecodes::_if_acmpeq:
541 case Bytecodes::_if_acmpne:
542 case Bytecodes::_goto:
543 case Bytecodes::_jsr:
544 if( bcs.dest() < bcs.next_bci() ) _access_flags.set_has_loops();
545 break;
546
547 case Bytecodes::_goto_w:
548 case Bytecodes::_jsr_w:
549 if( bcs.dest_w() < bcs.next_bci() ) _access_flags.set_has_loops();
550 break;
551 }
552 }
553 _access_flags.set_loops_flag_init();
554 return _access_flags.has_loops();
555 }
556
557 bool Method::is_final_method(AccessFlags class_access_flags) const {
558 // or "does_not_require_vtable_entry"
559 // default method or overpass can occur, is not final (reuses vtable entry)
560 // private methods in classes get vtable entries for backward class compatibility.
561 if (is_overpass() || is_default_method()) return false;
562 return is_final() || class_access_flags.is_final();
563 }
564
565 bool Method::is_final_method() const {
566 return is_final_method(method_holder()->access_flags());
567 }
568
569 bool Method::is_default_method() const {
570 if (method_holder() != NULL &&
1371 cm->generic_signature_index(),
1372 method_annotations_len,
1373 parameter_annotations_len,
1374 type_annotations_len,
1375 default_annotations_len,
1376 0);
1377
1378 ClassLoaderData* loader_data = m->method_holder()->class_loader_data();
1379 Method* newm_oop = Method::allocate(loader_data,
1380 new_code_length,
1381 flags,
1382 &sizes,
1383 m->method_type(),
1384 CHECK_(methodHandle()));
1385 methodHandle newm (THREAD, newm_oop);
1386
1387 // Create a shallow copy of Method part, but be careful to preserve the new ConstMethod*
1388 ConstMethod* newcm = newm->constMethod();
1389 int new_const_method_size = newm->constMethod()->size();
1390
1391 memcpy(newm(), m(), sizeof(Method));
1392
1393 // Create shallow copy of ConstMethod.
1394 memcpy(newcm, m->constMethod(), sizeof(ConstMethod));
1395
1396 // Reset correct method/const method, method size, and parameter info
1397 newm->set_constMethod(newcm);
1398 newm->constMethod()->set_code_size(new_code_length);
1399 newm->constMethod()->set_constMethod_size(new_const_method_size);
1400 assert(newm->code_size() == new_code_length, "check");
1401 assert(newm->method_parameters_length() == method_parameters_len, "check");
1402 assert(newm->checked_exceptions_length() == checked_exceptions_len, "check");
1403 assert(newm->exception_table_length() == exception_table_len, "check");
1404 assert(newm->localvariable_table_length() == localvariable_len, "check");
1405 // Copy new byte codes
1406 memcpy(newm->code_base(), new_code, new_code_length);
1407 // Copy line number table
1408 if (new_compressed_linenumber_size > 0) {
1409 memcpy(newm->compressed_linenumber_table(),
1410 new_compressed_linenumber_table,
1411 new_compressed_linenumber_size);
1494 set_intrinsic_id(id);
1495 if (id == vmIntrinsics::_Class_cast) {
1496 // Even if the intrinsic is rejected, we want to inline this simple method.
1497 set_force_inline(true);
1498 }
1499 return;
1500 }
1501
1502 // A few slightly irregular cases:
1503 switch (klass_id) {
1504 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_StrictMath):
1505 // Second chance: check in regular Math.
1506 switch (name_id) {
1507 case vmSymbols::VM_SYMBOL_ENUM_NAME(min_name):
1508 case vmSymbols::VM_SYMBOL_ENUM_NAME(max_name):
1509 case vmSymbols::VM_SYMBOL_ENUM_NAME(sqrt_name):
1510 // pretend it is the corresponding method in the non-strict class:
1511 klass_id = vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_Math);
1512 id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
1513 break;
1514 }
1515 break;
1516
1517 // Signature-polymorphic methods: MethodHandle.invoke*, InvokeDynamic.*., VarHandle
1518 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle):
1519 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_VarHandle):
1520 if (!is_native()) break;
1521 id = MethodHandles::signature_polymorphic_name_id(method_holder(), name());
1522 if (is_static() != MethodHandles::is_signature_polymorphic_static(id))
1523 id = vmIntrinsics::_none;
1524 break;
1525 }
1526
1527 if (id != vmIntrinsics::_none) {
1528 // Set up its iid. It is an alias method.
1529 set_intrinsic_id(id);
1530 return;
1531 }
1532 }
1533
1534 // These two methods are static since a GC may move the Method
1535 bool Method::load_signature_classes(methodHandle m, TRAPS) {
1536 if (!THREAD->can_call_java()) {
1537 // There is nothing useful this routine can do from within the Compile thread.
1538 // Hopefully, the signature contains only well-known classes.
1539 // We could scan for this and return true/false, but the caller won't care.
1540 return false;
1541 }
1542 bool sig_is_loaded = true;
1543 Handle class_loader(THREAD, m->method_holder()->class_loader());
1544 Handle protection_domain(THREAD, m->method_holder()->protection_domain());
|
531 case Bytecodes::_ifnonnull:
532 case Bytecodes::_ifgt:
533 case Bytecodes::_ifge:
534 case Bytecodes::_if_icmpeq:
535 case Bytecodes::_if_icmpne:
536 case Bytecodes::_if_icmplt:
537 case Bytecodes::_if_icmpgt:
538 case Bytecodes::_if_icmple:
539 case Bytecodes::_if_icmpge:
540 case Bytecodes::_if_acmpeq:
541 case Bytecodes::_if_acmpne:
542 case Bytecodes::_goto:
543 case Bytecodes::_jsr:
544 if( bcs.dest() < bcs.next_bci() ) _access_flags.set_has_loops();
545 break;
546
547 case Bytecodes::_goto_w:
548 case Bytecodes::_jsr_w:
549 if( bcs.dest_w() < bcs.next_bci() ) _access_flags.set_has_loops();
550 break;
551
552 default:
553 break;
554 }
555 }
556 _access_flags.set_loops_flag_init();
557 return _access_flags.has_loops();
558 }
559
560 bool Method::is_final_method(AccessFlags class_access_flags) const {
561 // or "does_not_require_vtable_entry"
562 // default method or overpass can occur, is not final (reuses vtable entry)
563 // private methods in classes get vtable entries for backward class compatibility.
564 if (is_overpass() || is_default_method()) return false;
565 return is_final() || class_access_flags.is_final();
566 }
567
568 bool Method::is_final_method() const {
569 return is_final_method(method_holder()->access_flags());
570 }
571
572 bool Method::is_default_method() const {
573 if (method_holder() != NULL &&
1374 cm->generic_signature_index(),
1375 method_annotations_len,
1376 parameter_annotations_len,
1377 type_annotations_len,
1378 default_annotations_len,
1379 0);
1380
1381 ClassLoaderData* loader_data = m->method_holder()->class_loader_data();
1382 Method* newm_oop = Method::allocate(loader_data,
1383 new_code_length,
1384 flags,
1385 &sizes,
1386 m->method_type(),
1387 CHECK_(methodHandle()));
1388 methodHandle newm (THREAD, newm_oop);
1389
1390 // Create a shallow copy of Method part, but be careful to preserve the new ConstMethod*
1391 ConstMethod* newcm = newm->constMethod();
1392 int new_const_method_size = newm->constMethod()->size();
1393
1394 // This works because the source and target are both Methods. Some compilers
1395 // (e.g., clang) complain that the target vtable pointer will be stomped,
1396 // so cast away newm()'s and m()'s Methodness.
1397 memcpy((void*)newm(), (void*)m(), sizeof(Method));
1398
1399 // Create shallow copy of ConstMethod.
1400 memcpy(newcm, m->constMethod(), sizeof(ConstMethod));
1401
1402 // Reset correct method/const method, method size, and parameter info
1403 newm->set_constMethod(newcm);
1404 newm->constMethod()->set_code_size(new_code_length);
1405 newm->constMethod()->set_constMethod_size(new_const_method_size);
1406 assert(newm->code_size() == new_code_length, "check");
1407 assert(newm->method_parameters_length() == method_parameters_len, "check");
1408 assert(newm->checked_exceptions_length() == checked_exceptions_len, "check");
1409 assert(newm->exception_table_length() == exception_table_len, "check");
1410 assert(newm->localvariable_table_length() == localvariable_len, "check");
1411 // Copy new byte codes
1412 memcpy(newm->code_base(), new_code, new_code_length);
1413 // Copy line number table
1414 if (new_compressed_linenumber_size > 0) {
1415 memcpy(newm->compressed_linenumber_table(),
1416 new_compressed_linenumber_table,
1417 new_compressed_linenumber_size);
1500 set_intrinsic_id(id);
1501 if (id == vmIntrinsics::_Class_cast) {
1502 // Even if the intrinsic is rejected, we want to inline this simple method.
1503 set_force_inline(true);
1504 }
1505 return;
1506 }
1507
1508 // A few slightly irregular cases:
1509 switch (klass_id) {
1510 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_StrictMath):
1511 // Second chance: check in regular Math.
1512 switch (name_id) {
1513 case vmSymbols::VM_SYMBOL_ENUM_NAME(min_name):
1514 case vmSymbols::VM_SYMBOL_ENUM_NAME(max_name):
1515 case vmSymbols::VM_SYMBOL_ENUM_NAME(sqrt_name):
1516 // pretend it is the corresponding method in the non-strict class:
1517 klass_id = vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_Math);
1518 id = vmIntrinsics::find_id(klass_id, name_id, sig_id, flags);
1519 break;
1520 default:
1521 break;
1522 }
1523 break;
1524
1525 // Signature-polymorphic methods: MethodHandle.invoke*, InvokeDynamic.*., VarHandle
1526 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_MethodHandle):
1527 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_VarHandle):
1528 if (!is_native()) break;
1529 id = MethodHandles::signature_polymorphic_name_id(method_holder(), name());
1530 if (is_static() != MethodHandles::is_signature_polymorphic_static(id))
1531 id = vmIntrinsics::_none;
1532 break;
1533
1534 default:
1535 break;
1536 }
1537
1538 if (id != vmIntrinsics::_none) {
1539 // Set up its iid. It is an alias method.
1540 set_intrinsic_id(id);
1541 return;
1542 }
1543 }
1544
1545 // These two methods are static since a GC may move the Method
1546 bool Method::load_signature_classes(methodHandle m, TRAPS) {
1547 if (!THREAD->can_call_java()) {
1548 // There is nothing useful this routine can do from within the Compile thread.
1549 // Hopefully, the signature contains only well-known classes.
1550 // We could scan for this and return true/false, but the caller won't care.
1551 return false;
1552 }
1553 bool sig_is_loaded = true;
1554 Handle class_loader(THREAD, m->method_holder()->class_loader());
1555 Handle protection_domain(THREAD, m->method_holder()->protection_domain());
|