1700 // the fields within the same contended group are not treated distinct. 1701 // The only exception is default group, which does not incur the 1702 // equivalence. Naturally, contention group for classes is meaningless. 1703 // 1704 // While the contention group is specified as String, annotation 1705 // values are already interned, and we might as well use the constant 1706 // pool index as the group tag. 1707 // 1708 u2 group_index = 0; // default contended group 1709 if (count == 1 1710 && s_size == (index - index0) // match size 1711 && s_tag_val == *(abase + tag_off) 1712 && member == vmSymbols::value_name()) { 1713 group_index = Bytes::get_Java_u2(abase + s_con_off); 1714 if (_cp->symbol_at(group_index)->utf8_length() == 0) { 1715 group_index = 0; // default contended group 1716 } 1717 } 1718 coll->set_contended_group(group_index); 1719 } 1720 } 1721 } 1722 1723 ClassFileParser::AnnotationCollector::ID 1724 ClassFileParser::AnnotationCollector::annotation_index(ClassLoaderData* loader_data, 1725 Symbol* name) { 1726 vmSymbols::SID sid = vmSymbols::find_sid(name); 1727 // Privileged code can use all annotations. Other code silently drops some. 1728 const bool privileged = loader_data->is_the_null_class_loader_data() || 1729 loader_data->is_ext_class_loader_data() || 1730 loader_data->is_anonymous(); 1731 switch (sid) { 1732 case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_reflect_CallerSensitive_signature): 1733 if (_location != _in_method) break; // only allow for methods 1734 if (!privileged) break; // only allow in privileged code 1735 return _method_CallerSensitive; 1736 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature): 1737 if (_location != _in_method) break; // only allow for methods 1738 if (!privileged) break; // only allow in privileged code 1739 return _method_ForceInline; 1740 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_DontInline_signature): 1741 if (_location != _in_method) break; // only allow for methods 1742 if (!privileged) break; // only allow in privileged code 1743 return _method_DontInline; 1744 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_InjectedProfile_signature): 1745 if (_location != _in_method) break; // only allow for methods 1746 if (!privileged) break; // only allow in privileged code 1747 return _method_InjectedProfile; 1748 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Compiled_signature): 1749 if (_location != _in_method) break; // only allow for methods 1750 if (!privileged) break; // only allow in privileged code 1751 return _method_LambdaForm_Compiled; 1752 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature): 1753 if (_location != _in_method) break; // only allow for methods 1754 if (!privileged) break; // only allow in privileged code 1755 return _method_LambdaForm_Hidden; 1756 case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_internal_HotSpotIntrinsicCandidate_signature): 1757 if (_location != _in_method) break; // only allow for methods 1758 if (!privileged) break; // only allow in privileged code 1759 return _method_HotSpotIntrinsicCandidate; 1760 #if INCLUDE_JVMCI 1761 case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_vm_ci_hotspot_Stable_signature): 1762 if (_location != _in_field) break; // only allow for fields 1763 if (!privileged) break; // only allow in privileged code 1764 return _field_Stable; 1765 #endif 1766 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_Stable_signature): 1767 if (_location != _in_field) break; // only allow for fields 1768 if (!privileged) break; // only allow in privileged code 1769 return _field_Stable; 1770 case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_misc_Contended_signature): 1771 if (_location != _in_field && _location != _in_class) break; // only allow for fields and classes 1772 if (!EnableContended || (RestrictContended && !privileged)) break; // honor privileges 1773 return _sun_misc_Contended; 1774 default: break; 1775 } 1776 return AnnotationCollector::_unknown; 1777 } 1778 1779 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) { 1787 // If there's an error deallocate metadata for field annotations 1788 MetadataFactory::free_array<u1>(_loader_data, _field_annotations); 1789 MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations); 1790 } 1791 1792 void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) { 1793 if (has_annotation(_method_CallerSensitive)) 1794 m->set_caller_sensitive(true); 1795 if (has_annotation(_method_ForceInline)) 1796 m->set_force_inline(true); 1797 if (has_annotation(_method_DontInline)) 1798 m->set_dont_inline(true); 1799 if (has_annotation(_method_InjectedProfile)) 1800 m->set_has_injected_profile(true); 1801 if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none) 1802 m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm); 1803 if (has_annotation(_method_LambdaForm_Hidden)) 1804 m->set_hidden(true); 1805 if (has_annotation(_method_HotSpotIntrinsicCandidate) && !m->is_synthetic()) 1806 m->set_intrinsic_candidate(true); 1807 } 1808 1809 void ClassFileParser::ClassAnnotationCollector::apply_to(instanceKlassHandle k) { 1810 k->set_is_contended(is_contended()); 1811 } 1812 1813 1814 #define MAX_ARGS_SIZE 255 1815 #define MAX_CODE_SIZE 65535 1816 #define INITIAL_MAX_LVT_NUMBER 256 1817 1818 /* Copy class file LVT's/LVTT's into the HotSpot internal LVT. 1819 * 1820 * Rules for LVT's and LVTT's are: 1821 * - There can be any number of LVT's and LVTT's. 1822 * - If there are n LVT's, it is the same as if there was just 1823 * one LVT containing all the entries from the n LVT's. 1824 * - There may be no more than one LVT entry per local variable. 1825 * Two LVT entries are 'equal' if these fields are the same: 1826 * start_pc, length, name, slot | 1700 // the fields within the same contended group are not treated distinct. 1701 // The only exception is default group, which does not incur the 1702 // equivalence. Naturally, contention group for classes is meaningless. 1703 // 1704 // While the contention group is specified as String, annotation 1705 // values are already interned, and we might as well use the constant 1706 // pool index as the group tag. 1707 // 1708 u2 group_index = 0; // default contended group 1709 if (count == 1 1710 && s_size == (index - index0) // match size 1711 && s_tag_val == *(abase + tag_off) 1712 && member == vmSymbols::value_name()) { 1713 group_index = Bytes::get_Java_u2(abase + s_con_off); 1714 if (_cp->symbol_at(group_index)->utf8_length() == 0) { 1715 group_index = 0; // default contended group 1716 } 1717 } 1718 coll->set_contended_group(group_index); 1719 } 1720 // The Accessor-Annotation specifies the field name it 1721 // belongs to. The index of the symbol is later stored in 1722 // the method. 1723 if (id == AnnotationCollector::_method_Accessor_Method) { 1724 u2 group_index = 0; 1725 if (count == 1 1726 && s_size == (index - index0) // match size 1727 && s_tag_val == *(abase + tag_off) 1728 && member == vmSymbols::value_name()) { 1729 group_index = Bytes::get_Java_u2(abase + s_con_off); 1730 if (_cp->symbol_at(group_index)->utf8_length() != 0) { 1731 coll->set_accessor_field_name(group_index); 1732 } 1733 } 1734 } 1735 } 1736 } 1737 1738 ClassFileParser::AnnotationCollector::ID 1739 ClassFileParser::AnnotationCollector::annotation_index(ClassLoaderData* loader_data, 1740 Symbol* name) { 1741 vmSymbols::SID sid = vmSymbols::find_sid(name); 1742 // Privileged code can use all annotations. Other code silently drops some. 1743 const bool privileged = loader_data->is_the_null_class_loader_data() || 1744 loader_data->is_ext_class_loader_data() || 1745 loader_data->is_anonymous(); 1746 switch (sid) { 1747 case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_reflect_CallerSensitive_signature): 1748 if (_location != _in_method) break; // only allow for methods 1749 if (!privileged) break; // only allow in privileged code 1750 return _method_CallerSensitive; 1751 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature): 1752 if (_location != _in_method) break; // only allow for methods 1753 if (!privileged) break; // only allow in privileged code 1754 return _method_ForceInline; 1755 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_DontInline_signature): 1756 if (_location != _in_method) break; // only allow for methods 1757 if (!privileged) break; // only allow in privileged code 1758 return _method_DontInline; 1759 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_InjectedProfile_signature): 1760 if (_location != _in_method) break; // only allow for methods 1761 if (!privileged) break; // only allow in privileged code 1762 return _method_InjectedProfile; 1763 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Compiled_signature): 1764 if (_location != _in_method) break; // only allow for methods 1765 if (!privileged) break; // only allow in privileged code 1766 return _method_LambdaForm_Compiled; 1767 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature): 1768 if (_location != _in_method) break; // only allow for methods 1769 if (!privileged) break; // only allow in privileged code 1770 return _method_LambdaForm_Hidden; 1771 case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_internal_HotSpotIntrinsicCandidate_signature): 1772 if (_location != _in_method) break; // only allow for methods 1773 if (!privileged) break; // only allow in privileged code 1774 return _method_HotSpotIntrinsicCandidate; 1775 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_reflect_Accessor_signature): 1776 if (_location != _in_method) break; // only allow for methods 1777 return _method_Accessor_Method; 1778 #if INCLUDE_JVMCI 1779 case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_vm_ci_hotspot_Stable_signature): 1780 if (_location != _in_field) break; // only allow for fields 1781 if (!privileged) break; // only allow in privileged code 1782 return _field_Stable; 1783 #endif 1784 case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_Stable_signature): 1785 if (_location != _in_field) break; // only allow for fields 1786 if (!privileged) break; // only allow in privileged code 1787 return _field_Stable; 1788 case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_misc_Contended_signature): 1789 if (_location != _in_field && _location != _in_class) break; // only allow for fields and classes 1790 if (!EnableContended || (RestrictContended && !privileged)) break; // honor privileges 1791 return _sun_misc_Contended; 1792 default: break; 1793 } 1794 return AnnotationCollector::_unknown; 1795 } 1796 1797 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) { 1805 // If there's an error deallocate metadata for field annotations 1806 MetadataFactory::free_array<u1>(_loader_data, _field_annotations); 1807 MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations); 1808 } 1809 1810 void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) { 1811 if (has_annotation(_method_CallerSensitive)) 1812 m->set_caller_sensitive(true); 1813 if (has_annotation(_method_ForceInline)) 1814 m->set_force_inline(true); 1815 if (has_annotation(_method_DontInline)) 1816 m->set_dont_inline(true); 1817 if (has_annotation(_method_InjectedProfile)) 1818 m->set_has_injected_profile(true); 1819 if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none) 1820 m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm); 1821 if (has_annotation(_method_LambdaForm_Hidden)) 1822 m->set_hidden(true); 1823 if (has_annotation(_method_HotSpotIntrinsicCandidate) && !m->is_synthetic()) 1824 m->set_intrinsic_candidate(true); 1825 if (is_accessor()) { 1826 m->set_accessor_field_name(accessor_field_name()); 1827 } 1828 } 1829 1830 void ClassFileParser::ClassAnnotationCollector::apply_to(instanceKlassHandle k) { 1831 k->set_is_contended(is_contended()); 1832 } 1833 1834 1835 #define MAX_ARGS_SIZE 255 1836 #define MAX_CODE_SIZE 65535 1837 #define INITIAL_MAX_LVT_NUMBER 256 1838 1839 /* Copy class file LVT's/LVTT's into the HotSpot internal LVT. 1840 * 1841 * Rules for LVT's and LVTT's are: 1842 * - There can be any number of LVT's and LVTT's. 1843 * - If there are n LVT's, it is the same as if there was just 1844 * one LVT containing all the entries from the n LVT's. 1845 * - There may be no more than one LVT entry per local variable. 1846 * Two LVT entries are 'equal' if these fields are the same: 1847 * start_pc, length, name, slot |