annotate src/share/vm/interpreter/bytecode.hpp @ 1579:e9ff18c4ace7

Merge
author jrose
date Wed, 02 Jun 2010 22:45:42 -0700
parents c18cbe5936b8 ab102d5d923e
children 136b78722a08
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
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // Base class for different kinds of abstractions working
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // relative to an objects 'this' pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class ThisRelativeObj VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
29 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Address computation
a61af66fc99e Initial load
duke
parents:
diff changeset
31 address addr_at (int offset) const { return (address)this + offset; }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
32 int byte_at (int offset) const { return *(addr_at(offset)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33 address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
34 int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
35
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
36 // Word access:
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
37 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
38 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
39 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
40 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
41 };
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // The base class for different kinds of bytecode abstractions.
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // Provides the primitive operations to manipulate code relative
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // to an objects 'this' pointer.
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
47 // FIXME: Make this a ResourceObj, include the enclosing methodOop, and cache the opcode.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class Bytecode: public ThisRelativeObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
50 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
51 u_char byte_at(int offset) const { return *addr_at(offset); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
52 bool check_must_rewrite(Bytecodes::Code bc) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
56 address bcp() const { return addr_at(0); }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
57 int instruction_size() const { return Bytecodes::length_at(bcp()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
59 // Warning: Use code() with caution on live bytecode streams. 4926272
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 Bytecodes::Code code() const { return Bytecodes::code_at(addr_at(0)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
62 bool must_rewrite(Bytecodes::Code code) const { return Bytecodes::can_rewrite(code) && check_must_rewrite(code); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
65 inline friend Bytecode* Bytecode_at(address bcp);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
66
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
67 // Static functions for parsing bytecodes in place.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
68 int get_index_u1(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
69 assert_same_format_as(bc); assert_index_size(1, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
70 return *(jubyte*)addr_at(1);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
71 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
72 int get_index_u2(Bytecodes::Code bc, bool is_wide = false) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
73 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
74 address p = addr_at(is_wide ? 2 : 1);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
75 if (can_use_native_byte_order(bc, is_wide))
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
76 return Bytes::get_native_u2(p);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
77 else return Bytes::get_Java_u2(p);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
78 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
79 int get_index_u2_cpcache(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
80 assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
81 return Bytes::get_native_u2(addr_at(1)) DEBUG_ONLY(+ constantPoolOopDesc::CPCACHE_INDEX_TAG);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
82 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
83 int get_index_u4(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
84 assert_same_format_as(bc); assert_index_size(4, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
85 assert(can_use_native_byte_order(bc), "");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
86 return Bytes::get_native_u4(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 bool has_index_u4(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
89 return bc == Bytecodes::_invokedynamic;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
90 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
91
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
92 int get_offset_s2(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
93 assert_same_format_as(bc); assert_offset_size(2, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
94 return (jshort) Bytes::get_Java_u2(addr_at(1));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
95 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
96 int get_offset_s4(Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
97 assert_same_format_as(bc); assert_offset_size(4, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
98 return (jint) Bytes::get_Java_u4(addr_at(1));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
99 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
100
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
101 int get_constant_u1(int offset, Bytecodes::Code bc) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
102 assert_same_format_as(bc); assert_constant_size(1, offset, bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
103 return *(jbyte*)addr_at(offset);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
104 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
105 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
106 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
107 return (jshort) Bytes::get_Java_u2(addr_at(offset));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
108 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
109
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
110 // These are used locally and also from bytecode streams.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
119 };
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 inline Bytecode* Bytecode_at(address bcp) {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
122 // Warning: Use with caution on live bytecode streams. 4926272
0
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return (Bytecode*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // Abstractions for lookupswitch bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 class LookupswitchPair: ThisRelativeObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
131 int _match;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 int _offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 public:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
135 int match() const { return get_Java_u4_at(0 * jintSize); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
136 int offset() const { return get_Java_u4_at(1 * jintSize); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
137 };
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 class Bytecode_lookupswitch: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
142 void verify() const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Attributes
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
145 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
146 int number_of_pairs() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
147 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
148 return (LookupswitchPair*)aligned_addr_at(1 + (1 + i)*2*jintSize); }
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
150 inline friend Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 };
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 inline Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 Bytecode_lookupswitch* b = (Bytecode_lookupswitch*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return b;
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_tableswitch: 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 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
167 int high_key() const { return get_Java_u4_at(aligned_offset(1 + 2*jintSize)); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
168 int dest_offset_at(int i) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 int length() { return high_key()-low_key()+1; }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
172 inline friend Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 };
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 inline Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 Bytecode_tableswitch* b = (Bytecode_tableswitch*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
178 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Abstraction for invoke_{virtual, static, interface, special}
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 class Bytecode_invoke: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
186 methodHandle _method; // method containing the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
187 int _bci; // position of the bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 Bytecode_invoke(methodHandle method, int bci) : _method(method), _bci(bci) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
192 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // Attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
195 methodHandle method() const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 int bci() const { return _bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
197 address bcp() const { return _method->bcp_from(bci()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 int index() const; // the constant pool index for the invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
200 symbolOop name() const; // returns the name of the invoked method
a61af66fc99e Initial load
duke
parents:
diff changeset
201 symbolOop signature() const; // returns the signature of the invoked method
a61af66fc99e Initial load
duke
parents:
diff changeset
202 BasicType result_type(Thread *thread) const; // returns the result type of the invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 Bytecodes::Code code() const { return Bytecodes::code_at(bcp(), _method()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
205 Bytecodes::Code adjusted_invoke_code() const { return Bytecodes::java_code(code()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 methodHandle static_target(TRAPS); // "specified" method (from constant pool)
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // Testers
a61af66fc99e Initial load
duke
parents:
diff changeset
210 bool is_invokeinterface() const { return adjusted_invoke_code() == Bytecodes::_invokeinterface; }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 bool is_invokevirtual() const { return adjusted_invoke_code() == Bytecodes::_invokevirtual; }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 bool is_invokestatic() const { return adjusted_invoke_code() == Bytecodes::_invokestatic; }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 bool is_invokespecial() const { return adjusted_invoke_code() == Bytecodes::_invokespecial; }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
214 bool is_invokedynamic() const { return adjusted_invoke_code() == Bytecodes::_invokedynamic; }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
215
1138
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1135
diff changeset
216 bool has_receiver() const { return !is_invokestatic() && !is_invokedynamic(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 bool is_valid() const { return is_invokeinterface() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
219 is_invokevirtual() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
220 is_invokestatic() ||
1135
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 844
diff changeset
221 is_invokespecial() ||
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 844
diff changeset
222 is_invokedynamic(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
225 inline friend Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // Like Bytecode_invoke_at. Instead it returns NULL if the bci is not at an invoke.
a61af66fc99e Initial load
duke
parents:
diff changeset
228 inline friend Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 };
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 inline Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 Bytecode_invoke* b = new Bytecode_invoke(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
233 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 }
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 inline Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
238 Bytecode_invoke* b = new Bytecode_invoke(method, bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return b->is_valid() ? b : NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // Abstraction for all field accesses (put/get field/static_
a61af66fc99e Initial load
duke
parents:
diff changeset
244 class Bytecode_field: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
246 void verify() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 int index() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
249 bool is_static() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
252 inline friend Bytecode_field* Bytecode_field_at(const methodOop method, address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 };
a61af66fc99e Initial load
duke
parents:
diff changeset
254
a61af66fc99e Initial load
duke
parents:
diff changeset
255 inline Bytecode_field* Bytecode_field_at(const methodOop method, address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 Bytecode_field* b = (Bytecode_field*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // Abstraction for checkcast
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 class Bytecode_checkcast: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
266 void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
269 long index() const { return get_index_u2(Bytecodes::_checkcast); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
270
a61af66fc99e Initial load
duke
parents:
diff changeset
271 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
272 inline friend Bytecode_checkcast* Bytecode_checkcast_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
273 };
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 inline Bytecode_checkcast* Bytecode_checkcast_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
276 Bytecode_checkcast* b = (Bytecode_checkcast*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
278 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 // Abstraction for instanceof
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 class Bytecode_instanceof: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
285 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
286 void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
289 long index() const { return get_index_u2(Bytecodes::_instanceof); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
292 inline friend Bytecode_instanceof* Bytecode_instanceof_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
293 };
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 inline Bytecode_instanceof* Bytecode_instanceof_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 Bytecode_instanceof* b = (Bytecode_instanceof*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
297 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
298 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 class Bytecode_new: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
304 void verify() const { assert(java_code() == Bytecodes::_new, "check new"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
307 long index() const { return get_index_u2(Bytecodes::_new); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
310 inline friend Bytecode_new* Bytecode_new_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
311 };
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 inline Bytecode_new* Bytecode_new_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
314 Bytecode_new* b = (Bytecode_new*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
315 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 class Bytecode_multianewarray: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
321 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
322 void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
323
a61af66fc99e Initial load
duke
parents:
diff changeset
324 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
325 long index() const { return get_index_u2(Bytecodes::_multianewarray); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
328 inline friend Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
329 };
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 inline Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
332 Bytecode_multianewarray* b = (Bytecode_multianewarray*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
333 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
334 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 class Bytecode_anewarray: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
340 void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); }
a61af66fc99e Initial load
duke
parents:
diff changeset
341
a61af66fc99e Initial load
duke
parents:
diff changeset
342 // Returns index
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
343 long index() const { return get_index_u2(Bytecodes::_anewarray); };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // Creation
a61af66fc99e Initial load
duke
parents:
diff changeset
346 inline friend Bytecode_anewarray* Bytecode_anewarray_at(address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
347 };
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 inline Bytecode_anewarray* Bytecode_anewarray_at(address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
350 Bytecode_anewarray* b = (Bytecode_anewarray*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
352 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 }
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // Abstraction for ldc, ldc_w and ldc2_w
a61af66fc99e Initial load
duke
parents:
diff changeset
357
a61af66fc99e Initial load
duke
parents:
diff changeset
358 class Bytecode_loadconstant: public Bytecode {
a61af66fc99e Initial load
duke
parents:
diff changeset
359 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
360 void verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
361 Bytecodes::Code stdc = Bytecodes::java_code(code());
a61af66fc99e Initial load
duke
parents:
diff changeset
362 assert(stdc == Bytecodes::_ldc ||
a61af66fc99e Initial load
duke
parents:
diff changeset
363 stdc == Bytecodes::_ldc_w ||
a61af66fc99e Initial load
duke
parents:
diff changeset
364 stdc == Bytecodes::_ldc2_w, "load constant");
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 int index() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 inline friend Bytecode_loadconstant* Bytecode_loadconstant_at(const methodOop method, address bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
370 };
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 inline Bytecode_loadconstant* Bytecode_loadconstant_at(const methodOop method, address bcp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
373 Bytecode_loadconstant* b = (Bytecode_loadconstant*)bcp;
a61af66fc99e Initial load
duke
parents:
diff changeset
374 debug_only(b->verify());
a61af66fc99e Initial load
duke
parents:
diff changeset
375 return b;
a61af66fc99e Initial load
duke
parents:
diff changeset
376 }