annotate src/share/vm/prims/methodComparator.hpp @ 3917:eca1193ca245

4965777: GC changes to support use of discovered field for pending references Summary: If and when the reference handler thread is able to use the discovered field to link reference objects in its pending list, so will GC. In that case, GC will scan through this field once a reference object has been placed on the pending list, but not scan that field before that stage, as the field is used by the concurrent GC thread to link discovered objects. When ReferenceHandleR thread does not use the discovered field for the purpose of linking the elements in the pending list, as would be the case in older JDKs, the JVM will fall back to the old behaviour of using the next field for that purpose. Reviewed-by: jcoomes, mchung, stefank
author ysr
date Wed, 07 Sep 2011 13:55:42 -0700
parents f95d63e2154a
children da91efe96a93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1913
3b2dea75431e 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 1552
diff changeset
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
25 #ifndef SHARE_VM_PRIMS_METHODCOMPARATOR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
26 #define SHARE_VM_PRIMS_METHODCOMPARATOR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
28 #include "interpreter/bytecodeStream.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
29 #include "oops/constantPoolOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
30 #include "oops/methodOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 class BciMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // methodComparator provides an interface for determining if methods of
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // different versions of classes are equivalent or switchable
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class MethodComparator {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
39 static BytecodeStream *_s_old, *_s_new;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 static constantPoolOop _old_cp, _new_cp;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 static BciMap *_bci_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static bool _switchable_test;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static GrowableArray<int> *_fwd_jmps;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static bool args_same(Bytecodes::Code c_old, Bytecodes::Code c_new);
1913
3b2dea75431e 6984311: JSR 292 needs optional bootstrap method parameters
jrose
parents: 1552
diff changeset
46 static bool pool_constants_same(int cpi_old, int cpi_new);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 static int check_stack_and_locals_size(methodOop old_method, methodOop new_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Check if the new method is equivalent to the old one modulo constant pool (EMCP).
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // Intuitive definition: two versions of the same method are EMCP, if they don't differ
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // on the source code level. Practically, we check whether the only difference between
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // method versions is some constantpool indices embedded into the bytecodes, and whether
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // these indices eventually point to the same constants for both method versions.
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static bool methods_EMCP(methodOop old_method, methodOop new_method);
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 static bool methods_switchable(methodOop old_method, methodOop new_method, BciMap &bci_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 };
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // ByteCode Index Map. For two versions of the same method, where the new version may contain
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // fragments not found in the old version, provides a mapping from an index of a bytecode in
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // the old method to the index of the same bytecode in the new method.
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 class BciMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
67 int *_old_bci, *_new_st_bci, *_new_end_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 int _cur_size, _cur_pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 int _pos;
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
72 BciMap() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _cur_size = 50;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _old_bci = (int*) malloc(sizeof(int) * _cur_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 _new_st_bci = (int*) malloc(sizeof(int) * _cur_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _new_end_bci = (int*) malloc(sizeof(int) * _cur_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _cur_pos = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 ~BciMap() {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 free(_old_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 free(_new_st_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 free(_new_end_bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Store the position of an added fragment, e.g.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 //
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // |<- old_bci
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // -----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Old method |invokevirtual 5|aload 1|...
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // -----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
92 //
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // |<- new_st_bci |<- new_end_bci
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // --------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // New method |invokevirual 5|aload 2|invokevirtual 6|aload 1|...
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // --------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // ^^^^^^^^^^^^^^^^^^^^^^^^
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Added fragment
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 void store_fragment_location(int old_bci, int new_st_bci, int new_end_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (_cur_pos == _cur_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 _cur_size += 10;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 _old_bci = (int*) realloc(_old_bci, sizeof(int) * _cur_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 _new_st_bci = (int*) realloc(_new_st_bci, sizeof(int) * _cur_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _new_end_bci = (int*) realloc(_new_end_bci, sizeof(int) * _cur_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 _old_bci[_cur_pos] = old_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _new_st_bci[_cur_pos] = new_st_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _new_end_bci[_cur_pos] = new_end_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
110 _cur_pos++;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 int new_bci_for_old(int old_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (_cur_pos == 0 || old_bci < _old_bci[0]) return old_bci;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 _pos = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 while (_pos < _cur_pos && old_bci >= _old_bci[_pos])
a61af66fc99e Initial load
duke
parents:
diff changeset
117 _pos++;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return _new_end_bci[_pos-1] + (old_bci - _old_bci[_pos-1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // Test if two indexes - one in the old method and another in the new one - correspond
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // to the same bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bool old_and_new_locations_same(int old_dest_bci, int new_dest_bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 if (new_bci_for_old(old_dest_bci) == new_dest_bci)
a61af66fc99e Initial load
duke
parents:
diff changeset
125 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
126 else if (_old_bci[_pos-1] == old_dest_bci)
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return (new_dest_bci == _new_st_bci[_pos-1]);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 else return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
131
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1913
diff changeset
132 #endif // SHARE_VM_PRIMS_METHODCOMPARATOR_HPP