annotate src/share/vm/interpreter/bytecodeStream.hpp @ 2192:b92c45f2bc75

7016023: Enable building ARM and PPC from src/closed repository Reviewed-by: dholmes, bdelsart
author bobv
date Wed, 02 Feb 2011 11:35:26 -0500
parents 8012aa3ccede
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
2 * Copyright (c) 1997, 2011, 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: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
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: 844
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: 1579
diff changeset
25 #ifndef SHARE_VM_INTERPRETER_BYTECODESTREAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
26 #define SHARE_VM_INTERPRETER_BYTECODESTREAM_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
28 #include "interpreter/bytecode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
30 #include "oops/methodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
31 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
32 # include "bytes_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
33 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
34 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
35 # include "bytes_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
36 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
37 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
38 # include "bytes_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
39 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2142
diff changeset
40 #ifdef TARGET_ARCH_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2142
diff changeset
41 # include "bytes_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2142
diff changeset
42 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2142
diff changeset
43 #ifdef TARGET_ARCH_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2142
diff changeset
44 # include "bytes_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 2142
diff changeset
45 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
46
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // A BytecodeStream is used for fast iteration over the bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // of a methodOop.
a61af66fc99e Initial load
duke
parents:
diff changeset
49 //
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Usage:
a61af66fc99e Initial load
duke
parents:
diff changeset
51 //
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // BytecodeStream s(method);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Bytecodes::Code c;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // while ((c = s.next()) >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // ...
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
57
0
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // A RawBytecodeStream is a simple version of BytecodeStream.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // It is used ONLY when we know the bytecodes haven't been rewritten
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
60 // yet, such as in the rewriter or the verifier.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
62 // Here is the common base class for both RawBytecodeStream and BytecodeStream:
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
63 class BaseBytecodeStream: StackObj {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
64 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // stream buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
66 methodHandle _method; // read from method directly
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // reading position
a61af66fc99e Initial load
duke
parents:
diff changeset
69 int _bci; // bci if current bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
70 int _next_bci; // bci of next bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
71 int _end_bci; // bci after the current iteration interval
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // last bytecode read
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
74 Bytecodes::Code _raw_code;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75 bool _is_wide;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
76 bool _is_raw; // false in 'cooked' BytecodeStream
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
77
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
78 // Construction
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
79 BaseBytecodeStream(methodHandle method) : _method(method) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
80 set_interval(0, _method->code_size());
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
81 _is_raw = false;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
82 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // Iteration control
a61af66fc99e Initial load
duke
parents:
diff changeset
86 void set_interval(int beg_bci, int end_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // iterate over the interval [beg_bci, end_bci)
a61af66fc99e Initial load
duke
parents:
diff changeset
88 assert(0 <= beg_bci && beg_bci <= method()->code_size(), "illegal beg_bci");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 assert(0 <= end_bci && end_bci <= method()->code_size(), "illegal end_bci");
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // setup of iteration pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
91 _bci = beg_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 _next_bci = beg_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 _end_bci = end_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 void set_start (int beg_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 set_interval(beg_bci, _method->code_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
99 bool is_raw() const { return _is_raw; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
100
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
101 // Stream attributes
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
102 methodHandle method() const { return _method; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
103
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
104 int bci() const { return _bci; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
105 int next_bci() const { return _next_bci; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
106 int end_bci() const { return _end_bci; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
107
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
108 Bytecodes::Code raw_code() const { return _raw_code; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
109 bool is_wide() const { return _is_wide; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
110 int instruction_size() const { return (_next_bci - _bci); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
111 bool is_last_bytecode() const { return _next_bci >= _end_bci; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
112
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
113 address bcp() const { return method()->code_base() + _bci; }
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
114 Bytecode bytecode() const { return Bytecode(_method(), bcp()); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
115
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
116 // State changes
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
117 void set_next_bci(int bci) { assert(0 <= bci && bci <= method()->code_size(), "illegal bci"); _next_bci = bci; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
118
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
119 // Bytecode-specific attributes
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
120 int dest() const { return bci() + bytecode().get_offset_s2(raw_code()); }
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
121 int dest_w() const { return bci() + bytecode().get_offset_s4(raw_code()); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
122
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
123 // One-byte indices.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
124 int get_index_u1() const { assert_raw_index_size(1); return *(jubyte*)(bcp()+1); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
125
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
126 protected:
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
127 void assert_raw_index_size(int size) const NOT_DEBUG_RETURN;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
128 void assert_raw_stream(bool want_raw) const NOT_DEBUG_RETURN;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
129 };
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
130
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
131 class RawBytecodeStream: public BaseBytecodeStream {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
132 public:
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
133 // Construction
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
134 RawBytecodeStream(methodHandle method) : BaseBytecodeStream(method) {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
135 _is_raw = true;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
136 }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
137
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
138 public:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // Iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Use raw_next() rather than next() for faster method reference
a61af66fc99e Initial load
duke
parents:
diff changeset
141 Bytecodes::Code raw_next() {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 Bytecodes::Code code;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // set reading position
a61af66fc99e Initial load
duke
parents:
diff changeset
144 _bci = _next_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 assert(!is_last_bytecode(), "caller should check is_last_bytecode()");
a61af66fc99e Initial load
duke
parents:
diff changeset
146
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
147 address bcp = this->bcp();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
148 code = Bytecodes::code_or_bp_at(bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // set next bytecode position
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int l = Bytecodes::length_for(code);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 if (l > 0 && (_bci + l) <= _end_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 assert(code != Bytecodes::_wide && code != Bytecodes::_tableswitch
a61af66fc99e Initial load
duke
parents:
diff changeset
154 && code != Bytecodes::_lookupswitch, "can't be special bytecode");
a61af66fc99e Initial load
duke
parents:
diff changeset
155 _is_wide = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 _next_bci += l;
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
157 _raw_code = code;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
158 return code;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return raw_next_special(code);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 Bytecodes::Code raw_next_special(Bytecodes::Code code);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
165 // Unsigned indices, widening, with no swapping of bytes
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
166 int get_index() const { return (is_wide()) ? get_index_u2_raw(bcp() + 2) : get_index_u1(); }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
167 // Get an unsigned 2-byte index, with no swapping of bytes.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
168 int get_index_u2() const { assert(!is_wide(), ""); return get_index_u2_raw(bcp() + 1); }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
169
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
170 private:
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
171 int get_index_u2_raw(address p) const {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
172 assert_raw_index_size(2); assert_raw_stream(true);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
173 return Bytes::get_Java_u2(p);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
174 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
175 };
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // In BytecodeStream, non-java bytecodes will be translated into the
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // corresponding java bytecodes.
a61af66fc99e Initial load
duke
parents:
diff changeset
179
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
180 class BytecodeStream: public BaseBytecodeStream {
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
181 Bytecodes::Code _code;
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
182
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Construction
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
185 BytecodeStream(methodHandle method) : BaseBytecodeStream(method) { }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // Iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
188 Bytecodes::Code next() {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
189 Bytecodes::Code raw_code, code;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // set reading position
a61af66fc99e Initial load
duke
parents:
diff changeset
191 _bci = _next_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if (is_last_bytecode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 // indicate end of bytecode stream
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
194 raw_code = code = Bytecodes::_illegal;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
195 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // get bytecode
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
197 address bcp = this->bcp();
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
198 raw_code = Bytecodes::code_at(_method(), bcp);
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
199 code = Bytecodes::java_code(raw_code);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // set next bytecode position
a61af66fc99e Initial load
duke
parents:
diff changeset
201 //
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // note that we cannot advance before having the
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // tty bytecode otherwise the stepping is wrong!
a61af66fc99e Initial load
duke
parents:
diff changeset
204 // (carefull: length_for(...) must be used first!)
a61af66fc99e Initial load
duke
parents:
diff changeset
205 int l = Bytecodes::length_for(code);
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
206 if (l == 0) l = Bytecodes::length_at(_method(), bcp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
207 _next_bci += l;
a61af66fc99e Initial load
duke
parents:
diff changeset
208 assert(_bci < _next_bci, "length must be > 0");
a61af66fc99e Initial load
duke
parents:
diff changeset
209 // set attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
210 _is_wide = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // check for special (uncommon) cases
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if (code == Bytecodes::_wide) {
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
213 raw_code = (Bytecodes::Code)bcp[1];
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
214 code = raw_code; // wide BCs are always Java-normal
0
a61af66fc99e Initial load
duke
parents:
diff changeset
215 _is_wide = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 assert(Bytecodes::is_java_code(code), "sanity check");
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
219 _raw_code = raw_code;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
220 _code = code;
a61af66fc99e Initial load
duke
parents:
diff changeset
221 return _code;
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 bool is_active_breakpoint() const { return Bytecodes::is_active_breakpoint_at(bcp()); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
225 Bytecodes::Code code() const { return _code; }
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
226
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
227 // Unsigned indices, widening
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
228 int get_index() const { return is_wide() ? bytecode().get_index_u2(raw_code(), true) : get_index_u1(); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
229 // Get an unsigned 2-byte index, swapping the bytes if necessary.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
230 int get_index_u2() const { assert_raw_stream(false);
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
231 return bytecode().get_index_u2(raw_code(), false); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
232 // Get an unsigned 2-byte index in native order.
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
233 int get_index_u2_cpcache() const { assert_raw_stream(false);
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
234 return bytecode().get_index_u2_cpcache(raw_code()); }
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 844
diff changeset
235 int get_index_u4() const { assert_raw_stream(false);
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
236 return bytecode().get_index_u4(raw_code()); }
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 1972
diff changeset
237 bool has_index_u4() const { return bytecode().has_index_u4(raw_code()); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
238 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
239
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1579
diff changeset
240 #endif // SHARE_VM_INTERPRETER_BYTECODESTREAM_HPP