annotate src/share/vm/interpreter/bytecode.cpp @ 2045:9c96c873c42b

Fix includes to match new hotspot mechanism.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Fri, 07 Jan 2011 18:45:09 +0100
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 1574
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: 1135
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1135
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: 1135
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 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
26 #include "interpreter/bytecode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
27 #include "interpreter/linkResolver.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
28 #include "oops/constantPoolOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
29 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
30 #include "runtime/fieldType.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
31 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
32 #include "runtime/safepoint.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1602
diff changeset
33 #include "runtime/signature.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // Implementation of Bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
36
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
37 bool Bytecode::check_must_rewrite(Bytecodes::Code code) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
38 assert(Bytecodes::can_rewrite(code), "post-check only");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // Some codes are conditionally rewriting. Look closely at them.
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
41 switch (code) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42 case Bytecodes::_aload_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Even if RewriteFrequentPairs is turned on,
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // the _aload_0 code might delay its rewrite until
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // a following _getfield rewrites itself.
a61af66fc99e Initial load
duke
parents:
diff changeset
46 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 case Bytecodes::_lookupswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 return false; // the rewrite is not done by the interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 case Bytecodes::_new:
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // (Could actually look at the class here, but the profit would be small.)
a61af66fc99e Initial load
duke
parents:
diff changeset
53 return false; // the rewrite is not always done
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // No other special cases.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 }
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
61 #ifdef ASSERT
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
62
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
63 void Bytecode::assert_same_format_as(Bytecodes::Code testbc, bool is_wide) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
64 Bytecodes::Code thisbc = Bytecodes::cast(byte_at(0));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
65 if (thisbc == Bytecodes::_breakpoint) return; // let the assertion fail silently
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
66 if (is_wide) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
67 assert(thisbc == Bytecodes::_wide, "expected a wide instruction");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
68 thisbc = Bytecodes::cast(byte_at(1));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
69 if (thisbc == Bytecodes::_breakpoint) return;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
70 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
71 int thisflags = Bytecodes::flags(testbc, is_wide) & Bytecodes::_all_fmt_bits;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
72 int testflags = Bytecodes::flags(thisbc, is_wide) & Bytecodes::_all_fmt_bits;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
73 if (thisflags != testflags)
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
74 tty->print_cr("assert_same_format_as(%d) failed on bc=%d%s; %d != %d",
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
75 (int)testbc, (int)thisbc, (is_wide?"/wide":""), testflags, thisflags);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
76 assert(thisflags == testflags, "expected format");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
77 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
78
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
79 void Bytecode::assert_index_size(int size, Bytecodes::Code bc, bool is_wide) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
80 int have_fmt = (Bytecodes::flags(bc, is_wide)
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
81 & (Bytecodes::_fmt_has_u2 | Bytecodes::_fmt_has_u4 |
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
82 Bytecodes::_fmt_not_simple |
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
83 // Not an offset field:
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
84 Bytecodes::_fmt_has_o));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
85 int need_fmt = -1;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
86 switch (size) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
87 case 1: need_fmt = 0; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
88 case 2: need_fmt = Bytecodes::_fmt_has_u2; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
89 case 4: need_fmt = Bytecodes::_fmt_has_u4; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
90 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
91 if (is_wide) need_fmt |= Bytecodes::_fmt_not_simple;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
92 if (have_fmt != need_fmt) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
93 tty->print_cr("assert_index_size %d: bc=%d%s %d != %d", size, bc, (is_wide?"/wide":""), have_fmt, need_fmt);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
94 assert(have_fmt == need_fmt, "assert_index_size");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
95 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
96 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
97
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
98 void Bytecode::assert_offset_size(int size, Bytecodes::Code bc, bool is_wide) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
99 int have_fmt = Bytecodes::flags(bc, is_wide) & Bytecodes::_all_fmt_bits;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
100 int need_fmt = -1;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
101 switch (size) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
102 case 2: need_fmt = Bytecodes::_fmt_bo2; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
103 case 4: need_fmt = Bytecodes::_fmt_bo4; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
104 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
105 if (is_wide) need_fmt |= Bytecodes::_fmt_not_simple;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
106 if (have_fmt != need_fmt) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
107 tty->print_cr("assert_offset_size %d: bc=%d%s %d != %d", size, bc, (is_wide?"/wide":""), have_fmt, need_fmt);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
108 assert(have_fmt == need_fmt, "assert_offset_size");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
109 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
110 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
111
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
112 void Bytecode::assert_constant_size(int size, int where, Bytecodes::Code bc, bool is_wide) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
113 int have_fmt = Bytecodes::flags(bc, is_wide) & (Bytecodes::_all_fmt_bits
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
114 // Ignore any 'i' field (for iinc):
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
115 & ~Bytecodes::_fmt_has_i);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
116 int need_fmt = -1;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
117 switch (size) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
118 case 1: need_fmt = Bytecodes::_fmt_bc; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
119 case 2: need_fmt = Bytecodes::_fmt_bc | Bytecodes::_fmt_has_u2; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
120 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
121 if (is_wide) need_fmt |= Bytecodes::_fmt_not_simple;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
122 int length = is_wide ? Bytecodes::wide_length_for(bc) : Bytecodes::length_for(bc);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
123 if (have_fmt != need_fmt || where + size != length) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
124 tty->print_cr("assert_constant_size %d @%d: bc=%d%s %d != %d", size, where, bc, (is_wide?"/wide":""), have_fmt, need_fmt);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
125 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
126 assert(have_fmt == need_fmt, "assert_constant_size");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
127 assert(where + size == length, "assert_constant_size oob");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
128 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
129
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
130 void Bytecode::assert_native_index(Bytecodes::Code bc, bool is_wide) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
131 assert((Bytecodes::flags(bc, is_wide) & Bytecodes::_fmt_has_nbo) != 0, "native index");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
132 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
133
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
134 #endif //ASSERT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 // Implementation of Bytecode_tableupswitch
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 int Bytecode_tableswitch::dest_offset_at(int i) const {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
139 return get_Java_u4_at(aligned_offset(1 + (3 + i)*jintSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
140 }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // Implementation of Bytecode_invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 void Bytecode_invoke::verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
146 assert(is_valid(), "check invoke");
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
147 assert(method()->constants()->cache() != NULL, "do not call this from verifier or rewriter");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
151 symbolOop Bytecode_member_ref::signature() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
152 constantPoolOop constants = method()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
153 return constants->signature_ref_at(index());
a61af66fc99e Initial load
duke
parents:
diff changeset
154 }
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
157 symbolOop Bytecode_member_ref::name() const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
158 constantPoolOop constants = method()->constants();
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return constants->name_ref_at(index());
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
163 BasicType Bytecode_member_ref::result_type(Thread *thread) const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
164 symbolHandle sh(thread, signature());
a61af66fc99e Initial load
duke
parents:
diff changeset
165 ResultTypeFinder rts(sh);
a61af66fc99e Initial load
duke
parents:
diff changeset
166 rts.iterate();
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return rts.type();
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 methodHandle Bytecode_invoke::static_target(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 methodHandle m;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 KlassHandle resolved_klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
174 constantPoolHandle constants(THREAD, _method->constants());
a61af66fc99e Initial load
duke
parents:
diff changeset
175
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
176 if (java_code() == Bytecodes::_invokedynamic) {
1135
e66fd840cb6b 6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents: 844
diff changeset
177 LinkResolver::resolve_dynamic_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
178 } else if (java_code() != Bytecodes::_invokeinterface) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
179 LinkResolver::resolve_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
a61af66fc99e Initial load
duke
parents:
diff changeset
180 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 LinkResolver::resolve_interface_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return m;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
187 int Bytecode_member_ref::index() const {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
188 // Note: Rewriter::rewrite changes the Java_u2 of an invokedynamic to a native_u4,
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
189 // at the same time it allocates per-call-site CP cache entries.
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
190 Bytecodes::Code rawc = code();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
191 Bytecode* invoke = bytecode();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
192 if (invoke->has_index_u4(rawc))
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
193 return invoke->get_index_u4(rawc);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
194 else
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
195 return invoke->get_index_u2_cpcache(rawc);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
196 }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
198 int Bytecode_member_ref::pool_index() const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
199 int index = this->index();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
200 DEBUG_ONLY({
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
201 if (!bytecode()->has_index_u4(code()))
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
202 index -= constantPoolOopDesc::CPCACHE_INDEX_TAG;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
203 });
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
204 return _method->constants()->cache()->entry_at(index)->constant_pool_index();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
205 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // Implementation of Bytecode_field
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 void Bytecode_field::verify() const {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
210 assert(is_valid(), "check field");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
214 // Implementation of Bytecode_loadconstant
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
215
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
216 int Bytecode_loadconstant::raw_index() const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
217 Bytecode* bcp = bytecode();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
218 Bytecodes::Code rawc = bcp->code();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
219 assert(rawc != Bytecodes::_wide, "verifier prevents this");
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
220 if (Bytecodes::java_code(rawc) == Bytecodes::_ldc)
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
221 return bcp->get_index_u1(rawc);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
222 else
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
223 return bcp->get_index_u2(rawc, false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
226 int Bytecode_loadconstant::pool_index() const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
227 int index = raw_index();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
228 if (has_cache_index()) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
229 return _method->constants()->cache()->entry_at(index)->constant_pool_index();
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 return index;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
232 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
233
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
234 BasicType Bytecode_loadconstant::result_type() const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
235 int index = pool_index();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
236 constantTag tag = _method->constants()->tag_at(index);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
237 return tag.basic_type();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
238 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
239
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
240 oop Bytecode_loadconstant::resolve_constant(TRAPS) const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
241 assert(_method.not_null(), "must supply method to resolve constant");
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
242 int index = raw_index();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
243 constantPoolOop constants = _method->constants();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
244 if (has_cache_index()) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
245 return constants->resolve_cached_constant_at(index, THREAD);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
246 } else {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
247 return constants->resolve_constant_at(index, THREAD);
1574
1eb493f33423 6957080: MethodComparator needs stress testing
jrose
parents: 1565
diff changeset
248 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
249 }
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 //------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // Non-product code
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 void Bytecode_lookupswitch::verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 switch (Bytecodes::java_code(code())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 case Bytecodes::_lookupswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
259 { int i = number_of_pairs() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 while (i-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 assert(pair_at(i)->match() < pair_at(i+1)->match(), "unsorted table entries");
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
266 fatal("not a lookupswitch bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 }
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 void Bytecode_tableswitch::verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
271 switch (Bytecodes::java_code(code())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
272 case Bytecodes::_tableswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
273 { int lo = low_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
274 int hi = high_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 assert (hi >= lo, "incorrect hi/lo values in tableswitch");
a61af66fc99e Initial load
duke
parents:
diff changeset
276 int i = hi - lo - 1 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
277 while (i-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // no special check needed
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
282 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
283 fatal("not a tableswitch bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 #endif