src/share/vm/ci/ciStreams.cpp

changeset 1957
136b78722a08
parent 1934
e9ff18c4ace7
child 2314
f95d63e2154a
     1.1 --- a/src/share/vm/ci/ciStreams.cpp	Mon Jun 07 14:17:01 2010 -0700
     1.2 +++ b/src/share/vm/ci/ciStreams.cpp	Wed Jun 09 18:50:45 2010 -0700
     1.3 @@ -186,12 +186,13 @@
     1.4  }
     1.5  
     1.6  // ------------------------------------------------------------------
     1.7 -// ciBytecodeStream::get_constant_index
     1.8 +// ciBytecodeStream::get_constant_raw_index
     1.9  //
    1.10  // If this bytecode is one of the ldc variants, get the index of the
    1.11  // referenced constant.
    1.12 -int ciBytecodeStream::get_constant_index() const {
    1.13 -  switch(cur_bc()) {
    1.14 +int ciBytecodeStream::get_constant_raw_index() const {
    1.15 +  // work-alike for Bytecode_loadconstant::raw_index()
    1.16 +  switch (cur_bc()) {
    1.17    case Bytecodes::_ldc:
    1.18      return get_index_u1();
    1.19    case Bytecodes::_ldc_w:
    1.20 @@ -202,25 +203,52 @@
    1.21      return 0;
    1.22    }
    1.23  }
    1.24 +
    1.25 +// ------------------------------------------------------------------
    1.26 +// ciBytecodeStream::get_constant_pool_index
    1.27 +// Decode any CP cache index into a regular pool index.
    1.28 +int ciBytecodeStream::get_constant_pool_index() const {
    1.29 +  // work-alike for Bytecode_loadconstant::pool_index()
    1.30 +  int index = get_constant_raw_index();
    1.31 +  if (has_cache_index()) {
    1.32 +    return get_cpcache()->get_pool_index(index);
    1.33 +  }
    1.34 +  return index;
    1.35 +}
    1.36 +
    1.37 +// ------------------------------------------------------------------
    1.38 +// ciBytecodeStream::get_constant_cache_index
    1.39 +// Return the CP cache index, or -1 if there isn't any.
    1.40 +int ciBytecodeStream::get_constant_cache_index() const {
    1.41 +  // work-alike for Bytecode_loadconstant::cache_index()
    1.42 +  return has_cache_index() ? get_constant_raw_index() : -1;
    1.43 +}
    1.44 +
    1.45  // ------------------------------------------------------------------
    1.46  // ciBytecodeStream::get_constant
    1.47  //
    1.48  // If this bytecode is one of the ldc variants, get the referenced
    1.49  // constant.
    1.50  ciConstant ciBytecodeStream::get_constant() {
    1.51 +  int pool_index = get_constant_raw_index();
    1.52 +  int cache_index = -1;
    1.53 +  if (has_cache_index()) {
    1.54 +    cache_index = pool_index;
    1.55 +    pool_index = -1;
    1.56 +  }
    1.57    VM_ENTRY_MARK;
    1.58    constantPoolHandle cpool(_method->get_methodOop()->constants());
    1.59 -  return CURRENT_ENV->get_constant_by_index(cpool, get_constant_index(), _holder);
    1.60 +  return CURRENT_ENV->get_constant_by_index(cpool, pool_index, cache_index, _holder);
    1.61  }
    1.62  
    1.63  // ------------------------------------------------------------------
    1.64 -bool ciBytecodeStream::is_unresolved_string() const {
    1.65 -  return CURRENT_ENV->is_unresolved_string(_holder, get_constant_index());
    1.66 -}
    1.67 -
    1.68 -// ------------------------------------------------------------------
    1.69 -bool ciBytecodeStream::is_unresolved_klass() const {
    1.70 -  return CURRENT_ENV->is_unresolved_klass(_holder, get_klass_index());
    1.71 +// ciBytecodeStream::get_constant_pool_tag
    1.72 +//
    1.73 +// If this bytecode is one of the ldc variants, get the referenced
    1.74 +// constant.
    1.75 +constantTag ciBytecodeStream::get_constant_pool_tag(int index) const {
    1.76 +  VM_ENTRY_MARK;
    1.77 +  return _method->get_methodOop()->constants()->tag_at(index);
    1.78  }
    1.79  
    1.80  // ------------------------------------------------------------------
    1.81 @@ -378,13 +406,16 @@
    1.82  
    1.83  // ------------------------------------------------------------------
    1.84  // ciBytecodeStream::get_cpcache
    1.85 -ciCPCache* ciBytecodeStream::get_cpcache() {
    1.86 -  VM_ENTRY_MARK;
    1.87 -  // Get the constant pool.
    1.88 -  constantPoolOop      cpool   = _holder->get_instanceKlass()->constants();
    1.89 -  constantPoolCacheOop cpcache = cpool->cache();
    1.90 +ciCPCache* ciBytecodeStream::get_cpcache() const {
    1.91 +  if (_cpcache == NULL) {
    1.92 +    VM_ENTRY_MARK;
    1.93 +    // Get the constant pool.
    1.94 +    constantPoolOop      cpool   = _holder->get_instanceKlass()->constants();
    1.95 +    constantPoolCacheOop cpcache = cpool->cache();
    1.96  
    1.97 -  return CURRENT_ENV->get_object(cpcache)->as_cpcache();
    1.98 +    *(ciCPCache**)&_cpcache = CURRENT_ENV->get_object(cpcache)->as_cpcache();
    1.99 +  }
   1.100 +  return _cpcache;
   1.101  }
   1.102  
   1.103  // ------------------------------------------------------------------

mercurial