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 #ifndef SHARE_VM_CODE_RELOCINFO_HPP
26 #define SHARE_VM_CODE_RELOCINFO_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/os.hpp"
30
31 class nmethod;
32 class CompiledMethod;
33 class Metadata;
34 class NativeMovConstReg;
35
36 // Types in this file:
37 // relocInfo
38 // One element of an array of halfwords encoding compressed relocations.
39 // Also, the source of relocation types (relocInfo::oop_type, ...).
40 // Relocation
41 // A flyweight object representing a single relocation.
42 // It is fully unpacked from the compressed relocation array.
43 // metadata_Relocation, ... (subclasses of Relocation)
44 // The location of some type-specific operations (metadata_addr, ...).
45 // Also, the source of relocation specs (metadata_Relocation::spec, ...).
46 // oop_Relocation, ... (subclasses of Relocation)
47 // oops in the code stream (strings, class loaders)
48 // Also, the source of relocation specs (oop_Relocation::spec, ...).
49 // RelocationHolder
406 static int data1_from_int(jint x) { return (short)x; }
407 static jint jint_from_data(short* data) {
408 return (data[0] << value_width) + (unsigned short)data[1];
409 }
410
411 static jint short_data_at(int n, short* data, int datalen) {
412 return datalen > n ? data[n] : 0;
413 }
414
415 static jint jint_data_at(int n, short* data, int datalen) {
416 return datalen > n+1 ? jint_from_data(&data[n]) : short_data_at(n, data, datalen);
417 }
418
419 // Update methods for relocation information
420 // (since code is dynamically patched, we also need to dynamically update the relocation info)
421 // Both methods takes old_type, so it is able to performe sanity checks on the information removed.
422 static void change_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type, relocType new_type);
423 static void remove_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type);
424
425 // Machine dependent stuff
426 #ifdef TARGET_ARCH_x86
427 # include "relocInfo_x86.hpp"
428 #endif
429 #ifdef TARGET_ARCH_sparc
430 # include "relocInfo_sparc.hpp"
431 #endif
432 #ifdef TARGET_ARCH_zero
433 # include "relocInfo_zero.hpp"
434 #endif
435 #ifdef TARGET_ARCH_arm
436 # include "relocInfo_arm.hpp"
437 #endif
438 #ifdef TARGET_ARCH_ppc
439 # include "relocInfo_ppc.hpp"
440 #endif
441 #ifdef TARGET_ARCH_aarch64
442 # include "relocInfo_aarch64.hpp"
443 #endif
444
445 protected:
446 // Derived constant, based on format_width which is PD:
447 enum {
448 offset_width = nontype_width - format_width,
449 offset_mask = (1<<offset_width) - 1,
450 format_mask = (1<<format_width) - 1
451 };
452 public:
453 enum {
454 #ifdef _LP64
455 // for use in format
456 // format_width must be at least 1 on _LP64
457 narrow_oop_in_const = 1,
458 #endif
459 // Conservatively large estimate of maximum length (in shorts)
460 // of any relocation record.
461 // Extended format is length prefix, data words, and tag/offset suffix.
462 length_limit = 1 + 1 + (3*BytesPerWord/BytesPerShort) + 1,
463 have_format = format_width > 0
|
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 #ifndef SHARE_VM_CODE_RELOCINFO_HPP
26 #define SHARE_VM_CODE_RELOCINFO_HPP
27
28 #include "memory/allocation.hpp"
29 #include "runtime/os.hpp"
30 #include "utilities/macros.hpp"
31
32 class nmethod;
33 class CompiledMethod;
34 class Metadata;
35 class NativeMovConstReg;
36
37 // Types in this file:
38 // relocInfo
39 // One element of an array of halfwords encoding compressed relocations.
40 // Also, the source of relocation types (relocInfo::oop_type, ...).
41 // Relocation
42 // A flyweight object representing a single relocation.
43 // It is fully unpacked from the compressed relocation array.
44 // metadata_Relocation, ... (subclasses of Relocation)
45 // The location of some type-specific operations (metadata_addr, ...).
46 // Also, the source of relocation specs (metadata_Relocation::spec, ...).
47 // oop_Relocation, ... (subclasses of Relocation)
48 // oops in the code stream (strings, class loaders)
49 // Also, the source of relocation specs (oop_Relocation::spec, ...).
50 // RelocationHolder
407 static int data1_from_int(jint x) { return (short)x; }
408 static jint jint_from_data(short* data) {
409 return (data[0] << value_width) + (unsigned short)data[1];
410 }
411
412 static jint short_data_at(int n, short* data, int datalen) {
413 return datalen > n ? data[n] : 0;
414 }
415
416 static jint jint_data_at(int n, short* data, int datalen) {
417 return datalen > n+1 ? jint_from_data(&data[n]) : short_data_at(n, data, datalen);
418 }
419
420 // Update methods for relocation information
421 // (since code is dynamically patched, we also need to dynamically update the relocation info)
422 // Both methods takes old_type, so it is able to performe sanity checks on the information removed.
423 static void change_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type, relocType new_type);
424 static void remove_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type);
425
426 // Machine dependent stuff
427 #include CPU_HEADER(relocInfo)
428
429 protected:
430 // Derived constant, based on format_width which is PD:
431 enum {
432 offset_width = nontype_width - format_width,
433 offset_mask = (1<<offset_width) - 1,
434 format_mask = (1<<format_width) - 1
435 };
436 public:
437 enum {
438 #ifdef _LP64
439 // for use in format
440 // format_width must be at least 1 on _LP64
441 narrow_oop_in_const = 1,
442 #endif
443 // Conservatively large estimate of maximum length (in shorts)
444 // of any relocation record.
445 // Extended format is length prefix, data words, and tag/offset suffix.
446 length_limit = 1 + 1 + (3*BytesPerWord/BytesPerShort) + 1,
447 have_format = format_width > 0
|