Print this page
rev 1024 : imported patch indy-cleanup-6893081.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/interpreter/bytecode.cpp
+++ new/src/share/vm/interpreter/bytecode.cpp
1 1 /*
2 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 #include "incls/_precompiled.incl"
26 26 #include "incls/_bytecode.cpp.incl"
27 27
28 28 // Implementation of Bytecode
29 29 // Should eventually get rid of these functions and use ThisRelativeObj methods instead
30 30
31 31 void Bytecode::set_code(Bytecodes::Code code) {
32 32 Bytecodes::check(code);
33 33 *addr_at(0) = u_char(code);
34 34 }
35 35
36 36
37 37 bool Bytecode::check_must_rewrite() const {
38 38 assert(Bytecodes::can_rewrite(code()), "post-check only");
39 39
40 40 // Some codes are conditionally rewriting. Look closely at them.
41 41 switch (code()) {
42 42 case Bytecodes::_aload_0:
43 43 // Even if RewriteFrequentPairs is turned on,
44 44 // the _aload_0 code might delay its rewrite until
45 45 // a following _getfield rewrites itself.
46 46 return false;
47 47
48 48 case Bytecodes::_lookupswitch:
49 49 return false; // the rewrite is not done by the interpreter
50 50
51 51 case Bytecodes::_new:
52 52 // (Could actually look at the class here, but the profit would be small.)
53 53 return false; // the rewrite is not always done
54 54 }
55 55
56 56 // No other special cases.
57 57 return true;
58 58 }
59 59
60 60
61 61
62 62 // Implementation of Bytecode_tableupswitch
63 63
64 64 int Bytecode_tableswitch::dest_offset_at(int i) const {
65 65 address x = aligned_addr_at(1);
66 66 int x2 = aligned_offset(1 + (3 + i)*jintSize);
67 67 int val = java_signed_word_at(x2);
68 68 return java_signed_word_at(aligned_offset(1 + (3 + i)*jintSize));
69 69 }
70 70
71 71
72 72 // Implementation of Bytecode_invoke
73 73
74 74 void Bytecode_invoke::verify() const {
75 75 Bytecodes::Code bc = adjusted_invoke_code();
76 76 assert(is_valid(), "check invoke");
77 77 }
78 78
79 79
80 80 symbolOop Bytecode_invoke::signature() const {
81 81 constantPoolOop constants = method()->constants();
82 82 return constants->signature_ref_at(index());
83 83 }
84 84
85 85
86 86 symbolOop Bytecode_invoke::name() const {
87 87 constantPoolOop constants = method()->constants();
88 88 return constants->name_ref_at(index());
89 89 }
90 90
91 91
92 92 BasicType Bytecode_invoke::result_type(Thread *thread) const {
93 93 symbolHandle sh(thread, signature());
94 94 ResultTypeFinder rts(sh);
↓ open down ↓ |
94 lines elided |
↑ open up ↑ |
95 95 rts.iterate();
96 96 return rts.type();
97 97 }
98 98
99 99
100 100 methodHandle Bytecode_invoke::static_target(TRAPS) {
101 101 methodHandle m;
102 102 KlassHandle resolved_klass;
103 103 constantPoolHandle constants(THREAD, _method->constants());
104 104
105 - if (adjusted_invoke_code() != Bytecodes::_invokeinterface) {
105 + if (adjusted_invoke_code() == Bytecodes::_invokedynamic) {
106 + LinkResolver::resolve_dynamic_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
107 + } else if (adjusted_invoke_code() != Bytecodes::_invokeinterface) {
106 108 LinkResolver::resolve_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
107 109 } else {
108 110 LinkResolver::resolve_interface_method(m, resolved_klass, constants, index(), CHECK_(methodHandle()));
109 111 }
110 112 return m;
111 113 }
112 114
113 115
114 116 int Bytecode_invoke::index() const {
115 117 // Note: Rewriter::rewrite changes the Java_u2 of an invokedynamic to a native_u4,
116 118 // at the same time it allocates per-call-site CP cache entries.
117 119 if (has_giant_index())
118 120 return Bytes::get_native_u4(bcp() + 1);
119 121 else
120 122 return Bytes::get_Java_u2(bcp() + 1);
121 123 }
122 124
123 125
124 126 // Implementation of Bytecode_static
125 127
126 128 void Bytecode_static::verify() const {
127 129 assert(Bytecodes::java_code(code()) == Bytecodes::_putstatic
128 130 || Bytecodes::java_code(code()) == Bytecodes::_getstatic, "check static");
129 131 }
130 132
131 133
132 134 BasicType Bytecode_static::result_type(methodOop method) const {
133 135 int index = java_hwrd_at(1);
134 136 constantPoolOop constants = method->constants();
135 137 symbolOop field_type = constants->signature_ref_at(index);
136 138 BasicType basic_type = FieldType::basic_type(field_type);
137 139 return basic_type;
138 140 }
139 141
140 142
141 143 // Implementation of Bytecode_field
142 144
143 145 void Bytecode_field::verify() const {
144 146 Bytecodes::Code stdc = Bytecodes::java_code(code());
145 147 assert(stdc == Bytecodes::_putstatic || stdc == Bytecodes::_getstatic ||
146 148 stdc == Bytecodes::_putfield || stdc == Bytecodes::_getfield, "check field");
147 149 }
148 150
149 151
150 152 bool Bytecode_field::is_static() const {
151 153 Bytecodes::Code stdc = Bytecodes::java_code(code());
152 154 return stdc == Bytecodes::_putstatic || stdc == Bytecodes::_getstatic;
153 155 }
154 156
155 157
156 158 int Bytecode_field::index() const {
157 159 return java_hwrd_at(1);
158 160 }
159 161
160 162
161 163 // Implementation of Bytecodes loac constant
162 164
163 165 int Bytecode_loadconstant::index() const {
164 166 Bytecodes::Code stdc = Bytecodes::java_code(code());
165 167 return stdc == Bytecodes::_ldc ? java_byte_at(1) : java_hwrd_at(1);
166 168 }
167 169
168 170 //------------------------------------------------------------------------------
169 171 // Non-product code
170 172
171 173 #ifndef PRODUCT
172 174
173 175 void Bytecode_lookupswitch::verify() const {
174 176 switch (Bytecodes::java_code(code())) {
175 177 case Bytecodes::_lookupswitch:
176 178 { int i = number_of_pairs() - 1;
177 179 while (i-- > 0) {
178 180 assert(pair_at(i)->match() < pair_at(i+1)->match(), "unsorted table entries");
179 181 }
180 182 }
181 183 break;
182 184 default:
183 185 fatal("not a lookupswitch bytecode");
184 186 }
185 187 }
186 188
187 189 void Bytecode_tableswitch::verify() const {
188 190 switch (Bytecodes::java_code(code())) {
189 191 case Bytecodes::_tableswitch:
190 192 { int lo = low_key();
191 193 int hi = high_key();
192 194 assert (hi >= lo, "incorrect hi/lo values in tableswitch");
193 195 int i = hi - lo - 1 ;
194 196 while (i-- > 0) {
195 197 // no special check needed
196 198 }
197 199 }
198 200 break;
199 201 default:
200 202 fatal("not a tableswitch bytecode");
201 203 }
202 204 }
203 205
204 206 #endif
↓ open down ↓ |
89 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX