hotspot/src/share/vm/ci/ciStreams.cpp
author jrose
Wed, 09 Jun 2010 18:50:45 -0700
changeset 5882 6b2aecc4f7d8
parent 5702 201c5cde25bb
child 7397 5b173b4ca846
permissions -rw-r--r--
6939203: JSR 292 needs method handle constants Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode. Reviewed-by: twisti, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
5702
jrose
parents: 5547 5688
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4567
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4567
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4567
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_ciStreams.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// ciExceptionHandlerStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// Walk over some selected set of a methods exception handlers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// ciExceptionHandlerStream::count
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// How many exception handlers are there in this stream?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// Implementation note: Compiler2 needs this functionality, so I had
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
int ciExceptionHandlerStream::count() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  int save_pos = _pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  int save_end = _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  _pos = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  _end = _method->_handler_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  while (!is_done()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  _pos = save_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  _end = save_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  return count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
int ciExceptionHandlerStream::count_remaining() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  int save_pos = _pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  int save_end = _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  while (!is_done()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  _pos = save_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  _end = save_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  return count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
// ciBytecodeStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
// The class is used to iterate over the bytecodes of a method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
// It hides the details of constant pool structure/access by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
// providing accessors for constant pool items.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
// ------------------------------------------------------------------
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    84
// ciBytecodeStream::next_wide_or_table
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
// Special handling for switch ops
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    87
Bytecodes::Code ciBytecodeStream::next_wide_or_table(Bytecodes::Code bc) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    88
  switch (bc) {                // Check for special bytecode handling
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    89
  case Bytecodes::_wide:
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    90
    // Special handling for the wide bytcode
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    91
    // Get following bytecode; do not return wide
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    92
    assert(Bytecodes::Code(_pc[0]) == Bytecodes::_wide, "");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    93
    bc = Bytecodes::java_code(_raw_bc = (Bytecodes::Code)_pc[1]);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    94
    assert(Bytecodes::wide_length_for(bc) > 2, "must make progress");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    95
    _pc += Bytecodes::wide_length_for(bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    96
    _was_wide = _pc;              // Flag last wide bytecode found
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    97
    assert(is_wide(), "accessor works right");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    98
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  case Bytecodes::_lookupswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    _pc++;                      // Skip wide bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    _pc += (_start-_pc)&3;      // Word align
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    _table_base = (jint*)_pc;   // Capture for later usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
                                // table_base[0] is default far_dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    // Table has 2 lead elements (default, length), then pairs of u4 values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    // So load table length, and compute address at end of table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    _pc = (address)&_table_base[2+ 2*Bytes::get_Java_u4((address)&_table_base[1])];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  case Bytecodes::_tableswitch: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    _pc++;                      // Skip wide bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    _pc += (_start-_pc)&3;      // Word align
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    _table_base = (jint*)_pc;   // Capture for later usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
                                // table_base[0] is default far_dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    int lo = Bytes::get_Java_u4((address)&_table_base[1]);// Low bound
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    int hi = Bytes::get_Java_u4((address)&_table_base[2]);// High bound
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    int len = hi - lo + 1;      // Dense table size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    _pc = (address)&_table_base[3+len]; // Skip past table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    fatal("unhandled bytecode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  return bc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
// ciBytecodeStream::reset_to_bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
void ciBytecodeStream::reset_to_bci( int bci ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  _bc_start=_was_wide=0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  _pc = _start+bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
// ciBytecodeStream::force_bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
void ciBytecodeStream::force_bci(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  if (bci < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    reset_to_bci(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    _bc_start = _start + bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    _bc = EOBC();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    reset_to_bci(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
// Constant pool access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// ciBytecodeStream::get_klass_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// If this bytecodes references a klass, return the index of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
// referenced klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
int ciBytecodeStream::get_klass_index() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  switch(cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  case Bytecodes::_ldc:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   161
    return get_index_u1();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  case Bytecodes::_ldc2_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  case Bytecodes::_checkcast:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  case Bytecodes::_instanceof:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  case Bytecodes::_anewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  case Bytecodes::_multianewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  case Bytecodes::_new:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  case Bytecodes::_newarray:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   170
    return get_index_u2();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
// ciBytecodeStream::get_klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
// If this bytecode is a new, newarray, multianewarray, instanceof,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
// or checkcast, get the referenced klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
ciKlass* ciBytecodeStream::get_klass(bool& will_link) {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   183
  VM_ENTRY_MARK;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   184
  constantPoolHandle cpool(_method->get_methodOop()->constants());
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   185
  return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
// ------------------------------------------------------------------
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   189
// ciBytecodeStream::get_constant_raw_index
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
// If this bytecode is one of the ldc variants, get the index of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
// referenced constant.
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   193
int ciBytecodeStream::get_constant_raw_index() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   194
  // work-alike for Bytecode_loadconstant::raw_index()
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   195
  switch (cur_bc()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  case Bytecodes::_ldc:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   197
    return get_index_u1();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  case Bytecodes::_ldc2_w:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   200
    return get_index_u2();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
}
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   206
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   207
// ------------------------------------------------------------------
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   208
// ciBytecodeStream::get_constant_pool_index
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   209
// Decode any CP cache index into a regular pool index.
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   210
int ciBytecodeStream::get_constant_pool_index() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   211
  // work-alike for Bytecode_loadconstant::pool_index()
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   212
  int index = get_constant_raw_index();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   213
  if (has_cache_index()) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   214
    return get_cpcache()->get_pool_index(index);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   215
  }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   216
  return index;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   217
}
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   218
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   219
// ------------------------------------------------------------------
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   220
// ciBytecodeStream::get_constant_cache_index
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   221
// Return the CP cache index, or -1 if there isn't any.
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   222
int ciBytecodeStream::get_constant_cache_index() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   223
  // work-alike for Bytecode_loadconstant::cache_index()
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   224
  return has_cache_index() ? get_constant_raw_index() : -1;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   225
}
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   226
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// ciBytecodeStream::get_constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
// If this bytecode is one of the ldc variants, get the referenced
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
// constant.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
ciConstant ciBytecodeStream::get_constant() {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   233
  int pool_index = get_constant_raw_index();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   234
  int cache_index = -1;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   235
  if (has_cache_index()) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   236
    cache_index = pool_index;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   237
    pool_index = -1;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   238
  }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   239
  VM_ENTRY_MARK;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   240
  constantPoolHandle cpool(_method->get_methodOop()->constants());
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   241
  return CURRENT_ENV->get_constant_by_index(cpool, pool_index, cache_index, _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
// ------------------------------------------------------------------
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   245
// ciBytecodeStream::get_constant_pool_tag
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   246
//
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   247
// If this bytecode is one of the ldc variants, get the referenced
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   248
// constant.
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   249
constantTag ciBytecodeStream::get_constant_pool_tag(int index) const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   250
  VM_ENTRY_MARK;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   251
  return _method->get_methodOop()->constants()->tag_at(index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
// ciBytecodeStream::get_field_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
// If this is a field access bytecode, get the constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
// index of the referenced field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
int ciBytecodeStream::get_field_index() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  assert(cur_bc() == Bytecodes::_getfield ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
         cur_bc() == Bytecodes::_putfield ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
         cur_bc() == Bytecodes::_getstatic ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
         cur_bc() == Bytecodes::_putstatic, "wrong bc");
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   264
  return get_index_u2_cpcache();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
// ciBytecodeStream::get_field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
// If this bytecode is one of get_field, get_static, put_field,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
// or put_static, get the referenced field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
ciField* ciBytecodeStream::get_field(bool& will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  will_link = f->will_link(_holder, _bc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  return f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
// ciBytecodeStream::get_declared_field_holder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
// Get the declared holder of the currently referenced field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
// Usage note: the holder() of a ciField class returns the canonical
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
// holder of the field, rather than the holder declared in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
// bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// There is no "will_link" result passed back.  The user is responsible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
// for checking linkability when retrieving the associated field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   292
  VM_ENTRY_MARK;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   293
  constantPoolHandle cpool(_method->get_methodOop()->constants());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  int holder_index = get_field_holder_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  bool ignore;
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   296
  return CURRENT_ENV->get_klass_by_index(cpool, holder_index, ignore, _holder)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
      ->as_instance_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
// ciBytecodeStream::get_field_holder_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
// Get the constant pool index of the declared holder of the field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
// deoptimization information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
int ciBytecodeStream::get_field_holder_index() {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   307
  GUARDED_VM_ENTRY(
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   308
    constantPoolOop cpool = _holder->get_instanceKlass()->constants();
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   309
    return cpool->klass_ref_index_at(get_field_index());
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   310
  )
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
// ciBytecodeStream::get_field_signature_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
// Get the constant pool index of the signature of the field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
// deoptimization information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
int ciBytecodeStream::get_field_signature_index() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  VM_ENTRY_MARK;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  constantPoolOop cpool = _holder->get_instanceKlass()->constants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  int nt_index = cpool->name_and_type_ref_index_at(get_field_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  return cpool->signature_ref_index_at(nt_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
// ciBytecodeStream::get_method_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
// If this is a method invocation bytecode, get the constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
// index of the invoked method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
int ciBytecodeStream::get_method_index() {
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   332
#ifdef ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  switch (cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  case Bytecodes::_invokeinterface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  case Bytecodes::_invokespecial:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  case Bytecodes::_invokestatic:
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   338
  case Bytecodes::_invokedynamic:
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   339
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  }
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   343
#endif
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   344
  if (has_index_u4())
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   345
    return get_index_u4();  // invokedynamic
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   346
  return get_index_u2_cpcache();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
// ciBytecodeStream::get_method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
// If this is a method invocation bytecode, get the invoked method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
ciMethod* ciBytecodeStream::get_method(bool& will_link) {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   354
  VM_ENTRY_MARK;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   355
  constantPoolHandle cpool(_method->get_methodOop()->constants());
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   356
  ciMethod* m = CURRENT_ENV->get_method_by_index(cpool, get_method_index(), cur_bc(), _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  will_link = m->is_loaded();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  return m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
// ciBytecodeStream::get_declared_method_holder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
// Get the declared holder of the currently referenced method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
// Usage note: the holder() of a ciMethod class returns the canonical
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
// holder of the method, rather than the holder declared in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
// bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
// There is no "will_link" result passed back.  The user is responsible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
// for checking linkability when retrieving the associated method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
ciKlass* ciBytecodeStream::get_declared_method_holder() {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   373
  VM_ENTRY_MARK;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   374
  constantPoolHandle cpool(_method->get_methodOop()->constants());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  bool ignore;
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 3261
diff changeset
   376
  // report as InvokeDynamic for invokedynamic, which is syntactically classless
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   377
  if (cur_bc() == Bytecodes::_invokedynamic)
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 3261
diff changeset
   378
    return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_dyn_InvokeDynamic(), false);
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   379
  return CURRENT_ENV->get_klass_by_index(cpool, get_method_holder_index(), ignore, _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
// ciBytecodeStream::get_method_holder_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
// Get the constant pool index of the declared holder of the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
// deoptimization information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
int ciBytecodeStream::get_method_holder_index() {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   389
  constantPoolOop cpool = _method->get_methodOop()->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  return cpool->klass_ref_index_at(get_method_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
// ciBytecodeStream::get_method_signature_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
// Get the constant pool index of the signature of the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
// deoptimization information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
int ciBytecodeStream::get_method_signature_index() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  VM_ENTRY_MARK;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  constantPoolOop cpool = _holder->get_instanceKlass()->constants();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  int method_index = get_method_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  int name_and_type_index = cpool->name_and_type_ref_index_at(method_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  return cpool->signature_ref_index_at(name_and_type_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
}
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 4564
diff changeset
   406
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 4564
diff changeset
   407
// ------------------------------------------------------------------
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 4564
diff changeset
   408
// ciBytecodeStream::get_cpcache
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   409
ciCPCache* ciBytecodeStream::get_cpcache() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   410
  if (_cpcache == NULL) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   411
    VM_ENTRY_MARK;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   412
    // Get the constant pool.
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   413
    constantPoolOop      cpool   = _holder->get_instanceKlass()->constants();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   414
    constantPoolCacheOop cpcache = cpool->cache();
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 4564
diff changeset
   415
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   416
    *(ciCPCache**)&_cpcache = CURRENT_ENV->get_object(cpcache)->as_cpcache();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   417
  }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   418
  return _cpcache;
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 4564
diff changeset
   419
}
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   420
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   421
// ------------------------------------------------------------------
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   422
// ciBytecodeStream::get_call_site
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   423
ciCallSite* ciBytecodeStream::get_call_site() {
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   424
  VM_ENTRY_MARK;
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   425
  // Get the constant pool.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   426
  constantPoolOop      cpool   = _holder->get_instanceKlass()->constants();
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   427
  constantPoolCacheOop cpcache = cpool->cache();
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   428
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   429
  // Get the CallSite from the constant pool cache.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   430
  int method_index = get_method_index();
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   431
  ConstantPoolCacheEntry* cpcache_entry = cpcache->secondary_entry_at(method_index);
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   432
  oop call_site_oop = cpcache_entry->f1();
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   433
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   434
  // Create a CallSite object and return it.
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   435
  return CURRENT_ENV->get_object(call_site_oop)->as_call_site();
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   436
}