src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8076112 Sdiff src/share/vm/classfile

src/share/vm/classfile/classFileParser.cpp

Print this page




1737   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature):
1738     if (_location != _in_method)  break;  // only allow for methods
1739     if (!privileged)              break;  // only allow in privileged code
1740     return _method_ForceInline;
1741   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_DontInline_signature):
1742     if (_location != _in_method)  break;  // only allow for methods
1743     if (!privileged)              break;  // only allow in privileged code
1744     return _method_DontInline;
1745   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_InjectedProfile_signature):
1746     if (_location != _in_method)  break;  // only allow for methods
1747     if (!privileged)              break;  // only allow in privileged code
1748     return _method_InjectedProfile;
1749   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Compiled_signature):
1750     if (_location != _in_method)  break;  // only allow for methods
1751     if (!privileged)              break;  // only allow in privileged code
1752     return _method_LambdaForm_Compiled;
1753   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature):
1754     if (_location != _in_method)  break;  // only allow for methods
1755     if (!privileged)              break;  // only allow in privileged code
1756     return _method_LambdaForm_Hidden;




1757   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_Stable_signature):
1758     if (_location != _in_field)   break;  // only allow for fields
1759     if (!privileged)              break;  // only allow in privileged code
1760     return _field_Stable;
1761   case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_misc_Contended_signature):
1762     if (_location != _in_field && _location != _in_class)          break;  // only allow for fields and classes
1763     if (!EnableContended || (RestrictContended && !privileged))    break;  // honor privileges
1764     return _sun_misc_Contended;
1765   default: break;
1766   }
1767   return AnnotationCollector::_unknown;
1768 }
1769 
1770 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
1771   if (is_contended())
1772     f->set_contended_group(contended_group());
1773   if (is_stable())
1774     f->set_stable(true);
1775 }
1776 
1777 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
1778   // If there's an error deallocate metadata for field annotations
1779   MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
1780   MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
1781 }
1782 
1783 void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) {
1784   if (has_annotation(_method_CallerSensitive))
1785     m->set_caller_sensitive(true);
1786   if (has_annotation(_method_ForceInline))
1787     m->set_force_inline(true);
1788   if (has_annotation(_method_DontInline))
1789     m->set_dont_inline(true);
1790   if (has_annotation(_method_InjectedProfile))
1791     m->set_has_injected_profile(true);
1792   if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
1793     m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
1794   if (has_annotation(_method_LambdaForm_Hidden))
1795     m->set_hidden(true);


1796 }
1797 
1798 void ClassFileParser::ClassAnnotationCollector::apply_to(instanceKlassHandle k) {
1799   k->set_is_contended(is_contended());
1800 }
1801 
1802 
1803 #define MAX_ARGS_SIZE 255
1804 #define MAX_CODE_SIZE 65535
1805 #define INITIAL_MAX_LVT_NUMBER 256
1806 
1807 /* Copy class file LVT's/LVTT's into the HotSpot internal LVT.
1808  *
1809  * Rules for LVT's and LVTT's are:
1810  *   - There can be any number of LVT's and LVTT's.
1811  *   - If there are n LVT's, it is the same as if there was just
1812  *     one LVT containing all the entries from the n LVT's.
1813  *   - There may be no more than one LVT entry per local variable.
1814  *     Two LVT entries are 'equal' if these fields are the same:
1815  *        start_pc, length, name, slot


4120     // has to be changed accordingly.
4121     this_klass->set_initial_method_idnum(methods->length());
4122     this_klass->set_name(cp->klass_name_at(this_class_index));
4123     if (is_anonymous())  // I am well known to myself
4124       cp->klass_at_put(this_class_index, this_klass()); // eagerly resolve
4125 
4126     this_klass->set_minor_version(minor_version);
4127     this_klass->set_major_version(major_version);
4128     this_klass->set_has_default_methods(has_default_methods);
4129     this_klass->set_declares_default_methods(declares_default_methods);
4130 
4131     if (!host_klass.is_null()) {
4132       assert (this_klass->is_anonymous(), "should be the same");
4133       this_klass->set_host_klass(host_klass());
4134     }
4135 
4136     // Set up Method*::intrinsic_id as soon as we know the names of methods.
4137     // (We used to do this lazily, but now we query it in Rewriter,
4138     // which is eagerly done for every method, so we might as well do it now,
4139     // when everything is fresh in memory.)
4140     if (Method::klass_id_for_intrinsics(this_klass()) != vmSymbols::NO_SID) {

4141       for (int j = 0; j < methods->length(); j++) {
4142         methods->at(j)->init_intrinsic_id();




































































4143       }
4144     }
4145 
4146     if (cached_class_file != NULL) {
4147       // JVMTI: we have an InstanceKlass now, tell it about the cached bytes
4148       this_klass->set_cached_class_file(cached_class_file);
4149     }
4150 
4151     // Fill in field values obtained by parse_classfile_attributes
4152     if (parsed_annotations.has_any_annotations())
4153       parsed_annotations.apply_to(this_klass);
4154     apply_parsed_class_attributes(this_klass);
4155 
4156     // Miranda methods
4157     if ((num_miranda_methods > 0) ||
4158         // if this class introduced new miranda methods or
4159         (super_klass.not_null() && (super_klass->has_miranda_methods()))
4160         // super class exists and this class inherited miranda methods
4161         ) {
4162       this_klass->set_has_miranda_methods(); // then set a flag




1737   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_ForceInline_signature):
1738     if (_location != _in_method)  break;  // only allow for methods
1739     if (!privileged)              break;  // only allow in privileged code
1740     return _method_ForceInline;
1741   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_DontInline_signature):
1742     if (_location != _in_method)  break;  // only allow for methods
1743     if (!privileged)              break;  // only allow in privileged code
1744     return _method_DontInline;
1745   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_InjectedProfile_signature):
1746     if (_location != _in_method)  break;  // only allow for methods
1747     if (!privileged)              break;  // only allow in privileged code
1748     return _method_InjectedProfile;
1749   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Compiled_signature):
1750     if (_location != _in_method)  break;  // only allow for methods
1751     if (!privileged)              break;  // only allow in privileged code
1752     return _method_LambdaForm_Compiled;
1753   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_LambdaForm_Hidden_signature):
1754     if (_location != _in_method)  break;  // only allow for methods
1755     if (!privileged)              break;  // only allow in privileged code
1756     return _method_LambdaForm_Hidden;
1757   case vmSymbols::VM_SYMBOL_ENUM_NAME(jdk_internal_HotSpotIntrinsicCandidate_signature):
1758     if (_location != _in_method)  break;  // only allow for methods
1759     if (!privileged)              break;  // only allow in privileged code
1760     return _method_HotSpotIntrinsicCandidate;
1761   case vmSymbols::VM_SYMBOL_ENUM_NAME(java_lang_invoke_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   case vmSymbols::VM_SYMBOL_ENUM_NAME(sun_misc_Contended_signature):
1766     if (_location != _in_field && _location != _in_class)          break;  // only allow for fields and classes
1767     if (!EnableContended || (RestrictContended && !privileged))    break;  // honor privileges
1768     return _sun_misc_Contended;
1769   default: break;
1770   }
1771   return AnnotationCollector::_unknown;
1772 }
1773 
1774 void ClassFileParser::FieldAnnotationCollector::apply_to(FieldInfo* f) {
1775   if (is_contended())
1776     f->set_contended_group(contended_group());
1777   if (is_stable())
1778     f->set_stable(true);
1779 }
1780 
1781 ClassFileParser::FieldAnnotationCollector::~FieldAnnotationCollector() {
1782   // If there's an error deallocate metadata for field annotations
1783   MetadataFactory::free_array<u1>(_loader_data, _field_annotations);
1784   MetadataFactory::free_array<u1>(_loader_data, _field_type_annotations);
1785 }
1786 
1787 void ClassFileParser::MethodAnnotationCollector::apply_to(methodHandle m) {
1788   if (has_annotation(_method_CallerSensitive))
1789     m->set_caller_sensitive(true);
1790   if (has_annotation(_method_ForceInline))
1791     m->set_force_inline(true);
1792   if (has_annotation(_method_DontInline))
1793     m->set_dont_inline(true);
1794   if (has_annotation(_method_InjectedProfile))
1795     m->set_has_injected_profile(true);
1796   if (has_annotation(_method_LambdaForm_Compiled) && m->intrinsic_id() == vmIntrinsics::_none)
1797     m->set_intrinsic_id(vmIntrinsics::_compiledLambdaForm);
1798   if (has_annotation(_method_LambdaForm_Hidden))
1799     m->set_hidden(true);
1800   if (has_annotation(_method_HotSpotIntrinsicCandidate) && !m->is_synthetic())
1801     m->set_intrinsic_candidate(true);
1802 }
1803 
1804 void ClassFileParser::ClassAnnotationCollector::apply_to(instanceKlassHandle k) {
1805   k->set_is_contended(is_contended());
1806 }
1807 
1808 
1809 #define MAX_ARGS_SIZE 255
1810 #define MAX_CODE_SIZE 65535
1811 #define INITIAL_MAX_LVT_NUMBER 256
1812 
1813 /* Copy class file LVT's/LVTT's into the HotSpot internal LVT.
1814  *
1815  * Rules for LVT's and LVTT's are:
1816  *   - There can be any number of LVT's and LVTT's.
1817  *   - If there are n LVT's, it is the same as if there was just
1818  *     one LVT containing all the entries from the n LVT's.
1819  *   - There may be no more than one LVT entry per local variable.
1820  *     Two LVT entries are 'equal' if these fields are the same:
1821  *        start_pc, length, name, slot


4126     // has to be changed accordingly.
4127     this_klass->set_initial_method_idnum(methods->length());
4128     this_klass->set_name(cp->klass_name_at(this_class_index));
4129     if (is_anonymous())  // I am well known to myself
4130       cp->klass_at_put(this_class_index, this_klass()); // eagerly resolve
4131 
4132     this_klass->set_minor_version(minor_version);
4133     this_klass->set_major_version(major_version);
4134     this_klass->set_has_default_methods(has_default_methods);
4135     this_klass->set_declares_default_methods(declares_default_methods);
4136 
4137     if (!host_klass.is_null()) {
4138       assert (this_klass->is_anonymous(), "should be the same");
4139       this_klass->set_host_klass(host_klass());
4140     }
4141 
4142     // Set up Method*::intrinsic_id as soon as we know the names of methods.
4143     // (We used to do this lazily, but now we query it in Rewriter,
4144     // which is eagerly done for every method, so we might as well do it now,
4145     // when everything is fresh in memory.)
4146     vmSymbols::SID klass_id = Method::klass_id_for_intrinsics(this_klass());
4147     if (klass_id != vmSymbols::NO_SID) {
4148       for (int j = 0; j < methods->length(); j++) {
4149         Method* method = methods->at(j);
4150         method->init_intrinsic_id();
4151 
4152         if (CheckIntrinsics) {
4153           // Check if an intrinsic is defined for method 'method',
4154           // but the method is not annotated with @HotSpotIntrinsicCandidate.
4155           if (method->intrinsic_id() != vmIntrinsics::_none &&
4156               !method->intrinsic_candidate()) {
4157             tty->print("Compiler intrinsic is defined for method [%s], "
4158                        "but the method is not annotated with @HotSpotIntrinsicCandidate.%s",
4159                        method->name_and_sig_as_C_string(),
4160                        NOT_DEBUG(" Method will not be inlined.") DEBUG_ONLY(" Exiting.")
4161                        );
4162             tty->cr();
4163             DEBUG_ONLY(vm_exit(1));
4164           }
4165           // Check is the method 'method' is annotated with @HotSpotIntrinsicCandidate,
4166           // but there is no intrinsic available for it.
4167           if (method->intrinsic_candidate() &&
4168               method->intrinsic_id() == vmIntrinsics::_none) {
4169             tty->print("Method [%s] is annotated with @HotSpotIntrinsicCandidate, "
4170                        "but no compiler intrinsic is defined for the method.%s",
4171                        method->name_and_sig_as_C_string(),
4172                        NOT_DEBUG("") DEBUG_ONLY(" Exiting.")
4173                        );
4174             tty->cr();
4175             DEBUG_ONLY(vm_exit(1));
4176           }
4177         }
4178       }
4179 
4180       if (CheckIntrinsics) {
4181         // Check for orphan methods in the current class. A method m
4182         // of a class C is orphan if an intrinsic is defined for method m,
4183         // but class C does not declare m.
4184 
4185         for (int id = vmIntrinsics::FIRST_ID; id < (int)vmIntrinsics::ID_LIMIT; id++) {
4186           if (id == vmIntrinsics::_compiledLambdaForm) {
4187             // The _compiledLamdbdaForm intrinsic is a special marker for bytecode
4188             // generated for the JVM from a LambdaForm and therefore no method
4189             // is defined for it.
4190             continue;
4191           }
4192 
4193           if (vmIntrinsics::class_for(vmIntrinsics::ID_from(id)) == klass_id) {
4194             // Check if the current class contains a method with the same
4195             // name, flags, signature.
4196             bool match = false;
4197             for (int j = 0; j < methods->length(); j++) {
4198               Method* method = methods->at(j);
4199               if (id == method->intrinsic_id()) {
4200                 match = true;
4201                 break;
4202               }
4203             }
4204 
4205             if (!match) {
4206               char buf[1000];
4207               tty->print("Compiler intrinsic is defined for method [%s], "
4208                          "but the method is not available in class [%s].%s",
4209                          vmIntrinsics::short_name_as_C_string(vmIntrinsics::ID_from(id), buf, sizeof(buf)),
4210                          this_klass->name()->as_C_string(),
4211                          NOT_DEBUG("") DEBUG_ONLY(" Exiting.")
4212                          );
4213               tty->cr();
4214               DEBUG_ONLY(vm_exit(1));
4215             }
4216           }
4217         }
4218       }
4219     }
4220 
4221     if (cached_class_file != NULL) {
4222       // JVMTI: we have an InstanceKlass now, tell it about the cached bytes
4223       this_klass->set_cached_class_file(cached_class_file);
4224     }
4225 
4226     // Fill in field values obtained by parse_classfile_attributes
4227     if (parsed_annotations.has_any_annotations())
4228       parsed_annotations.apply_to(this_klass);
4229     apply_parsed_class_attributes(this_klass);
4230 
4231     // Miranda methods
4232     if ((num_miranda_methods > 0) ||
4233         // if this class introduced new miranda methods or
4234         (super_klass.not_null() && (super_klass->has_miranda_methods()))
4235         // super class exists and this class inherited miranda methods
4236         ) {
4237       this_klass->set_has_miranda_methods(); // then set a flag


src/share/vm/classfile/classFileParser.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File