107 int next_bci() const { return _next_bci; } |
107 int next_bci() const { return _next_bci; } |
108 int end_bci() const { return _end_bci; } |
108 int end_bci() const { return _end_bci; } |
109 |
109 |
110 Bytecodes::Code code() const { return _code; } |
110 Bytecodes::Code code() const { return _code; } |
111 bool is_wide() const { return _is_wide; } |
111 bool is_wide() const { return _is_wide; } |
|
112 int instruction_size() const { return (_next_bci - _bci); } |
112 bool is_last_bytecode() const { return _next_bci >= _end_bci; } |
113 bool is_last_bytecode() const { return _next_bci >= _end_bci; } |
113 |
114 |
114 address bcp() const { return method()->code_base() + _bci; } |
115 address bcp() const { return method()->code_base() + _bci; } |
115 address next_bcp() { return method()->code_base() + _next_bci; } |
116 address next_bcp() { return method()->code_base() + _next_bci; } |
116 |
117 |
120 // Bytecode-specific attributes |
121 // Bytecode-specific attributes |
121 int dest() const { return bci() + (short)Bytes::get_Java_u2(bcp() + 1); } |
122 int dest() const { return bci() + (short)Bytes::get_Java_u2(bcp() + 1); } |
122 int dest_w() const { return bci() + (int )Bytes::get_Java_u4(bcp() + 1); } |
123 int dest_w() const { return bci() + (int )Bytes::get_Java_u4(bcp() + 1); } |
123 |
124 |
124 // Unsigned indices, widening |
125 // Unsigned indices, widening |
125 int get_index() const { return (is_wide()) ? Bytes::get_Java_u2(bcp() + 2) : bcp()[1]; } |
126 int get_index() const { assert_index_size(is_wide() ? 2 : 1); |
126 int get_index_big() const { return (int)Bytes::get_Java_u2(bcp() + 1); } |
127 return (is_wide()) ? Bytes::get_Java_u2(bcp() + 2) : bcp()[1]; } |
|
128 int get_index_big() const { assert_index_size(2); |
|
129 return (int)Bytes::get_Java_u2(bcp() + 1); } |
|
130 int get_index_int() const { return has_giant_index() ? get_index_giant() : get_index_big(); } |
|
131 int get_index_giant() const { assert_index_size(4); return Bytes::get_native_u4(bcp() + 1); } |
|
132 int has_giant_index() const { return (code() == Bytecodes::_invokedynamic); } |
|
133 |
|
134 private: |
|
135 void assert_index_size(int required_size) const { |
|
136 #ifdef ASSERT |
|
137 int isize = instruction_size() - (int)_is_wide - 1; |
|
138 if (isize == 2 && code() == Bytecodes::_iinc) |
|
139 isize = 1; |
|
140 else if (isize <= 2) |
|
141 ; // no change |
|
142 else if (has_giant_index()) |
|
143 isize = 4; |
|
144 else |
|
145 isize = 2; |
|
146 assert(isize = required_size, "wrong index size"); |
|
147 #endif |
|
148 } |
127 }; |
149 }; |
128 |
150 |
129 // In BytecodeStream, non-java bytecodes will be translated into the |
151 // In BytecodeStream, non-java bytecodes will be translated into the |
130 // corresponding java bytecodes. |
152 // corresponding java bytecodes. |
131 |
153 |