annotate src/share/vm/interpreter/bytecode.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 1d7922586cf6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
2 * Copyright (c) 1997, 2012, 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"
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
28 #include "oops/constantPool.hpp"
1972
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 #ifdef ASSERT
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
38
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
39 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
40 Bytecodes::Code thisbc = Bytecodes::cast(byte_at(0));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
41 if (thisbc == Bytecodes::_breakpoint) return; // let the assertion fail silently
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
42 if (is_wide) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
43 assert(thisbc == Bytecodes::_wide, "expected a wide instruction");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
44 thisbc = Bytecodes::cast(byte_at(1));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
45 if (thisbc == Bytecodes::_breakpoint) return;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
46 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
47 int thisflags = Bytecodes::flags(testbc, is_wide) & Bytecodes::_all_fmt_bits;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
48 int testflags = Bytecodes::flags(thisbc, is_wide) & Bytecodes::_all_fmt_bits;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
49 if (thisflags != testflags)
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
50 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
51 (int)testbc, (int)thisbc, (is_wide?"/wide":""), testflags, thisflags);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
52 assert(thisflags == testflags, "expected format");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
53 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
54
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
55 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
56 int have_fmt = (Bytecodes::flags(bc, is_wide)
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
57 & (Bytecodes::_fmt_has_u2 | Bytecodes::_fmt_has_u4 |
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
58 Bytecodes::_fmt_not_simple |
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
59 // Not an offset field:
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
60 Bytecodes::_fmt_has_o));
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
61 int need_fmt = -1;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
62 switch (size) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
63 case 1: need_fmt = 0; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
64 case 2: need_fmt = Bytecodes::_fmt_has_u2; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
65 case 4: need_fmt = Bytecodes::_fmt_has_u4; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
66 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
67 if (is_wide) need_fmt |= Bytecodes::_fmt_not_simple;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
68 if (have_fmt != need_fmt) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
69 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
70 assert(have_fmt == need_fmt, "assert_index_size");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
71 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
72 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
73
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
74 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
75 int have_fmt = Bytecodes::flags(bc, is_wide) & Bytecodes::_all_fmt_bits;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
76 int need_fmt = -1;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
77 switch (size) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
78 case 2: need_fmt = Bytecodes::_fmt_bo2; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
79 case 4: need_fmt = Bytecodes::_fmt_bo4; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
80 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
81 if (is_wide) need_fmt |= Bytecodes::_fmt_not_simple;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
82 if (have_fmt != need_fmt) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
83 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
84 assert(have_fmt == need_fmt, "assert_offset_size");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
85 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
86 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
87
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
88 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
89 int have_fmt = Bytecodes::flags(bc, is_wide) & (Bytecodes::_all_fmt_bits
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
90 // Ignore any 'i' field (for iinc):
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
91 & ~Bytecodes::_fmt_has_i);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
92 int need_fmt = -1;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
93 switch (size) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
94 case 1: need_fmt = Bytecodes::_fmt_bc; break;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
95 case 2: need_fmt = Bytecodes::_fmt_bc | Bytecodes::_fmt_has_u2; break;
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 if (is_wide) need_fmt |= Bytecodes::_fmt_not_simple;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
98 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
99 if (have_fmt != need_fmt || where + size != length) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
100 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
101 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
102 assert(have_fmt == need_fmt, "assert_constant_size");
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
103 assert(where + size == length, "assert_constant_size oob");
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
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
106 void Bytecode::assert_native_index(Bytecodes::Code bc, bool is_wide) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
107 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
108 }
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 #endif //ASSERT
0
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // Implementation of Bytecode_tableupswitch
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 int Bytecode_tableswitch::dest_offset_at(int i) const {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1135
diff changeset
115 return get_Java_u4_at(aligned_offset(1 + (3 + i)*jintSize));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Implementation of Bytecode_invoke
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 void Bytecode_invoke::verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 assert(is_valid(), "check invoke");
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
123 assert(cpcache() != NULL, "do not call this from verifier or rewriter");
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
124 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
125
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
126
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
127 Symbol* Bytecode_member_ref::klass() const {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
128 return constants()->klass_ref_at_noresolve(index());
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
129 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
130
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
131
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
132 Symbol* Bytecode_member_ref::name() const {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
133 return constants()->name_ref_at(index());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
137 Symbol* Bytecode_member_ref::signature() const {
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
138 return constants()->signature_ref_at(index());
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
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
142 BasicType Bytecode_member_ref::result_type() const {
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 2142
diff changeset
143 ResultTypeFinder rts(signature());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
144 rts.iterate();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return rts.type();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 methodHandle Bytecode_invoke::static_target(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 methodHandle m;
a61af66fc99e Initial load
duke
parents:
diff changeset
151 KlassHandle resolved_klass;
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
152 constantPoolHandle constants(THREAD, this->constants());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
153
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
154 Bytecodes::Code bc = invoke_code();
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
155 LinkResolver::resolve_method_statically(m, resolved_klass, bc, constants, index(), CHECK_(methodHandle()));
0
a61af66fc99e Initial load
duke
parents:
diff changeset
156 return m;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
159 Handle Bytecode_invoke::appendix(TRAPS) {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
160 ConstantPoolCacheEntry* cpce = cpcache_entry();
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
161 if (cpce->has_appendix())
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
162 return Handle(THREAD, cpce->appendix_if_resolved(constants()));
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
163 return Handle(); // usual case
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
164 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
165
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
166 int Bytecode_member_ref::index() const {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
167 // 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
168 // 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
169 Bytecodes::Code rawc = code();
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
170 if (has_index_u4(rawc))
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
171 return get_index_u4(rawc);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
172 else
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
173 return get_index_u2_cpcache(rawc);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
176 int Bytecode_member_ref::pool_index() const {
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
177 return cpcache_entry()->constant_pool_index();
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
178 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
179
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 2177
diff changeset
180 ConstantPoolCacheEntry* Bytecode_member_ref::cpcache_entry() const {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
181 int index = this->index();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
182 return cpcache()->entry_at(ConstantPool::decode_cpcache_index(index, true));
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
183 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 // Implementation of Bytecode_field
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 void Bytecode_field::verify() const {
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
188 assert(is_valid(), "check field");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
189 }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
192 // Implementation of Bytecode_loadconstant
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
193
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
194 int Bytecode_loadconstant::raw_index() const {
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
195 Bytecodes::Code rawc = code();
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
196 assert(rawc != Bytecodes::_wide, "verifier prevents this");
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
197 if (Bytecodes::java_code(rawc) == Bytecodes::_ldc)
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
198 return get_index_u1(rawc);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
199 else
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
200 return get_index_u2(rawc, false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
201 }
a61af66fc99e Initial load
duke
parents:
diff changeset
202
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
203 int Bytecode_loadconstant::pool_index() const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
204 int index = raw_index();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
205 if (has_cache_index()) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
206 return _method->constants()->object_to_cp_index(index);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
207 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
208 return index;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
209 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
210
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
211 BasicType Bytecode_loadconstant::result_type() const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
212 int index = pool_index();
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
213 constantTag tag = _method->constants()->tag_at(index);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
214 return tag.basic_type();
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
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
217 oop Bytecode_loadconstant::resolve_constant(TRAPS) const {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
218 assert(_method.not_null(), "must supply method to resolve constant");
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
219 int index = raw_index();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
220 ConstantPool* constants = _method->constants();
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
221 if (has_cache_index()) {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
222 return constants->resolve_cached_constant_at(index, THREAD);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
223 } else {
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
224 return constants->resolve_constant_at(index, THREAD);
1574
1eb493f33423 6957080: MethodComparator needs stress testing
jrose
parents: 1565
diff changeset
225 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
226 }
a61af66fc99e Initial load
duke
parents:
diff changeset
227
a61af66fc99e Initial load
duke
parents:
diff changeset
228 //------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // Non-product code
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 void Bytecode_lookupswitch::verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 switch (Bytecodes::java_code(code())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 case Bytecodes::_lookupswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
236 { int i = number_of_pairs() - 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 while (i-- > 0) {
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
238 assert(pair_at(i).match() < pair_at(i+1).match(), "unsorted table entries");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
239 }
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
243 fatal("not a lookupswitch bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245 }
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 void Bytecode_tableswitch::verify() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
248 switch (Bytecodes::java_code(code())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 case Bytecodes::_tableswitch:
a61af66fc99e Initial load
duke
parents:
diff changeset
250 { int lo = low_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
251 int hi = high_key();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 assert (hi >= lo, "incorrect hi/lo values in tableswitch");
a61af66fc99e Initial load
duke
parents:
diff changeset
253 int i = hi - lo - 1 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 while (i-- > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
255 // no special check needed
a61af66fc99e Initial load
duke
parents:
diff changeset
256 }
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
260 fatal("not a tableswitch bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 #endif