comparison src/share/vm/interpreter/rewriter.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 1eb493f33423
comparison
equal deleted inserted replaced
1564:61b2245abf36 1565:ab102d5d923e
1 /* 1 /*
2 * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 1998-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.
101 } 101 }
102 } 102 }
103 103
104 104
105 // Rewrite a classfile-order CP index into a native-order CPC index. 105 // Rewrite a classfile-order CP index into a native-order CPC index.
106 int Rewriter::rewrite_member_reference(address bcp, int offset) { 106 void Rewriter::rewrite_member_reference(address bcp, int offset) {
107 address p = bcp + offset; 107 address p = bcp + offset;
108 int cp_index = Bytes::get_Java_u2(p); 108 int cp_index = Bytes::get_Java_u2(p);
109 int cache_index = cp_entry_to_cp_cache(cp_index); 109 int cache_index = cp_entry_to_cp_cache(cp_index);
110 Bytes::put_native_u2(p, cache_index); 110 Bytes::put_native_u2(p, cache_index);
111 return cp_index; 111 }
112 } 112
113 113
114 114 void Rewriter::rewrite_invokedynamic(address bcp, int offset) {
115 void Rewriter::rewrite_invokedynamic(address bcp, int offset, int delete_me) {
116 address p = bcp + offset; 115 address p = bcp + offset;
117 assert(p[-1] == Bytecodes::_invokedynamic, ""); 116 assert(p[-1] == Bytecodes::_invokedynamic, "");
118 int cp_index = Bytes::get_Java_u2(p); 117 int cp_index = Bytes::get_Java_u2(p);
119 int cpc = maybe_add_cp_cache_entry(cp_index); // add lazily 118 int cpc = maybe_add_cp_cache_entry(cp_index); // add lazily
120 int cpc2 = add_secondary_cp_cache_entry(cpc); 119 int cpc2 = add_secondary_cp_cache_entry(cpc);
176 175
177 switch (c) { 176 switch (c) {
178 case Bytecodes::_lookupswitch : { 177 case Bytecodes::_lookupswitch : {
179 #ifndef CC_INTERP 178 #ifndef CC_INTERP
180 Bytecode_lookupswitch* bc = Bytecode_lookupswitch_at(bcp); 179 Bytecode_lookupswitch* bc = Bytecode_lookupswitch_at(bcp);
181 bc->set_code( 180 (*bcp) = (
182 bc->number_of_pairs() < BinarySwitchThreshold 181 bc->number_of_pairs() < BinarySwitchThreshold
183 ? Bytecodes::_fast_linearswitch 182 ? Bytecodes::_fast_linearswitch
184 : Bytecodes::_fast_binaryswitch 183 : Bytecodes::_fast_binaryswitch
185 ); 184 );
186 #endif 185 #endif
195 case Bytecodes::_invokestatic : 194 case Bytecodes::_invokestatic :
196 case Bytecodes::_invokeinterface: 195 case Bytecodes::_invokeinterface:
197 rewrite_member_reference(bcp, prefix_length+1); 196 rewrite_member_reference(bcp, prefix_length+1);
198 break; 197 break;
199 case Bytecodes::_invokedynamic: 198 case Bytecodes::_invokedynamic:
200 rewrite_invokedynamic(bcp, prefix_length+1, int(sizeof"@@@@DELETE ME")); 199 rewrite_invokedynamic(bcp, prefix_length+1);
201 break; 200 break;
202 case Bytecodes::_jsr : // fall through 201 case Bytecodes::_jsr : // fall through
203 case Bytecodes::_jsr_w : nof_jsrs++; break; 202 case Bytecodes::_jsr_w : nof_jsrs++; break;
204 case Bytecodes::_monitorenter : // fall through 203 case Bytecodes::_monitorenter : // fall through
205 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break; 204 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break;