hotspot/src/share/vm/interpreter/bytecode.hpp
author twisti
Tue, 24 Jul 2012 10:51:00 -0700
changeset 13391 30245956af37
parent 10979 c25dd872c62f
child 13728 882756847a04
permissions -rw-r--r--
7023639: JSR 292 method handle invocation needs a fast path for compiled code 6984705: JSR 292 method handle creation should not go through JNI Summary: remove assembly code for JDK 7 chained method handles Reviewed-by: jrose, twisti, kvn, mhaupt Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
     2
 * Copyright (c) 1997, 2011, 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
#ifndef SHARE_VM_INTERPRETER_BYTECODE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    26
#define SHARE_VM_INTERPRETER_BYTECODE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    28
#include "interpreter/bytecodes.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    29
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    30
#include "oops/methodOop.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    31
#ifdef TARGET_ARCH_x86
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    32
# include "bytes_x86.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    33
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    34
#ifdef TARGET_ARCH_sparc
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    35
# include "bytes_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    36
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    37
#ifdef TARGET_ARCH_zero
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    38
# include "bytes_zero.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    39
#endif
8107
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8076
diff changeset
    40
#ifdef TARGET_ARCH_arm
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8076
diff changeset
    41
# include "bytes_arm.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8076
diff changeset
    42
#endif
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8076
diff changeset
    43
#ifdef TARGET_ARCH_ppc
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8076
diff changeset
    44
# include "bytes_ppc.hpp"
78e5bd944384 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 8076
diff changeset
    45
#endif
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
    46
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    47
class ciBytecodeStream;
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    48
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    49
// The base class for different kinds of bytecode abstractions.
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    50
// Provides the primitive operations to manipulate code relative
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    51
// to the bcp.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    53
class Bytecode: public StackObj {
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    54
 protected:
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    55
  const address   _bcp;
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    56
  const Bytecodes::Code _code;
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    57
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Address computation
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    59
  address addr_at            (int offset)        const     { return (address)_bcp + offset; }
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    60
  u_char byte_at(int offset) const               { return *addr_at(offset); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  address aligned_addr_at    (int offset)        const     { return (address)round_to((intptr_t)addr_at(offset), jintSize); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  int     aligned_offset     (int offset)        const     { return aligned_addr_at(offset) - addr_at(0); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    64
  // Word access:
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    65
  int     get_Java_u2_at     (int offset)        const     { return Bytes::get_Java_u2(addr_at(offset)); }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    66
  int     get_Java_u4_at     (int offset)        const     { return Bytes::get_Java_u4(addr_at(offset)); }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    67
  int     get_native_u2_at   (int offset)        const     { return Bytes::get_native_u2(addr_at(offset)); }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    68
  int     get_native_u4_at   (int offset)        const     { return Bytes::get_native_u4(addr_at(offset)); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    71
  Bytecode(methodOop method, address bcp): _bcp(bcp), _code(Bytecodes::code_at(method, addr_at(0))) {
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    72
    assert(method != NULL, "this form requires a valid methodOop");
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    73
  }
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    74
  // Defined in ciStreams.hpp
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    75
  inline Bytecode(const ciBytecodeStream* stream, address bcp = NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    77
  // Attributes
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    78
  address bcp() const                            { return _bcp; }
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    79
  int instruction_size() const                   { return Bytecodes::length_for_code_at(_code, bcp()); }
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    80
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    81
  Bytecodes::Code code() const                   { return _code; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  Bytecodes::Code java_code() const              { return Bytecodes::java_code(code()); }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
    83
  Bytecodes::Code invoke_code() const            { return (code() == Bytecodes::_invokehandle) ? code() : java_code(); }
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
    84
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    85
  // Static functions for parsing bytecodes in place.
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    86
  int get_index_u1(Bytecodes::Code bc) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    87
    assert_same_format_as(bc); assert_index_size(1, bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    88
    return *(jubyte*)addr_at(1);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    89
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    90
  int get_index_u2(Bytecodes::Code bc, bool is_wide = false) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    91
    assert_same_format_as(bc, is_wide); assert_index_size(2, bc, is_wide);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    92
    address p = addr_at(is_wide ? 2 : 1);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    93
    if (can_use_native_byte_order(bc, is_wide))
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
    94
      return Bytes::get_native_u2(p);
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    95
    else  return Bytes::get_Java_u2(p);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
    96
  }
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    97
  int get_index_u1_cpcache(Bytecodes::Code bc) const {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    98
    assert_same_format_as(bc); assert_index_size(1, bc);
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
    99
    return *(jubyte*)addr_at(1) + constantPoolOopDesc::CPCACHE_INDEX_TAG;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   100
  }
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   101
  int get_index_u2_cpcache(Bytecodes::Code bc) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   102
    assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc);
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   103
    return Bytes::get_native_u2(addr_at(1)) + constantPoolOopDesc::CPCACHE_INDEX_TAG;
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   104
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   105
  int get_index_u4(Bytecodes::Code bc) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   106
    assert_same_format_as(bc); assert_index_size(4, bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   107
    assert(can_use_native_byte_order(bc), "");
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   108
    return Bytes::get_native_u4(addr_at(1));
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   109
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   110
  bool has_index_u4(Bytecodes::Code bc) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   111
    return bc == Bytecodes::_invokedynamic;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   112
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   113
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   114
  int get_offset_s2(Bytecodes::Code bc) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   115
    assert_same_format_as(bc); assert_offset_size(2, bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   116
    return (jshort) Bytes::get_Java_u2(addr_at(1));
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   117
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   118
  int get_offset_s4(Bytecodes::Code bc) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   119
    assert_same_format_as(bc); assert_offset_size(4, bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   120
    return (jint) Bytes::get_Java_u4(addr_at(1));
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   121
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   122
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   123
  int get_constant_u1(int offset, Bytecodes::Code bc) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   124
    assert_same_format_as(bc); assert_constant_size(1, offset, bc);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   125
    return *(jbyte*)addr_at(offset);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   126
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   127
  int get_constant_u2(int offset, Bytecodes::Code bc, bool is_wide = false) const {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   128
    assert_same_format_as(bc, is_wide); assert_constant_size(2, offset, bc, is_wide);
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   129
    return (jshort) Bytes::get_Java_u2(addr_at(offset));
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   130
  }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   131
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   132
  // These are used locally and also from bytecode streams.
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   133
  void assert_same_format_as(Bytecodes::Code testbc, bool is_wide = false) const NOT_DEBUG_RETURN;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   134
  static void assert_index_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   135
  static void assert_offset_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   136
  static void assert_constant_size(int required_size, int where, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   137
  static void assert_native_index(Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   138
  static bool can_use_native_byte_order(Bytecodes::Code bc, bool is_wide = false) {
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   139
    return (!Bytes::is_Java_byte_ordering_different() || Bytecodes::native_byte_order(bc /*, is_wide*/));
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   140
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
// Abstractions for lookupswitch bytecode
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   145
class LookupswitchPair VALUE_OBJ_CLASS_SPEC {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
 private:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   147
  const address _bcp;
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   148
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   149
  address addr_at            (int offset)        const     { return _bcp + offset; }
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   150
  int     get_Java_u4_at     (int offset)        const     { return Bytes::get_Java_u4(addr_at(offset)); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   153
  LookupswitchPair(address bcp): _bcp(bcp) {}
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   154
  int  match() const                             { return get_Java_u4_at(0 * jintSize); }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   155
  int  offset() const                            { return get_Java_u4_at(1 * jintSize); }
1
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
class Bytecode_lookupswitch: public Bytecode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   161
  Bytecode_lookupswitch(methodOop method, address bcp): Bytecode(method, bcp) { verify(); }
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   162
  // Defined in ciStreams.hpp
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   163
  inline Bytecode_lookupswitch(const ciBytecodeStream* stream);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  void verify() const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // Attributes
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   167
  int  default_offset() const                    { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   168
  int  number_of_pairs() const                   { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); }
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   169
  LookupswitchPair pair_at(int i) const          {
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   170
    assert(0 <= i && i < number_of_pairs(), "pair index out of bounds");
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   171
    return LookupswitchPair(aligned_addr_at(1 + (1 + i)*2*jintSize));
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   172
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
class Bytecode_tableswitch: public Bytecode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   177
  Bytecode_tableswitch(methodOop method, address bcp): Bytecode(method, bcp) { verify(); }
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   178
  // Defined in ciStreams.hpp
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   179
  inline Bytecode_tableswitch(const ciBytecodeStream* stream);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  void verify() const PRODUCT_RETURN;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // Attributes
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   183
  int  default_offset() const                    { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   184
  int  low_key() const                           { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); }
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   185
  int  high_key() const                          { return get_Java_u4_at(aligned_offset(1 + 2*jintSize)); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  int  dest_offset_at(int i) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  int  length()                                  { return high_key()-low_key()+1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   190
// Common code for decoding invokes and field references.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   192
class Bytecode_member_ref: public Bytecode {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
 protected:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   194
  const methodHandle _method;                          // method containing the bytecode
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   196
  Bytecode_member_ref(methodHandle method, int bci)  : Bytecode(method(), method()->bcp_from(bci)), _method(method) {}
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   197
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   198
  methodHandle method() const                    { return _method; }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   199
  constantPoolOop constants() const              { return _method->constants(); }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   200
  constantPoolCacheOop cpcache() const           { return _method->constants()->cache(); }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   201
  ConstantPoolCacheEntry* cpcache_entry() const;
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   202
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   203
 public:
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   204
  int          index() const;                    // cache index (loaded from instruction)
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   205
  int          pool_index() const;               // constant pool index
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   206
  Symbol*      klass() const;                    // returns the klass of the method or field
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   207
  Symbol*      name() const;                     // returns the name of the method or field
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   208
  Symbol*      signature() const;                // returns the signature of the method or field
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   209
8076
96d498ec7ae1 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 7913
diff changeset
   210
  BasicType    result_type() const;              // returns the result type of the getfield or invoke
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
// Abstraction for invoke_{virtual, static, interface, special}
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   214
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   215
class Bytecode_invoke: public Bytecode_member_ref {
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   216
 protected:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   217
  // Constructor that skips verification
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   218
  Bytecode_invoke(methodHandle method, int bci, bool unused)  : Bytecode_member_ref(method, bci) {}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   221
  Bytecode_invoke(methodHandle method, int bci)  : Bytecode_member_ref(method, bci) { verify(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  void verify() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // Attributes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  methodHandle static_target(TRAPS);             // "specified" method   (from constant pool)
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   226
  Handle       appendix(TRAPS);                  // if CPCE::has_appendix (from constant pool)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // Testers
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   229
  bool is_invokeinterface() const                { return invoke_code() == Bytecodes::_invokeinterface; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   230
  bool is_invokevirtual() const                  { return invoke_code() == Bytecodes::_invokevirtual; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   231
  bool is_invokestatic() const                   { return invoke_code() == Bytecodes::_invokestatic; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   232
  bool is_invokespecial() const                  { return invoke_code() == Bytecodes::_invokespecial; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   233
  bool is_invokedynamic() const                  { return invoke_code() == Bytecodes::_invokedynamic; }
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   234
  bool is_invokehandle() const                   { return invoke_code() == Bytecodes::_invokehandle; }
2570
ecc7862946d4 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 1
diff changeset
   235
4567
7fc02fbe5c7a 6893268: additional dynamic language related optimizations in C2
twisti
parents: 4564
diff changeset
   236
  bool has_receiver() const                      { return !is_invokestatic() && !is_invokedynamic(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  bool is_valid() const                          { return is_invokeinterface() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
                                                          is_invokevirtual()   ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
                                                          is_invokestatic()    ||
4564
55dfb20908d0 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 3261
diff changeset
   241
                                                          is_invokespecial()   ||
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   242
                                                          is_invokedynamic()   ||
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   243
                                                          is_invokehandle(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   245
  bool has_appendix()                            { return cpcache_entry()->has_appendix(); }
10979
c25dd872c62f 7106774: JSR 292: nightly test inlineMHTarget fails with wrong result
twisti
parents: 8107
diff changeset
   246
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10979
diff changeset
   247
 private:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   248
  // Helper to skip verification.   Used is_valid() to check if the result is really an invoke
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   249
  inline friend Bytecode_invoke Bytecode_invoke_check(methodHandle method, int bci);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   252
inline Bytecode_invoke Bytecode_invoke_check(methodHandle method, int bci) {
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   253
  return Bytecode_invoke(method, bci, false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   257
// Abstraction for all field accesses (put/get field/static)
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   258
class Bytecode_field: public Bytecode_member_ref {
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   259
 public:
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   260
  Bytecode_field(methodHandle method, int bci)  : Bytecode_member_ref(method, bci) { verify(); }
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   261
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   262
  // Testers
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   263
  bool is_getfield() const                       { return java_code() == Bytecodes::_getfield; }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   264
  bool is_putfield() const                       { return java_code() == Bytecodes::_putfield; }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   265
  bool is_getstatic() const                      { return java_code() == Bytecodes::_getstatic; }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   266
  bool is_putstatic() const                      { return java_code() == Bytecodes::_putstatic; }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   267
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   268
  bool is_getter() const                         { return is_getfield()  || is_getstatic(); }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   269
  bool is_static() const                         { return is_getstatic() || is_putstatic(); }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   270
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   271
  bool is_valid() const                          { return is_getfield()   ||
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   272
                                                          is_putfield()   ||
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   273
                                                          is_getstatic()  ||
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   274
                                                          is_putstatic(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  void verify() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// Abstraction for checkcast
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
class Bytecode_checkcast: public Bytecode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   281
  Bytecode_checkcast(methodOop method, address bcp): Bytecode(method, bcp) { verify(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  // Returns index
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   285
  long index() const   { return get_index_u2(Bytecodes::_checkcast); };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
// Abstraction for instanceof
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
class Bytecode_instanceof: public Bytecode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   291
  Bytecode_instanceof(methodOop method, address bcp): Bytecode(method, bcp) { verify(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // Returns index
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   295
  long index() const   { return get_index_u2(Bytecodes::_instanceof); };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
class Bytecode_new: public Bytecode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   300
  Bytecode_new(methodOop method, address bcp): Bytecode(method, bcp) { verify(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  void verify() const { assert(java_code() == Bytecodes::_new, "check new"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // Returns index
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   304
  long index() const   { return get_index_u2(Bytecodes::_new); };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
class Bytecode_multianewarray: public Bytecode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   309
  Bytecode_multianewarray(methodOop method, address bcp): Bytecode(method, bcp) { verify(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // Returns index
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   313
  long index() const   { return get_index_u2(Bytecodes::_multianewarray); };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
class Bytecode_anewarray: public Bytecode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   318
  Bytecode_anewarray(methodOop method, address bcp): Bytecode(method, bcp) { verify(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  // Returns index
5688
9052dc91ea67 6939207: refactor constant pool index processing
jrose
parents: 4567
diff changeset
   322
  long index() const   { return get_index_u2(Bytecodes::_anewarray); };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
// Abstraction for ldc, ldc_w and ldc2_w
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   326
class Bytecode_loadconstant: public Bytecode {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   327
 private:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   328
  const methodHandle _method;
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   329
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   330
  int raw_index() const;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   331
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
 public:
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   333
  Bytecode_loadconstant(methodHandle method, int bci): Bytecode(method(), method->bcp_from(bci)), _method(method) { verify(); }
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   334
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  void verify() const {
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   336
    assert(_method.not_null(), "must supply method");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    Bytecodes::Code stdc = Bytecodes::java_code(code());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    assert(stdc == Bytecodes::_ldc ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
           stdc == Bytecodes::_ldc_w ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
           stdc == Bytecodes::_ldc2_w, "load constant");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   343
  // Only non-standard bytecodes (fast_aldc) have CP cache indexes.
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   344
  bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
5882
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   346
  int pool_index() const;               // index into constant pool
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   347
  int cache_index() const {             // index into CP cache (or -1 if none)
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   348
    return has_cache_index() ? raw_index() : -1;
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   349
  }
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   350
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   351
  BasicType result_type() const;        // returns the result type of the ldc
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   352
6b2aecc4f7d8 6939203: JSR 292 needs method handle constants
jrose
parents: 5702
diff changeset
   353
  oop resolve_constant(TRAPS) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5882
diff changeset
   356
#endif // SHARE_VM_INTERPRETER_BYTECODE_HPP