src/hotspot/share/ci/ciStreams.cpp
author coleenp
Fri, 16 Mar 2018 09:12:13 -0400
changeset 49449 ef5d5d343e2a
parent 48826 c4d9d1b08e2e
child 50971 34872a21af82
permissions -rw-r--r--
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files Summary: interfaceSupport.hpp is an inline file so moved to interfaceSupport.inline.hpp and stopped including it in .hpp files Reviewed-by: stefank, rehn, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
38309
9b8e9c373740 8155951: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents: 31046
diff changeset
     2
 * Copyright (c) 1999, 2016, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    26
#include "ci/ciCallSite.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    27
#include "ci/ciConstant.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    28
#include "ci/ciField.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    29
#include "ci/ciStreams.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 48826
diff changeset
    30
#include "ci/ciUtilities.inline.hpp"
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 48826
diff changeset
    31
#include "runtime/handles.inline.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// ciExceptionHandlerStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// Walk over some selected set of a methods exception handlers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// ciExceptionHandlerStream::count
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// How many exception handlers are there in this stream?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// Implementation note: Compiler2 needs this functionality, so I had
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
int ciExceptionHandlerStream::count() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  int save_pos = _pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  int save_end = _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  _pos = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  _end = _method->_handler_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  while (!is_done()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  _pos = save_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  _end = save_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  return count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
int ciExceptionHandlerStream::count_remaining() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  int save_pos = _pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  int save_end = _end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  int count = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  while (!is_done()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    count++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  _pos = save_pos;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  _end = save_end;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  return count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
// ciBytecodeStream
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
// The class is used to iterate over the bytecodes of a method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
// It hides the details of constant pool structure/access by
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
// providing accessors for constant pool items.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
// ------------------------------------------------------------------
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    89
// ciBytecodeStream::next_wide_or_table
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
// Special handling for switch ops
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    92
Bytecodes::Code ciBytecodeStream::next_wide_or_table(Bytecodes::Code bc) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    93
  switch (bc) {                // Check for special bytecode handling
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    94
  case Bytecodes::_wide:
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    95
    // Special handling for the wide bytcode
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    96
    // Get following bytecode; do not return wide
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    97
    assert(Bytecodes::Code(_pc[0]) == Bytecodes::_wide, "");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    98
    bc = Bytecodes::java_code(_raw_bc = (Bytecodes::Code)_pc[1]);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    99
    assert(Bytecodes::wide_length_for(bc) > 2, "must make progress");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   100
    _pc += Bytecodes::wide_length_for(bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   101
    _was_wide = _pc;              // Flag last wide bytecode found
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   102
    assert(is_wide(), "accessor works right");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   103
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  case Bytecodes::_lookupswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    _pc++;                      // Skip wide bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    _pc += (_start-_pc)&3;      // Word align
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    _table_base = (jint*)_pc;   // Capture for later usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
                                // table_base[0] is default far_dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    // Table has 2 lead elements (default, length), then pairs of u4 values.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    // So load table length, and compute address at end of table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    _pc = (address)&_table_base[2+ 2*Bytes::get_Java_u4((address)&_table_base[1])];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  case Bytecodes::_tableswitch: {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    _pc++;                      // Skip wide bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    _pc += (_start-_pc)&3;      // Word align
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    _table_base = (jint*)_pc;   // Capture for later usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
                                // table_base[0] is default far_dest
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    int lo = Bytes::get_Java_u4((address)&_table_base[1]);// Low bound
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    int hi = Bytes::get_Java_u4((address)&_table_base[2]);// High bound
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    int len = hi - lo + 1;      // Dense table size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    _pc = (address)&_table_base[3+len]; // Skip past table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    fatal("unhandled bytecode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  return bc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
// ciBytecodeStream::reset_to_bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
void ciBytecodeStream::reset_to_bci( int bci ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  _bc_start=_was_wide=0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  _pc = _start+bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
// ciBytecodeStream::force_bci
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
void ciBytecodeStream::force_bci(int bci) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  if (bci < 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    reset_to_bci(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    _bc_start = _start + bci;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    _bc = EOBC();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
    reset_to_bci(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  }
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
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
// Constant pool access
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// ciBytecodeStream::get_klass_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// If this bytecodes references a klass, return the index of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
// referenced klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
int ciBytecodeStream::get_klass_index() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  switch(cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  case Bytecodes::_ldc:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   166
    return get_index_u1();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  case Bytecodes::_ldc2_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  case Bytecodes::_checkcast:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  case Bytecodes::_instanceof:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  case Bytecodes::_anewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  case Bytecodes::_multianewarray:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  case Bytecodes::_new:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  case Bytecodes::_newarray:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   175
    return get_index_u2();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
// ciBytecodeStream::get_klass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
// If this bytecode is a new, newarray, multianewarray, instanceof,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
// or checkcast, get the referenced klass.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
ciKlass* ciBytecodeStream::get_klass(bool& will_link) {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   188
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   189
  constantPoolHandle cpool(_method->get_Method()->constants());
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   190
  return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
// ------------------------------------------------------------------
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   194
// ciBytecodeStream::get_constant_raw_index
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
// If this bytecode is one of the ldc variants, get the index of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
// referenced constant.
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   198
int ciBytecodeStream::get_constant_raw_index() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   199
  // work-alike for Bytecode_loadconstant::raw_index()
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   200
  switch (cur_bc()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  case Bytecodes::_ldc:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   202
    return get_index_u1();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  case Bytecodes::_ldc_w:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  case Bytecodes::_ldc2_w:
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   205
    return get_index_u2();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
    return 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
}
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   211
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   212
// ------------------------------------------------------------------
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   213
// ciBytecodeStream::get_constant_pool_index
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   214
// Decode any reference index into a regular pool index.
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   215
int ciBytecodeStream::get_constant_pool_index() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   216
  // work-alike for Bytecode_loadconstant::pool_index()
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   217
  int index = get_constant_raw_index();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   218
  if (has_cache_index()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   219
    VM_ENTRY_MARK;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   220
    constantPoolHandle cpool(_method->get_Method()->constants());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   221
    return cpool->object_to_cp_index(index);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   222
  }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   223
  return index;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   224
}
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
// ------------------------------------------------------------------
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   227
// ciBytecodeStream::get_constant_cache_index
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   228
// 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
   229
int ciBytecodeStream::get_constant_cache_index() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   230
  // work-alike for Bytecode_loadconstant::cache_index()
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   231
  return has_cache_index() ? get_constant_raw_index() : -1;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   232
}
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   233
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
// ciBytecodeStream::get_constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
// If this bytecode is one of the ldc variants, get the referenced
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
// constant.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
ciConstant ciBytecodeStream::get_constant() {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   240
  int pool_index = get_constant_raw_index();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   241
  int cache_index = -1;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   242
  if (has_cache_index()) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   243
    cache_index = pool_index;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   244
    pool_index = -1;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   245
  }
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   246
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   247
  constantPoolHandle cpool(_method->get_Method()->constants());
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   248
  return CURRENT_ENV->get_constant_by_index(cpool, pool_index, cache_index, _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
// ------------------------------------------------------------------
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   252
// ciBytecodeStream::get_constant_pool_tag
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   253
//
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   254
// 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
   255
// constant.
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   256
constantTag ciBytecodeStream::get_constant_pool_tag(int index) const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   257
  VM_ENTRY_MARK;
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   258
  BasicType bt = _method->get_Method()->constants()->basic_type_for_constant_at(index);
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   259
  return constantTag::ofBasicType(bt);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
// ciBytecodeStream::get_field_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
// If this is a field access bytecode, get the constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
// index of the referenced field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
int ciBytecodeStream::get_field_index() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  assert(cur_bc() == Bytecodes::_getfield ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
         cur_bc() == Bytecodes::_putfield ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
         cur_bc() == Bytecodes::_getstatic ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
         cur_bc() == Bytecodes::_putstatic, "wrong bc");
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   272
  return get_index_u2_cpcache();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
// ciBytecodeStream::get_field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// If this bytecode is one of get_field, get_static, put_field,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
// or put_static, get the referenced field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
ciField* ciBytecodeStream::get_field(bool& will_link) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index());
39421
a9652c919db8 8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents: 38309
diff changeset
   283
  will_link = f->will_link(_method, _bc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  return f;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
// ciBytecodeStream::get_declared_field_holder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
// Get the declared holder of the currently referenced field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
// Usage note: the holder() of a ciField class returns the canonical
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
// holder of the field, rather than the holder declared in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
// bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
// There is no "will_link" result passed back.  The user is responsible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
// for checking linkability when retrieving the associated field.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   300
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   301
  constantPoolHandle cpool(_method->get_Method()->constants());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  int holder_index = get_field_holder_index();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  bool ignore;
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   304
  return CURRENT_ENV->get_klass_by_index(cpool, holder_index, ignore, _holder)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
      ->as_instance_klass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
// ciBytecodeStream::get_field_holder_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
// Get the constant pool index of the declared holder of the field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
// deoptimization information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
int ciBytecodeStream::get_field_holder_index() {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   315
  GUARDED_VM_ENTRY(
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   316
    ConstantPool* cpool = _holder->get_instanceKlass()->constants();
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   317
    return cpool->klass_ref_index_at(get_field_index());
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   318
  )
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
// ciBytecodeStream::get_field_signature_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
// Get the constant pool index of the signature of the field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
// deoptimization information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
int ciBytecodeStream::get_field_signature_index() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   329
  ConstantPool* cpool = _holder->get_instanceKlass()->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  int nt_index = cpool->name_and_type_ref_index_at(get_field_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  return cpool->signature_ref_index_at(nt_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
// ciBytecodeStream::get_method_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
// If this is a method invocation bytecode, get the constant pool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
// index of the invoked method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
int ciBytecodeStream::get_method_index() {
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   340
#ifdef ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  switch (cur_bc()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  case Bytecodes::_invokeinterface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  case Bytecodes::_invokespecial:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  case Bytecodes::_invokestatic:
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   346
  case Bytecodes::_invokedynamic:
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   347
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   351
#endif
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   352
  if (has_index_u4())
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   353
    return get_index_u4();  // invokedynamic
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   354
  return get_index_u2_cpcache();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
// ciBytecodeStream::get_method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
// If this is a method invocation bytecode, get the invoked method.
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   361
// Additionally return the declared signature to get more concrete
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   362
// type information if required (Cf. invokedynamic and invokehandle).
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   363
ciMethod* ciBytecodeStream::get_method(bool& will_link, ciSignature* *declared_signature_result) {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   364
  VM_ENTRY_MARK;
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   365
  ciEnv* env = CURRENT_ENV;
38309
9b8e9c373740 8155951: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents: 31046
diff changeset
   366
  constantPoolHandle cpool(THREAD, _method->get_Method()->constants());
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   367
  ciMethod* m = env->get_method_by_index(cpool, get_method_index(), cur_bc(), _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  will_link = m->is_loaded();
13929
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   369
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   370
  // Use the MethodType stored in the CP cache to create a signature
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   371
  // with correct types (in respect to class loaders).
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   372
  if (has_method_type()) {
38309
9b8e9c373740 8155951: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents: 31046
diff changeset
   373
    ciSymbol*     sig_sym     = env->get_symbol(cpool->symbol_at(get_method_signature_index(cpool)));
13929
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   374
    ciKlass*      pool_holder = env->get_klass(cpool->pool_holder());
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   375
    ciMethodType* method_type = get_method_type();
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   376
    ciSignature* declared_signature = new (env->arena()) ciSignature(pool_holder, sig_sym, method_type);
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   377
    (*declared_signature_result) = declared_signature;
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   378
  } else {
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   379
    (*declared_signature_result) = m->signature();
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   380
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  return m;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
// ------------------------------------------------------------------
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   385
// ciBytecodeStream::has_appendix
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   386
//
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   387
// Returns true if there is an appendix argument stored in the
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   388
// constant pool cache at the current bci.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   389
bool ciBytecodeStream::has_appendix() {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   390
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   391
  constantPoolHandle cpool(_method->get_Method()->constants());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   392
  return ConstantPool::has_appendix_at_if_loaded(cpool, get_method_index());
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   393
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   394
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   395
// ------------------------------------------------------------------
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   396
// ciBytecodeStream::get_appendix
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   397
//
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   398
// Return the appendix argument stored in the constant pool cache at
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   399
// the current bci.
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   400
ciObject* ciBytecodeStream::get_appendix() {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   401
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   402
  constantPoolHandle cpool(_method->get_Method()->constants());
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   403
  oop appendix_oop = ConstantPool::appendix_at_if_loaded(cpool, get_method_index());
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   404
  return CURRENT_ENV->get_object(appendix_oop);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   405
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   406
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   407
// ------------------------------------------------------------------
13929
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   408
// ciBytecodeStream::has_method_type
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   409
//
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   410
// Returns true if there is a MethodType argument stored in the
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   411
// constant pool cache at the current bci.
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   412
bool ciBytecodeStream::has_method_type() {
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   413
  GUARDED_VM_ENTRY(
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   414
    constantPoolHandle cpool(_method->get_Method()->constants());
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   415
    return ConstantPool::has_method_type_at_if_loaded(cpool, get_method_index());
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   416
  )
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   417
}
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   418
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   419
// ------------------------------------------------------------------
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   420
// ciBytecodeStream::get_method_type
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   421
//
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   422
// Return the MethodType stored in the constant pool cache at
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   423
// the current bci.
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   424
ciMethodType* ciBytecodeStream::get_method_type() {
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   425
  GUARDED_VM_ENTRY(
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   426
    constantPoolHandle cpool(_method->get_Method()->constants());
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   427
    oop method_type_oop = ConstantPool::method_type_at_if_loaded(cpool, get_method_index());
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   428
    return CURRENT_ENV->get_object(method_type_oop)->as_method_type();
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   429
  )
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   430
}
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   431
8da0dc50a6e4 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 13728
diff changeset
   432
// ------------------------------------------------------------------
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
// ciBytecodeStream::get_declared_method_holder
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
// Get the declared holder of the currently referenced method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
// Usage note: the holder() of a ciMethod class returns the canonical
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
// holder of the method, rather than the holder declared in the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
// bytecodes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
// There is no "will_link" result passed back.  The user is responsible
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
// for checking linkability when retrieving the associated method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
ciKlass* ciBytecodeStream::get_declared_method_holder() {
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   444
  VM_ENTRY_MARK;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   445
  constantPoolHandle cpool(_method->get_Method()->constants());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  bool ignore;
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   447
  // report as MethodHandle for invokedynamic, which is syntactically classless
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   448
  if (cur_bc() == Bytecodes::_invokedynamic)
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8676
diff changeset
   449
    return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_lang_invoke_MethodHandle(), false);
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4566
diff changeset
   450
  return CURRENT_ENV->get_klass_by_index(cpool, get_method_holder_index(), ignore, _holder);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
// ciBytecodeStream::get_method_holder_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
// Get the constant pool index of the declared holder of the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
// deoptimization information.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
int ciBytecodeStream::get_method_holder_index() {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   460
  ConstantPool* cpool = _method->get_Method()->constants();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  return cpool->klass_ref_index_at(get_method_index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
// ------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
// ciBytecodeStream::get_method_signature_index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
// Get the constant pool index of the signature of the method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
// referenced by the current bytecode.  Used for generating
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
// deoptimization information.
38309
9b8e9c373740 8155951: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool
coleenp
parents: 31046
diff changeset
   470
int ciBytecodeStream::get_method_signature_index(const constantPoolHandle& cpool) {
13522
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   471
  GUARDED_VM_ENTRY(
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   472
    const int method_index = get_method_index();
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   473
    const int name_and_type_index = cpool->name_and_type_ref_index_at(method_index);
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   474
    return cpool->signature_ref_index_at(name_and_type_index);
5ad4627e792a 7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents: 13391
diff changeset
   475
  )
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
}
4566
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 4564
diff changeset
   477
b363f6ef4068 6829187: compiler optimizations required for JSR 292
twisti
parents: 4564
diff changeset
   478
// ------------------------------------------------------------------
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   479
// ciBytecodeStream::get_resolved_references
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   480
ciObjArray* ciBytecodeStream::get_resolved_references() {
31046
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   481
    VM_ENTRY_MARK;
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   482
    // Get the constant pool.
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   483
  ConstantPool*        cpool   = _holder->get_instanceKlass()->constants();
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   484
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13522
diff changeset
   485
  // Create a resolved references array and return it.
31046
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   486
  return CURRENT_ENV->get_object(cpool->resolved_references())->as_obj_array();
d01ad7a0ecb0 8081320: Backout JDK-8059340: ConstantPool::_resolved_references is missing in heap dump
vlivanov
parents: 31038
diff changeset
   487
  }