author | prr |
Mon, 06 Nov 2017 10:11:19 -0800 (2017-11-06) | |
changeset 47717 | 4a00b088902e |
parent 47216 | 71c04702a3d5 |
child 49480 | d7df2dd501ce |
permissions | -rw-r--r-- |
1 | 1 |
/* |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
2 |
* Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4567
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_INTERPRETER_REWRITER_HPP |
26 |
#define SHARE_VM_INTERPRETER_REWRITER_HPP |
|
27 |
||
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "runtime/handles.inline.hpp" |
|
30 |
#include "utilities/growableArray.hpp" |
|
31 |
||
1 | 32 |
// The Rewriter adds caches to the constant pool and rewrites bytecode indices |
33 |
// pointing into the constant pool for better interpreter performance. |
|
34 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
35 |
class Rewriter: public StackObj { |
1 | 36 |
private: |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
37 |
InstanceKlass* _klass; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
38 |
constantPoolHandle _pool; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
39 |
Array<Method*>* _methods; |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
40 |
GrowableArray<int> _cp_map; |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
41 |
GrowableArray<int> _cp_cache_map; // for Methodref, Fieldref, |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
42 |
// InterfaceMethodref and InvokeDynamic |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
43 |
GrowableArray<int> _reference_map; // maps from cp index to resolved_refs index (or -1) |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
44 |
GrowableArray<int> _resolved_references_map; // for strings, methodHandle, methodType |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
45 |
GrowableArray<int> _invokedynamic_references_map; // for invokedynamic resolved refs |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
46 |
GrowableArray<int> _method_handle_invokers; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
47 |
int _resolved_reference_limit; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
48 |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
49 |
// For mapping invokedynamic bytecodes, which are discovered during method |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
50 |
// scanning. The invokedynamic entries are added at the end of the cpCache. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
51 |
// If there are any invokespecial/InterfaceMethodref special case bytecodes, |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
52 |
// these entries are added before invokedynamic entries so that the |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
53 |
// invokespecial bytecode 16 bit index doesn't overflow. |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
54 |
GrowableArray<int> _invokedynamic_cp_cache_map; |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
55 |
|
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
56 |
// For patching. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
57 |
GrowableArray<address>* _patch_invokedynamic_bcps; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
58 |
GrowableArray<int>* _patch_invokedynamic_refs; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
59 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
60 |
void init_maps(int length) { |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
61 |
_cp_map.trunc_to(0); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
62 |
_cp_map.at_grow(length, -1); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
63 |
|
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
64 |
_cp_cache_map.trunc_to(0); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
65 |
// Also cache resolved objects, in another different cache. |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
66 |
_reference_map.trunc_to(0); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
67 |
_reference_map.at_grow(length, -1); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
68 |
|
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
69 |
_method_handle_invokers.trunc_to(0); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
70 |
_resolved_references_map.trunc_to(0); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
71 |
_invokedynamic_references_map.trunc_to(0); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
72 |
_resolved_reference_limit = -1; |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
73 |
_first_iteration_cp_cache_limit = -1; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
74 |
|
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
75 |
// invokedynamic specific fields |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
76 |
_invokedynamic_cp_cache_map.trunc_to(0); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
77 |
_patch_invokedynamic_bcps = new GrowableArray<address>(length / 4); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
78 |
_patch_invokedynamic_refs = new GrowableArray<int>(length / 4); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
79 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
80 |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
81 |
int _first_iteration_cp_cache_limit; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
82 |
void record_map_limits() { |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
83 |
// Record initial size of the two arrays generated for the CP cache |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
84 |
// relative to walking the constant pool. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
85 |
_first_iteration_cp_cache_limit = _cp_cache_map.length(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
86 |
_resolved_reference_limit = _resolved_references_map.length(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
87 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
88 |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
89 |
int cp_cache_delta() { |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
90 |
// How many cp cache entries were added since recording map limits after |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
91 |
// cp cache initialization? |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
92 |
assert(_first_iteration_cp_cache_limit != -1, "only valid after first iteration"); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
93 |
return _cp_cache_map.length() - _first_iteration_cp_cache_limit; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
94 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
95 |
|
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
96 |
int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map.at(i); } |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
97 |
bool has_cp_cache(int i) { return (uint) i < (uint) _cp_map.length() && _cp_map.at(i) >= 0; } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
98 |
|
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
99 |
int add_map_entry(int cp_index, GrowableArray<int>* cp_map, GrowableArray<int>* cp_cache_map) { |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
100 |
assert(cp_map->at(cp_index) == -1, "not twice on same cp_index"); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
101 |
int cache_index = cp_cache_map->append(cp_index); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
102 |
cp_map->at_put(cp_index, cache_index); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
103 |
return cache_index; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
104 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
105 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
106 |
int add_cp_cache_entry(int cp_index) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
107 |
assert(_pool->tag_at(cp_index).value() != JVM_CONSTANT_InvokeDynamic, "use indy version"); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
108 |
assert(_first_iteration_cp_cache_limit == -1, "do not add cache entries after first iteration"); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
109 |
int cache_index = add_map_entry(cp_index, &_cp_map, &_cp_cache_map); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
110 |
assert(cp_entry_to_cp_cache(cp_index) == cache_index, ""); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
111 |
assert(cp_cache_entry_pool_index(cache_index) == cp_index, ""); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
112 |
return cache_index; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
113 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
114 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
115 |
int add_invokedynamic_cp_cache_entry(int cp_index) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
116 |
assert(_pool->tag_at(cp_index).value() == JVM_CONSTANT_InvokeDynamic, "use non-indy version"); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
117 |
assert(_first_iteration_cp_cache_limit >= 0, "add indy cache entries after first iteration"); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
118 |
// add to the invokedynamic index map. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
119 |
int cache_index = _invokedynamic_cp_cache_map.append(cp_index); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
120 |
// do not update _cp_map, since the mapping is one-to-many |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
121 |
assert(invokedynamic_cp_cache_entry_pool_index(cache_index) == cp_index, ""); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
122 |
// this index starts at one but in the bytecode it's appended to the end. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
123 |
return cache_index + _first_iteration_cp_cache_limit; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
124 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
125 |
|
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
126 |
int invokedynamic_cp_cache_entry_pool_index(int cache_index) { |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
127 |
int cp_index = _invokedynamic_cp_cache_map.at(cache_index); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
128 |
return cp_index; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
129 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
130 |
|
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
131 |
// add a new CP cache entry beyond the normal cache for the special case of |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
132 |
// invokespecial with InterfaceMethodref as cpool operand. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
133 |
int add_invokespecial_cp_cache_entry(int cp_index) { |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
134 |
assert(_first_iteration_cp_cache_limit >= 0, "add these special cache entries after first iteration"); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
135 |
// Don't add InterfaceMethodref if it already exists at the end. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
136 |
for (int i = _first_iteration_cp_cache_limit; i < _cp_cache_map.length(); i++) { |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
137 |
if (cp_cache_entry_pool_index(i) == cp_index) { |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
138 |
return i; |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
139 |
} |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
140 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
141 |
int cache_index = _cp_cache_map.append(cp_index); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
142 |
assert(cache_index >= _first_iteration_cp_cache_limit, ""); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
143 |
// do not update _cp_map, since the mapping is one-to-many |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
144 |
assert(cp_cache_entry_pool_index(cache_index) == cp_index, ""); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
145 |
return cache_index; |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
146 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
147 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
148 |
int cp_entry_to_resolved_references(int cp_index) const { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
149 |
assert(has_entry_in_resolved_references(cp_index), "oob"); |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
150 |
return _reference_map.at(cp_index); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
151 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
152 |
bool has_entry_in_resolved_references(int cp_index) const { |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
153 |
return (uint) cp_index < (uint) _reference_map.length() && _reference_map.at(cp_index) >= 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
154 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
155 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
156 |
// add a new entry to the resolved_references map |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
157 |
int add_resolved_references_entry(int cp_index) { |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
158 |
int ref_index = add_map_entry(cp_index, &_reference_map, &_resolved_references_map); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
159 |
assert(cp_entry_to_resolved_references(cp_index) == ref_index, ""); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
160 |
return ref_index; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
161 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
162 |
|
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
163 |
// add a new entries to the resolved_references map (for invokedynamic and invokehandle only) |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
164 |
int add_invokedynamic_resolved_references_entries(int cp_index, int cache_index) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
165 |
assert(_resolved_reference_limit >= 0, "must add indy refs after first iteration"); |
13929
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
166 |
int ref_index = -1; |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
167 |
for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
168 |
const int index = _resolved_references_map.append(cp_index); // many-to-one |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
169 |
assert(index >= _resolved_reference_limit, ""); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
170 |
if (entry == 0) { |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
171 |
ref_index = index; |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
172 |
} |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
173 |
assert((index - entry) == ref_index, "entries must be consecutive"); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
174 |
_invokedynamic_references_map.at_put_grow(index, cache_index, -1); |
8da0dc50a6e4
7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents:
13728
diff
changeset
|
175 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
176 |
return ref_index; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
177 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
178 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
179 |
int resolved_references_entry_to_pool_index(int ref_index) { |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
180 |
int cp_index = _resolved_references_map.at(ref_index); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
181 |
return cp_index; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
182 |
} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
183 |
|
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
184 |
// Access the contents of _cp_cache_map to determine CP cache layout. |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
185 |
int cp_cache_entry_pool_index(int cache_index) { |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
33593
diff
changeset
|
186 |
int cp_index = _cp_cache_map.at(cache_index); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
187 |
return cp_index; |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
188 |
} |
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
189 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
190 |
// All the work goes in here: |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
191 |
Rewriter(InstanceKlass* klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
192 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
193 |
void compute_index_maps(); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
194 |
void make_constant_pool_cache(TRAPS); |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
195 |
void scan_method(Method* m, bool reverse, bool* invokespecial_error); |
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46329
diff
changeset
|
196 |
void rewrite_Object_init(const methodHandle& m, TRAPS); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
197 |
void rewrite_member_reference(address bcp, int offset, bool reverse); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
198 |
void maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
199 |
void rewrite_invokedynamic(address bcp, int offset, bool reverse); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
200 |
void maybe_rewrite_ldc(address bcp, int offset, bool is_wide, bool reverse); |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
201 |
void rewrite_invokespecial(address bcp, int offset, bool reverse, bool* invokespecial_error); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
202 |
|
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
203 |
void patch_invokedynamic_bytecodes(); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15099
diff
changeset
|
204 |
|
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
205 |
// Do all the work. |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
206 |
void rewrite_bytecodes(TRAPS); |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
207 |
|
9971 | 208 |
// Revert bytecodes in case of an exception. |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
209 |
void restore_bytecodes(); |
1 | 210 |
|
46727
6e4a84748e2c
8183039: Re-examine methodHandle methods uninlined by 8144256
coleenp
parents:
46329
diff
changeset
|
211 |
static methodHandle rewrite_jsrs(const methodHandle& m, TRAPS); |
1 | 212 |
public: |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
1
diff
changeset
|
213 |
// Driver routine: |
46329
53ccc37bda19
8155672: Remove instanceKlassHandles and KlassHandles
coleenp
parents:
38031
diff
changeset
|
214 |
static void rewrite(InstanceKlass* klass, TRAPS); |
1 | 215 |
}; |
7397 | 216 |
|
217 |
#endif // SHARE_VM_INTERPRETER_REWRITER_HPP |