< prev index next >

src/hotspot/share/oops/resolvedFieldEntry.cpp

Print this page

  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  *
 23  */
 24 
 25 #include "cds/archiveBuilder.hpp"
 26 #include "cppstdlib/type_traits.hpp"
 27 #include "oops/instanceKlass.hpp"
 28 #include "oops/instanceOop.hpp"
 29 #include "oops/resolvedFieldEntry.hpp"
 30 #include "runtime/fieldDescriptor.inline.hpp"
 31 #include "utilities/checkedCast.hpp"
 32 #include "utilities/globalDefinitions.hpp"
 33 
 34 static_assert(std::is_trivially_copyable_v<ResolvedFieldEntry>);
 35 
 36 // Detect inadvertently introduced trailing padding.
 37 class ResolvedFieldEntryWithExtra : public ResolvedFieldEntry {
 38   u1 _extra_field;
 39 };
 40 static_assert(sizeof(ResolvedFieldEntryWithExtra) > sizeof(ResolvedFieldEntry));
 41 
 42 void ResolvedFieldEntry::fill_in(const fieldDescriptor& info, u1 tos_state, u1 get_code, u1 put_code) {
 43   set_flags(info.access_flags().is_final(), info.access_flags().is_volatile());




 44   _field_holder = info.field_holder();
 45   _field_offset = info.offset();
 46   _field_index = checked_cast<u2>(info.index());
 47   _tos_state = tos_state;
 48 
 49   // These must be set after the other fields
 50   set_bytecode(&_get_code, get_code);
 51   set_bytecode(&_put_code, put_code);
 52   assert_is_valid();
 53 }
 54 
 55 void ResolvedFieldEntry::print_on(outputStream* st) const {
 56   st->print_cr("Field Entry:");
 57 
 58   if (field_holder() != nullptr) {
 59     st->print_cr(" - Holder: " INTPTR_FORMAT " %s", p2i(field_holder()), field_holder()->external_name());
 60   } else {
 61     st->print_cr("- Holder: null");
 62   }
 63   st->print_cr(" - Offset: %d", field_offset());
 64   st->print_cr(" - Field Index: %d", field_index());
 65   st->print_cr(" - CP Index: %d", constant_pool_index());
 66   st->print_cr(" - TOS: %s", type2name(as_BasicType((TosState)tos_state())));
 67   st->print_cr(" - Is Final: %d", is_final());
 68   st->print_cr(" - Is Volatile: %d", is_volatile());



 69   st->print_cr(" - Get Bytecode: %s", Bytecodes::name((Bytecodes::Code)get_code()));
 70   st->print_cr(" - Put Bytecode: %s", Bytecodes::name((Bytecodes::Code)put_code()));
 71 }
 72 
 73 #ifdef ASSERT
 74 void ResolvedFieldEntry::assert_is_valid() const {
 75   assert(field_holder()->is_instance_klass(), "should be instanceKlass");
 76   assert(field_offset() >= instanceOopDesc::base_offset_in_bytes(),
 77          "field offset out of range %d >= %d", field_offset(), instanceOopDesc::base_offset_in_bytes());
 78   assert(as_BasicType((TosState)tos_state()) != T_ILLEGAL, "tos_state is ILLEGAL");
 79   assert(_flags < (1 << (max_flag_shift + 1)), "flags are too large %d", _flags);
 80 
 81   // Read each bytecode once.
 82   volatile Bytecodes::Code g = (Bytecodes::Code)get_code();
 83   assert(g == 0 || g == Bytecodes::_getstatic || g == Bytecodes::_getfield, "invalid get bytecode %d", g);
 84 
 85   volatile Bytecodes::Code p = (Bytecodes::Code)put_code();
 86   assert(p == 0 || p == Bytecodes::_putstatic || p == Bytecodes::_putfield, "invalid put bytecode %d", p);
 87 }
 88 #endif

  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  *
 23  */
 24 
 25 #include "cds/archiveBuilder.hpp"
 26 #include "cppstdlib/type_traits.hpp"
 27 #include "interpreter/bytecodes.hpp"

 28 #include "oops/resolvedFieldEntry.hpp"
 29 #include "runtime/fieldDescriptor.inline.hpp"
 30 #include "utilities/checkedCast.hpp"
 31 #include "utilities/globalDefinitions.hpp"
 32 
 33 static_assert(std::is_trivially_copyable_v<ResolvedFieldEntry>);
 34 
 35 // Detect inadvertently introduced trailing padding.
 36 class ResolvedFieldEntryWithExtra : public ResolvedFieldEntry {
 37   u1 _extra_field;
 38 };
 39 static_assert(sizeof(ResolvedFieldEntryWithExtra) > sizeof(ResolvedFieldEntry));
 40 
 41 void ResolvedFieldEntry::fill_in(const fieldDescriptor& info, u1 tos_state, u1 get_code, u1 put_code) {
 42   set_flags(info.access_flags().is_volatile(),
 43             info.access_flags().is_final(),
 44             info.is_flat(),
 45             info.is_null_free_inline_type(),
 46             info.has_null_marker());
 47   _field_holder = info.field_holder();
 48   _field_offset = info.offset();
 49   _field_index = checked_cast<u2>(info.index());
 50   _tos_state = tos_state;
 51 
 52   // These must be set after the other fields
 53   set_bytecode(&_get_code, get_code);
 54   set_bytecode(&_put_code, put_code);
 55   assert_is_valid();
 56 }
 57 
 58 void ResolvedFieldEntry::print_on(outputStream* st) const {
 59   st->print_cr("Field Entry:");
 60 
 61   if (field_holder() != nullptr) {
 62     st->print_cr(" - Holder: " INTPTR_FORMAT " %s", p2i(field_holder()), field_holder()->external_name());
 63   } else {
 64     st->print_cr("- Holder: null");
 65   }
 66   st->print_cr(" - Offset: %d", field_offset());
 67   st->print_cr(" - Field Index: %d", field_index());
 68   st->print_cr(" - CP Index: %d", constant_pool_index());
 69   st->print_cr(" - TOS: %s", type2name(as_BasicType((TosState)tos_state())));
 70   st->print_cr(" - Is Final: %d", is_final());
 71   st->print_cr(" - Is Volatile: %d", is_volatile());
 72   st->print_cr(" - Is Flat: %d", is_flat());
 73   st->print_cr(" - Is Null Free Inline Type: %d", is_null_free_inline_type());
 74   st->print_cr(" - Has null marker: %d", has_null_marker());
 75   st->print_cr(" - Get Bytecode: %s", Bytecodes::name((Bytecodes::Code)get_code()));
 76   st->print_cr(" - Put Bytecode: %s", Bytecodes::name((Bytecodes::Code)put_code()));
 77 }
 78 
 79 #ifdef ASSERT
 80 void ResolvedFieldEntry::assert_is_valid() const {
 81   assert(field_holder()->is_instance_klass(), "should be instanceKlass");
 82   assert(field_offset() >= instanceOopDesc::base_offset_in_bytes(),
 83          "field offset out of range %d >= %d", field_offset(), instanceOopDesc::base_offset_in_bytes());
 84   assert(as_BasicType((TosState)tos_state()) != T_ILLEGAL, "tos_state is ILLEGAL");
 85   assert(_flags < (1 << (max_flag_shift + 1)), "flags are too large %d", _flags);
 86 
 87   // Read each bytecode once.
 88   volatile Bytecodes::Code g = (Bytecodes::Code)get_code();
 89   assert(g == 0 || g == Bytecodes::_getstatic || g == Bytecodes::_getfield, "invalid get bytecode %d", g);
 90 
 91   volatile Bytecodes::Code p = (Bytecodes::Code)put_code();
 92   assert(p == 0 || p == Bytecodes::_putstatic || p == Bytecodes::_putfield, "invalid put bytecode %d", p);
 93 }
 94 #endif
< prev index next >