equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, 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 "runtime/os.hpp" |
29 #include "runtime/os.hpp" |
30 |
30 |
|
31 class nmethod; |
|
32 class CompiledMethod; |
31 class Metadata; |
33 class Metadata; |
32 class NativeMovConstReg; |
34 class NativeMovConstReg; |
33 |
35 |
34 // Types in this file: |
36 // Types in this file: |
35 // relocInfo |
37 // relocInfo |
537 |
539 |
538 private: |
540 private: |
539 address _limit; // stop producing relocations after this _addr |
541 address _limit; // stop producing relocations after this _addr |
540 relocInfo* _current; // the current relocation information |
542 relocInfo* _current; // the current relocation information |
541 relocInfo* _end; // end marker; we're done iterating when _current == _end |
543 relocInfo* _end; // end marker; we're done iterating when _current == _end |
542 nmethod* _code; // compiled method containing _addr |
544 CompiledMethod* _code; // compiled method containing _addr |
543 address _addr; // instruction to which the relocation applies |
545 address _addr; // instruction to which the relocation applies |
544 short _databuf; // spare buffer for compressed data |
546 short _databuf; // spare buffer for compressed data |
545 short* _data; // pointer to the relocation's data |
547 short* _data; // pointer to the relocation's data |
546 short _datalen; // number of halfwords in _data |
548 short _datalen; // number of halfwords in _data |
547 char _format; // position within the instruction |
549 char _format; // position within the instruction |
568 |
570 |
569 void advance_over_prefix(); // helper method |
571 void advance_over_prefix(); // helper method |
570 |
572 |
571 void initialize_misc(); |
573 void initialize_misc(); |
572 |
574 |
573 void initialize(nmethod* nm, address begin, address limit); |
575 void initialize(CompiledMethod* nm, address begin, address limit); |
574 |
576 |
575 RelocIterator() { initialize_misc(); } |
577 RelocIterator() { initialize_misc(); } |
576 |
578 |
577 public: |
579 public: |
578 // constructor |
580 // constructor |
579 RelocIterator(nmethod* nm, address begin = NULL, address limit = NULL); |
581 RelocIterator(CompiledMethod* nm, address begin = NULL, address limit = NULL); |
580 RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL); |
582 RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL); |
581 |
583 |
582 // get next reloc info, return !eos |
584 // get next reloc info, return !eos |
583 bool next() { |
585 bool next() { |
584 _current++; |
586 _current++; |
609 address limit() const { return _limit; } |
611 address limit() const { return _limit; } |
610 void set_limit(address x); |
612 void set_limit(address x); |
611 relocType type() const { return current()->type(); } |
613 relocType type() const { return current()->type(); } |
612 int format() const { return (relocInfo::have_format) ? current()->format() : 0; } |
614 int format() const { return (relocInfo::have_format) ? current()->format() : 0; } |
613 address addr() const { return _addr; } |
615 address addr() const { return _addr; } |
614 nmethod* code() const { return _code; } |
616 CompiledMethod* code() const { return _code; } |
|
617 nmethod* code_as_nmethod() const; |
615 short* data() const { return _data; } |
618 short* data() const { return _data; } |
616 int datalen() const { return _datalen; } |
619 int datalen() const { return _datalen; } |
617 bool has_current() const { return _datalen >= 0; } |
620 bool has_current() const { return _datalen >= 0; } |
618 |
621 |
619 void set_addr(address addr) { _addr = addr; } |
622 void set_addr(address addr) { _addr = addr; } |
808 address new_addr_for(address olda, const CodeBuffer* src, CodeBuffer* dest); |
811 address new_addr_for(address olda, const CodeBuffer* src, CodeBuffer* dest); |
809 void normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections = false); |
812 void normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections = false); |
810 |
813 |
811 public: |
814 public: |
812 // accessors which only make sense for a bound Relocation |
815 // accessors which only make sense for a bound Relocation |
813 address addr() const { return binding()->addr(); } |
816 address addr() const { return binding()->addr(); } |
814 nmethod* code() const { return binding()->code(); } |
817 CompiledMethod* code() const { return binding()->code(); } |
815 bool addr_in_const() const { return binding()->addr_in_const(); } |
818 nmethod* code_as_nmethod() const { return binding()->code_as_nmethod(); } |
|
819 bool addr_in_const() const { return binding()->addr_in_const(); } |
816 protected: |
820 protected: |
817 short* data() const { return binding()->data(); } |
821 short* data() const { return binding()->data(); } |
818 int datalen() const { return binding()->datalen(); } |
822 int datalen() const { return binding()->datalen(); } |
819 int format() const { return binding()->format(); } |
823 int format() const { return binding()->format(); } |
820 |
824 |
1369 return r; \ |
1373 return r; \ |
1370 } |
1374 } |
1371 APPLY_TO_RELOCATIONS(EACH_CASE); |
1375 APPLY_TO_RELOCATIONS(EACH_CASE); |
1372 #undef EACH_CASE |
1376 #undef EACH_CASE |
1373 |
1377 |
1374 inline RelocIterator::RelocIterator(nmethod* nm, address begin, address limit) { |
1378 inline RelocIterator::RelocIterator(CompiledMethod* nm, address begin, address limit) { |
1375 initialize(nm, begin, limit); |
1379 initialize(nm, begin, limit); |
1376 } |
1380 } |
1377 |
1381 |
1378 #endif // SHARE_VM_CODE_RELOCINFO_HPP |
1382 #endif // SHARE_VM_CODE_RELOCINFO_HPP |