< prev index next >

src/hotspot/share/ci/ciEnv.cpp

Print this page

   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciConstant.hpp"
  27 #include "ci/ciEnv.hpp"
  28 #include "ci/ciField.hpp"

  29 #include "ci/ciInstance.hpp"
  30 #include "ci/ciInstanceKlass.hpp"
  31 #include "ci/ciMethod.hpp"
  32 #include "ci/ciNullObject.hpp"
  33 #include "ci/ciReplay.hpp"
  34 #include "ci/ciSymbols.hpp"
  35 #include "ci/ciUtilities.inline.hpp"
  36 #include "classfile/javaClasses.hpp"
  37 #include "classfile/javaClasses.inline.hpp"
  38 #include "classfile/systemDictionary.hpp"
  39 #include "classfile/vmClasses.hpp"
  40 #include "classfile/vmSymbols.hpp"
  41 #include "code/codeCache.hpp"
  42 #include "code/scopeDesc.hpp"
  43 #include "compiler/compilationLog.hpp"
  44 #include "compiler/compilationPolicy.hpp"
  45 #include "compiler/compileBroker.hpp"
  46 #include "compiler/compilerEvent.hpp"
  47 #include "compiler/compileLog.hpp"
  48 #include "compiler/compileTask.hpp"

 462   }
 463 
 464   Handle loader;
 465   Handle domain;
 466   if (accessing_klass != nullptr) {
 467     loader = Handle(current, accessing_klass->loader());
 468     domain = Handle(current, accessing_klass->protection_domain());
 469   }
 470 
 471   Klass* found_klass = require_local ?
 472                          SystemDictionary::find_instance_or_array_klass(current, sym, loader, domain) :
 473                          SystemDictionary::find_constrained_instance_or_array_klass(current, sym, loader);
 474 
 475   // If we fail to find an array klass, look again for its element type.
 476   // The element type may be available either locally or via constraints.
 477   // In either case, if we can find the element type in the system dictionary,
 478   // we must build an array type around it.  The CI requires array klasses
 479   // to be loaded if their element klasses are loaded, except when memory
 480   // is exhausted.
 481   if (Signature::is_array(sym) &&
 482       (sym->char_at(1) == JVM_SIGNATURE_ARRAY || sym->char_at(1) == JVM_SIGNATURE_CLASS)) {

 483     // We have an unloaded array.
 484     // Build it on the fly if the element class exists.
 485     SignatureStream ss(sym, false);
 486     ss.skip_array_prefix(1);
 487     // Get element ciKlass recursively.
 488     ciKlass* elem_klass =
 489       get_klass_by_name_impl(accessing_klass,
 490                              cpool,
 491                              get_symbol(ss.as_symbol()),
 492                              require_local);
 493     if (elem_klass != nullptr && elem_klass->is_loaded()) {
 494       // Now make an array for it
 495       return ciObjArrayKlass::make_impl(elem_klass);
 496     }
 497   }
 498 
 499   if (found_klass == nullptr && !cpool.is_null() && cpool->has_preresolution()) {
 500     // Look inside the constant pool for pre-resolved class entries.
 501     for (int i = cpool->length() - 1; i >= 1; i--) {
 502       if (cpool->tag_at(i).is_klass()) {
 503         Klass* kls = cpool->resolved_klass_at(i);
 504         if (kls->name() == sym) {
 505           found_klass = kls;
 506           break;
 507         }
 508       }
 509     }
 510   }
 511 
 512   if (found_klass != nullptr) {
 513     // Found it.  Build a CI handle.
 514     return get_klass(found_klass);
 515   }
 516 
 517   if (require_local)  return nullptr;
 518 
 519   // Not yet loaded into the VM, or not governed by loader constraints.
 520   // Make a CI representative for it.




 521   return get_unloaded_klass(accessing_klass, name);
 522 }
 523 
 524 // ------------------------------------------------------------------
 525 // ciEnv::get_klass_by_name
 526 ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
 527                                   ciSymbol* klass_name,
 528                                   bool require_local) {
 529   GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
 530                                                  constantPoolHandle(),
 531                                                  klass_name,
 532                                                  require_local);)
 533 }
 534 
 535 // ------------------------------------------------------------------
 536 // ciEnv::get_klass_by_index_impl
 537 //
 538 // Implementation of get_klass_by_index.
 539 ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
 540                                         int index,

   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciConstant.hpp"
  27 #include "ci/ciEnv.hpp"
  28 #include "ci/ciField.hpp"
  29 #include "ci/ciInlineKlass.hpp"
  30 #include "ci/ciInstance.hpp"
  31 #include "ci/ciInstanceKlass.hpp"
  32 #include "ci/ciMethod.hpp"
  33 #include "ci/ciNullObject.hpp"
  34 #include "ci/ciReplay.hpp"
  35 #include "ci/ciSymbols.hpp"
  36 #include "ci/ciUtilities.inline.hpp"
  37 #include "classfile/javaClasses.hpp"
  38 #include "classfile/javaClasses.inline.hpp"
  39 #include "classfile/systemDictionary.hpp"
  40 #include "classfile/vmClasses.hpp"
  41 #include "classfile/vmSymbols.hpp"
  42 #include "code/codeCache.hpp"
  43 #include "code/scopeDesc.hpp"
  44 #include "compiler/compilationLog.hpp"
  45 #include "compiler/compilationPolicy.hpp"
  46 #include "compiler/compileBroker.hpp"
  47 #include "compiler/compilerEvent.hpp"
  48 #include "compiler/compileLog.hpp"
  49 #include "compiler/compileTask.hpp"

 463   }
 464 
 465   Handle loader;
 466   Handle domain;
 467   if (accessing_klass != nullptr) {
 468     loader = Handle(current, accessing_klass->loader());
 469     domain = Handle(current, accessing_klass->protection_domain());
 470   }
 471 
 472   Klass* found_klass = require_local ?
 473                          SystemDictionary::find_instance_or_array_klass(current, sym, loader, domain) :
 474                          SystemDictionary::find_constrained_instance_or_array_klass(current, sym, loader);
 475 
 476   // If we fail to find an array klass, look again for its element type.
 477   // The element type may be available either locally or via constraints.
 478   // In either case, if we can find the element type in the system dictionary,
 479   // we must build an array type around it.  The CI requires array klasses
 480   // to be loaded if their element klasses are loaded, except when memory
 481   // is exhausted.
 482   if (Signature::is_array(sym) &&
 483       (sym->char_at(1) == JVM_SIGNATURE_ARRAY ||
 484        sym->char_at(1) == JVM_SIGNATURE_CLASS )) {
 485     // We have an unloaded array.
 486     // Build it on the fly if the element class exists.
 487     SignatureStream ss(sym, false);
 488     ss.skip_array_prefix(1);
 489     // Get element ciKlass recursively.
 490     ciKlass* elem_klass =
 491       get_klass_by_name_impl(accessing_klass,
 492                              cpool,
 493                              get_symbol(ss.as_symbol()),
 494                              require_local);
 495     if (elem_klass != nullptr && elem_klass->is_loaded()) {
 496       // Now make an array for it
 497       return ciArrayKlass::make(elem_klass);
 498     }
 499   }
 500 
 501   if (found_klass == nullptr && !cpool.is_null() && cpool->has_preresolution()) {
 502     // Look inside the constant pool for pre-resolved class entries.
 503     for (int i = cpool->length() - 1; i >= 1; i--) {
 504       if (cpool->tag_at(i).is_klass()) {
 505         Klass* kls = cpool->resolved_klass_at(i);
 506         if (kls->name() == sym) {
 507           found_klass = kls;
 508           break;
 509         }
 510       }
 511     }
 512   }
 513 
 514   if (found_klass != nullptr) {
 515     // Found it.  Build a CI handle.
 516     return get_klass(found_klass);
 517   }
 518 
 519   if (require_local)  return nullptr;
 520 
 521   // Not yet loaded into the VM, or not governed by loader constraints.
 522   // Make a CI representative for it.
 523   int i = 0;
 524   while (sym->char_at(i) == JVM_SIGNATURE_ARRAY) {
 525     i++;
 526   }
 527   return get_unloaded_klass(accessing_klass, name);
 528 }
 529 
 530 // ------------------------------------------------------------------
 531 // ciEnv::get_klass_by_name
 532 ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
 533                                   ciSymbol* klass_name,
 534                                   bool require_local) {
 535   GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
 536                                                  constantPoolHandle(),
 537                                                  klass_name,
 538                                                  require_local);)
 539 }
 540 
 541 // ------------------------------------------------------------------
 542 // ciEnv::get_klass_by_index_impl
 543 //
 544 // Implementation of get_klass_by_index.
 545 ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
 546                                         int index,
< prev index next >