< prev index next >

src/hotspot/share/classfile/systemDictionary.hpp

Print this page
rev 52749 : Bootstrap method consolidation
* clean up and simplify JDK support code for BSM invocation
* simplify JVM bootstrap handshake: use BootstrapCallInfo only
* remove unused JVM paths and data fields
* move bootstrap argument processing from MethodHandleNatives to ConstantPool
* remove ConstantGroup; merge argument access into BootstrapCallInfo
* adjust BSM argument access: remove copyArguments, add argumentRef API
* add metadata-free BSM modes, including symbolic arguments from CP


  56 //
  57 // When class loading is finished, a new entry is added to the dictionary
  58 // of the class loader and the placeholder is removed. Note that the protection
  59 // domain field of the dictionary entry has not yet been filled in when
  60 // the "real" dictionary entry is created.
  61 //
  62 // Clients of this class who are interested in finding if a class has
  63 // been completely loaded -- not classes in the process of being loaded --
  64 // can read the dictionary unlocked. This is safe because
  65 //    - entries are only deleted at safepoints
  66 //    - readers cannot come to a safepoint while actively examining
  67 //         an entry  (an entry cannot be deleted from under a reader)
  68 //    - entries must be fully formed before they are available to concurrent
  69 //         readers (we must ensure write ordering)
  70 //
  71 // Note that placeholders are deleted at any time, as they are removed
  72 // when a class is completely loaded. Therefore, readers as well as writers
  73 // of placeholders must hold the SystemDictionary_lock.
  74 //
  75 

  76 class ClassFileStream;
  77 class Dictionary;
  78 class PlaceholderTable;
  79 class LoaderConstraintTable;
  80 template <MEMFLAGS F> class HashtableBucket;
  81 class ResolutionErrorTable;
  82 class SymbolPropertyTable;
  83 class ProtectionDomainCacheTable;
  84 class ProtectionDomainCacheEntry;
  85 class GCTimer;
  86 class OopStorage;
  87 
  88 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  89 // They are all "well-known", in the sense that no class loader is allowed
  90 // to provide a different definition.
  91 //
  92 // These klasses must all have names defined in vmSymbols.
  93 
  94 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  95 


 490     return m;
 491   }
 492 
 493 public:
 494   // Note:  java_lang_Class::primitive_type is the inverse of java_mirror
 495 
 496   // Check class loader constraints
 497   static bool add_loader_constraint(Symbol* name, Handle loader1,
 498                                     Handle loader2, TRAPS);
 499   static Symbol* check_signature_loaders(Symbol* signature, Handle loader1,
 500                                          Handle loader2, bool is_method, TRAPS);
 501 
 502   // JSR 292
 503   // find a java.lang.invoke.MethodHandle.invoke* method for a given signature
 504   // (asks Java to compute it if necessary, except in a compiler thread)
 505   static methodHandle find_method_handle_invoker(Klass* klass,
 506                                                  Symbol* name,
 507                                                  Symbol* signature,
 508                                                  Klass* accessing_klass,
 509                                                  Handle *appendix_result,
 510                                                  Handle *method_type_result,
 511                                                  TRAPS);
 512   // for a given signature, find the internal MethodHandle method (linkTo* or invokeBasic)
 513   // (does not ask Java, since this is a low-level intrinsic defined by the JVM)
 514   static methodHandle find_method_handle_intrinsic(vmIntrinsics::ID iid,
 515                                                    Symbol* signature,
 516                                                    TRAPS);
 517 
 518   // compute java_mirror (java.lang.Class instance) for a type ("I", "[[B", "LFoo;", etc.)
 519   // Either the accessing_klass or the CL/PD can be non-null, but not both.
 520   static Handle    find_java_mirror_for_type(Symbol* signature,
 521                                              Klass* accessing_klass,
 522                                              Handle class_loader,
 523                                              Handle protection_domain,
 524                                              SignatureStream::FailureMode failure_mode,

 525                                              TRAPS);
 526   static Handle    find_java_mirror_for_type(Symbol* signature,
 527                                              Klass* accessing_klass,
 528                                              SignatureStream::FailureMode failure_mode,

 529                                              TRAPS) {
 530     // callee will fill in CL/PD from AK, if they are needed
 531     return find_java_mirror_for_type(signature, accessing_klass, Handle(), Handle(),
 532                                      failure_mode, THREAD);
 533   }
 534 
 535 
 536   // fast short-cut for the one-character case:
 537   static oop       find_java_mirror_for_type(char signature_char);
 538 
 539   // find a java.lang.invoke.MethodType object for a given signature
 540   // (asks Java to compute it if necessary, except in a compiler thread)
 541   static Handle    find_method_handle_type(Symbol* signature,
 542                                            Klass* accessing_klass,
 543                                            TRAPS);
 544 
 545   // find a java.lang.Class object for a given signature
 546   static Handle    find_field_handle_type(Symbol* signature,
 547                                           Klass* accessing_klass,
 548                                           TRAPS);
 549 
 550   // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry
 551   static Handle    link_method_handle_constant(Klass* caller,
 552                                                int ref_kind, //e.g., JVM_REF_invokeVirtual
 553                                                Klass* callee,
 554                                                Symbol* name,
 555                                                Symbol* signature,
 556                                                TRAPS);
 557 
 558   // ask Java to compute a constant by invoking a BSM given a Dynamic_info CP entry
 559   static Handle    link_dynamic_constant(Klass* caller,
 560                                          int condy_index,
 561                                          Handle bootstrap_specifier,
 562                                          Symbol* name,
 563                                          Symbol* type,
 564                                          TRAPS);
 565 
 566   // ask Java to create a dynamic call site, while linking an invokedynamic op
 567   static methodHandle find_dynamic_call_site_invoker(Klass* caller,
 568                                                      int indy_index,
 569                                                      Handle bootstrap_method,
 570                                                      Symbol* name,
 571                                                      Symbol* type,
 572                                                      Handle *appendix_result,
 573                                                      Handle *method_type_result,
 574                                                      TRAPS);
 575 
 576   // Record the error when the first attempt to resolve a reference from a constant
 577   // pool entry to a class fails.
 578   static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
 579                                    Symbol* message);
 580   static void delete_resolution_error(ConstantPool* pool);
 581   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
 582                                        Symbol** message);
 583 
 584 
 585   static ProtectionDomainCacheEntry* cache_get(Handle protection_domain);
 586 
 587  protected:
 588 
 589   enum Constants {
 590     _loader_constraint_size = 107,                     // number of entries in constraint table
 591     _resolution_error_size  = 107,                     // number of entries in resolution error table
 592     _invoke_method_size     = 139,                     // number of entries in invoke method table
 593     _shared_dictionary_size = 1009,                    // number of entries in shared dictionary
 594     _placeholder_table_size = 1009                     // number of entries in hash table for placeholders




  56 //
  57 // When class loading is finished, a new entry is added to the dictionary
  58 // of the class loader and the placeholder is removed. Note that the protection
  59 // domain field of the dictionary entry has not yet been filled in when
  60 // the "real" dictionary entry is created.
  61 //
  62 // Clients of this class who are interested in finding if a class has
  63 // been completely loaded -- not classes in the process of being loaded --
  64 // can read the dictionary unlocked. This is safe because
  65 //    - entries are only deleted at safepoints
  66 //    - readers cannot come to a safepoint while actively examining
  67 //         an entry  (an entry cannot be deleted from under a reader)
  68 //    - entries must be fully formed before they are available to concurrent
  69 //         readers (we must ensure write ordering)
  70 //
  71 // Note that placeholders are deleted at any time, as they are removed
  72 // when a class is completely loaded. Therefore, readers as well as writers
  73 // of placeholders must hold the SystemDictionary_lock.
  74 //
  75 
  76 class BootstrapInfo;
  77 class ClassFileStream;
  78 class Dictionary;
  79 class PlaceholderTable;
  80 class LoaderConstraintTable;
  81 template <MEMFLAGS F> class HashtableBucket;
  82 class ResolutionErrorTable;
  83 class SymbolPropertyTable;
  84 class ProtectionDomainCacheTable;
  85 class ProtectionDomainCacheEntry;
  86 class GCTimer;
  87 class OopStorage;
  88 
  89 // Certain classes are preloaded, such as java.lang.Object and java.lang.String.
  90 // They are all "well-known", in the sense that no class loader is allowed
  91 // to provide a different definition.
  92 //
  93 // These klasses must all have names defined in vmSymbols.
  94 
  95 #define WK_KLASS_ENUM_NAME(kname)    kname##_knum
  96 


 491     return m;
 492   }
 493 
 494 public:
 495   // Note:  java_lang_Class::primitive_type is the inverse of java_mirror
 496 
 497   // Check class loader constraints
 498   static bool add_loader_constraint(Symbol* name, Handle loader1,
 499                                     Handle loader2, TRAPS);
 500   static Symbol* check_signature_loaders(Symbol* signature, Handle loader1,
 501                                          Handle loader2, bool is_method, TRAPS);
 502 
 503   // JSR 292
 504   // find a java.lang.invoke.MethodHandle.invoke* method for a given signature
 505   // (asks Java to compute it if necessary, except in a compiler thread)
 506   static methodHandle find_method_handle_invoker(Klass* klass,
 507                                                  Symbol* name,
 508                                                  Symbol* signature,
 509                                                  Klass* accessing_klass,
 510                                                  Handle *appendix_result,

 511                                                  TRAPS);
 512   // for a given signature, find the internal MethodHandle method (linkTo* or invokeBasic)
 513   // (does not ask Java, since this is a low-level intrinsic defined by the JVM)
 514   static methodHandle find_method_handle_intrinsic(vmIntrinsics::ID iid,
 515                                                    Symbol* signature,
 516                                                    TRAPS);
 517 
 518   // compute java_mirror (java.lang.Class instance) for a type ("I", "[[B", "LFoo;", etc.)
 519   // Either the accessing_klass or the CL/PD can be non-null, but not both.
 520   static Handle    find_java_mirror_for_type(Symbol* signature,
 521                                              Klass* accessing_klass,
 522                                              Handle class_loader,
 523                                              Handle protection_domain,
 524                                              SignatureStream::FailureMode failure_mode,
 525                                              bool check_access,
 526                                              TRAPS);
 527   static Handle    find_java_mirror_for_type(Symbol* signature,
 528                                              Klass* accessing_klass,
 529                                              SignatureStream::FailureMode failure_mode,
 530                                              bool check_access,
 531                                              TRAPS) {
 532     // callee will fill in CL/PD from AK, if they are needed
 533     return find_java_mirror_for_type(signature, accessing_klass, Handle(), Handle(),
 534                                      failure_mode, check_access, THREAD);
 535   }
 536 
 537 
 538   // fast short-cut for the one-character case:
 539   static oop       find_java_mirror_for_type(char signature_char);
 540 
 541   // find a java.lang.invoke.MethodType object for a given signature
 542   // (asks Java to compute it if necessary, except in a compiler thread)
 543   static Handle    find_method_handle_type(Symbol* signature,
 544                                            Klass* accessing_klass,
 545                                            TRAPS);
 546 





 547   // ask Java to compute a java.lang.invoke.MethodHandle object for a given CP entry
 548   static Handle    link_method_handle_constant(Klass* caller,
 549                                                int ref_kind, //e.g., JVM_REF_invokeVirtual
 550                                                Klass* callee,
 551                                                Symbol* name,
 552                                                Symbol* signature,
 553                                                TRAPS);
 554 
 555   // ask Java to run a bootstrap method, in order to create a dynamic call site
 556   // while linking an invokedynamic op, or compute a constant for Dynamic_info CP entry
 557   // with linkage results being stored back into the bootstrap specifier
 558   static void      invoke_bootstrap_method(BootstrapInfo& bootstrap_specifier, TRAPS);













 559 
 560   // Record the error when the first attempt to resolve a reference from a constant
 561   // pool entry to a class fails.
 562   static void add_resolution_error(const constantPoolHandle& pool, int which, Symbol* error,
 563                                    Symbol* message);
 564   static void delete_resolution_error(ConstantPool* pool);
 565   static Symbol* find_resolution_error(const constantPoolHandle& pool, int which,
 566                                        Symbol** message);
 567 
 568 
 569   static ProtectionDomainCacheEntry* cache_get(Handle protection_domain);
 570 
 571  protected:
 572 
 573   enum Constants {
 574     _loader_constraint_size = 107,                     // number of entries in constraint table
 575     _resolution_error_size  = 107,                     // number of entries in resolution error table
 576     _invoke_method_size     = 139,                     // number of entries in invoke method table
 577     _shared_dictionary_size = 1009,                    // number of entries in shared dictionary
 578     _placeholder_table_size = 1009                     // number of entries in hash table for placeholders


< prev index next >