src/hotspot/share/interpreter/bytecode.cpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 58861 2c3cc4b01880
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58861
diff changeset
     2
 * Copyright (c) 1997, 2019, 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: 4564
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4564
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: 4564
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"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 49189
diff changeset
    26
#include "interpreter/bytecode.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    27
#include "interpreter/linkResolver.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    28
#include "oops/constantPool.hpp"
49340
4e82736053ae 8191102: Incorrect include file use in classLoader.hpp
hseigel
parents: 49189
diff changeset
    29
#include "oops/cpCache.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    30
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    31
#include "runtime/fieldType.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    32
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    33
#include "runtime/safepoint.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    34
#include "runtime/signature.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// Implementation of Bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    38
#ifdef ASSERT
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    39
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    40
void Bytecode::assert_same_format_as(Bytecodes::Code testbc, bool is_wide) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    41
  Bytecodes::Code thisbc = Bytecodes::cast(byte_at(0));
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    42
  if (thisbc == Bytecodes::_breakpoint)  return;  // let the assertion fail silently
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    43
  if (is_wide) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    44
    assert(thisbc == Bytecodes::_wide, "expected a wide instruction");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    45
    thisbc = Bytecodes::cast(byte_at(1));
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    46
    if (thisbc == Bytecodes::_breakpoint)  return;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    47
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    48
  int thisflags = Bytecodes::flags(testbc, is_wide) & Bytecodes::_all_fmt_bits;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    49
  int testflags = Bytecodes::flags(thisbc, is_wide) & Bytecodes::_all_fmt_bits;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    50
  if (thisflags != testflags)
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    51
    tty->print_cr("assert_same_format_as(%d) failed on bc=%d%s; %d != %d",
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    52
                  (int)testbc, (int)thisbc, (is_wide?"/wide":""), testflags, thisflags);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    53
  assert(thisflags == testflags, "expected format");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    54
}
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    55
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    56
void Bytecode::assert_index_size(int size, Bytecodes::Code bc, bool is_wide) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    57
  int have_fmt = (Bytecodes::flags(bc, is_wide)
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    58
                  & (Bytecodes::_fmt_has_u2 | Bytecodes::_fmt_has_u4 |
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    59
                     Bytecodes::_fmt_not_simple |
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    60
                     // Not an offset field:
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    61
                     Bytecodes::_fmt_has_o));
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    62
  int need_fmt = -1;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    63
  switch (size) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    64
  case 1: need_fmt = 0;                      break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    65
  case 2: need_fmt = Bytecodes::_fmt_has_u2; break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    66
  case 4: need_fmt = Bytecodes::_fmt_has_u4; break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    67
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    68
  if (is_wide)  need_fmt |= Bytecodes::_fmt_not_simple;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    69
  if (have_fmt != need_fmt) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    70
    tty->print_cr("assert_index_size %d: bc=%d%s %d != %d", size, bc, (is_wide?"/wide":""), have_fmt, need_fmt);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    71
    assert(have_fmt == need_fmt, "assert_index_size");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    72
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    73
}
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    74
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    75
void Bytecode::assert_offset_size(int size, Bytecodes::Code bc, bool is_wide) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    76
  int have_fmt = Bytecodes::flags(bc, is_wide) & Bytecodes::_all_fmt_bits;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    77
  int need_fmt = -1;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    78
  switch (size) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    79
  case 2: need_fmt = Bytecodes::_fmt_bo2; break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    80
  case 4: need_fmt = Bytecodes::_fmt_bo4; break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    81
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    82
  if (is_wide)  need_fmt |= Bytecodes::_fmt_not_simple;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    83
  if (have_fmt != need_fmt) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    84
    tty->print_cr("assert_offset_size %d: bc=%d%s %d != %d", size, bc, (is_wide?"/wide":""), have_fmt, need_fmt);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    85
    assert(have_fmt == need_fmt, "assert_offset_size");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    86
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    87
}
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    88
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    89
void Bytecode::assert_constant_size(int size, int where, Bytecodes::Code bc, bool is_wide) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    90
  int have_fmt = Bytecodes::flags(bc, is_wide) & (Bytecodes::_all_fmt_bits
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    91
                                                  // Ignore any 'i' field (for iinc):
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    92
                                                  & ~Bytecodes::_fmt_has_i);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    93
  int need_fmt = -1;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    94
  switch (size) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    95
  case 1: need_fmt = Bytecodes::_fmt_bc;                          break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    96
  case 2: need_fmt = Bytecodes::_fmt_bc | Bytecodes::_fmt_has_u2; break;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    97
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    98
  if (is_wide)  need_fmt |= Bytecodes::_fmt_not_simple;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
    99
  int length = is_wide ? Bytecodes::wide_length_for(bc) : Bytecodes::length_for(bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   100
  if (have_fmt != need_fmt || where + size != length) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   101
    tty->print_cr("assert_constant_size %d @%d: bc=%d%s %d != %d", size, where, bc, (is_wide?"/wide":""), have_fmt, need_fmt);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   102
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   103
  assert(have_fmt == need_fmt, "assert_constant_size");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   104
  assert(where + size == length, "assert_constant_size oob");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   105
}
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   106
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   107
void Bytecode::assert_native_index(Bytecodes::Code bc, bool is_wide) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   108
  assert((Bytecodes::flags(bc, is_wide) & Bytecodes::_fmt_has_nbo) != 0, "native index");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   109
}
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   110
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4564
diff changeset
   111
#endif //ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// Implementation of Bytecode_tableupswitch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
int Bytecode_tableswitch::dest_offset_at(int i) const {
43458
61ab1daf0fc8 8144518: ClassVerboseTest crashes on Windows
coleenp
parents: 31019
diff changeset
   116
  return get_aligned_Java_u4_at(1 + (3 + i)*jintSize);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
// Implementation of Bytecode_invoke
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
void Bytecode_invoke::verify() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  assert(is_valid(), "check invoke");
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   124
  assert(cpcache() != NULL, "do not call this from verifier or rewriter");
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   125
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   126
49189
41e570d862b4 8148871: Possible wrong expression stack depth at deopt point
thartmann
parents: 48826
diff changeset
   127
int Bytecode_invoke::size_of_parameters() const {
41e570d862b4 8148871: Possible wrong expression stack depth at deopt point
thartmann
parents: 48826
diff changeset
   128
  ArgumentSizeComputer asc(signature());
41e570d862b4 8148871: Possible wrong expression stack depth at deopt point
thartmann
parents: 48826
diff changeset
   129
  return asc.size() + (has_receiver() ? 1 : 0);
41e570d862b4 8148871: Possible wrong expression stack depth at deopt point
thartmann
parents: 48826
diff changeset
   130
}
41e570d862b4 8148871: Possible wrong expression stack depth at deopt point
thartmann
parents: 48826
diff changeset
   131
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   132
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   133
Symbol* Bytecode_member_ref::klass() const {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   134
  return constants()->klass_ref_at_noresolve(index());
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   135
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   136
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   137
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   138
Symbol* Bytecode_member_ref::name() const {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   139
  return constants()->name_ref_at(index());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   143
Symbol* Bytecode_member_ref::signature() const {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   144
  return constants()->signature_ref_at(index());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   148
BasicType Bytecode_member_ref::result_type() const {
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   149
  ResultTypeFinder rts(signature());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  return rts.type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58861
diff changeset
   154
Method* Bytecode_invoke::static_target(TRAPS) {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   155
  constantPoolHandle constants(THREAD, this->constants());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   157
  Bytecodes::Code bc = invoke_code();
31019
d05fcdd70109 8029567: Clean up linkResolver code
coleenp
parents: 13728
diff changeset
   158
  return LinkResolver::resolve_method_statically(bc, constants, index(), THREAD);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   161
Handle Bytecode_invoke::appendix(TRAPS) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   162
  ConstantPoolCacheEntry* cpce = cpcache_entry();
59056
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58861
diff changeset
   163
  if (cpce->has_appendix()) {
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58861
diff changeset
   164
    constantPoolHandle cp(THREAD, constants());
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58861
diff changeset
   165
    return Handle(THREAD, cpce->appendix_if_resolved(cp));
15936b142f86 8233913: Remove implicit conversion from Method* to methodHandle
coleenp
parents: 58861
diff changeset
   166
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   167
  return Handle();  // usual case
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   168
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   170
int Bytecode_member_ref::index() const {
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   171
  // Note:  Rewriter::rewrite changes the Java_u2 of an invokedynamic to a native_u4,
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   172
  // at the same time it allocates per-call-site CP cache entries.
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   173
  Bytecodes::Code rawc = code();
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   174
  if (has_index_u4(rawc))
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   175
    return get_index_u4(rawc);
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   176
  else
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   177
    return get_index_u2_cpcache(rawc);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   180
int Bytecode_member_ref::pool_index() const {
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   181
  return cpcache_entry()->constant_pool_index();
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   182
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   183
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 8076
diff changeset
   184
ConstantPoolCacheEntry* Bytecode_member_ref::cpcache_entry() const {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   185
  int index = this->index();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   186
  return cpcache()->entry_at(ConstantPool::decode_cpcache_index(index, true));
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   187
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
// Implementation of Bytecode_field
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
void Bytecode_field::verify() const {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   192
  assert(is_valid(), "check field");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   196
// Implementation of Bytecode_loadconstant
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   197
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   198
int Bytecode_loadconstant::raw_index() const {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   199
  Bytecodes::Code rawc = code();
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   200
  assert(rawc != Bytecodes::_wide, "verifier prevents this");
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   201
  if (Bytecodes::java_code(rawc) == Bytecodes::_ldc)
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   202
    return get_index_u1(rawc);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   203
  else
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   204
    return get_index_u2(rawc, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   207
int Bytecode_loadconstant::pool_index() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   208
  int index = raw_index();
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   209
  if (has_cache_index()) {
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   210
    return _method->constants()->object_to_cp_index(index);
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
  return index;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   213
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   215
BasicType Bytecode_loadconstant::result_type() const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   216
  int index = pool_index();
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   217
  return _method->constants()->basic_type_for_constant_at(index);
5882
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
oop Bytecode_loadconstant::resolve_constant(TRAPS) const {
46727
6e4a84748e2c 8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents: 43458
diff changeset
   221
  assert(_method != NULL, "must supply method to resolve constant");
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   222
  int index = raw_index();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   223
  ConstantPool* constants = _method->constants();
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   224
  if (has_cache_index()) {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   225
    return constants->resolve_cached_constant_at(index, THREAD);
48826
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   226
  } else if (_method->constants()->tag_at(index).is_dynamic_constant()) {
c4d9d1b08e2e 8186209: Tool support for ConstantDynamic
psandoz
parents: 47216
diff changeset
   227
    return constants->resolve_possibly_cached_constant_at(index, THREAD);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   228
  } else {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   229
    return constants->resolve_constant_at(index, THREAD);
5697
0cf7190475ee 6957080: MethodComparator needs stress testing
jrose
parents: 5688
diff changeset
   230
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
//------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
// Non-product code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
void Bytecode_lookupswitch::verify() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  switch (Bytecodes::java_code(code())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    case Bytecodes::_lookupswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
      { int i = number_of_pairs() - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
        while (i-- > 0) {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   243
          assert(pair_at(i).match() < pair_at(i+1).match(), "unsorted table entries");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
      fatal("not a lookupswitch bytecode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
void Bytecode_tableswitch::verify() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  switch (Bytecodes::java_code(code())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    case Bytecodes::_tableswitch:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
      { int lo = low_key();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
        int hi = high_key();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
        assert (hi >= lo, "incorrect hi/lo values in tableswitch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
        int i  = hi - lo - 1 ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
        while (i-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
          // no special check needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
      fatal("not a tableswitch bytecode");
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
#endif