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 // 26 // 27 // Compute stack layouts for each instruction in method. 28 // 29 // Problems: 30 // - What to do about jsr with different types of local vars? 31 // Need maps that are conditional on jsr path? 32 // - Jsr and exceptions should be done more efficiently (the retAddr stuff) 33 // 34 // Alternative: 35 // - Could extend verifier to provide this information. 36 // For: one fewer abstract interpreter to maintain. Against: the verifier 37 // solves a bigger problem so slower (undesirable to force verification of 38 // everything?). 39 // 40 // Algorithm: 41 // Partition bytecodes into basic blocks 42 // For each basic block: store entry state (vars, stack). For instructions 43 // inside basic blocks we do not store any state (instead we recompute it 44 // from state produced by previous instruction). 68 // find basic blocks; 69 // initialize them with uninitialized state; 70 // initialize first BB according to method signature; 71 // mark first BB changed 72 // while (some BB is changed) do { 73 // perform abstract interpration of all bytecodes in BB; 74 // merge exit state of BB into entry state of all successor BBs, 75 // noting if any of these change; 76 // } 77 // 78 // One additional complication is necessary. The jsr instruction pushes 79 // a return PC on the stack (a 'p' type in the abstract interpretation). 80 // To be able to process "ret" bytecodes, we keep track of these return 81 // PC's in a 'retAddrs' structure in abstract interpreter context (when 82 // processing a "ret" bytecodes, it is not sufficient to know that it gets 83 // an argument of the right type 'p'; we need to know which address it 84 // returns to). 85 // 86 // (Note this comment is borrowed form the original author of the algorithm) 87 88 #include "incls/_precompiled.incl" 89 #include "incls/_generateOopMap.cpp.incl" 90 91 // ComputeCallStack 92 // 93 // Specialization of SignatureIterator - compute the effects of a call 94 // 95 class ComputeCallStack : public SignatureIterator { 96 CellTypeState *_effect; 97 int _idx; 98 99 void setup(); 100 void set(CellTypeState state) { _effect[_idx++] = state; } 101 int length() { return _idx; }; 102 103 virtual void do_bool () { set(CellTypeState::value); }; 104 virtual void do_char () { set(CellTypeState::value); }; 105 virtual void do_float () { set(CellTypeState::value); }; 106 virtual void do_byte () { set(CellTypeState::value); }; 107 virtual void do_short () { set(CellTypeState::value); }; 108 virtual void do_int () { set(CellTypeState::value); }; 109 virtual void do_void () { set(CellTypeState::bottom);}; 110 virtual void do_object(int begin, int end) { set(CellTypeState::ref); }; | 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 "oops/generateOopMap.hpp" 28 #include "oops/oop.inline.hpp" 29 #include "oops/symbolOop.hpp" 30 #include "runtime/handles.inline.hpp" 31 #include "runtime/java.hpp" 32 #include "runtime/relocator.hpp" 33 #include "utilities/bitMap.inline.hpp" 34 35 // 36 // 37 // Compute stack layouts for each instruction in method. 38 // 39 // Problems: 40 // - What to do about jsr with different types of local vars? 41 // Need maps that are conditional on jsr path? 42 // - Jsr and exceptions should be done more efficiently (the retAddr stuff) 43 // 44 // Alternative: 45 // - Could extend verifier to provide this information. 46 // For: one fewer abstract interpreter to maintain. Against: the verifier 47 // solves a bigger problem so slower (undesirable to force verification of 48 // everything?). 49 // 50 // Algorithm: 51 // Partition bytecodes into basic blocks 52 // For each basic block: store entry state (vars, stack). For instructions 53 // inside basic blocks we do not store any state (instead we recompute it 54 // from state produced by previous instruction). 78 // find basic blocks; 79 // initialize them with uninitialized state; 80 // initialize first BB according to method signature; 81 // mark first BB changed 82 // while (some BB is changed) do { 83 // perform abstract interpration of all bytecodes in BB; 84 // merge exit state of BB into entry state of all successor BBs, 85 // noting if any of these change; 86 // } 87 // 88 // One additional complication is necessary. The jsr instruction pushes 89 // a return PC on the stack (a 'p' type in the abstract interpretation). 90 // To be able to process "ret" bytecodes, we keep track of these return 91 // PC's in a 'retAddrs' structure in abstract interpreter context (when 92 // processing a "ret" bytecodes, it is not sufficient to know that it gets 93 // an argument of the right type 'p'; we need to know which address it 94 // returns to). 95 // 96 // (Note this comment is borrowed form the original author of the algorithm) 97 98 // ComputeCallStack 99 // 100 // Specialization of SignatureIterator - compute the effects of a call 101 // 102 class ComputeCallStack : public SignatureIterator { 103 CellTypeState *_effect; 104 int _idx; 105 106 void setup(); 107 void set(CellTypeState state) { _effect[_idx++] = state; } 108 int length() { return _idx; }; 109 110 virtual void do_bool () { set(CellTypeState::value); }; 111 virtual void do_char () { set(CellTypeState::value); }; 112 virtual void do_float () { set(CellTypeState::value); }; 113 virtual void do_byte () { set(CellTypeState::value); }; 114 virtual void do_short () { set(CellTypeState::value); }; 115 virtual void do_int () { set(CellTypeState::value); }; 116 virtual void do_void () { set(CellTypeState::bottom);}; 117 virtual void do_object(int begin, int end) { set(CellTypeState::ref); }; |