< prev index next >

src/hotspot/share/classfile/resolutionErrors.hpp

Print this page


   1 /*
   2  * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


  29 #include "utilities/hashtable.hpp"
  30 
  31 class ResolutionErrorEntry;
  32 
  33 // ResolutionError objects are used to record errors encountered during
  34 // constant pool resolution (JVMS 5.4.3).
  35 
  36 // This value is added to the cpCache index of an invokedynamic instruction when
  37 // storing the resolution error resulting from that invokedynamic instruction.
  38 // This prevents issues where the cpCache index is the same as the constant pool
  39 // index of another entry in the table.
  40 const int CPCACHE_INDEX_MANGLE_VALUE = 1000000;
  41 
  42 class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
  43 
  44 public:
  45   ResolutionErrorTable(int table_size);
  46 
  47   ResolutionErrorEntry* new_entry(int hash, ConstantPool* pool, int cp_index,
  48                                   Symbol* error, Symbol* message);


  49   void free_entry(ResolutionErrorEntry *entry);
  50 
  51   ResolutionErrorEntry* bucket(int i) {
  52     return (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::bucket(i);
  53   }
  54 
  55   ResolutionErrorEntry** bucket_addr(int i) {
  56     return (ResolutionErrorEntry**)Hashtable<ConstantPool*, mtClass>::bucket_addr(i);
  57   }
  58 
  59   void add_entry(int index, ResolutionErrorEntry* new_entry) {
  60     Hashtable<ConstantPool*, mtClass>::add_entry(index,
  61       (HashtableEntry<ConstantPool*, mtClass>*)new_entry);
  62   }
  63 
  64   void add_entry(int index, unsigned int hash,
  65                  const constantPoolHandle& pool, int which, Symbol* error, Symbol* message);
  66 


  67 
  68   // find error given the constant pool and constant pool index
  69   ResolutionErrorEntry* find_entry(int index, unsigned int hash,
  70                                    const constantPoolHandle& pool, int cp_index);
  71 
  72 
  73   unsigned int compute_hash(const constantPoolHandle& pool, int cp_index) {
  74     return (unsigned int) pool->identity_hash() + cp_index;
  75   }
  76 
  77   // purges unloaded entries from the table
  78   void purge_resolution_errors();
  79 
  80   // RedefineClasses support - remove obsolete constant pool entry
  81   void delete_entry(ConstantPool* c);
  82 
  83   // This function is used to encode an index to differentiate it from a
  84   // constant pool index.  It assumes it is being called with a cpCache index
  85   // (that is less than 0).
  86   static int encode_cpcache_index(int index) {
  87     assert(index < 0, "Unexpected non-negative cpCache index");
  88     return index + CPCACHE_INDEX_MANGLE_VALUE;
  89   }
  90 };
  91 
  92 
  93 class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
  94  private:
  95   int               _cp_index;
  96   Symbol*           _error;
  97   Symbol*           _message;

  98 
  99  public:
 100   ConstantPool*      pool() const               { return literal(); }
 101 
 102   int                cp_index() const           { return _cp_index; }
 103   void               set_cp_index(int cp_index) { _cp_index = cp_index; }
 104 
 105   Symbol*            error() const              { return _error; }
 106   void               set_error(Symbol* e);
 107 
 108   Symbol*            message() const            { return _message; }
 109   void               set_message(Symbol* c);



 110 
 111   ResolutionErrorEntry* next() const {
 112     return (ResolutionErrorEntry*)HashtableEntry<ConstantPool*, mtClass>::next();
 113   }
 114 
 115   ResolutionErrorEntry** next_addr() {
 116     return (ResolutionErrorEntry**)HashtableEntry<ConstantPool*, mtClass>::next_addr();
 117   }
 118 };
 119 
 120 #endif // SHARE_CLASSFILE_RESOLUTIONERRORS_HPP
   1 /*
   2  * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   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  *


  29 #include "utilities/hashtable.hpp"
  30 
  31 class ResolutionErrorEntry;
  32 
  33 // ResolutionError objects are used to record errors encountered during
  34 // constant pool resolution (JVMS 5.4.3).
  35 
  36 // This value is added to the cpCache index of an invokedynamic instruction when
  37 // storing the resolution error resulting from that invokedynamic instruction.
  38 // This prevents issues where the cpCache index is the same as the constant pool
  39 // index of another entry in the table.
  40 const int CPCACHE_INDEX_MANGLE_VALUE = 1000000;
  41 
  42 class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
  43 
  44 public:
  45   ResolutionErrorTable(int table_size);
  46 
  47   ResolutionErrorEntry* new_entry(int hash, ConstantPool* pool, int cp_index,
  48                                   Symbol* error, Symbol* message);
  49   ResolutionErrorEntry* new_entry(int hash, ConstantPool* pool, int cp_index,
  50                                   const char* message);
  51   void free_entry(ResolutionErrorEntry *entry);
  52 
  53   ResolutionErrorEntry* bucket(int i) {
  54     return (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::bucket(i);
  55   }
  56 
  57   ResolutionErrorEntry** bucket_addr(int i) {
  58     return (ResolutionErrorEntry**)Hashtable<ConstantPool*, mtClass>::bucket_addr(i);
  59   }
  60 
  61   void add_entry(int index, ResolutionErrorEntry* new_entry) {
  62     Hashtable<ConstantPool*, mtClass>::add_entry(index,
  63       (HashtableEntry<ConstantPool*, mtClass>*)new_entry);
  64   }
  65 
  66   void add_entry(int index, unsigned int hash,
  67                  const constantPoolHandle& pool, int which, Symbol* error, Symbol* message);
  68 
  69   void add_entry(int index, unsigned int hash,
  70                  const constantPoolHandle& pool, int which, const char* message);
  71 
  72   // find error given the constant pool and constant pool index
  73   ResolutionErrorEntry* find_entry(int index, unsigned int hash,
  74                                    const constantPoolHandle& pool, int cp_index);
  75 
  76 
  77   unsigned int compute_hash(const constantPoolHandle& pool, int cp_index) {
  78     return (unsigned int) pool->identity_hash() + cp_index;
  79   }
  80 
  81   // purges unloaded entries from the table
  82   void purge_resolution_errors();
  83 
  84   // RedefineClasses support - remove obsolete constant pool entry
  85   void delete_entry(ConstantPool* c);
  86 
  87   // This function is used to encode an index to differentiate it from a
  88   // constant pool index.  It assumes it is being called with a cpCache index
  89   // (that is less than 0).
  90   static int encode_cpcache_index(int index) {
  91     assert(index < 0, "Unexpected non-negative cpCache index");
  92     return index + CPCACHE_INDEX_MANGLE_VALUE;
  93   }
  94 };
  95 
  96 
  97 class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
  98  private:
  99   int               _cp_index;
 100   Symbol*           _error;
 101   Symbol*           _message;
 102   const char*       _nest_host_error;
 103 
 104  public:
 105   ConstantPool*      pool() const               { return literal(); }
 106 
 107   int                cp_index() const           { return _cp_index; }
 108   void               set_cp_index(int cp_index) { _cp_index = cp_index; }
 109 
 110   Symbol*            error() const              { return _error; }
 111   void               set_error(Symbol* e);
 112 
 113   Symbol*            message() const            { return _message; }
 114   void               set_message(Symbol* c);
 115 
 116   const char*        nest_host_error() const    { return _nest_host_error; }
 117   void               set_nest_host_error(const char* message);
 118 
 119   ResolutionErrorEntry* next() const {
 120     return (ResolutionErrorEntry*)HashtableEntry<ConstantPool*, mtClass>::next();
 121   }
 122 
 123   ResolutionErrorEntry** next_addr() {
 124     return (ResolutionErrorEntry**)HashtableEntry<ConstantPool*, mtClass>::next_addr();
 125   }
 126 };
 127 
 128 #endif // SHARE_CLASSFILE_RESOLUTIONERRORS_HPP
< prev index next >