annotate src/share/vm/interpreter/rewriter.hpp @ 13390:d61a1a166f44

8028347: Rewriter::scan_method asserts with array oob in RT_Baseline Summary: Fix reversing rewriting for invokespecial Reviewed-by: jrose, hseigel
author coleenp
date Fri, 15 Nov 2013 17:20:22 -0500
parents 41cb10cbfb3c
children 26c3b944dc35
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
2 * Copyright (c) 1998, 2013, 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: 1138
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
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: 1138
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: 1660
diff changeset
25 #ifndef SHARE_VM_INTERPRETER_REWRITER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
26 #define SHARE_VM_INTERPRETER_REWRITER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
28 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
29 #include "runtime/handles.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
30 #include "utilities/growableArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
31
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // The Rewriter adds caches to the constant pool and rewrites bytecode indices
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // pointing into the constant pool for better interpreter performance.
a61af66fc99e Initial load
duke
parents:
diff changeset
34
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
35 class Rewriter: public StackObj {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36 private:
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
37 instanceKlassHandle _klass;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
38 constantPoolHandle _pool;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
39 Array<Method*>* _methods;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
40 intArray _cp_map;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
41 intStack _cp_cache_map; // for Methodref, Fieldref,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
42 // InterfaceMethodref and InvokeDynamic
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
43 intArray _reference_map; // maps from cp index to resolved_refs index (or -1)
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
44 intStack _resolved_references_map; // for strings, methodHandle, methodType
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
45 intStack _invokedynamic_references_map; // for invokedynamic resolved refs
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
46 intArray _method_handle_invokers;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
47 int _resolved_reference_limit;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
48
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
49 // For mapping invokedynamic bytecodes, which are discovered during method
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
50 // scanning. The invokedynamic entries are added at the end of the cpCache.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
51 // If there are any invokespecial/InterfaceMethodref special case bytecodes,
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
52 // these entries are added before invokedynamic entries so that the
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
53 // invokespecial bytecode 16 bit index doesn't overflow.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
54 intStack _invokedynamic_cp_cache_map;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
55
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
56 // For patching.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
57 GrowableArray<address>* _patch_invokedynamic_bcps;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
58 GrowableArray<int>* _patch_invokedynamic_refs;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
59
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
60 void init_maps(int length) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
61 _cp_map.initialize(length, -1);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
62 // Choose an initial value large enough that we don't get frequent
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
63 // calls to grow().
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
64 _cp_cache_map.initialize(length/2);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
65 // Also cache resolved objects, in another different cache.
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
66 _reference_map.initialize(length, -1);
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
67 _resolved_references_map.initialize(length/2);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
68 _invokedynamic_references_map.initialize(length/2);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
69 _resolved_reference_limit = -1;
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
70 _first_iteration_cp_cache_limit = -1;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
71
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
72 // invokedynamic specific fields
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
73 _invokedynamic_cp_cache_map.initialize(length/4);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
74 _patch_invokedynamic_bcps = new GrowableArray<address>(length/4);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
75 _patch_invokedynamic_refs = new GrowableArray<int>(length/4);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
76 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
77
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
78 int _first_iteration_cp_cache_limit;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
79 void record_map_limits() {
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
80 // Record initial size of the two arrays generated for the CP cache
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
81 // relative to walking the constant pool.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
82 _first_iteration_cp_cache_limit = _cp_cache_map.length();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
83 _resolved_reference_limit = _resolved_references_map.length();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
84 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
85
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
86 int cp_cache_delta() {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
87 // How many cp cache entries were added since recording map limits after
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
88 // cp cache initialization?
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
89 assert(_first_iteration_cp_cache_limit != -1, "only valid after first iteration");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
90 return _cp_cache_map.length() - _first_iteration_cp_cache_limit;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
91 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
92
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
93 int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
94 bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
95
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
96 int add_map_entry(int cp_index, intArray* cp_map, intStack* cp_cache_map) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
97 assert(cp_map->at(cp_index) == -1, "not twice on same cp_index");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
98 int cache_index = cp_cache_map->append(cp_index);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
99 cp_map->at_put(cp_index, cache_index);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
100 return cache_index;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
101 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
102
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
103 int add_cp_cache_entry(int cp_index) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
104 assert(_pool->tag_at(cp_index).value() != JVM_CONSTANT_InvokeDynamic, "use indy version");
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
105 assert(_first_iteration_cp_cache_limit == -1, "do not add cache entries after first iteration");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
106 int cache_index = add_map_entry(cp_index, &_cp_map, &_cp_cache_map);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
107 assert(cp_entry_to_cp_cache(cp_index) == cache_index, "");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
108 assert(cp_cache_entry_pool_index(cache_index) == cp_index, "");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
109 return cache_index;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
110 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
111
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
112 int add_invokedynamic_cp_cache_entry(int cp_index) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
113 assert(_pool->tag_at(cp_index).value() == JVM_CONSTANT_InvokeDynamic, "use non-indy version");
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
114 assert(_first_iteration_cp_cache_limit >= 0, "add indy cache entries after first iteration");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
115 // add to the invokedynamic index map.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
116 int cache_index = _invokedynamic_cp_cache_map.append(cp_index);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
117 // do not update _cp_map, since the mapping is one-to-many
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
118 assert(invokedynamic_cp_cache_entry_pool_index(cache_index) == cp_index, "");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
119 // this index starts at one but in the bytecode it's appended to the end.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
120 return cache_index + _first_iteration_cp_cache_limit;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
121 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
122
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
123 int invokedynamic_cp_cache_entry_pool_index(int cache_index) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
124 int cp_index = _invokedynamic_cp_cache_map[cache_index];
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
125 return cp_index;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
126 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
127
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
128 // add a new CP cache entry beyond the normal cache for the special case of
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
129 // invokespecial with InterfaceMethodref as cpool operand.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
130 int add_invokespecial_cp_cache_entry(int cp_index) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
131 assert(_first_iteration_cp_cache_limit >= 0, "add these special cache entries after first iteration");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
132 // Don't add InterfaceMethodref if it already exists at the end.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
133 for (int i = _first_iteration_cp_cache_limit; i < _cp_cache_map.length(); i++) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
134 if (cp_cache_entry_pool_index(i) == cp_index) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
135 return i;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
136 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
137 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
138 int cache_index = _cp_cache_map.append(cp_index);
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
139 assert(cache_index >= _first_iteration_cp_cache_limit, "");
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
140 // do not update _cp_map, since the mapping is one-to-many
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
141 assert(cp_cache_entry_pool_index(cache_index) == cp_index, "");
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
142 return cache_index;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
143 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
144
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
145 int cp_entry_to_resolved_references(int cp_index) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
146 assert(has_entry_in_resolved_references(cp_index), "oob");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
147 return _reference_map[cp_index];
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
148 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
149 bool has_entry_in_resolved_references(int cp_index) const {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
150 return (uint)cp_index < (uint)_reference_map.length() && _reference_map[cp_index] >= 0;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
151 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
152
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
153 // add a new entry to the resolved_references map
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
154 int add_resolved_references_entry(int cp_index) {
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
155 int ref_index = add_map_entry(cp_index, &_reference_map, &_resolved_references_map);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
156 assert(cp_entry_to_resolved_references(cp_index) == ref_index, "");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
157 return ref_index;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
158 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
159
6822
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
160 // add a new entries to the resolved_references map (for invokedynamic and invokehandle only)
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
161 int add_invokedynamic_resolved_references_entries(int cp_index, int cache_index) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
162 assert(_resolved_reference_limit >= 0, "must add indy refs after first iteration");
6822
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
163 int ref_index = -1;
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
164 for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
165 const int index = _resolved_references_map.append(cp_index); // many-to-one
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
166 assert(index >= _resolved_reference_limit, "");
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
167 if (entry == 0) {
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
168 ref_index = index;
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
169 }
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
170 assert((index - entry) == ref_index, "entries must be consecutive");
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
171 _invokedynamic_references_map.at_put_grow(index, cache_index, -1);
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
172 }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
173 return ref_index;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
174 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
175
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
176 int resolved_references_entry_to_pool_index(int ref_index) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
177 int cp_index = _resolved_references_map[ref_index];
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
178 return cp_index;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
179 }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
180
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
181 // Access the contents of _cp_cache_map to determine CP cache layout.
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
182 int cp_cache_entry_pool_index(int cache_index) {
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
183 int cp_index = _cp_cache_map[cache_index];
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
184 return cp_index;
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
185 }
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
186
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
187 // All the work goes in here:
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
188 Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
189
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
190 void compute_index_maps();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
191 void make_constant_pool_cache(TRAPS);
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
192 void scan_method(Method* m, bool reverse, bool* invokespecial_error);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
193 void rewrite_Object_init(methodHandle m, TRAPS);
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
194 void rewrite_member_reference(address bcp, int offset, bool reverse);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
195 void maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
196 void rewrite_invokedynamic(address bcp, int offset, bool reverse);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
197 void maybe_rewrite_ldc(address bcp, int offset, bool is_wide, bool reverse);
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
198 void rewrite_invokespecial(address bcp, int offset, bool reverse, bool* invokespecial_error);
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
199
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
200 void patch_invokedynamic_bytecodes();
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 7459
diff changeset
201
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 1972
diff changeset
202 // Revert bytecodes in case of an exception.
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
203 void restore_bytecodes();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
204
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 1972
diff changeset
205 static methodHandle rewrite_jsrs(methodHandle m, TRAPS);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
206 public:
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
207 // Driver routine:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
208 static void rewrite(instanceKlassHandle klass, TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
210
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
211 #endif // SHARE_VM_INTERPRETER_REWRITER_HPP