< prev index next >

src/share/vm/oops/generateOopMap.cpp

Print this page
rev 13015 : imported patch 8180755-remove-bitmap-inline-hpp-include
rev 13016 : [mq]: 8180755-dholmes-review
   1 /*
   2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "interpreter/bytecodeStream.hpp"
  27 #include "logging/log.hpp"
  28 #include "oops/generateOopMap.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "oops/symbol.hpp"

  31 #include "runtime/handles.inline.hpp"
  32 #include "runtime/java.hpp"
  33 #include "runtime/relocator.hpp"
  34 #include "runtime/timerTrace.hpp"
  35 #include "utilities/bitMap.inline.hpp"
  36 #include "utilities/ostream.hpp"
  37 #include "prims/methodHandles.hpp"
  38 
  39 //
  40 //
  41 // Compute stack layouts for each instruction in method.
  42 //
  43 //  Problems:
  44 //  - What to do about jsr with different types of local vars?
  45 //  Need maps that are conditional on jsr path?
  46 //  - Jsr and exceptions should be done more efficiently (the retAddr stuff)
  47 //
  48 //  Alternative:
  49 //  - Could extend verifier to provide this information.
  50 //    For: one fewer abstract interpreter to maintain. Against: the verifier
  51 //    solves a bigger problem so slower (undesirable to force verification of
  52 //    everything?).
  53 //
  54 //  Algorithm:
  55 //    Partition bytecodes into basic blocks
  56 //    For each basic block: store entry state (vars, stack). For instructions
  57 //    inside basic blocks we do not store any state (instead we recompute it


 418     if (!fellThrough)
 419         bb_mark_fct(this, bci, NULL);
 420 
 421     fellThrough = jump_targets_do(&bcs, &GenerateOopMap::bb_mark_fct, NULL);
 422 
 423      /* We will also mark successors of jsr's as basic block headers. */
 424     switch (bytecode) {
 425       case Bytecodes::_jsr:
 426         assert(!fellThrough, "should not happen");
 427         bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
 428         break;
 429       case Bytecodes::_jsr_w:
 430         assert(!fellThrough, "should not happen");
 431         bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
 432         break;
 433     }
 434 
 435     if (possible_gc_point(&bcs))
 436       _gc_points++;
 437   }




 438 }
 439 
 440 void GenerateOopMap::reachable_basicblock(GenerateOopMap *c, int bci, int *data) {
 441   assert(bci>= 0 && bci < c->method()->code_size(), "index out of bounds");
 442   BasicBlock* bb = c->get_basic_block_at(bci);
 443   if (bb->is_dead()) {
 444     bb->mark_as_alive();
 445     *data = 1; // Mark basicblock as changed
 446   }
 447 }
 448 
 449 
 450 void GenerateOopMap::mark_reachable_code() {
 451   int change = 1; // int to get function pointers to work
 452 
 453   // Mark entry basic block as alive and all exception handlers
 454   _basic_blocks[0].mark_as_alive();
 455   ExceptionTable excps(method());
 456   for(int i = 0; i < excps.length(); i++) {
 457     BasicBlock *bb = get_basic_block_at(excps.handler_pc(i));


   1 /*
   2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "interpreter/bytecodeStream.hpp"
  27 #include "logging/log.hpp"
  28 #include "oops/generateOopMap.hpp"
  29 #include "oops/oop.inline.hpp"
  30 #include "oops/symbol.hpp"
  31 #include "prims/methodHandles.hpp"
  32 #include "runtime/handles.inline.hpp"
  33 #include "runtime/java.hpp"
  34 #include "runtime/relocator.hpp"
  35 #include "runtime/timerTrace.hpp"
  36 #include "utilities/bitMap.inline.hpp"
  37 #include "utilities/ostream.hpp"

  38 
  39 //
  40 //
  41 // Compute stack layouts for each instruction in method.
  42 //
  43 //  Problems:
  44 //  - What to do about jsr with different types of local vars?
  45 //  Need maps that are conditional on jsr path?
  46 //  - Jsr and exceptions should be done more efficiently (the retAddr stuff)
  47 //
  48 //  Alternative:
  49 //  - Could extend verifier to provide this information.
  50 //    For: one fewer abstract interpreter to maintain. Against: the verifier
  51 //    solves a bigger problem so slower (undesirable to force verification of
  52 //    everything?).
  53 //
  54 //  Algorithm:
  55 //    Partition bytecodes into basic blocks
  56 //    For each basic block: store entry state (vars, stack). For instructions
  57 //    inside basic blocks we do not store any state (instead we recompute it


 418     if (!fellThrough)
 419         bb_mark_fct(this, bci, NULL);
 420 
 421     fellThrough = jump_targets_do(&bcs, &GenerateOopMap::bb_mark_fct, NULL);
 422 
 423      /* We will also mark successors of jsr's as basic block headers. */
 424     switch (bytecode) {
 425       case Bytecodes::_jsr:
 426         assert(!fellThrough, "should not happen");
 427         bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
 428         break;
 429       case Bytecodes::_jsr_w:
 430         assert(!fellThrough, "should not happen");
 431         bb_mark_fct(this, bci + Bytecodes::length_for(bytecode), NULL);
 432         break;
 433     }
 434 
 435     if (possible_gc_point(&bcs))
 436       _gc_points++;
 437   }
 438 }
 439 
 440 void GenerateOopMap::set_bbmark_bit(int bci) {
 441   _bb_hdr_bits.at_put(bci, true);
 442 }
 443 
 444 void GenerateOopMap::reachable_basicblock(GenerateOopMap *c, int bci, int *data) {
 445   assert(bci>= 0 && bci < c->method()->code_size(), "index out of bounds");
 446   BasicBlock* bb = c->get_basic_block_at(bci);
 447   if (bb->is_dead()) {
 448     bb->mark_as_alive();
 449     *data = 1; // Mark basicblock as changed
 450   }
 451 }
 452 
 453 
 454 void GenerateOopMap::mark_reachable_code() {
 455   int change = 1; // int to get function pointers to work
 456 
 457   // Mark entry basic block as alive and all exception handlers
 458   _basic_blocks[0].mark_as_alive();
 459   ExceptionTable excps(method());
 460   for(int i = 0; i < excps.length(); i++) {
 461     BasicBlock *bb = get_basic_block_at(excps.handler_pc(i));


< prev index next >