hotspot/src/share/vm/oops/methodDataOop.cpp
changeset 7913 dd096a83bdbb
parent 7397 5b173b4ca846
child 8297 f05d10c1c4b8
child 8322 8f11ba61239f
equal deleted inserted replaced
7901:ea3d83447861 7913:dd096a83bdbb
     1 /*
     1 /*
     2  * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2000, 2011, Oracle and/or its affiliates. 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.
   415 // case was taken and specify the data displacment for each branch target.
   415 // case was taken and specify the data displacment for each branch target.
   416 
   416 
   417 int MultiBranchData::compute_cell_count(BytecodeStream* stream) {
   417 int MultiBranchData::compute_cell_count(BytecodeStream* stream) {
   418   int cell_count = 0;
   418   int cell_count = 0;
   419   if (stream->code() == Bytecodes::_tableswitch) {
   419   if (stream->code() == Bytecodes::_tableswitch) {
   420     Bytecode_tableswitch* sw = Bytecode_tableswitch_at(stream->bcp());
   420     Bytecode_tableswitch sw(stream->method()(), stream->bcp());
   421     cell_count = 1 + per_case_cell_count * (1 + sw->length()); // 1 for default
   421     cell_count = 1 + per_case_cell_count * (1 + sw.length()); // 1 for default
   422   } else {
   422   } else {
   423     Bytecode_lookupswitch* sw = Bytecode_lookupswitch_at(stream->bcp());
   423     Bytecode_lookupswitch sw(stream->method()(), stream->bcp());
   424     cell_count = 1 + per_case_cell_count * (sw->number_of_pairs() + 1); // 1 for default
   424     cell_count = 1 + per_case_cell_count * (sw.number_of_pairs() + 1); // 1 for default
   425   }
   425   }
   426   return cell_count;
   426   return cell_count;
   427 }
   427 }
   428 
   428 
   429 void MultiBranchData::post_initialize(BytecodeStream* stream,
   429 void MultiBranchData::post_initialize(BytecodeStream* stream,
   432   int target;
   432   int target;
   433   int my_di;
   433   int my_di;
   434   int target_di;
   434   int target_di;
   435   int offset;
   435   int offset;
   436   if (stream->code() == Bytecodes::_tableswitch) {
   436   if (stream->code() == Bytecodes::_tableswitch) {
   437     Bytecode_tableswitch* sw = Bytecode_tableswitch_at(stream->bcp());
   437     Bytecode_tableswitch sw(stream->method()(), stream->bcp());
   438     int len = sw->length();
   438     int len = sw.length();
   439     assert(array_len() == per_case_cell_count * (len + 1), "wrong len");
   439     assert(array_len() == per_case_cell_count * (len + 1), "wrong len");
   440     for (int count = 0; count < len; count++) {
   440     for (int count = 0; count < len; count++) {
   441       target = sw->dest_offset_at(count) + bci();
   441       target = sw.dest_offset_at(count) + bci();
   442       my_di = mdo->dp_to_di(dp());
   442       my_di = mdo->dp_to_di(dp());
   443       target_di = mdo->bci_to_di(target);
   443       target_di = mdo->bci_to_di(target);
   444       offset = target_di - my_di;
   444       offset = target_di - my_di;
   445       set_displacement_at(count, offset);
   445       set_displacement_at(count, offset);
   446     }
   446     }
   447     target = sw->default_offset() + bci();
   447     target = sw.default_offset() + bci();
   448     my_di = mdo->dp_to_di(dp());
   448     my_di = mdo->dp_to_di(dp());
   449     target_di = mdo->bci_to_di(target);
   449     target_di = mdo->bci_to_di(target);
   450     offset = target_di - my_di;
   450     offset = target_di - my_di;
   451     set_default_displacement(offset);
   451     set_default_displacement(offset);
   452 
   452 
   453   } else {
   453   } else {
   454     Bytecode_lookupswitch* sw = Bytecode_lookupswitch_at(stream->bcp());
   454     Bytecode_lookupswitch sw(stream->method()(), stream->bcp());
   455     int npairs = sw->number_of_pairs();
   455     int npairs = sw.number_of_pairs();
   456     assert(array_len() == per_case_cell_count * (npairs + 1), "wrong len");
   456     assert(array_len() == per_case_cell_count * (npairs + 1), "wrong len");
   457     for (int count = 0; count < npairs; count++) {
   457     for (int count = 0; count < npairs; count++) {
   458       LookupswitchPair *pair = sw->pair_at(count);
   458       LookupswitchPair pair = sw.pair_at(count);
   459       target = pair->offset() + bci();
   459       target = pair.offset() + bci();
   460       my_di = mdo->dp_to_di(dp());
   460       my_di = mdo->dp_to_di(dp());
   461       target_di = mdo->bci_to_di(target);
   461       target_di = mdo->bci_to_di(target);
   462       offset = target_di - my_di;
   462       offset = target_di - my_di;
   463       set_displacement_at(count, offset);
   463       set_displacement_at(count, offset);
   464     }
   464     }
   465     target = sw->default_offset() + bci();
   465     target = sw.default_offset() + bci();
   466     my_di = mdo->dp_to_di(dp());
   466     my_di = mdo->dp_to_di(dp());
   467     target_di = mdo->bci_to_di(target);
   467     target_di = mdo->bci_to_di(target);
   468     offset = target_di - my_di;
   468     offset = target_di - my_di;
   469     set_default_displacement(offset);
   469     set_default_displacement(offset);
   470   }
   470   }