Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/vm/code/relocInfo.cpp
          +++ new/src/share/vm/code/relocInfo.cpp
   1    1  /*
   2      - * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
        2 + * Copyright 1997-2010 Sun Microsystems, Inc.  All Rights Reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.
   8    8   *
   9    9   * This code is distributed in the hope that it will be useful, but WITHOUT
  10   10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11   11   * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12   12   * version 2 for more details (a copy is included in the LICENSE file that
↓ open down ↓ 95 lines elided ↑ open up ↑
 108  108  
 109  109  
 110  110  void relocInfo::remove_reloc_info_for_address(RelocIterator *itr, address pc, relocType old_type) {
 111  111    change_reloc_info_for_address(itr, pc, old_type, none);
 112  112  }
 113  113  
 114  114  
 115  115  // ----------------------------------------------------------------------------------------------------
 116  116  // Implementation of RelocIterator
 117  117  
 118      -void RelocIterator::initialize(CodeBlob* cb, address begin, address limit) {
      118 +void RelocIterator::initialize(nmethod* nm, address begin, address limit) {
 119  119    initialize_misc();
 120  120  
 121      -  if (cb == NULL && begin != NULL) {
 122      -    // allow CodeBlob to be deduced from beginning address
 123      -    cb = CodeCache::find_blob(begin);
 124      -  }
 125      -  assert(cb != NULL, "must be able to deduce nmethod from other arguments");
 126      -
 127      -  _code    = cb;
 128      -  _current = cb->relocation_begin()-1;
 129      -  _end     = cb->relocation_end();
 130      -  _addr    = (address) cb->instructions_begin();
      121 +  if (nm == NULL && begin != NULL) {
      122 +    // allow nmethod to be deduced from beginning address
      123 +    CodeBlob* cb = CodeCache::find_blob(begin);
      124 +    nm = cb->as_nmethod_or_null();
      125 +  }
      126 +  assert(nm != NULL, "must be able to deduce nmethod from other arguments");
      127 +
      128 +  _code    = nm;
      129 +  _current = nm->relocation_begin() - 1;
      130 +  _end     = nm->relocation_end();
      131 +  _addr    = (address) nm->instructions_begin();
 131  132  
 132  133    assert(!has_current(), "just checking");
 133      -  address code_end = cb->instructions_end();
      134 +  address code_end = nm->instructions_end();
 134  135  
 135      -  assert(begin == NULL || begin >= cb->instructions_begin(), "in bounds");
      136 +  assert(begin == NULL || begin >= nm->instructions_begin(), "in bounds");
 136  137   // FIX THIS  assert(limit == NULL || limit <= code_end,     "in bounds");
 137  138    set_limits(begin, limit);
 138  139  }
 139  140  
 140  141  
 141  142  RelocIterator::RelocIterator(CodeSection* cs, address begin, address limit) {
 142  143    initialize_misc();
 143  144  
 144  145    _current = cs->locs_start()-1;
 145  146    _end     = cs->locs_end();
↓ open down ↓ 601 lines elided ↑ open up ↑
 747  748  }
 748  749  
 749  750  
 750  751  //// miscellaneous methods
 751  752  oop* oop_Relocation::oop_addr() {
 752  753    int n = _oop_index;
 753  754    if (n == 0) {
 754  755      // oop is stored in the code stream
 755  756      return (oop*) pd_address_in_code();
 756  757    } else {
 757      -    // oop is stored in table at CodeBlob::oops_begin
      758 +    // oop is stored in table at nmethod::oops_begin
 758  759      return code()->oop_addr_at(n);
 759  760    }
 760  761  }
 761  762  
 762  763  
 763  764  oop oop_Relocation::oop_value() {
 764  765    oop v = *oop_addr();
 765  766    // clean inline caches store a special pseudo-null
 766  767    if (v == (oop)Universe::non_oop_word())  v = NULL;
 767  768    return v;
↓ open down ↓ 1 lines elided ↑ open up ↑
 769  770  
 770  771  
 771  772  void oop_Relocation::fix_oop_relocation() {
 772  773    if (!oop_is_immediate()) {
 773  774      // get the oop from the pool, and re-insert it into the instruction:
 774  775      set_value(value());
 775  776    }
 776  777  }
 777  778  
 778  779  
 779      -RelocIterator virtual_call_Relocation::parse_ic(CodeBlob* &code, address &ic_call, address &first_oop,
      780 +RelocIterator virtual_call_Relocation::parse_ic(nmethod* &nm, address &ic_call, address &first_oop,
 780  781                                                  oop* &oop_addr, bool *is_optimized) {
 781  782    assert(ic_call != NULL, "ic_call address must be set");
 782  783    assert(ic_call != NULL || first_oop != NULL, "must supply a non-null input");
 783      -  if (code == NULL) {
      784 +  if (nm == NULL) {
      785 +    CodeBlob* code;
 784  786      if (ic_call != NULL) {
 785  787        code = CodeCache::find_blob(ic_call);
 786  788      } else if (first_oop != NULL) {
 787  789        code = CodeCache::find_blob(first_oop);
 788  790      }
 789      -    assert(code != NULL, "address to parse must be in CodeBlob");
      791 +    nm = code->as_nmethod_or_null();
      792 +    assert(nm != NULL, "address to parse must be in nmethod");
 790  793    }
 791      -  assert(ic_call   == NULL || code->contains(ic_call),   "must be in CodeBlob");
 792      -  assert(first_oop == NULL || code->contains(first_oop), "must be in CodeBlob");
      794 +  assert(ic_call   == NULL || nm->contains(ic_call),   "must be in nmethod");
      795 +  assert(first_oop == NULL || nm->contains(first_oop), "must be in nmethod");
 793  796  
 794  797    address oop_limit = NULL;
 795  798  
 796  799    if (ic_call != NULL) {
 797  800      // search for the ic_call at the given address
 798      -    RelocIterator iter(code, ic_call, ic_call+1);
      801 +    RelocIterator iter(nm, ic_call, ic_call+1);
 799  802      bool ret = iter.next();
 800  803      assert(ret == true, "relocInfo must exist at this address");
 801  804      assert(iter.addr() == ic_call, "must find ic_call");
 802  805      if (iter.type() == relocInfo::virtual_call_type) {
 803  806        virtual_call_Relocation* r = iter.virtual_call_reloc();
 804  807        first_oop = r->first_oop();
 805  808        oop_limit = r->oop_limit();
 806  809        *is_optimized = false;
 807  810      } else {
 808  811        assert(iter.type() == relocInfo::opt_virtual_call_type, "must be a virtual call");
 809  812        *is_optimized = true;
 810  813        oop_addr = NULL;
 811  814        first_oop = NULL;
 812  815        return iter;
 813  816      }
 814  817    }
 815  818  
 816  819    // search for the first_oop, to get its oop_addr
 817      -  RelocIterator all_oops(code, first_oop);
      820 +  RelocIterator all_oops(nm, first_oop);
 818  821    RelocIterator iter = all_oops;
 819  822    iter.set_limit(first_oop+1);
 820  823    bool found_oop = false;
 821  824    while (iter.next()) {
 822  825      if (iter.type() == relocInfo::oop_type) {
 823  826        assert(iter.addr() == first_oop, "must find first_oop");
 824  827        oop_addr = iter.oop_reloc()->oop_addr();
 825  828        found_oop = true;
 826  829        break;
 827  830      }
↓ open down ↓ 7 lines elided ↑ open up ↑
 835  838        if (iter.type() == relocInfo::virtual_call_type) {
 836  839          virtual_call_Relocation* r = iter.virtual_call_reloc();
 837  840          if (r->first_oop() == first_oop) {
 838  841            ic_call   = r->addr();
 839  842            oop_limit = r->oop_limit();
 840  843            break;
 841  844          }
 842  845        }
 843  846      }
 844  847      guarantee(!did_reset, "cannot find ic_call");
 845      -    iter = RelocIterator(code); // search the whole CodeBlob
      848 +    iter = RelocIterator(nm); // search the whole nmethod
 846  849      did_reset = true;
 847  850    }
 848  851  
 849  852    assert(oop_limit != NULL && first_oop != NULL && ic_call != NULL, "");
 850  853    all_oops.set_limit(oop_limit);
 851  854    return all_oops;
 852  855  }
 853  856  
 854  857  
 855  858  address virtual_call_Relocation::first_oop() {
↓ open down ↓ 312 lines elided ↑ open up ↑
1168 1171  
1169 1172      if (!got_next)  break;
1170 1173      print_current();
1171 1174    }
1172 1175  
1173 1176    (*this) = save_this;
1174 1177  }
1175 1178  
1176 1179  // For the debugger:
1177 1180  extern "C"
1178      -void print_blob_locs(CodeBlob* cb) {
1179      -  cb->print();
1180      -  RelocIterator iter(cb);
     1181 +void print_blob_locs(nmethod* nm) {
     1182 +  nm->print();
     1183 +  RelocIterator iter(nm);
1181 1184    iter.print();
1182 1185  }
1183 1186  extern "C"
1184 1187  void print_buf_locs(CodeBuffer* cb) {
1185 1188    FlagSetting fs(PrintRelocations, true);
1186 1189    cb->print();
1187 1190  }
1188 1191  #endif // !PRODUCT
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX