comparison src/share/vm/ci/ciStreams.hpp @ 726:be93aad57795

6655646: dynamic languages need dynamically linked call sites Summary: invokedynamic instruction (JSR 292 RI) Reviewed-by: twisti, never
author jrose
date Tue, 21 Apr 2009 23:21:04 -0700
parents a61af66fc99e
children bd02caa94611
comparison
equal deleted inserted replaced
725:928912ce8438 726:be93aad57795
89 89
90 void set_max_bci( int max ) { 90 void set_max_bci( int max ) {
91 _end = _start + max; 91 _end = _start + max;
92 } 92 }
93 93
94 address cur_bcp() { return _bc_start; } // Returns bcp to current instruction 94 address cur_bcp() const { return _bc_start; } // Returns bcp to current instruction
95 int next_bci() const { return _pc -_start; } 95 int next_bci() const { return _pc -_start; }
96 int cur_bci() const { return _bc_start - _start; } 96 int cur_bci() const { return _bc_start - _start; }
97 int instruction_size() const { return _pc - _bc_start; }
97 98
98 Bytecodes::Code cur_bc() const{ return check_java(_bc); } 99 Bytecodes::Code cur_bc() const{ return check_java(_bc); }
99 Bytecodes::Code next_bc() { return Bytecodes::java_code((Bytecodes::Code)* _pc); } 100 Bytecodes::Code next_bc() { return Bytecodes::java_code((Bytecodes::Code)* _pc); }
100 101
101 // Return current ByteCode and increment PC to next bytecode, skipping all 102 // Return current ByteCode and increment PC to next bytecode, skipping all
119 _pc += csize; // Bump PC past bytecode 120 _pc += csize; // Bump PC past bytecode
120 } 121 }
121 return check_java(_bc); 122 return check_java(_bc);
122 } 123 }
123 124
124 bool is_wide() { return ( _pc == _was_wide ); } 125 bool is_wide() const { return ( _pc == _was_wide ); }
125 126
126 // Get a byte index following this bytecode. 127 // Get a byte index following this bytecode.
127 // If prefixed with a wide bytecode, get a wide index. 128 // If prefixed with a wide bytecode, get a wide index.
128 int get_index() const { 129 int get_index() const {
130 assert_index_size(is_wide() ? 2 : 1);
129 return (_pc == _was_wide) // was widened? 131 return (_pc == _was_wide) // was widened?
130 ? Bytes::get_Java_u2(_bc_start+2) // yes, return wide index 132 ? Bytes::get_Java_u2(_bc_start+2) // yes, return wide index
131 : _bc_start[1]; // no, return narrow index 133 : _bc_start[1]; // no, return narrow index
132 } 134 }
133 135
134 // Set a byte index following this bytecode.
135 // If prefixed with a wide bytecode, get a wide index.
136 void put_index(int idx) {
137 if (_pc == _was_wide) // was widened?
138 Bytes::put_Java_u2(_bc_start+2,idx); // yes, set wide index
139 else
140 _bc_start[1]=idx; // no, set narrow index
141 }
142
143 // Get 2-byte index (getfield/putstatic/etc) 136 // Get 2-byte index (getfield/putstatic/etc)
144 int get_index_big() const { return Bytes::get_Java_u2(_bc_start+1); } 137 int get_index_big() const {
138 assert_index_size(2);
139 return Bytes::get_Java_u2(_bc_start+1);
140 }
141
142 // Get 2-byte index (or 4-byte, for invokedynamic)
143 int get_index_int() const {
144 return has_giant_index() ? get_index_giant() : get_index_big();
145 }
146
147 // Get 4-byte index, for invokedynamic.
148 int get_index_giant() const {
149 assert_index_size(4);
150 return Bytes::get_native_u4(_bc_start+1);
151 }
152
153 bool has_giant_index() const { return (cur_bc() == Bytecodes::_invokedynamic); }
145 154
146 // Get dimensions byte (multinewarray) 155 // Get dimensions byte (multinewarray)
147 int get_dimensions() const { return *(unsigned char*)(_pc-1); } 156 int get_dimensions() const { return *(unsigned char*)(_pc-1); }
148
149 // Get unsigned index fast
150 int get_index_fast() const { return Bytes::get_native_u2(_pc-2); }
151 157
152 // Sign-extended index byte/short, no widening 158 // Sign-extended index byte/short, no widening
153 int get_byte() const { return (int8_t)(_pc[-1]); } 159 int get_byte() const { return (int8_t)(_pc[-1]); }
154 int get_short() const { return (int16_t)Bytes::get_Java_u2(_pc-2); } 160 int get_short() const { return (int16_t)Bytes::get_Java_u2(_pc-2); }
155 int get_long() const { return (int32_t)Bytes::get_Java_u4(_pc-4); } 161 int get_long() const { return (int32_t)Bytes::get_Java_u4(_pc-4); }
223 // If this is a method invocation bytecode, get the invoked method. 229 // If this is a method invocation bytecode, get the invoked method.
224 ciMethod* get_method(bool& will_link); 230 ciMethod* get_method(bool& will_link);
225 ciKlass* get_declared_method_holder(); 231 ciKlass* get_declared_method_holder();
226 int get_method_holder_index(); 232 int get_method_holder_index();
227 int get_method_signature_index(); 233 int get_method_signature_index();
234
235 private:
236 void assert_index_size(int required_size) const {
237 #ifdef ASSERT
238 int isize = instruction_size() - (is_wide() ? 1 : 0) - 1;
239 if (isize == 2 && cur_bc() == Bytecodes::_iinc)
240 isize = 1;
241 else if (isize <= 2)
242 ; // no change
243 else if (has_giant_index())
244 isize = 4;
245 else
246 isize = 2;
247 assert(isize = required_size, "wrong index size");
248 #endif
249 }
228 }; 250 };
229 251
230 252
231 // ciSignatureStream 253 // ciSignatureStream
232 // 254 //