1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Wed Jan 12 13:59:18 2011 -0800 1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Thu Jan 13 22:15:41 2011 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -319,24 +319,24 @@ 1.11 1.12 case Bytecodes::_tableswitch: { 1.13 // set block for each case 1.14 - Bytecode_tableswitch *switch_ = Bytecode_tableswitch_at(s.cur_bcp()); 1.15 - int l = switch_->length(); 1.16 + Bytecode_tableswitch sw(&s); 1.17 + int l = sw.length(); 1.18 for (int i = 0; i < l; i++) { 1.19 - make_block_at(cur_bci + switch_->dest_offset_at(i), current); 1.20 + make_block_at(cur_bci + sw.dest_offset_at(i), current); 1.21 } 1.22 - make_block_at(cur_bci + switch_->default_offset(), current); 1.23 + make_block_at(cur_bci + sw.default_offset(), current); 1.24 current = NULL; 1.25 break; 1.26 } 1.27 1.28 case Bytecodes::_lookupswitch: { 1.29 // set block for each case 1.30 - Bytecode_lookupswitch *switch_ = Bytecode_lookupswitch_at(s.cur_bcp()); 1.31 - int l = switch_->number_of_pairs(); 1.32 + Bytecode_lookupswitch sw(&s); 1.33 + int l = sw.number_of_pairs(); 1.34 for (int i = 0; i < l; i++) { 1.35 - make_block_at(cur_bci + switch_->pair_at(i)->offset(), current); 1.36 + make_block_at(cur_bci + sw.pair_at(i).offset(), current); 1.37 } 1.38 - make_block_at(cur_bci + switch_->default_offset(), current); 1.39 + make_block_at(cur_bci + sw.default_offset(), current); 1.40 current = NULL; 1.41 break; 1.42 } 1.43 @@ -1275,15 +1275,15 @@ 1.44 1.45 1.46 void GraphBuilder::table_switch() { 1.47 - Bytecode_tableswitch* switch_ = Bytecode_tableswitch_at(method()->code() + bci()); 1.48 - const int l = switch_->length(); 1.49 + Bytecode_tableswitch sw(stream()); 1.50 + const int l = sw.length(); 1.51 if (CanonicalizeNodes && l == 1) { 1.52 // total of 2 successors => use If instead of switch 1.53 // Note: This code should go into the canonicalizer as soon as it can 1.54 // can handle canonicalized forms that contain more than one node. 1.55 - Value key = append(new Constant(new IntConstant(switch_->low_key()))); 1.56 - BlockBegin* tsux = block_at(bci() + switch_->dest_offset_at(0)); 1.57 - BlockBegin* fsux = block_at(bci() + switch_->default_offset()); 1.58 + Value key = append(new Constant(new IntConstant(sw.low_key()))); 1.59 + BlockBegin* tsux = block_at(bci() + sw.dest_offset_at(0)); 1.60 + BlockBegin* fsux = block_at(bci() + sw.default_offset()); 1.61 bool is_bb = tsux->bci() < bci() || fsux->bci() < bci(); 1.62 ValueStack* state_before = is_bb ? copy_state_before() : NULL; 1.63 append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); 1.64 @@ -1293,29 +1293,29 @@ 1.65 int i; 1.66 bool has_bb = false; 1.67 for (i = 0; i < l; i++) { 1.68 - sux->at_put(i, block_at(bci() + switch_->dest_offset_at(i))); 1.69 - if (switch_->dest_offset_at(i) < 0) has_bb = true; 1.70 + sux->at_put(i, block_at(bci() + sw.dest_offset_at(i))); 1.71 + if (sw.dest_offset_at(i) < 0) has_bb = true; 1.72 } 1.73 // add default successor 1.74 - sux->at_put(i, block_at(bci() + switch_->default_offset())); 1.75 + sux->at_put(i, block_at(bci() + sw.default_offset())); 1.76 ValueStack* state_before = has_bb ? copy_state_before() : NULL; 1.77 - append(new TableSwitch(ipop(), sux, switch_->low_key(), state_before, has_bb)); 1.78 + append(new TableSwitch(ipop(), sux, sw.low_key(), state_before, has_bb)); 1.79 } 1.80 } 1.81 1.82 1.83 void GraphBuilder::lookup_switch() { 1.84 - Bytecode_lookupswitch* switch_ = Bytecode_lookupswitch_at(method()->code() + bci()); 1.85 - const int l = switch_->number_of_pairs(); 1.86 + Bytecode_lookupswitch sw(stream()); 1.87 + const int l = sw.number_of_pairs(); 1.88 if (CanonicalizeNodes && l == 1) { 1.89 // total of 2 successors => use If instead of switch 1.90 // Note: This code should go into the canonicalizer as soon as it can 1.91 // can handle canonicalized forms that contain more than one node. 1.92 // simplify to If 1.93 - LookupswitchPair* pair = switch_->pair_at(0); 1.94 - Value key = append(new Constant(new IntConstant(pair->match()))); 1.95 - BlockBegin* tsux = block_at(bci() + pair->offset()); 1.96 - BlockBegin* fsux = block_at(bci() + switch_->default_offset()); 1.97 + LookupswitchPair pair = sw.pair_at(0); 1.98 + Value key = append(new Constant(new IntConstant(pair.match()))); 1.99 + BlockBegin* tsux = block_at(bci() + pair.offset()); 1.100 + BlockBegin* fsux = block_at(bci() + sw.default_offset()); 1.101 bool is_bb = tsux->bci() < bci() || fsux->bci() < bci(); 1.102 ValueStack* state_before = is_bb ? copy_state_before() : NULL; 1.103 append(new If(ipop(), If::eql, true, key, tsux, fsux, state_before, is_bb)); 1.104 @@ -1326,13 +1326,13 @@ 1.105 int i; 1.106 bool has_bb = false; 1.107 for (i = 0; i < l; i++) { 1.108 - LookupswitchPair* pair = switch_->pair_at(i); 1.109 - if (pair->offset() < 0) has_bb = true; 1.110 - sux->at_put(i, block_at(bci() + pair->offset())); 1.111 - keys->at_put(i, pair->match()); 1.112 + LookupswitchPair pair = sw.pair_at(i); 1.113 + if (pair.offset() < 0) has_bb = true; 1.114 + sux->at_put(i, block_at(bci() + pair.offset())); 1.115 + keys->at_put(i, pair.match()); 1.116 } 1.117 // add default successor 1.118 - sux->at_put(i, block_at(bci() + switch_->default_offset())); 1.119 + sux->at_put(i, block_at(bci() + sw.default_offset())); 1.120 ValueStack* state_before = has_bb ? copy_state_before() : NULL; 1.121 append(new LookupSwitch(ipop(), sux, keys, state_before, has_bb)); 1.122 }