Mercurial > hg > truffle
diff 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 |
line wrap: on
line diff
--- a/src/share/vm/ci/ciStreams.cpp Fri May 21 02:59:24 2010 -0700 +++ b/src/share/vm/ci/ciStreams.cpp Sun May 23 01:38:26 2010 -0700 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved. + * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,27 +81,21 @@ // providing accessors for constant pool items. // ------------------------------------------------------------------ -// ciBytecodeStream::wide -// -// Special handling for the wide bytcode -Bytecodes::Code ciBytecodeStream::wide() -{ - // Get following bytecode; do not return wide - Bytecodes::Code bc = (Bytecodes::Code)_pc[1]; - _pc += 2; // Skip both bytecodes - _pc += 2; // Skip index always - if( bc == Bytecodes::_iinc ) - _pc += 2; // Skip optional constant - _was_wide = _pc; // Flag last wide bytecode found - return bc; -} - -// ------------------------------------------------------------------ -// ciBytecodeStream::table +// ciBytecodeStream::next_wide_or_table // // Special handling for switch ops -Bytecodes::Code ciBytecodeStream::table( Bytecodes::Code bc ) { - switch( bc ) { // Check for special bytecode handling +Bytecodes::Code ciBytecodeStream::next_wide_or_table(Bytecodes::Code bc) { + switch (bc) { // Check for special bytecode handling + case Bytecodes::_wide: + // Special handling for the wide bytcode + // Get following bytecode; do not return wide + assert(Bytecodes::Code(_pc[0]) == Bytecodes::_wide, ""); + bc = Bytecodes::java_code(_raw_bc = (Bytecodes::Code)_pc[1]); + assert(Bytecodes::wide_length_for(bc) > 2, "must make progress"); + _pc += Bytecodes::wide_length_for(bc); + _was_wide = _pc; // Flag last wide bytecode found + assert(is_wide(), "accessor works right"); + break; case Bytecodes::_lookupswitch: _pc++; // Skip wide bytecode @@ -164,7 +158,7 @@ int ciBytecodeStream::get_klass_index() const { switch(cur_bc()) { case Bytecodes::_ldc: - return get_index(); + return get_index_u1(); case Bytecodes::_ldc_w: case Bytecodes::_ldc2_w: case Bytecodes::_checkcast: @@ -173,7 +167,7 @@ case Bytecodes::_multianewarray: case Bytecodes::_new: case Bytecodes::_newarray: - return get_index_big(); + return get_index_u2(); default: ShouldNotReachHere(); return 0; @@ -199,10 +193,10 @@ int ciBytecodeStream::get_constant_index() const { switch(cur_bc()) { case Bytecodes::_ldc: - return get_index(); + return get_index_u1(); case Bytecodes::_ldc_w: case Bytecodes::_ldc2_w: - return get_index_big(); + return get_index_u2(); default: ShouldNotReachHere(); return 0; @@ -239,7 +233,7 @@ cur_bc() == Bytecodes::_putfield || cur_bc() == Bytecodes::_getstatic || cur_bc() == Bytecodes::_putstatic, "wrong bc"); - return get_index_big(); + return get_index_u2_cpcache(); } @@ -319,7 +313,9 @@ ShouldNotReachHere(); } #endif - return get_index_int(); + if (has_index_u4()) + return get_index_u4(); // invokedynamic + return get_index_u2_cpcache(); } // ------------------------------------------------------------------