Mercurial > hg > truffle
comparison src/share/vm/code/relocInfo.hpp @ 1930:2d26b0046e0d
Merge.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Tue, 30 Nov 2010 14:53:30 +0100 |
parents | 0878d7bae69f |
children | f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1484:6b7001391c97 | 1930:2d26b0046e0d |
---|---|
1 /* | 1 /* |
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright (c) 1997, 2010, 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. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License version | 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, | 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. | 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
18 * | 18 * |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | 20 * or visit www.oracle.com if you need additional information or have any |
21 * have any questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 // Types in this file: | 25 // Types in this file: |
26 // relocInfo | 26 // relocInfo |
500 // ... | 500 // ... |
501 // } | 501 // } |
502 // } | 502 // } |
503 | 503 |
504 class RelocIterator : public StackObj { | 504 class RelocIterator : public StackObj { |
505 enum { SECT_CONSTS = 2, | 505 enum { SECT_LIMIT = 3 }; // must be equal to CodeBuffer::SECT_LIMIT, checked in ctor |
506 SECT_LIMIT = 3 }; // must be equal to CodeBuffer::SECT_LIMIT | |
507 friend class Relocation; | 506 friend class Relocation; |
508 friend class relocInfo; // for change_reloc_info_for_address only | 507 friend class relocInfo; // for change_reloc_info_for_address only |
509 typedef relocInfo::relocType relocType; | 508 typedef relocInfo::relocType relocType; |
510 | 509 |
511 private: | 510 private: |
512 address _limit; // stop producing relocations after this _addr | 511 address _limit; // stop producing relocations after this _addr |
513 relocInfo* _current; // the current relocation information | 512 relocInfo* _current; // the current relocation information |
514 relocInfo* _end; // end marker; we're done iterating when _current == _end | 513 relocInfo* _end; // end marker; we're done iterating when _current == _end |
515 CodeBlob* _code; // compiled method containing _addr | 514 nmethod* _code; // compiled method containing _addr |
516 address _addr; // instruction to which the relocation applies | 515 address _addr; // instruction to which the relocation applies |
517 short _databuf; // spare buffer for compressed data | 516 short _databuf; // spare buffer for compressed data |
518 short* _data; // pointer to the relocation's data | 517 short* _data; // pointer to the relocation's data |
519 short _datalen; // number of halfwords in _data | 518 short _datalen; // number of halfwords in _data |
520 char _format; // position within the instruction | 519 char _format; // position within the instruction |
521 | 520 |
522 // Base addresses needed to compute targets of section_word_type relocs. | 521 // Base addresses needed to compute targets of section_word_type relocs. |
523 address _section_start[SECT_LIMIT]; | 522 address _section_start[SECT_LIMIT]; |
523 address _section_end [SECT_LIMIT]; | |
524 | 524 |
525 void set_has_current(bool b) { | 525 void set_has_current(bool b) { |
526 _datalen = !b ? -1 : 0; | 526 _datalen = !b ? -1 : 0; |
527 debug_only(_data = NULL); | 527 debug_only(_data = NULL); |
528 } | 528 } |
538 | 538 |
539 void set_limits(address begin, address limit); | 539 void set_limits(address begin, address limit); |
540 | 540 |
541 void advance_over_prefix(); // helper method | 541 void advance_over_prefix(); // helper method |
542 | 542 |
543 void initialize_misc() { | 543 void initialize_misc(); |
544 set_has_current(false); | 544 |
545 for (int i = 0; i < SECT_LIMIT; i++) { | 545 void initialize(nmethod* nm, address begin, address limit); |
546 _section_start[i] = NULL; // these will be lazily computed, if needed | |
547 } | |
548 } | |
549 | |
550 address compute_section_start(int n) const; // out-of-line helper | |
551 | |
552 void initialize(CodeBlob* nm, address begin, address limit); | |
553 | 546 |
554 friend class PatchingRelocIterator; | 547 friend class PatchingRelocIterator; |
555 // make an uninitialized one, for PatchingRelocIterator: | 548 // make an uninitialized one, for PatchingRelocIterator: |
556 RelocIterator() { initialize_misc(); } | 549 RelocIterator() { initialize_misc(); } |
557 | 550 |
558 public: | 551 public: |
559 // constructor | 552 // constructor |
560 RelocIterator(CodeBlob* cb, address begin = NULL, address limit = NULL); | 553 RelocIterator(nmethod* nm, address begin = NULL, address limit = NULL); |
561 RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL); | 554 RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL); |
562 | 555 |
563 // get next reloc info, return !eos | 556 // get next reloc info, return !eos |
564 bool next() { | 557 bool next() { |
565 _current++; | 558 _current++; |
590 address limit() const { return _limit; } | 583 address limit() const { return _limit; } |
591 void set_limit(address x); | 584 void set_limit(address x); |
592 relocType type() const { return current()->type(); } | 585 relocType type() const { return current()->type(); } |
593 int format() const { return (relocInfo::have_format) ? current()->format() : 0; } | 586 int format() const { return (relocInfo::have_format) ? current()->format() : 0; } |
594 address addr() const { return _addr; } | 587 address addr() const { return _addr; } |
595 CodeBlob* code() const { return _code; } | 588 nmethod* code() const { return _code; } |
596 short* data() const { return _data; } | 589 short* data() const { return _data; } |
597 int datalen() const { return _datalen; } | 590 int datalen() const { return _datalen; } |
598 bool has_current() const { return _datalen >= 0; } | 591 bool has_current() const { return _datalen >= 0; } |
599 | 592 |
600 void set_addr(address addr) { _addr = addr; } | 593 void set_addr(address addr) { _addr = addr; } |
601 bool addr_in_const() const { return addr() >= section_start(SECT_CONSTS); } | 594 bool addr_in_const() const; |
602 | 595 |
603 address section_start(int n) const { | 596 address section_start(int n) const { |
604 address res = _section_start[n]; | 597 assert(_section_start[n], "must be initialized"); |
605 return (res != NULL) ? res : compute_section_start(n); | 598 return _section_start[n]; |
599 } | |
600 address section_end(int n) const { | |
601 assert(_section_end[n], "must be initialized"); | |
602 return _section_end[n]; | |
606 } | 603 } |
607 | 604 |
608 // The address points to the affected displacement part of the instruction. | 605 // The address points to the affected displacement part of the instruction. |
609 // For RISC, this is just the whole instruction. | 606 // For RISC, this is just the whole instruction. |
610 // For Intel, this is an unaligned 32-bit word. | 607 // For Intel, this is an unaligned 32-bit word. |
788 address new_addr_for(address olda, const CodeBuffer* src, CodeBuffer* dest); | 785 address new_addr_for(address olda, const CodeBuffer* src, CodeBuffer* dest); |
789 void normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections = false); | 786 void normalize_address(address& addr, const CodeSection* dest, bool allow_other_sections = false); |
790 | 787 |
791 public: | 788 public: |
792 // accessors which only make sense for a bound Relocation | 789 // accessors which only make sense for a bound Relocation |
793 address addr() const { return binding()->addr(); } | 790 address addr() const { return binding()->addr(); } |
794 CodeBlob* code() const { return binding()->code(); } | 791 nmethod* code() const { return binding()->code(); } |
795 bool addr_in_const() const { return binding()->addr_in_const(); } | 792 bool addr_in_const() const { return binding()->addr_in_const(); } |
796 protected: | 793 protected: |
797 short* data() const { return binding()->data(); } | 794 short* data() const { return binding()->data(); } |
798 int datalen() const { return binding()->datalen(); } | 795 int datalen() const { return binding()->datalen(); } |
799 int format() const { return binding()->format(); } | 796 int format() const { return binding()->format(); } |
800 | 797 |
980 | 977 |
981 void clear_inline_cache(); | 978 void clear_inline_cache(); |
982 | 979 |
983 // Figure out where an ic_call is hiding, given a set-oop or call. | 980 // Figure out where an ic_call is hiding, given a set-oop or call. |
984 // Either ic_call or first_oop must be non-null; the other is deduced. | 981 // Either ic_call or first_oop must be non-null; the other is deduced. |
985 // Code if non-NULL must be the CodeBlob, else it is deduced. | 982 // Code if non-NULL must be the nmethod, else it is deduced. |
986 // The address of the patchable oop is also deduced. | 983 // The address of the patchable oop is also deduced. |
987 // The returned iterator will enumerate over the oops and the ic_call, | 984 // The returned iterator will enumerate over the oops and the ic_call, |
988 // as well as any other relocations that happen to be in that span of code. | 985 // as well as any other relocations that happen to be in that span of code. |
989 // Recognize relevant set_oops with: oop_reloc()->oop_addr() == oop_addr. | 986 // Recognize relevant set_oops with: oop_reloc()->oop_addr() == oop_addr. |
990 static RelocIterator parse_ic(CodeBlob* &code, address &ic_call, address &first_oop, oop* &oop_addr, bool *is_optimized); | 987 static RelocIterator parse_ic(nmethod* &nm, address &ic_call, address &first_oop, oop* &oop_addr, bool *is_optimized); |
991 }; | 988 }; |
992 | 989 |
993 | 990 |
994 class opt_virtual_call_Relocation : public CallRelocation { | 991 class opt_virtual_call_Relocation : public CallRelocation { |
995 relocInfo::relocType type() { return relocInfo::opt_virtual_call_type; } | 992 relocInfo::relocType type() { return relocInfo::opt_virtual_call_type; } |
1302 return r; \ | 1299 return r; \ |
1303 } | 1300 } |
1304 APPLY_TO_RELOCATIONS(EACH_CASE); | 1301 APPLY_TO_RELOCATIONS(EACH_CASE); |
1305 #undef EACH_CASE | 1302 #undef EACH_CASE |
1306 | 1303 |
1307 inline RelocIterator::RelocIterator(CodeBlob* cb, address begin, address limit) { | 1304 inline RelocIterator::RelocIterator(nmethod* nm, address begin, address limit) { |
1308 initialize(cb, begin, limit); | 1305 initialize(nm, begin, limit); |
1309 } | 1306 } |
1310 | 1307 |
1311 // if you are going to patch code, you should use this subclass of | 1308 // if you are going to patch code, you should use this subclass of |
1312 // RelocIterator | 1309 // RelocIterator |
1313 class PatchingRelocIterator : public RelocIterator { | 1310 class PatchingRelocIterator : public RelocIterator { |
1321 // these are private and have no bodies defined because they should not be called | 1318 // these are private and have no bodies defined because they should not be called |
1322 PatchingRelocIterator(const RelocIterator&); | 1319 PatchingRelocIterator(const RelocIterator&); |
1323 void operator=(const RelocIterator&); | 1320 void operator=(const RelocIterator&); |
1324 | 1321 |
1325 public: | 1322 public: |
1326 PatchingRelocIterator(CodeBlob* cb, address begin =NULL, address limit =NULL) | 1323 PatchingRelocIterator(nmethod* nm, address begin = NULL, address limit = NULL) |
1327 : RelocIterator(cb, begin, limit) { prepass(); } | 1324 : RelocIterator(nm, begin, limit) { prepass(); } |
1328 | 1325 |
1329 ~PatchingRelocIterator() { postpass(); } | 1326 ~PatchingRelocIterator() { postpass(); } |
1330 }; | 1327 }; |