Mercurial > hg > truffle
comparison src/share/vm/ci/ciStreams.cpp @ 1565:ab102d5d923e
6939207: refactor constant pool index processing
Summary: Factored cleanup of instruction decode which prepares for enhanced ldc semantics.
Reviewed-by: twisti
author | jrose |
---|---|
date | Sun, 23 May 2010 01:38:26 -0700 |
parents | dd57230ba8fe |
children | e9ff18c4ace7 |
comparison
equal
deleted
inserted
replaced
1564:61b2245abf36 | 1565:ab102d5d923e |
---|---|
1 /* | 1 /* |
2 * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. | 2 * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
79 // The class is used to iterate over the bytecodes of a method. | 79 // The class is used to iterate over the bytecodes of a method. |
80 // It hides the details of constant pool structure/access by | 80 // It hides the details of constant pool structure/access by |
81 // providing accessors for constant pool items. | 81 // providing accessors for constant pool items. |
82 | 82 |
83 // ------------------------------------------------------------------ | 83 // ------------------------------------------------------------------ |
84 // ciBytecodeStream::wide | 84 // ciBytecodeStream::next_wide_or_table |
85 // | |
86 // Special handling for the wide bytcode | |
87 Bytecodes::Code ciBytecodeStream::wide() | |
88 { | |
89 // Get following bytecode; do not return wide | |
90 Bytecodes::Code bc = (Bytecodes::Code)_pc[1]; | |
91 _pc += 2; // Skip both bytecodes | |
92 _pc += 2; // Skip index always | |
93 if( bc == Bytecodes::_iinc ) | |
94 _pc += 2; // Skip optional constant | |
95 _was_wide = _pc; // Flag last wide bytecode found | |
96 return bc; | |
97 } | |
98 | |
99 // ------------------------------------------------------------------ | |
100 // ciBytecodeStream::table | |
101 // | 85 // |
102 // Special handling for switch ops | 86 // Special handling for switch ops |
103 Bytecodes::Code ciBytecodeStream::table( Bytecodes::Code bc ) { | 87 Bytecodes::Code ciBytecodeStream::next_wide_or_table(Bytecodes::Code bc) { |
104 switch( bc ) { // Check for special bytecode handling | 88 switch (bc) { // Check for special bytecode handling |
89 case Bytecodes::_wide: | |
90 // Special handling for the wide bytcode | |
91 // Get following bytecode; do not return wide | |
92 assert(Bytecodes::Code(_pc[0]) == Bytecodes::_wide, ""); | |
93 bc = Bytecodes::java_code(_raw_bc = (Bytecodes::Code)_pc[1]); | |
94 assert(Bytecodes::wide_length_for(bc) > 2, "must make progress"); | |
95 _pc += Bytecodes::wide_length_for(bc); | |
96 _was_wide = _pc; // Flag last wide bytecode found | |
97 assert(is_wide(), "accessor works right"); | |
98 break; | |
105 | 99 |
106 case Bytecodes::_lookupswitch: | 100 case Bytecodes::_lookupswitch: |
107 _pc++; // Skip wide bytecode | 101 _pc++; // Skip wide bytecode |
108 _pc += (_start-_pc)&3; // Word align | 102 _pc += (_start-_pc)&3; // Word align |
109 _table_base = (jint*)_pc; // Capture for later usage | 103 _table_base = (jint*)_pc; // Capture for later usage |
162 // If this bytecodes references a klass, return the index of the | 156 // If this bytecodes references a klass, return the index of the |
163 // referenced klass. | 157 // referenced klass. |
164 int ciBytecodeStream::get_klass_index() const { | 158 int ciBytecodeStream::get_klass_index() const { |
165 switch(cur_bc()) { | 159 switch(cur_bc()) { |
166 case Bytecodes::_ldc: | 160 case Bytecodes::_ldc: |
167 return get_index(); | 161 return get_index_u1(); |
168 case Bytecodes::_ldc_w: | 162 case Bytecodes::_ldc_w: |
169 case Bytecodes::_ldc2_w: | 163 case Bytecodes::_ldc2_w: |
170 case Bytecodes::_checkcast: | 164 case Bytecodes::_checkcast: |
171 case Bytecodes::_instanceof: | 165 case Bytecodes::_instanceof: |
172 case Bytecodes::_anewarray: | 166 case Bytecodes::_anewarray: |
173 case Bytecodes::_multianewarray: | 167 case Bytecodes::_multianewarray: |
174 case Bytecodes::_new: | 168 case Bytecodes::_new: |
175 case Bytecodes::_newarray: | 169 case Bytecodes::_newarray: |
176 return get_index_big(); | 170 return get_index_u2(); |
177 default: | 171 default: |
178 ShouldNotReachHere(); | 172 ShouldNotReachHere(); |
179 return 0; | 173 return 0; |
180 } | 174 } |
181 } | 175 } |
197 // If this bytecode is one of the ldc variants, get the index of the | 191 // If this bytecode is one of the ldc variants, get the index of the |
198 // referenced constant. | 192 // referenced constant. |
199 int ciBytecodeStream::get_constant_index() const { | 193 int ciBytecodeStream::get_constant_index() const { |
200 switch(cur_bc()) { | 194 switch(cur_bc()) { |
201 case Bytecodes::_ldc: | 195 case Bytecodes::_ldc: |
202 return get_index(); | 196 return get_index_u1(); |
203 case Bytecodes::_ldc_w: | 197 case Bytecodes::_ldc_w: |
204 case Bytecodes::_ldc2_w: | 198 case Bytecodes::_ldc2_w: |
205 return get_index_big(); | 199 return get_index_u2(); |
206 default: | 200 default: |
207 ShouldNotReachHere(); | 201 ShouldNotReachHere(); |
208 return 0; | 202 return 0; |
209 } | 203 } |
210 } | 204 } |
237 int ciBytecodeStream::get_field_index() { | 231 int ciBytecodeStream::get_field_index() { |
238 assert(cur_bc() == Bytecodes::_getfield || | 232 assert(cur_bc() == Bytecodes::_getfield || |
239 cur_bc() == Bytecodes::_putfield || | 233 cur_bc() == Bytecodes::_putfield || |
240 cur_bc() == Bytecodes::_getstatic || | 234 cur_bc() == Bytecodes::_getstatic || |
241 cur_bc() == Bytecodes::_putstatic, "wrong bc"); | 235 cur_bc() == Bytecodes::_putstatic, "wrong bc"); |
242 return get_index_big(); | 236 return get_index_u2_cpcache(); |
243 } | 237 } |
244 | 238 |
245 | 239 |
246 // ------------------------------------------------------------------ | 240 // ------------------------------------------------------------------ |
247 // ciBytecodeStream::get_field | 241 // ciBytecodeStream::get_field |
317 break; | 311 break; |
318 default: | 312 default: |
319 ShouldNotReachHere(); | 313 ShouldNotReachHere(); |
320 } | 314 } |
321 #endif | 315 #endif |
322 return get_index_int(); | 316 if (has_index_u4()) |
317 return get_index_u4(); // invokedynamic | |
318 return get_index_u2_cpcache(); | |
323 } | 319 } |
324 | 320 |
325 // ------------------------------------------------------------------ | 321 // ------------------------------------------------------------------ |
326 // ciBytecodeStream::get_method | 322 // ciBytecodeStream::get_method |
327 // | 323 // |