author | zmajo |
Wed, 15 Jun 2016 14:27:58 +0200 | |
changeset 39421 | a9652c919db8 |
parent 38031 | e0b822facc03 |
child 39619 | 905b6eee37b3 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
2 |
* Copyright (c) 1998, 2016, 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 |
#include "precompiled.hpp" |
30764 | 26 |
#include "gc/shared/gcLocker.hpp" |
7397 | 27 |
#include "interpreter/bytecodes.hpp" |
28 |
#include "interpreter/interpreter.hpp" |
|
29 |
#include "interpreter/rewriter.hpp" |
|
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
30 |
#include "memory/metaspaceShared.hpp" |
7397 | 31 |
#include "memory/resourceArea.hpp" |
32 |
#include "oops/generateOopMap.hpp" |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
33 |
#include "prims/methodHandles.hpp" |
1 | 34 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
35 |
// Computes a CPC map (new_index -> original_index) for constant pool entries |
1 | 36 |
// that are referred to by the interpreter at runtime via the constant pool cache. |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
37 |
// Also computes a CP map (original_index -> new_index). |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
38 |
// Marks entries in CP which require additional processing. |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
39 |
void Rewriter::compute_index_maps() { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
40 |
const int length = _pool->length(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
41 |
init_maps(length); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
42 |
bool saw_mh_symbol = false; |
1 | 43 |
for (int i = 0; i < length; i++) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
44 |
int tag = _pool->tag_at(i).value(); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
45 |
switch (tag) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
46 |
case JVM_CONSTANT_InterfaceMethodref: |
1 | 47 |
case JVM_CONSTANT_Fieldref : // fall through |
48 |
case JVM_CONSTANT_Methodref : // fall through |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
49 |
add_cp_cache_entry(i); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
50 |
break; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
51 |
case JVM_CONSTANT_String: |
5882 | 52 |
case JVM_CONSTANT_MethodHandle : // fall through |
53 |
case JVM_CONSTANT_MethodType : // fall through |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
54 |
add_resolved_references_entry(i); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
55 |
break; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
56 |
case JVM_CONSTANT_Utf8: |
36819 | 57 |
if (_pool->symbol_at(i) == vmSymbols::java_lang_invoke_MethodHandle() || |
58 |
_pool->symbol_at(i) == vmSymbols::java_lang_invoke_VarHandle()) { |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
59 |
saw_mh_symbol = true; |
36819 | 60 |
} |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
61 |
break; |
1 | 62 |
} |
63 |
} |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
64 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
65 |
// Record limits of resolved reference map for constant pool cache indices |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
66 |
record_map_limits(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
67 |
|
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
68 |
guarantee((int) _cp_cache_map.length() - 1 <= (int) ((u2)-1), |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
69 |
"all cp cache indexes fit in a u2"); |
6062
bab93afe9df7
6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents:
5882
diff
changeset
|
70 |
|
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
71 |
if (saw_mh_symbol) { |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
72 |
_method_handle_invokers.at_grow(length, 0); |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
73 |
} |
1 | 74 |
} |
75 |
||
9971 | 76 |
// Unrewrite the bytecodes if an error occurs. |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
77 |
void Rewriter::restore_bytecodes() { |
9971 | 78 |
int len = _methods->length(); |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
79 |
bool invokespecial_error = false; |
9971 | 80 |
|
81 |
for (int i = len-1; i >= 0; i--) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
82 |
Method* method = _methods->at(i); |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
83 |
scan_method(method, true, &invokespecial_error); |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
84 |
assert(!invokespecial_error, "reversing should not get an invokespecial error"); |
9971 | 85 |
} |
86 |
} |
|
1 | 87 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
88 |
// Creates a constant pool cache given a CPC map |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
89 |
void Rewriter::make_constant_pool_cache(TRAPS) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
90 |
ClassLoaderData* loader_data = _pool->pool_holder()->class_loader_data(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
91 |
ConstantPoolCache* cache = |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
92 |
ConstantPoolCache::allocate(loader_data, _cp_cache_map, |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
93 |
_invokedynamic_cp_cache_map, |
15928
f9d5c6e4107f
8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents:
15799
diff
changeset
|
94 |
_invokedynamic_references_map, CHECK); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
95 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
96 |
// initialize object cache in constant pool |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
97 |
_pool->initialize_resolved_references(loader_data, _resolved_references_map, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
98 |
_resolved_reference_limit, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
99 |
CHECK); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
100 |
_pool->set_cache(cache); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
101 |
cache->set_constant_pool(_pool()); |
1 | 102 |
} |
103 |
||
104 |
||
105 |
||
106 |
// The new finalization semantics says that registration of |
|
107 |
// finalizable objects must be performed on successful return from the |
|
108 |
// Object.<init> constructor. We could implement this trivially if |
|
109 |
// <init> were never rewritten but since JVMTI allows this to occur, a |
|
110 |
// more complicated solution is required. A special return bytecode |
|
111 |
// is used only by Object.<init> to signal the finalization |
|
112 |
// registration point. Additionally local 0 must be preserved so it's |
|
31587
e48945b7849c
8076112: Add @HotSpotIntrinsicCandidate annotation to indicate methods for which Java Runtime has intrinsics
zmajo
parents:
30764
diff
changeset
|
113 |
// available to pass to the registration function. For simplicity we |
1 | 114 |
// require that local 0 is never overwritten so it's available as an |
115 |
// argument for registration. |
|
116 |
||
117 |
void Rewriter::rewrite_Object_init(methodHandle method, TRAPS) { |
|
118 |
RawBytecodeStream bcs(method); |
|
119 |
while (!bcs.is_last_bytecode()) { |
|
120 |
Bytecodes::Code opcode = bcs.raw_next(); |
|
121 |
switch (opcode) { |
|
122 |
case Bytecodes::_return: *bcs.bcp() = Bytecodes::_return_register_finalizer; break; |
|
123 |
||
124 |
case Bytecodes::_istore: |
|
125 |
case Bytecodes::_lstore: |
|
126 |
case Bytecodes::_fstore: |
|
127 |
case Bytecodes::_dstore: |
|
128 |
case Bytecodes::_astore: |
|
129 |
if (bcs.get_index() != 0) continue; |
|
130 |
||
131 |
// fall through |
|
132 |
case Bytecodes::_istore_0: |
|
133 |
case Bytecodes::_lstore_0: |
|
134 |
case Bytecodes::_fstore_0: |
|
135 |
case Bytecodes::_dstore_0: |
|
136 |
case Bytecodes::_astore_0: |
|
137 |
THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), |
|
138 |
"can't overwrite local 0 in Object.<init>"); |
|
139 |
break; |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
145 |
// Rewrite a classfile-order CP index into a native-order CPC index. |
9971 | 146 |
void Rewriter::rewrite_member_reference(address bcp, int offset, bool reverse) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
147 |
address p = bcp + offset; |
9971 | 148 |
if (!reverse) { |
149 |
int cp_index = Bytes::get_Java_u2(p); |
|
150 |
int cache_index = cp_entry_to_cp_cache(cp_index); |
|
151 |
Bytes::put_native_u2(p, cache_index); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
152 |
if (!_method_handle_invokers.is_empty()) |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
153 |
maybe_rewrite_invokehandle(p - 1, cp_index, cache_index, reverse); |
9971 | 154 |
} else { |
155 |
int cache_index = Bytes::get_native_u2(p); |
|
156 |
int pool_index = cp_cache_entry_pool_index(cache_index); |
|
157 |
Bytes::put_Java_u2(p, pool_index); |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
158 |
if (!_method_handle_invokers.is_empty()) |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
159 |
maybe_rewrite_invokehandle(p - 1, pool_index, cache_index, reverse); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
160 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
161 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
162 |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
163 |
// If the constant pool entry for invokespecial is InterfaceMethodref, |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
164 |
// we need to add a separate cpCache entry for its resolution, because it is |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
165 |
// different than the resolution for invokeinterface with InterfaceMethodref. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
166 |
// These cannot share cpCache entries. It's unclear if all invokespecial to |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
167 |
// InterfaceMethodrefs would resolve to the same thing so a new cpCache entry |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
168 |
// is created for each one. This was added with lambda. |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
169 |
void Rewriter::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:
15928
diff
changeset
|
170 |
address p = bcp + offset; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
171 |
if (!reverse) { |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
172 |
int cp_index = Bytes::get_Java_u2(p); |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
173 |
if (_pool->tag_at(cp_index).is_interface_method()) { |
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
174 |
int cache_index = add_invokespecial_cp_cache_entry(cp_index); |
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
175 |
if (cache_index != (int)(jushort) cache_index) { |
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
176 |
*invokespecial_error = true; |
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
177 |
} |
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
178 |
Bytes::put_native_u2(p, cache_index); |
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
179 |
} else { |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
180 |
rewrite_member_reference(bcp, offset, reverse); |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
181 |
} |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
182 |
} else { |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
183 |
rewrite_member_reference(bcp, offset, reverse); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
184 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
185 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
186 |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
187 |
|
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
188 |
// Adjust the invocation bytecode for a signature-polymorphic method (MethodHandle.invoke, etc.) |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
189 |
void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse) { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
190 |
if (!reverse) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
191 |
if ((*opc) == (u1)Bytecodes::_invokevirtual || |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
192 |
// allow invokespecial as an alias, although it would be very odd: |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
193 |
(*opc) == (u1)Bytecodes::_invokespecial) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
194 |
assert(_pool->tag_at(cp_index).is_method(), "wrong index"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
195 |
// Determine whether this is a signature-polymorphic method. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
196 |
if (cp_index >= _method_handle_invokers.length()) return; |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
197 |
int status = _method_handle_invokers.at(cp_index); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
198 |
assert(status >= -1 && status <= 1, "oob tri-state"); |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
199 |
if (status == 0) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
200 |
if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() && |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
201 |
MethodHandles::is_signature_polymorphic_name(SystemDictionary::MethodHandle_klass(), |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
202 |
_pool->name_ref_at(cp_index))) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
203 |
// we may need a resolved_refs entry for the appendix |
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
|
204 |
add_invokedynamic_resolved_references_entries(cp_index, cache_index); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
205 |
status = +1; |
36819 | 206 |
} else if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_VarHandle() && |
207 |
MethodHandles::is_signature_polymorphic_name(SystemDictionary::VarHandle_klass(), |
|
208 |
_pool->name_ref_at(cp_index))) { |
|
209 |
// we may need a resolved_refs entry for the appendix |
|
210 |
add_invokedynamic_resolved_references_entries(cp_index, cache_index); |
|
211 |
status = +1; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
212 |
} else { |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
213 |
status = -1; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
214 |
} |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
215 |
_method_handle_invokers.at(cp_index) = status; |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
216 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
217 |
// We use a special internal bytecode for such methods (if non-static). |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
218 |
// The basic reason for this is that such methods need an extra "appendix" argument |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
219 |
// to transmit the call site's intended call type. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
220 |
if (status > 0) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
221 |
(*opc) = (u1)Bytecodes::_invokehandle; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
222 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
223 |
} |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
224 |
} else { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
225 |
// Do not need to look at cp_index. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
226 |
if ((*opc) == (u1)Bytecodes::_invokehandle) { |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
227 |
(*opc) = (u1)Bytecodes::_invokevirtual; |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
228 |
// Ignore corner case of original _invokespecial instruction. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
229 |
// This is safe because (a) the signature polymorphic method was final, and |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
230 |
// (b) the implementation of MethodHandle will not call invokespecial on it. |
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
231 |
} |
9971 | 232 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
233 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
234 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
235 |
|
9971 | 236 |
void Rewriter::rewrite_invokedynamic(address bcp, int offset, bool reverse) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
237 |
address p = bcp + offset; |
9971 | 238 |
assert(p[-1] == Bytecodes::_invokedynamic, "not invokedynamic bytecode"); |
239 |
if (!reverse) { |
|
240 |
int cp_index = Bytes::get_Java_u2(p); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
241 |
int cache_index = add_invokedynamic_cp_cache_entry(cp_index); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
242 |
int resolved_index = add_invokedynamic_resolved_references_entries(cp_index, cache_index); |
9971 | 243 |
// Replace the trailing four bytes with a CPC index for the dynamic |
244 |
// call site. Unlike other CPC entries, there is one per bytecode, |
|
245 |
// not just one per distinct CP entry. In other words, the |
|
246 |
// CPC-to-CP relation is many-to-one for invokedynamic entries. |
|
247 |
// This means we must use a larger index size than u2 to address |
|
248 |
// all these entries. That is the main reason invokedynamic |
|
249 |
// must have a five-byte instruction format. (Of course, other JVM |
|
250 |
// implementations can use the bytes for other purposes.) |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
251 |
// Note: We use native_u4 format exclusively for 4-byte indexes. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
252 |
Bytes::put_native_u4(p, ConstantPool::encode_invokedynamic_index(cache_index)); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
253 |
// add the bcp in case we need to patch this bytecode if we also find a |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
254 |
// invokespecial/InterfaceMethodref in the bytecode stream |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
255 |
_patch_invokedynamic_bcps->push(p); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
256 |
_patch_invokedynamic_refs->push(resolved_index); |
9971 | 257 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
258 |
int cache_index = ConstantPool::decode_invokedynamic_index( |
9971 | 259 |
Bytes::get_native_u4(p)); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
260 |
// We will reverse the bytecode rewriting _after_ adjusting them. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
261 |
// Adjust the cache index by offset to the invokedynamic entries in the |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
262 |
// cpCache plus the delta if the invokedynamic bytecodes were adjusted. |
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
263 |
int adjustment = cp_cache_delta() + _first_iteration_cp_cache_limit; |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
264 |
int cp_index = invokedynamic_cp_cache_entry_pool_index(cache_index - adjustment); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
265 |
assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index"); |
9971 | 266 |
// zero out 4 bytes |
267 |
Bytes::put_Java_u4(p, 0); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
268 |
Bytes::put_Java_u2(p, cp_index); |
9971 | 269 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
270 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
271 |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
272 |
void Rewriter::patch_invokedynamic_bytecodes() { |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
273 |
// If the end of the cp_cache is the same as after initializing with the |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
274 |
// cpool, nothing needs to be done. Invokedynamic bytecodes are at the |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
275 |
// correct offsets. ie. no invokespecials added |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
276 |
int delta = cp_cache_delta(); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
277 |
if (delta > 0) { |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
278 |
int length = _patch_invokedynamic_bcps->length(); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
279 |
assert(length == _patch_invokedynamic_refs->length(), |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
280 |
"lengths should match"); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
281 |
for (int i = 0; i < length; i++) { |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
282 |
address p = _patch_invokedynamic_bcps->at(i); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
283 |
int cache_index = ConstantPool::decode_invokedynamic_index( |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
284 |
Bytes::get_native_u4(p)); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
285 |
Bytes::put_native_u4(p, ConstantPool::encode_invokedynamic_index(cache_index + delta)); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
286 |
|
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
287 |
// invokedynamic resolved references map also points to cp cache and must |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
288 |
// add delta to each. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
289 |
int resolved_index = _patch_invokedynamic_refs->at(i); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
290 |
for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
291 |
assert(_invokedynamic_references_map.at(resolved_index + entry) == cache_index, |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
292 |
"should be the same index"); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
293 |
_invokedynamic_references_map.at_put(resolved_index+entry, |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
294 |
cache_index + delta); |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
295 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
296 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
297 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
298 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
299 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
300 |
|
5882 | 301 |
// Rewrite some ldc bytecodes to _fast_aldc |
9971 | 302 |
void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide, |
303 |
bool reverse) { |
|
304 |
if (!reverse) { |
|
305 |
assert((*bcp) == (is_wide ? Bytecodes::_ldc_w : Bytecodes::_ldc), "not ldc bytecode"); |
|
306 |
address p = bcp + offset; |
|
307 |
int cp_index = is_wide ? Bytes::get_Java_u2(p) : (u1)(*p); |
|
308 |
constantTag tag = _pool->tag_at(cp_index).value(); |
|
15799 | 309 |
if (tag.is_method_handle() || tag.is_method_type() || tag.is_string()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
310 |
int ref_index = cp_entry_to_resolved_references(cp_index); |
9971 | 311 |
if (is_wide) { |
312 |
(*bcp) = Bytecodes::_fast_aldc_w; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
313 |
assert(ref_index == (u2)ref_index, "index overflow"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
314 |
Bytes::put_native_u2(p, ref_index); |
9971 | 315 |
} else { |
316 |
(*bcp) = Bytecodes::_fast_aldc; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
317 |
assert(ref_index == (u1)ref_index, "index overflow"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
318 |
(*p) = (u1)ref_index; |
9971 | 319 |
} |
320 |
} |
|
321 |
} else { |
|
322 |
Bytecodes::Code rewritten_bc = |
|
323 |
(is_wide ? Bytecodes::_fast_aldc_w : Bytecodes::_fast_aldc); |
|
324 |
if ((*bcp) == rewritten_bc) { |
|
325 |
address p = bcp + offset; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
326 |
int ref_index = is_wide ? Bytes::get_native_u2(p) : (u1)(*p); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
327 |
int pool_index = resolved_references_entry_to_pool_index(ref_index); |
9971 | 328 |
if (is_wide) { |
329 |
(*bcp) = Bytecodes::_ldc_w; |
|
330 |
assert(pool_index == (u2)pool_index, "index overflow"); |
|
331 |
Bytes::put_Java_u2(p, pool_index); |
|
332 |
} else { |
|
333 |
(*bcp) = Bytecodes::_ldc; |
|
334 |
assert(pool_index == (u1)pool_index, "index overflow"); |
|
335 |
(*p) = (u1)pool_index; |
|
336 |
} |
|
5882 | 337 |
} |
338 |
} |
|
339 |
} |
|
340 |
||
341 |
||
1 | 342 |
// Rewrites a method given the index_map information |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
343 |
void Rewriter::scan_method(Method* method, bool reverse, bool* invokespecial_error) { |
1 | 344 |
|
345 |
int nof_jsrs = 0; |
|
346 |
bool has_monitor_bytecodes = false; |
|
347 |
||
348 |
{ |
|
349 |
// We cannot tolerate a GC in this block, because we've |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
350 |
// cached the bytecodes in 'code_base'. If the Method* |
1 | 351 |
// moves, the bytecodes will also move. |
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
33593
diff
changeset
|
352 |
NoSafepointVerifier nsv; |
1 | 353 |
Bytecodes::Code c; |
354 |
||
355 |
// Bytecodes and their length |
|
356 |
const address code_base = method->code_base(); |
|
357 |
const int code_length = method->code_size(); |
|
358 |
||
359 |
int bc_length; |
|
360 |
for (int bci = 0; bci < code_length; bci += bc_length) { |
|
361 |
address bcp = code_base + bci; |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
362 |
int prefix_length = 0; |
1 | 363 |
c = (Bytecodes::Code)(*bcp); |
364 |
||
365 |
// Since we have the code, see if we can get the length |
|
366 |
// directly. Some more complicated bytecodes will report |
|
367 |
// a length of zero, meaning we need to make another method |
|
368 |
// call to calculate the length. |
|
369 |
bc_length = Bytecodes::length_for(c); |
|
370 |
if (bc_length == 0) { |
|
7913 | 371 |
bc_length = Bytecodes::length_at(method, bcp); |
1 | 372 |
|
373 |
// length_at will put us at the bytecode after the one modified |
|
374 |
// by 'wide'. We don't currently examine any of the bytecodes |
|
375 |
// modified by wide, but in case we do in the future... |
|
376 |
if (c == Bytecodes::_wide) { |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
377 |
prefix_length = 1; |
1 | 378 |
c = (Bytecodes::Code)bcp[1]; |
379 |
} |
|
380 |
} |
|
381 |
||
382 |
assert(bc_length != 0, "impossible bytecode length"); |
|
383 |
||
384 |
switch (c) { |
|
385 |
case Bytecodes::_lookupswitch : { |
|
386 |
#ifndef CC_INTERP |
|
7913 | 387 |
Bytecode_lookupswitch bc(method, bcp); |
5688 | 388 |
(*bcp) = ( |
7913 | 389 |
bc.number_of_pairs() < BinarySwitchThreshold |
1 | 390 |
? Bytecodes::_fast_linearswitch |
391 |
: Bytecodes::_fast_binaryswitch |
|
392 |
); |
|
393 |
#endif |
|
394 |
break; |
|
395 |
} |
|
9971 | 396 |
case Bytecodes::_fast_linearswitch: |
397 |
case Bytecodes::_fast_binaryswitch: { |
|
398 |
#ifndef CC_INTERP |
|
399 |
(*bcp) = Bytecodes::_lookupswitch; |
|
400 |
#endif |
|
401 |
break; |
|
402 |
} |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
403 |
|
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
404 |
case Bytecodes::_invokespecial : { |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
405 |
rewrite_invokespecial(bcp, prefix_length+1, reverse, invokespecial_error); |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
406 |
break; |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
407 |
} |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
408 |
|
39421
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
409 |
case Bytecodes::_putstatic : |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
410 |
case Bytecodes::_putfield : { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
411 |
if (!reverse) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
412 |
// Check if any final field of the class given as parameter is modified |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
413 |
// outside of initializer methods of the class. Fields that are modified |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
414 |
// are marked with a flag. For marked fields, the compilers do not perform |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
415 |
// constant folding (as the field can be changed after initialization). |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
416 |
// |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
417 |
// The check is performed after verification and only if verification has |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
418 |
// succeeded. Therefore, the class is guaranteed to be well-formed. |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
419 |
InstanceKlass* klass = method->method_holder(); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
420 |
u2 bc_index = Bytes::get_Java_u2(bcp + prefix_length + 1); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
421 |
constantPoolHandle cp(method->constants()); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
422 |
Symbol* field_name = cp->name_ref_at(bc_index); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
423 |
Symbol* field_sig = cp->signature_ref_at(bc_index); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
424 |
Symbol* ref_class_name = cp->klass_name_at(cp->klass_ref_index_at(bc_index)); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
425 |
|
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
426 |
if (klass->name() == ref_class_name) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
427 |
fieldDescriptor fd; |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
428 |
klass->find_field(field_name, field_sig, &fd); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
429 |
if (fd.access_flags().is_final()) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
430 |
if (fd.access_flags().is_static()) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
431 |
assert(c == Bytecodes::_putstatic, "must be putstatic"); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
432 |
if (!method->is_static_initializer()) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
433 |
fd.set_has_initialized_final_update(true); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
434 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
435 |
} else { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
436 |
assert(c == Bytecodes::_putfield, "must be putfield"); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
437 |
if (!method->is_object_initializer()) { |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
438 |
fd.set_has_initialized_final_update(true); |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
439 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
440 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
441 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
442 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
443 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
444 |
} |
a9652c919db8
8157181: Compilers accept modification of final fields outside initializer methods
zmajo
parents:
38031
diff
changeset
|
445 |
// fall through |
1 | 446 |
case Bytecodes::_getstatic : // fall through |
447 |
case Bytecodes::_getfield : // fall through |
|
448 |
case Bytecodes::_invokevirtual : // fall through |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
449 |
case Bytecodes::_invokestatic : |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
450 |
case Bytecodes::_invokeinterface: |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
451 |
case Bytecodes::_invokehandle : // if reverse=true |
9971 | 452 |
rewrite_member_reference(bcp, prefix_length+1, reverse); |
1 | 453 |
break; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
454 |
case Bytecodes::_invokedynamic: |
9971 | 455 |
rewrite_invokedynamic(bcp, prefix_length+1, reverse); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
456 |
break; |
5882 | 457 |
case Bytecodes::_ldc: |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
458 |
case Bytecodes::_fast_aldc: // if reverse=true |
9971 | 459 |
maybe_rewrite_ldc(bcp, prefix_length+1, false, reverse); |
5882 | 460 |
break; |
461 |
case Bytecodes::_ldc_w: |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
9971
diff
changeset
|
462 |
case Bytecodes::_fast_aldc_w: // if reverse=true |
9971 | 463 |
maybe_rewrite_ldc(bcp, prefix_length+1, true, reverse); |
5882 | 464 |
break; |
1 | 465 |
case Bytecodes::_jsr : // fall through |
466 |
case Bytecodes::_jsr_w : nof_jsrs++; break; |
|
467 |
case Bytecodes::_monitorenter : // fall through |
|
468 |
case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break; |
|
469 |
} |
|
470 |
} |
|
471 |
} |
|
472 |
||
473 |
// Update access flags |
|
474 |
if (has_monitor_bytecodes) { |
|
475 |
method->set_has_monitor_bytecodes(); |
|
476 |
} |
|
477 |
||
478 |
// The present of a jsr bytecode implies that the method might potentially |
|
479 |
// have to be rewritten, so we run the oopMapGenerator on the method |
|
480 |
if (nof_jsrs > 0) { |
|
481 |
method->set_has_jsrs(); |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
482 |
// Second pass will revisit this method. |
9971 | 483 |
assert(method->has_jsrs(), "didn't we just set this?"); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
484 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
485 |
} |
1 | 486 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
487 |
// After constant pool is created, revisit methods containing jsrs. |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
488 |
methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) { |
9971 | 489 |
ResourceMark rm(THREAD); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
490 |
ResolveOopMapConflicts romc(method); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
491 |
methodHandle original_method = method; |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
492 |
method = romc.do_potential_rewrite(CHECK_(methodHandle())); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
493 |
// Update monitor matching info. |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
494 |
if (romc.monitor_safe()) { |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
495 |
method->set_guaranteed_monitor_matching(); |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
496 |
} |
1 | 497 |
|
498 |
return method; |
|
499 |
} |
|
500 |
||
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
501 |
void Rewriter::rewrite_bytecodes(TRAPS) { |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
502 |
assert(_pool->cache() == NULL, "constant pool cache must not be set yet"); |
1 | 503 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
504 |
// determine index maps for Method* rewriting |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
505 |
compute_index_maps(); |
1 | 506 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
507 |
if (RegisterFinalizersAtInit && _klass->name() == vmSymbols::java_lang_Object()) { |
3273
6acf7084b1d3
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
2570
diff
changeset
|
508 |
bool did_rewrite = false; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
509 |
int i = _methods->length(); |
1 | 510 |
while (i-- > 0) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
511 |
Method* method = _methods->at(i); |
1 | 512 |
if (method->intrinsic_id() == vmIntrinsics::_Object_init) { |
513 |
// rewrite the return bytecodes of Object.<init> to register the |
|
514 |
// object for finalization if needed. |
|
515 |
methodHandle m(THREAD, method); |
|
516 |
rewrite_Object_init(m, CHECK); |
|
3273
6acf7084b1d3
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
2570
diff
changeset
|
517 |
did_rewrite = true; |
1 | 518 |
break; |
519 |
} |
|
520 |
} |
|
3273
6acf7084b1d3
6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents:
2570
diff
changeset
|
521 |
assert(did_rewrite, "must find Object::<init> to rewrite it"); |
1 | 522 |
} |
523 |
||
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
524 |
// rewrite methods, in two passes |
9971 | 525 |
int len = _methods->length(); |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
526 |
bool invokespecial_error = false; |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
527 |
|
9971 | 528 |
for (int i = len-1; i >= 0; i--) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
529 |
Method* method = _methods->at(i); |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
530 |
scan_method(method, false, &invokespecial_error); |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
531 |
if (invokespecial_error) { |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
532 |
// If you get an error here, there is no reversing bytecodes |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
533 |
// This exception is stored for this class and no further attempt is |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
534 |
// made at verifying or rewriting. |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
535 |
THROW_MSG(vmSymbols::java_lang_InternalError(), |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
536 |
"This classfile overflows invokespecial for interfaces " |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
537 |
"and cannot be loaded"); |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
538 |
return; |
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
539 |
} |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
540 |
} |
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
541 |
|
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
542 |
// May have to fix invokedynamic bytecodes if invokestatic/InterfaceMethodref |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
543 |
// entries had to be added. |
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
544 |
patch_invokedynamic_bytecodes(); |
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
545 |
} |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
546 |
|
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
547 |
void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) { |
30117
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
548 |
if (!DumpSharedSpaces) { |
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
549 |
assert(!MetaspaceShared::is_in_shared_space(klass()), "archive methods must not be rewritten at run time"); |
cce2cdac56dc
8074345: Enable RewriteBytecodes when VM runs with CDS
minqi
parents:
22750
diff
changeset
|
550 |
} |
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
551 |
ResourceMark rm(THREAD); |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
552 |
Rewriter rw(klass, klass->constants(), klass->methods(), CHECK); |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
553 |
// (That's all, folks.) |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
554 |
} |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
555 |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31587
diff
changeset
|
556 |
Rewriter::Rewriter(instanceKlassHandle klass, const constantPoolHandle& cpool, Array<Method*>* methods, TRAPS) |
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
557 |
: _klass(klass), |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
558 |
_pool(cpool), |
38031
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
559 |
_methods(methods), |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
560 |
_cp_map(cpool->length()), |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
561 |
_cp_cache_map(cpool->length() / 2), |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
562 |
_reference_map(cpool->length()), |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
563 |
_resolved_references_map(cpool->length() / 2), |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
564 |
_invokedynamic_references_map(cpool->length() / 2), |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
565 |
_method_handle_invokers(cpool->length()), |
e0b822facc03
8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents:
36819
diff
changeset
|
566 |
_invokedynamic_cp_cache_map(cpool->length() / 4) |
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
567 |
{ |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
568 |
|
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
569 |
// Rewrite bytecodes - exception here exits. |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
570 |
rewrite_bytecodes(CHECK); |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
571 |
|
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
572 |
// Stress restoring bytecodes |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
573 |
if (StressRewriter) { |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
574 |
restore_bytecodes(); |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
575 |
rewrite_bytecodes(CHECK); |
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
576 |
} |
21557
55115e0708f1
8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents:
15928
diff
changeset
|
577 |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
578 |
// allocate constant pool cache, now that we've seen all the bytecodes |
9971 | 579 |
make_constant_pool_cache(THREAD); |
580 |
||
581 |
// Restore bytecodes to their unrewritten state if there are exceptions |
|
582 |
// rewriting bytecodes or allocating the cpCache |
|
583 |
if (HAS_PENDING_EXCEPTION) { |
|
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
584 |
restore_bytecodes(); |
9971 | 585 |
return; |
586 |
} |
|
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
587 |
|
15099
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
588 |
// Relocate after everything, but still do this under the is_rewritten flag, |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
589 |
// so methods with jsrs in custom class lists in aren't attempted to be |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
590 |
// rewritten in the RO section of the shared archive. |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
591 |
// Relocated bytecodes don't have to be restored, only the cp cache entries |
22750
a3c879b18f22
8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents:
21734
diff
changeset
|
592 |
int len = _methods->length(); |
9971 | 593 |
for (int i = len-1; i >= 0; i--) { |
15099
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
594 |
methodHandle m(THREAD, _methods->at(i)); |
2570
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
595 |
|
ecc7862946d4
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
2105
diff
changeset
|
596 |
if (m->has_jsrs()) { |
15099
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
597 |
m = rewrite_jsrs(m, THREAD); |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
598 |
// Restore bytecodes to their unrewritten state if there are exceptions |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
599 |
// relocating bytecodes. If some are relocated, that is ok because that |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
600 |
// doesn't affect constant pool to cpCache rewriting. |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
601 |
if (HAS_PENDING_EXCEPTION) { |
21734
440a9598dc23
8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents:
21557
diff
changeset
|
602 |
restore_bytecodes(); |
15099
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
603 |
return; |
b31d40895bbb
8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents:
13929
diff
changeset
|
604 |
} |
1 | 605 |
// Method might have gotten rewritten. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13391
diff
changeset
|
606 |
methods->at_put(i, m()); |
1 | 607 |
} |
608 |
} |
|
609 |
} |