src/share/vm/code/relocInfo.hpp

changeset 4037
da91efe96a93
parent 2750
6c97c830fb6f
child 5314
7875ea94bea5
     1.1 --- a/src/share/vm/code/relocInfo.hpp	Fri Aug 31 16:39:35 2012 -0700
     1.2 +++ b/src/share/vm/code/relocInfo.hpp	Sat Sep 01 13:25:18 2012 -0400
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -28,6 +28,8 @@
    1.11  #include "memory/allocation.hpp"
    1.12  #include "utilities/top.hpp"
    1.13  
    1.14 +class NativeMovConstReg;
    1.15 +
    1.16  // Types in this file:
    1.17  //    relocInfo
    1.18  //      One element of an array of halfwords encoding compressed relocations.
    1.19 @@ -35,8 +37,11 @@
    1.20  //    Relocation
    1.21  //      A flyweight object representing a single relocation.
    1.22  //      It is fully unpacked from the compressed relocation array.
    1.23 +//    metadata_Relocation, ... (subclasses of Relocation)
    1.24 +//      The location of some type-specific operations (metadata_addr, ...).
    1.25 +//      Also, the source of relocation specs (metadata_Relocation::spec, ...).
    1.26  //    oop_Relocation, ... (subclasses of Relocation)
    1.27 -//      The location of some type-specific operations (oop_addr, ...).
    1.28 +//      oops in the code stream (strings, class loaders)
    1.29  //      Also, the source of relocation specs (oop_Relocation::spec, ...).
    1.30  //    RelocationHolder
    1.31  //      A ValueObj type which acts as a union holding a Relocation object.
    1.32 @@ -118,7 +123,7 @@
    1.33  //   (This means that any relocInfo can be disabled by setting
    1.34  //   its type to none.  See relocInfo::remove.)
    1.35  //
    1.36 -// relocInfo::oop_type -- a reference to an oop
    1.37 +// relocInfo::oop_type, relocInfo::metadata_type -- a reference to an oop or meta data
    1.38  //   Value:  an oop, or else the address (handle) of an oop
    1.39  //   Instruction types: memory (load), set (load address)
    1.40  //   Data:  []       an oop stored in 4 bytes of instruction
    1.41 @@ -267,7 +272,7 @@
    1.42      poll_type               = 10, // polling instruction for safepoints
    1.43      poll_return_type        = 11, // polling instruction for safepoints at return
    1.44      breakpoint_type         = 12, // an initialization barrier or safepoint
    1.45 -    yet_unused_type         = 13, // Still unused
    1.46 +    metadata_type           = 13, // metadata that used to be oops
    1.47      yet_unused_type_2       = 14, // Still unused
    1.48      data_prefix_tag         = 15, // tag for a prefix (carries data arguments)
    1.49      type_mask               = 15  // A mask which selects only the above values
    1.50 @@ -297,6 +302,7 @@
    1.51  
    1.52    #define APPLY_TO_RELOCATIONS(visitor) \
    1.53      visitor(oop) \
    1.54 +    visitor(metadata) \
    1.55      visitor(virtual_call) \
    1.56      visitor(opt_virtual_call) \
    1.57      visitor(static_call) \
    1.58 @@ -972,35 +978,94 @@
    1.59    // Note:  oop_value transparently converts Universe::non_oop_word to NULL.
    1.60  };
    1.61  
    1.62 +
    1.63 +// copy of oop_Relocation for now but may delete stuff in both/either
    1.64 +class metadata_Relocation : public DataRelocation {
    1.65 +  relocInfo::relocType type() { return relocInfo::metadata_type; }
    1.66 +
    1.67 + public:
    1.68 +  // encode in one of these formats:  [] [n] [n l] [Nn l] [Nn Ll]
    1.69 +  // an metadata in the CodeBlob's metadata pool
    1.70 +  static RelocationHolder spec(int metadata_index, int offset = 0) {
    1.71 +    assert(metadata_index > 0, "must be a pool-resident metadata");
    1.72 +    RelocationHolder rh = newHolder();
    1.73 +    new(rh) metadata_Relocation(metadata_index, offset);
    1.74 +    return rh;
    1.75 +  }
    1.76 +  // an metadata in the instruction stream
    1.77 +  static RelocationHolder spec_for_immediate() {
    1.78 +    const int metadata_index = 0;
    1.79 +    const int offset    = 0;    // if you want an offset, use the metadata pool
    1.80 +    RelocationHolder rh = newHolder();
    1.81 +    new(rh) metadata_Relocation(metadata_index, offset);
    1.82 +    return rh;
    1.83 +  }
    1.84 +
    1.85 + private:
    1.86 +  jint _metadata_index;            // if > 0, index into nmethod::metadata_at
    1.87 +  jint _offset;                     // byte offset to apply to the metadata itself
    1.88 +
    1.89 +  metadata_Relocation(int metadata_index, int offset) {
    1.90 +    _metadata_index = metadata_index; _offset = offset;
    1.91 +  }
    1.92 +
    1.93 +  friend class RelocIterator;
    1.94 +  metadata_Relocation() { }
    1.95 +
    1.96 +  // Fixes a Metadata pointer in the code. Most platforms embeds the
    1.97 +  // Metadata pointer in the code at compile time so this is empty
    1.98 +  // for them.
    1.99 +  void pd_fix_value(address x);
   1.100 +
   1.101 + public:
   1.102 +  int metadata_index() { return _metadata_index; }
   1.103 +  int offset()    { return _offset; }
   1.104 +
   1.105 +  // data is packed in "2_ints" format:  [i o] or [Ii Oo]
   1.106 +  void pack_data_to(CodeSection* dest);
   1.107 +  void unpack_data();
   1.108 +
   1.109 +  void fix_metadata_relocation();        // reasserts metadata value
   1.110 +
   1.111 +  void verify_metadata_relocation();
   1.112 +
   1.113 +  address value()  { return (address) *metadata_addr(); }
   1.114 +
   1.115 +  bool metadata_is_immediate()  { return metadata_index() == 0; }
   1.116 +
   1.117 +  Metadata**   metadata_addr();                  // addr or &pool[jint_data]
   1.118 +  Metadata*    metadata_value();                 // *metadata_addr
   1.119 +  // Note:  metadata_value transparently converts Universe::non_metadata_word to NULL.
   1.120 +};
   1.121 +
   1.122 +
   1.123  class virtual_call_Relocation : public CallRelocation {
   1.124    relocInfo::relocType type() { return relocInfo::virtual_call_type; }
   1.125  
   1.126   public:
   1.127 -  // "first_oop" points to the first associated set-oop.
   1.128 +  // "cached_value" points to the first associated set-oop.
   1.129    // The oop_limit helps find the last associated set-oop.
   1.130    // (See comments at the top of this file.)
   1.131 -  static RelocationHolder spec(address first_oop, address oop_limit = NULL) {
   1.132 +  static RelocationHolder spec(address cached_value) {
   1.133      RelocationHolder rh = newHolder();
   1.134 -    new(rh) virtual_call_Relocation(first_oop, oop_limit);
   1.135 +    new(rh) virtual_call_Relocation(cached_value);
   1.136      return rh;
   1.137    }
   1.138  
   1.139 -  virtual_call_Relocation(address first_oop, address oop_limit) {
   1.140 -    _first_oop = first_oop; _oop_limit = oop_limit;
   1.141 -    assert(first_oop != NULL, "first oop address must be specified");
   1.142 +  virtual_call_Relocation(address cached_value) {
   1.143 +    _cached_value = cached_value;
   1.144 +    assert(cached_value != NULL, "first oop address must be specified");
   1.145    }
   1.146  
   1.147   private:
   1.148 -  address _first_oop;               // location of first set-oop instruction
   1.149 -  address _oop_limit;               // search limit for set-oop instructions
   1.150 +  address _cached_value;               // location of set-value instruction
   1.151  
   1.152    friend class RelocIterator;
   1.153    virtual_call_Relocation() { }
   1.154  
   1.155  
   1.156   public:
   1.157 -  address first_oop();
   1.158 -  address oop_limit();
   1.159 +  address cached_value();
   1.160  
   1.161    // data is packed as scaled offsets in "2_ints" format:  [f l] or [Ff Ll]
   1.162    // oop_limit is set to 0 if the limit falls somewhere within the call.
   1.163 @@ -1010,15 +1075,6 @@
   1.164    void unpack_data();
   1.165  
   1.166    void clear_inline_cache();
   1.167 -
   1.168 -  // Figure out where an ic_call is hiding, given a set-oop or call.
   1.169 -  // Either ic_call or first_oop must be non-null; the other is deduced.
   1.170 -  // Code if non-NULL must be the nmethod, else it is deduced.
   1.171 -  // The address of the patchable oop is also deduced.
   1.172 -  // The returned iterator will enumerate over the oops and the ic_call,
   1.173 -  // as well as any other relocations that happen to be in that span of code.
   1.174 -  // Recognize relevant set_oops with:  oop_reloc()->oop_addr() == oop_addr.
   1.175 -  static RelocIterator parse_ic(nmethod* &nm, address &ic_call, address &first_oop, oop* &oop_addr, bool *is_optimized);
   1.176  };
   1.177  
   1.178  

mercurial