/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "interpreter/bytecodeStream.hpp"
#include "oops/constantPoolOop.hpp"
#include "oops/methodOop.hpp"
class BciMap;
// methodComparator provides an interface for determining if methods of
// different versions of classes are equivalent or switchable
class MethodComparator {
private:
static bool _switchable_test;
public:
// Check if the new method is equivalent to the old one modulo constant pool (EMCP).
// Intuitive definition: two versions of the same method are EMCP, if they don't differ
// on the source code level. Practically, we check whether the only difference between
// method versions is some constantpool indices embedded into the bytecodes, and whether
// these indices eventually point to the same constants for both method versions.
};
// ByteCode Index Map. For two versions of the same method, where the new version may contain
// fragments not found in the old version, provides a mapping from an index of a bytecode in
// the old method to the index of the same bytecode in the new method.
class BciMap {
private:
int _pos;
public:
BciMap() {
_cur_size = 50;
_cur_pos = 0;
}
~BciMap() {
}
// Store the position of an added fragment, e.g.
//
// |<- old_bci
// -----------------------------------------
// Old method |invokevirtual 5|aload 1|...
// -----------------------------------------
//
// |<- new_st_bci |<- new_end_bci
// --------------------------------------------------------------------
// New method |invokevirual 5|aload 2|invokevirtual 6|aload 1|...
// --------------------------------------------------------------------
// ^^^^^^^^^^^^^^^^^^^^^^^^
// Added fragment
_cur_size += 10;
}
_cur_pos++;
}
_pos = 1;
_pos++;
}
// Test if two indexes - one in the old method and another in the new one - correspond
// to the same bytecode
return true;
else return false;
}
};
#endif // SHARE_VM_PRIMS_METHODCOMPARATOR_HPP