annotate src/share/vm/interpreter/bytecode.hpp @ 1982:6a2d73358ff7

7004217: Remove IA64 workaround re-introduced with CR6953477 Summary: gcc bug worksaround for IA64 no longer needed Reviewed-by: andrew
author bobv
date Thu, 02 Dec 2010 14:00:03 -0500
parents f95d63e2154a
children 8012aa3ccede
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1579
jrose
parents: 1552 1565
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
25 #ifndef SHARE_VM_INTERPRETER_BYTECODE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
26 #define SHARE_VM_INTERPRETER_BYTECODE_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
28 #include "interpreter/bytecodes.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
30 #include "oops/methodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
31 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
32 # include "bytes_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
33 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
34 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
35 # include "bytes_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
36 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
37 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
38 # include "bytes_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
39 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
40
0
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Base class for different kinds of abstractions working
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // relative to an objects 'this' pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class ThisRelativeObj VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // Address computation
a61af66fc99e Initial load
duke
parents:
diff changeset
47 address addr_at (int offset) const { return (address)this + offset; }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
48 int byte_at (int offset) const { return *(addr_at(offset)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
49 address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
52 // Word access:
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
53 int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
54 int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
55 int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
56 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57 };
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // The base class for different kinds of bytecode abstractions.
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Provides the primitive operations to manipulate code relative
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // to an objects 'this' pointer.
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
63 // FIXME: Make this a ResourceObj, include the enclosing methodOop, and cache the opcode.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 class Bytecode: public ThisRelativeObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
67 u_char byte_at(int offset) const { return *addr_at(offset); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
68 bool check_must_rewrite(Bytecodes::Code bc) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
72 address bcp() const { return addr_at(0); }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
73 int instruction_size() const { return Bytecodes::length_at(bcp()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
74
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
75 // Warning: Use code() with caution on live bytecode streams. 4926272
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Bytecodes::Code code() const { return Bytecodes::code_at(addr_at(0)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
78 bool must_rewrite(Bytecodes::Code code) const { return Bytecodes::can_rewrite(code) && check_must_rewrite(code); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
81 inline friend Bytecode* Bytecode_at(address bcp);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
82
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
83 // Static functions for parsing bytecodes in place.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
84 int get_index_u1(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
85 assert_same_format_as(bc); assert_index_size(1, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
86 return *(jubyte*)addr_at(1);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
87 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
88 int get_index_u2(Bytecodes::Code bc, bool is_wide = false) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
89 assert_same_format_as(bc, is_wide); assert_index_size(2, bc, is_wide);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
90 address p = addr_at(is_wide ? 2 : 1);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
91 if (can_use_native_byte_order(bc, is_wide))
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
92 return Bytes::get_native_u2(p);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
93 else return Bytes::get_Java_u2(p);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
94 }
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
95 int get_index_u1_cpcache(Bytecodes::Code bc) const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
96 assert_same_format_as(bc); assert_index_size(1, bc);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
97 return *(jubyte*)addr_at(1) + constantPoolOopDesc::CPCACHE_INDEX_TAG;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
98 }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
99 int get_index_u2_cpcache(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
100 assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
101 return Bytes::get_native_u2(addr_at(1)) + constantPoolOopDesc::CPCACHE_INDEX_TAG;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
102 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
103 int get_index_u4(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
104 assert_same_format_as(bc); assert_index_size(4, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
105 assert(can_use_native_byte_order(bc), "");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
106 return Bytes::get_native_u4(addr_at(1));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
107 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
108 bool has_index_u4(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
109 return bc == Bytecodes::_invokedynamic;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
110 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
111
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
112 int get_offset_s2(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
113 assert_same_format_as(bc); assert_offset_size(2, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
114 return (jshort) Bytes::get_Java_u2(addr_at(1));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
115 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
116 int get_offset_s4(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
117 assert_same_format_as(bc); assert_offset_size(4, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
118 return (jint) Bytes::get_Java_u4(addr_at(1));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
119 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
120
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
121 int get_constant_u1(int offset, Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
122 assert_same_format_as(bc); assert_constant_size(1, offset, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
123 return *(jbyte*)addr_at(offset);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
124 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
125 int get_constant_u2(int offset, Bytecodes::Code bc, bool is_wide = false) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
126 assert_same_format_as(bc, is_wide); assert_constant_size(2, offset, bc, is_wide);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
127 return (jshort) Bytes::get_Java_u2(addr_at(offset));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
128 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
129
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
130 // These are used locally and also from bytecode streams.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
131 void assert_same_format_as(Bytecodes::Code testbc, bool is_wide = false) const NOT_DEBUG_RETURN;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
132 static void assert_index_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
133 static void assert_offset_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
134 static void assert_constant_size(int required_size, int where, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
135 static void assert_native_index(Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
136 static bool can_use_native_byte_order(Bytecodes::Code bc, bool is_wide = false) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
137 return (!Bytes::is_Java_byte_ordering_different() || Bytecodes::native_byte_order(bc /*, is_wide*/));
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
138 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
139 };
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 inline Bytecode* Bytecode_at(address bcp) {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
142 // Warning: Use with caution on live bytecode streams. 4926272
0
a61af66fc99e Initial load
duke
parents:
diff changeset
143 return (Bytecode*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Abstractions for lookupswitch bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 class LookupswitchPair: ThisRelativeObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int _match;
a61af66fc99e Initial load
duke
parents:
diff changeset
152 int _offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
153
a61af66fc99e Initial load
duke
parents:
diff changeset
154 public:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
155 int match() const { return get_Java_u4_at(0 * jintSize); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
156 int offset() const { return get_Java_u4_at(1 * jintSize); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
157 };
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 class Bytecode_lookupswitch: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
161 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
162 void verify() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // Attributes
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
165 int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
166 int number_of_pairs() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
167 LookupswitchPair* pair_at(int i) const { assert(0 <= i && i < number_of_pairs(), "pair index out of bounds");
a61af66fc99e Initial load
duke
parents:
diff changeset
168 return (LookupswitchPair*)aligned_addr_at(1 + (1 + i)*2*jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
170 inline friend Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 };
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 inline Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 Bytecode_lookupswitch* b = (Bytecode_lookupswitch*)bcp;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
175 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
176 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 class Bytecode_tableswitch: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void verify() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Attributes
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
185 int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
186 int low_key() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
187 int high_key() const { return get_Java_u4_at(aligned_offset(1 + 2*jintSize)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
188 int dest_offset_at(int i) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
189 int length() { return high_key()-low_key()+1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
192 inline friend Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 };
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 inline Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 Bytecode_tableswitch* b = (Bytecode_tableswitch*)bcp;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
197 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
198 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
202 // Common code for decoding invokes and field references.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
203
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
204 class Bytecode_member_ref: public ResourceObj {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
206 methodHandle _method; // method containing the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
207 int _bci; // position of the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
208
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
209 Bytecode_member_ref(methodHandle method, int bci) : _method(method), _bci(bci) {}
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
210
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
211 public:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
212 // Attributes
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
213 methodHandle method() const { return _method; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
214 int bci() const { return _bci; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
215 address bcp() const { return _method->bcp_from(bci()); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
216 Bytecode* bytecode() const { return Bytecode_at(bcp()); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
217
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
218 int index() const; // cache index (loaded from instruction)
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
219 int pool_index() const; // constant pool index
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
220 symbolOop name() const; // returns the name of the method or field
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
221 symbolOop signature() const; // returns the signature of the method or field
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
222
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
223 BasicType result_type(Thread* thread) const; // returns the result type of the getfield or invoke
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
224
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
225 Bytecodes::Code code() const { return Bytecodes::code_at(bcp(), _method()); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
226 Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
227 };
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
228
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
229 // Abstraction for invoke_{virtual, static, interface, special}
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
230
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
231 class Bytecode_invoke: public Bytecode_member_ref {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
232 protected:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
233 Bytecode_invoke(methodHandle method, int bci) : Bytecode_member_ref(method, bci) {}
0
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
236 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
239 methodHandle static_target(TRAPS); // "specified" method (from constant pool)
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // Testers
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
242 bool is_invokeinterface() const { return java_code() == Bytecodes::_invokeinterface; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
243 bool is_invokevirtual() const { return java_code() == Bytecodes::_invokevirtual; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
244 bool is_invokestatic() const { return java_code() == Bytecodes::_invokestatic; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
245 bool is_invokespecial() const { return java_code() == Bytecodes::_invokespecial; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
246 bool is_invokedynamic() const { return java_code() == Bytecodes::_invokedynamic; }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
247
1138
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1135
diff changeset
248 bool has_receiver() const { return !is_invokestatic() && !is_invokedynamic(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 bool is_valid() const { return is_invokeinterface() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
251 is_invokevirtual() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
252 is_invokestatic() ||
1135
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 844
diff changeset
253 is_invokespecial() ||
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 844
diff changeset
254 is_invokedynamic(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
257 inline friend Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Like Bytecode_invoke_at. Instead it returns NULL if the bci is not at an invoke.
a61af66fc99e Initial load
duke
parents:
diff changeset
260 inline friend Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
261 };
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 inline Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
264 Bytecode_invoke* b = new Bytecode_invoke(method, bci);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
265 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268
a61af66fc99e Initial load
duke
parents:
diff changeset
269 inline Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 Bytecode_invoke* b = new Bytecode_invoke(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
271 return b->is_valid() ? b : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
272 }
a61af66fc99e Initial load
duke
parents:
diff changeset
273
a61af66fc99e Initial load
duke
parents:
diff changeset
274
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
275 // Abstraction for all field accesses (put/get field/static)
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
276 class Bytecode_field: public Bytecode_member_ref {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
277 protected:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
278 Bytecode_field(methodHandle method, int bci) : Bytecode_member_ref(method, bci) {}
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
279
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
280 public:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
281 // Testers
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
282 bool is_getfield() const { return java_code() == Bytecodes::_getfield; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
283 bool is_putfield() const { return java_code() == Bytecodes::_putfield; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
284 bool is_getstatic() const { return java_code() == Bytecodes::_getstatic; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
285 bool is_putstatic() const { return java_code() == Bytecodes::_putstatic; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
286
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
287 bool is_getter() const { return is_getfield() || is_getstatic(); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
288 bool is_static() const { return is_getstatic() || is_putstatic(); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
289
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
290 bool is_valid() const { return is_getfield() ||
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
291 is_putfield() ||
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
292 is_getstatic() ||
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
293 is_putstatic(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
294 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // Creation
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
297 inline friend Bytecode_field* Bytecode_field_at(methodHandle method, int bci);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
298 };
a61af66fc99e Initial load
duke
parents:
diff changeset
299
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
300 inline Bytecode_field* Bytecode_field_at(methodHandle method, int bci) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
301 Bytecode_field* b = new Bytecode_field(method, bci);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
302 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
303 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 // Abstraction for checkcast
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 class Bytecode_checkcast: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
311 void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
314 long index() const { return get_index_u2(Bytecodes::_checkcast); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
317 inline friend Bytecode_checkcast* Bytecode_checkcast_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
318 };
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 inline Bytecode_checkcast* Bytecode_checkcast_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 Bytecode_checkcast* b = (Bytecode_checkcast*)bcp;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
322 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
323 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 }
a61af66fc99e Initial load
duke
parents:
diff changeset
325
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // Abstraction for instanceof
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 class Bytecode_instanceof: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
330 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
331 void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
334 long index() const { return get_index_u2(Bytecodes::_instanceof); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
337 inline friend Bytecode_instanceof* Bytecode_instanceof_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 };
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 inline Bytecode_instanceof* Bytecode_instanceof_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
341 Bytecode_instanceof* b = (Bytecode_instanceof*)bcp;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
342 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
343 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
344 }
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346
a61af66fc99e Initial load
duke
parents:
diff changeset
347 class Bytecode_new: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
348 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
349 void verify() const { assert(java_code() == Bytecodes::_new, "check new"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
350
a61af66fc99e Initial load
duke
parents:
diff changeset
351 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
352 long index() const { return get_index_u2(Bytecodes::_new); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
353
a61af66fc99e Initial load
duke
parents:
diff changeset
354 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
355 inline friend Bytecode_new* Bytecode_new_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
356 };
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 inline Bytecode_new* Bytecode_new_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 Bytecode_new* b = (Bytecode_new*)bcp;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
360 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
361 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 }
a61af66fc99e Initial load
duke
parents:
diff changeset
363
a61af66fc99e Initial load
duke
parents:
diff changeset
364
a61af66fc99e Initial load
duke
parents:
diff changeset
365 class Bytecode_multianewarray: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
366 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
367 void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
370 long index() const { return get_index_u2(Bytecodes::_multianewarray); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
373 inline friend Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
374 };
a61af66fc99e Initial load
duke
parents:
diff changeset
375
a61af66fc99e Initial load
duke
parents:
diff changeset
376 inline Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
377 Bytecode_multianewarray* b = (Bytecode_multianewarray*)bcp;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
378 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
379 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
380 }
a61af66fc99e Initial load
duke
parents:
diff changeset
381
a61af66fc99e Initial load
duke
parents:
diff changeset
382
a61af66fc99e Initial load
duke
parents:
diff changeset
383 class Bytecode_anewarray: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
384 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
385 void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
386
a61af66fc99e Initial load
duke
parents:
diff changeset
387 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
388 long index() const { return get_index_u2(Bytecodes::_anewarray); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
389
a61af66fc99e Initial load
duke
parents:
diff changeset
390 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
391 inline friend Bytecode_anewarray* Bytecode_anewarray_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
392 };
a61af66fc99e Initial load
duke
parents:
diff changeset
393
a61af66fc99e Initial load
duke
parents:
diff changeset
394 inline Bytecode_anewarray* Bytecode_anewarray_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
395 Bytecode_anewarray* b = (Bytecode_anewarray*)bcp;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
396 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
397 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
398 }
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // Abstraction for ldc, ldc_w and ldc2_w
a61af66fc99e Initial load
duke
parents:
diff changeset
402
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
403 class Bytecode_loadconstant: public ResourceObj {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
404 private:
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
405 int _bci;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
406 methodHandle _method;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
407
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
408 Bytecodes::Code code() const { return bytecode()->code(); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
409
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
410 int raw_index() const;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
411
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
412 Bytecode_loadconstant(methodHandle method, int bci) : _method(method), _bci(bci) {}
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
413
0
a61af66fc99e Initial load
duke
parents:
diff changeset
414 public:
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
415 // Attributes
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
416 methodHandle method() const { return _method; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
417 int bci() const { return _bci; }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
418 address bcp() const { return _method->bcp_from(bci()); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
419 Bytecode* bytecode() const { return Bytecode_at(bcp()); }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
420
0
a61af66fc99e Initial load
duke
parents:
diff changeset
421 void verify() const {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
422 assert(_method.not_null(), "must supply method");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
423 Bytecodes::Code stdc = Bytecodes::java_code(code());
a61af66fc99e Initial load
duke
parents:
diff changeset
424 assert(stdc == Bytecodes::_ldc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
425 stdc == Bytecodes::_ldc_w ||
a61af66fc99e Initial load
duke
parents:
diff changeset
426 stdc == Bytecodes::_ldc2_w, "load constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
427 }
a61af66fc99e Initial load
duke
parents:
diff changeset
428
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
429 // Only non-standard bytecodes (fast_aldc) have CP cache indexes.
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
430 bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
431
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
432 int pool_index() const; // index into constant pool
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
433 int cache_index() const { // index into CP cache (or -1 if none)
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
434 return has_cache_index() ? raw_index() : -1;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
435 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
436
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
437 BasicType result_type() const; // returns the result type of the ldc
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
438
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
439 oop resolve_constant(TRAPS) const;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
440
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
441 // Creation
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
442 inline friend Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
443 };
a61af66fc99e Initial load
duke
parents:
diff changeset
444
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
445 inline Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
446 Bytecode_loadconstant* b = new Bytecode_loadconstant(method, bci);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
447 DEBUG_ONLY(b->verify());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
448 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
449 }
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
450
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
451 #endif // SHARE_VM_INTERPRETER_BYTECODE_HPP