src/share/vm/prims/methodComparator.hpp

changeset 4037
da91efe96a93
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
equal deleted inserted replaced
4036:36d1d483d5d6 4037:da91efe96a93
1 /* 1 /*
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2000, 2012, 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.
24 24
25 #ifndef SHARE_VM_PRIMS_METHODCOMPARATOR_HPP 25 #ifndef SHARE_VM_PRIMS_METHODCOMPARATOR_HPP
26 #define SHARE_VM_PRIMS_METHODCOMPARATOR_HPP 26 #define SHARE_VM_PRIMS_METHODCOMPARATOR_HPP
27 27
28 #include "interpreter/bytecodeStream.hpp" 28 #include "interpreter/bytecodeStream.hpp"
29 #include "oops/constantPoolOop.hpp" 29 #include "oops/constantPool.hpp"
30 #include "oops/methodOop.hpp" 30 #include "oops/method.hpp"
31 31
32 class BciMap; 32 class BciMap;
33 33
34 // methodComparator provides an interface for determining if methods of 34 // methodComparator provides an interface for determining if methods of
35 // different versions of classes are equivalent or switchable 35 // different versions of classes are equivalent or switchable
36 36
37 class MethodComparator { 37 class MethodComparator {
38 private: 38 private:
39 static BytecodeStream *_s_old, *_s_new; 39 static BytecodeStream *_s_old, *_s_new;
40 static constantPoolOop _old_cp, _new_cp; 40 static ConstantPool* _old_cp;
41 static ConstantPool* _new_cp;
41 static BciMap *_bci_map; 42 static BciMap *_bci_map;
42 static bool _switchable_test; 43 static bool _switchable_test;
43 static GrowableArray<int> *_fwd_jmps; 44 static GrowableArray<int> *_fwd_jmps;
44 45
45 static bool args_same(Bytecodes::Code c_old, Bytecodes::Code c_new); 46 static bool args_same(Bytecodes::Code c_old, Bytecodes::Code c_new);
46 static bool pool_constants_same(int cpi_old, int cpi_new); 47 static bool pool_constants_same(int cpi_old, int cpi_new);
47 static int check_stack_and_locals_size(methodOop old_method, methodOop new_method); 48 static int check_stack_and_locals_size(Method* old_method, Method* new_method);
48 49
49 public: 50 public:
50 // Check if the new method is equivalent to the old one modulo constant pool (EMCP). 51 // Check if the new method is equivalent to the old one modulo constant pool (EMCP).
51 // Intuitive definition: two versions of the same method are EMCP, if they don't differ 52 // Intuitive definition: two versions of the same method are EMCP, if they don't differ
52 // on the source code level. Practically, we check whether the only difference between 53 // on the source code level. Practically, we check whether the only difference between
53 // method versions is some constantpool indices embedded into the bytecodes, and whether 54 // method versions is some constantpool indices embedded into the bytecodes, and whether
54 // these indices eventually point to the same constants for both method versions. 55 // these indices eventually point to the same constants for both method versions.
55 static bool methods_EMCP(methodOop old_method, methodOop new_method); 56 static bool methods_EMCP(Method* old_method, Method* new_method);
56 57
57 static bool methods_switchable(methodOop old_method, methodOop new_method, BciMap &bci_map); 58 static bool methods_switchable(Method* old_method, Method* new_method, BciMap &bci_map);
58 }; 59 };
59 60
60 61
61 // ByteCode Index Map. For two versions of the same method, where the new version may contain 62 // ByteCode Index Map. For two versions of the same method, where the new version may contain
62 // fragments not found in the old version, provides a mapping from an index of a bytecode in 63 // fragments not found in the old version, provides a mapping from an index of a bytecode in

mercurial