comparison src/share/vm/code/relocInfo.hpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 6c97c830fb6f
children 7875ea94bea5
comparison
equal deleted inserted replaced
6724:36d1d483d5d6 6725:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
26 #define SHARE_VM_CODE_RELOCINFO_HPP 26 #define SHARE_VM_CODE_RELOCINFO_HPP
27 27
28 #include "memory/allocation.hpp" 28 #include "memory/allocation.hpp"
29 #include "utilities/top.hpp" 29 #include "utilities/top.hpp"
30 30
31 class NativeMovConstReg;
32
31 // Types in this file: 33 // Types in this file:
32 // relocInfo 34 // relocInfo
33 // One element of an array of halfwords encoding compressed relocations. 35 // One element of an array of halfwords encoding compressed relocations.
34 // Also, the source of relocation types (relocInfo::oop_type, ...). 36 // Also, the source of relocation types (relocInfo::oop_type, ...).
35 // Relocation 37 // Relocation
36 // A flyweight object representing a single relocation. 38 // A flyweight object representing a single relocation.
37 // It is fully unpacked from the compressed relocation array. 39 // It is fully unpacked from the compressed relocation array.
40 // metadata_Relocation, ... (subclasses of Relocation)
41 // The location of some type-specific operations (metadata_addr, ...).
42 // Also, the source of relocation specs (metadata_Relocation::spec, ...).
38 // oop_Relocation, ... (subclasses of Relocation) 43 // oop_Relocation, ... (subclasses of Relocation)
39 // The location of some type-specific operations (oop_addr, ...). 44 // oops in the code stream (strings, class loaders)
40 // Also, the source of relocation specs (oop_Relocation::spec, ...). 45 // Also, the source of relocation specs (oop_Relocation::spec, ...).
41 // RelocationHolder 46 // RelocationHolder
42 // A ValueObj type which acts as a union holding a Relocation object. 47 // A ValueObj type which acts as a union holding a Relocation object.
43 // Represents a relocation spec passed into a CodeBuffer during assembly. 48 // Represents a relocation spec passed into a CodeBuffer during assembly.
44 // RelocIterator 49 // RelocIterator
116 // Instruction: The corresponding code address is ignored 121 // Instruction: The corresponding code address is ignored
117 // Data: Any data prefix and format code are ignored 122 // Data: Any data prefix and format code are ignored
118 // (This means that any relocInfo can be disabled by setting 123 // (This means that any relocInfo can be disabled by setting
119 // its type to none. See relocInfo::remove.) 124 // its type to none. See relocInfo::remove.)
120 // 125 //
121 // relocInfo::oop_type -- a reference to an oop 126 // relocInfo::oop_type, relocInfo::metadata_type -- a reference to an oop or meta data
122 // Value: an oop, or else the address (handle) of an oop 127 // Value: an oop, or else the address (handle) of an oop
123 // Instruction types: memory (load), set (load address) 128 // Instruction types: memory (load), set (load address)
124 // Data: [] an oop stored in 4 bytes of instruction 129 // Data: [] an oop stored in 4 bytes of instruction
125 // [n] n is the index of an oop in the CodeBlob's oop pool 130 // [n] n is the index of an oop in the CodeBlob's oop pool
126 // [[N]n l] and l is a byte offset to be applied to the oop 131 // [[N]n l] and l is a byte offset to be applied to the oop
265 internal_word_type = 8, // reference within the current code blob 270 internal_word_type = 8, // reference within the current code blob
266 section_word_type = 9, // internal, but a cross-section reference 271 section_word_type = 9, // internal, but a cross-section reference
267 poll_type = 10, // polling instruction for safepoints 272 poll_type = 10, // polling instruction for safepoints
268 poll_return_type = 11, // polling instruction for safepoints at return 273 poll_return_type = 11, // polling instruction for safepoints at return
269 breakpoint_type = 12, // an initialization barrier or safepoint 274 breakpoint_type = 12, // an initialization barrier or safepoint
270 yet_unused_type = 13, // Still unused 275 metadata_type = 13, // metadata that used to be oops
271 yet_unused_type_2 = 14, // Still unused 276 yet_unused_type_2 = 14, // Still unused
272 data_prefix_tag = 15, // tag for a prefix (carries data arguments) 277 data_prefix_tag = 15, // tag for a prefix (carries data arguments)
273 type_mask = 15 // A mask which selects only the above values 278 type_mask = 15 // A mask which selects only the above values
274 }; 279 };
275 280
295 ; 300 ;
296 #endif 301 #endif
297 302
298 #define APPLY_TO_RELOCATIONS(visitor) \ 303 #define APPLY_TO_RELOCATIONS(visitor) \
299 visitor(oop) \ 304 visitor(oop) \
305 visitor(metadata) \
300 visitor(virtual_call) \ 306 visitor(virtual_call) \
301 visitor(opt_virtual_call) \ 307 visitor(opt_virtual_call) \
302 visitor(static_call) \ 308 visitor(static_call) \
303 visitor(static_stub) \ 309 visitor(static_stub) \
304 visitor(runtime_call) \ 310 visitor(runtime_call) \
970 oop* oop_addr(); // addr or &pool[jint_data] 976 oop* oop_addr(); // addr or &pool[jint_data]
971 oop oop_value(); // *oop_addr 977 oop oop_value(); // *oop_addr
972 // Note: oop_value transparently converts Universe::non_oop_word to NULL. 978 // Note: oop_value transparently converts Universe::non_oop_word to NULL.
973 }; 979 };
974 980
981
982 // copy of oop_Relocation for now but may delete stuff in both/either
983 class metadata_Relocation : public DataRelocation {
984 relocInfo::relocType type() { return relocInfo::metadata_type; }
985
986 public:
987 // encode in one of these formats: [] [n] [n l] [Nn l] [Nn Ll]
988 // an metadata in the CodeBlob's metadata pool
989 static RelocationHolder spec(int metadata_index, int offset = 0) {
990 assert(metadata_index > 0, "must be a pool-resident metadata");
991 RelocationHolder rh = newHolder();
992 new(rh) metadata_Relocation(metadata_index, offset);
993 return rh;
994 }
995 // an metadata in the instruction stream
996 static RelocationHolder spec_for_immediate() {
997 const int metadata_index = 0;
998 const int offset = 0; // if you want an offset, use the metadata pool
999 RelocationHolder rh = newHolder();
1000 new(rh) metadata_Relocation(metadata_index, offset);
1001 return rh;
1002 }
1003
1004 private:
1005 jint _metadata_index; // if > 0, index into nmethod::metadata_at
1006 jint _offset; // byte offset to apply to the metadata itself
1007
1008 metadata_Relocation(int metadata_index, int offset) {
1009 _metadata_index = metadata_index; _offset = offset;
1010 }
1011
1012 friend class RelocIterator;
1013 metadata_Relocation() { }
1014
1015 // Fixes a Metadata pointer in the code. Most platforms embeds the
1016 // Metadata pointer in the code at compile time so this is empty
1017 // for them.
1018 void pd_fix_value(address x);
1019
1020 public:
1021 int metadata_index() { return _metadata_index; }
1022 int offset() { return _offset; }
1023
1024 // data is packed in "2_ints" format: [i o] or [Ii Oo]
1025 void pack_data_to(CodeSection* dest);
1026 void unpack_data();
1027
1028 void fix_metadata_relocation(); // reasserts metadata value
1029
1030 void verify_metadata_relocation();
1031
1032 address value() { return (address) *metadata_addr(); }
1033
1034 bool metadata_is_immediate() { return metadata_index() == 0; }
1035
1036 Metadata** metadata_addr(); // addr or &pool[jint_data]
1037 Metadata* metadata_value(); // *metadata_addr
1038 // Note: metadata_value transparently converts Universe::non_metadata_word to NULL.
1039 };
1040
1041
975 class virtual_call_Relocation : public CallRelocation { 1042 class virtual_call_Relocation : public CallRelocation {
976 relocInfo::relocType type() { return relocInfo::virtual_call_type; } 1043 relocInfo::relocType type() { return relocInfo::virtual_call_type; }
977 1044
978 public: 1045 public:
979 // "first_oop" points to the first associated set-oop. 1046 // "cached_value" points to the first associated set-oop.
980 // The oop_limit helps find the last associated set-oop. 1047 // The oop_limit helps find the last associated set-oop.
981 // (See comments at the top of this file.) 1048 // (See comments at the top of this file.)
982 static RelocationHolder spec(address first_oop, address oop_limit = NULL) { 1049 static RelocationHolder spec(address cached_value) {
983 RelocationHolder rh = newHolder(); 1050 RelocationHolder rh = newHolder();
984 new(rh) virtual_call_Relocation(first_oop, oop_limit); 1051 new(rh) virtual_call_Relocation(cached_value);
985 return rh; 1052 return rh;
986 } 1053 }
987 1054
988 virtual_call_Relocation(address first_oop, address oop_limit) { 1055 virtual_call_Relocation(address cached_value) {
989 _first_oop = first_oop; _oop_limit = oop_limit; 1056 _cached_value = cached_value;
990 assert(first_oop != NULL, "first oop address must be specified"); 1057 assert(cached_value != NULL, "first oop address must be specified");
991 } 1058 }
992 1059
993 private: 1060 private:
994 address _first_oop; // location of first set-oop instruction 1061 address _cached_value; // location of set-value instruction
995 address _oop_limit; // search limit for set-oop instructions
996 1062
997 friend class RelocIterator; 1063 friend class RelocIterator;
998 virtual_call_Relocation() { } 1064 virtual_call_Relocation() { }
999 1065
1000 1066
1001 public: 1067 public:
1002 address first_oop(); 1068 address cached_value();
1003 address oop_limit();
1004 1069
1005 // data is packed as scaled offsets in "2_ints" format: [f l] or [Ff Ll] 1070 // data is packed as scaled offsets in "2_ints" format: [f l] or [Ff Ll]
1006 // oop_limit is set to 0 if the limit falls somewhere within the call. 1071 // oop_limit is set to 0 if the limit falls somewhere within the call.
1007 // When unpacking, a zero oop_limit is taken to refer to the end of the call. 1072 // When unpacking, a zero oop_limit is taken to refer to the end of the call.
1008 // (This has the effect of bringing in the call's delay slot on SPARC.) 1073 // (This has the effect of bringing in the call's delay slot on SPARC.)
1009 void pack_data_to(CodeSection* dest); 1074 void pack_data_to(CodeSection* dest);
1010 void unpack_data(); 1075 void unpack_data();
1011 1076
1012 void clear_inline_cache(); 1077 void clear_inline_cache();
1013
1014 // Figure out where an ic_call is hiding, given a set-oop or call.
1015 // Either ic_call or first_oop must be non-null; the other is deduced.
1016 // Code if non-NULL must be the nmethod, else it is deduced.
1017 // The address of the patchable oop is also deduced.
1018 // The returned iterator will enumerate over the oops and the ic_call,
1019 // as well as any other relocations that happen to be in that span of code.
1020 // Recognize relevant set_oops with: oop_reloc()->oop_addr() == oop_addr.
1021 static RelocIterator parse_ic(nmethod* &nm, address &ic_call, address &first_oop, oop* &oop_addr, bool *is_optimized);
1022 }; 1078 };
1023 1079
1024 1080
1025 class opt_virtual_call_Relocation : public CallRelocation { 1081 class opt_virtual_call_Relocation : public CallRelocation {
1026 relocInfo::relocType type() { return relocInfo::opt_virtual_call_type; } 1082 relocInfo::relocType type() { return relocInfo::opt_virtual_call_type; }