hotspot/src/share/vm/code/relocInfo.hpp
changeset 6432 d36e09b60939
parent 5702 201c5cde25bb
child 7397 5b173b4ca846
equal deleted inserted replaced
6431:d76212f83824 6432:d36e09b60939
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2008, Oracle and/or its affiliates. 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.
   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:
   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);
       
   545     for (int i = 0; i < SECT_LIMIT; i++) {
       
   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 
   544 
   552   void initialize(nmethod* nm, address begin, address limit);
   545   void initialize(nmethod* 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:
   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.