annotate src/share/vm/interpreter/rewriter.cpp @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents 10c9507f544a
children d8041d695d19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
17665
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
26 #include "interpreter/bytecodes.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
27 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
28 #include "interpreter/rewriter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
29 #include "memory/gcLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
30 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1660
diff changeset
31 #include "oops/generateOopMap.hpp"
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
32 #include "prims/methodHandles.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
33
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
34 // Computes a CPC map (new_index -> original_index) for constant pool entries
0
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // that are referred to by the interpreter at runtime via the constant pool cache.
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
36 // Also computes a CP map (original_index -> new_index).
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
37 // Marks entries in CP which require additional processing.
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
38 void Rewriter::compute_index_maps() {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
39 const int length = _pool->length();
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
40 init_maps(length);
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
41 bool saw_mh_symbol = false;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
42 for (int i = 0; i < length; i++) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
43 int tag = _pool->tag_at(i).value();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
44 switch (tag) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
45 case JVM_CONSTANT_InterfaceMethodref:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46 case JVM_CONSTANT_Fieldref : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
47 case JVM_CONSTANT_Methodref : // fall through
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
48 add_cp_cache_entry(i);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
49 break;
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
50 case JVM_CONSTANT_String:
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
51 case JVM_CONSTANT_MethodHandle : // fall through
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
52 case JVM_CONSTANT_MethodType : // fall through
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
53 add_resolved_references_entry(i);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
54 break;
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
55 case JVM_CONSTANT_Utf8:
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
56 if (_pool->symbol_at(i) == vmSymbols::java_lang_invoke_MethodHandle())
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
57 saw_mh_symbol = true;
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
58 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
61
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
62 // Record limits of resolved reference map for constant pool cache indices
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
63 record_map_limits();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
64
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
65 guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1),
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
66 "all cp cache indexes fit in a u2");
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
67
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
68 if (saw_mh_symbol)
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
69 _method_handle_invokers.initialize(length, (int)0);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
72 // Unrewrite the bytecodes if an error occurs.
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
73 void Rewriter::restore_bytecodes() {
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
74 int len = _methods->length();
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
75 bool invokespecial_error = false;
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
76
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
77 for (int i = len-1; i >= 0; i--) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
78 Method* method = _methods->at(i);
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
79 scan_method(method, true, &invokespecial_error);
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
80 assert(!invokespecial_error, "reversing should not get an invokespecial error");
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
81 }
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
82 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
83
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
84 // Creates a constant pool cache given a CPC map
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
85 void Rewriter::make_constant_pool_cache(TRAPS) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
86 ClassLoaderData* loader_data = _pool->pool_holder()->class_loader_data();
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
87 ConstantPoolCache* cache =
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
88 ConstantPoolCache::allocate(loader_data, _cp_cache_map,
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
89 _invokedynamic_cp_cache_map,
8712
3efdfd6ddbf2 8003553: NPG: metaspace objects should be zeroed in constructors
coleenp
parents: 8104
diff changeset
90 _invokedynamic_references_map, CHECK);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
91
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
92 // initialize object cache in constant pool
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
93 _pool->initialize_resolved_references(loader_data, _resolved_references_map,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
94 _resolved_reference_limit,
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
95 CHECK);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
96 _pool->set_cache(cache);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
97 cache->set_constant_pool(_pool());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 // The new finalization semantics says that registration of
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // finalizable objects must be performed on successful return from the
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // Object.<init> constructor. We could implement this trivially if
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // <init> were never rewritten but since JVMTI allows this to occur, a
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // more complicated solution is required. A special return bytecode
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // is used only by Object.<init> to signal the finalization
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // registration point. Additionally local 0 must be preserved so it's
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // available to pass to the registration function. For simplicty we
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // require that local 0 is never overwritten so it's available as an
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // argument for registration.
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 void Rewriter::rewrite_Object_init(methodHandle method, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 RawBytecodeStream bcs(method);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 while (!bcs.is_last_bytecode()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 Bytecodes::Code opcode = bcs.raw_next();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 switch (opcode) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 case Bytecodes::_return: *bcs.bcp() = Bytecodes::_return_register_finalizer; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 case Bytecodes::_istore:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 case Bytecodes::_lstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
122 case Bytecodes::_fstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
123 case Bytecodes::_dstore:
a61af66fc99e Initial load
duke
parents:
diff changeset
124 case Bytecodes::_astore:
a61af66fc99e Initial load
duke
parents:
diff changeset
125 if (bcs.get_index() != 0) continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
128 case Bytecodes::_istore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
129 case Bytecodes::_lstore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
130 case Bytecodes::_fstore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
131 case Bytecodes::_dstore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
132 case Bytecodes::_astore_0:
a61af66fc99e Initial load
duke
parents:
diff changeset
133 THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(),
a61af66fc99e Initial load
duke
parents:
diff changeset
134 "can't overwrite local 0 in Object.<init>");
a61af66fc99e Initial load
duke
parents:
diff changeset
135 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
141 // Rewrite a classfile-order CP index into a native-order CPC index.
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
142 void Rewriter::rewrite_member_reference(address bcp, int offset, bool reverse) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
143 address p = bcp + offset;
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
144 if (!reverse) {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
145 int cp_index = Bytes::get_Java_u2(p);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
146 int cache_index = cp_entry_to_cp_cache(cp_index);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
147 Bytes::put_native_u2(p, cache_index);
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
148 if (!_method_handle_invokers.is_empty())
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
149 maybe_rewrite_invokehandle(p - 1, cp_index, cache_index, reverse);
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
150 } else {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
151 int cache_index = Bytes::get_native_u2(p);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
152 int pool_index = cp_cache_entry_pool_index(cache_index);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
153 Bytes::put_Java_u2(p, pool_index);
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
154 if (!_method_handle_invokers.is_empty())
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
155 maybe_rewrite_invokehandle(p - 1, pool_index, cache_index, reverse);
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
156 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
157 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
158
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
159 // If the constant pool entry for invokespecial is InterfaceMethodref,
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
160 // we need to add a separate cpCache entry for its resolution, because it is
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
161 // different than the resolution for invokeinterface with InterfaceMethodref.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
162 // These cannot share cpCache entries. It's unclear if all invokespecial to
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
163 // InterfaceMethodrefs would resolve to the same thing so a new cpCache entry
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
164 // is created for each one. This was added with lambda.
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
165 void Rewriter::rewrite_invokespecial(address bcp, int offset, bool reverse, bool* invokespecial_error) {
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
166 address p = bcp + offset;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
167 if (!reverse) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
168 int cp_index = Bytes::get_Java_u2(p);
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
169 if (_pool->tag_at(cp_index).is_interface_method()) {
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
170 int cache_index = add_invokespecial_cp_cache_entry(cp_index);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
171 if (cache_index != (int)(jushort) cache_index) {
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
172 *invokespecial_error = true;
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
173 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
174 Bytes::put_native_u2(p, cache_index);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
175 } else {
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
176 rewrite_member_reference(bcp, offset, reverse);
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
177 }
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
178 } else {
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
179 rewrite_member_reference(bcp, offset, reverse);
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
180 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
181 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
182
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
183
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
184 // Adjust the invocation bytecode for a signature-polymorphic method (MethodHandle.invoke, etc.)
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
185 void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_index, bool reverse) {
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
186 if (!reverse) {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
187 if ((*opc) == (u1)Bytecodes::_invokevirtual ||
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
188 // allow invokespecial as an alias, although it would be very odd:
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
189 (*opc) == (u1)Bytecodes::_invokespecial) {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
190 assert(_pool->tag_at(cp_index).is_method(), "wrong index");
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
191 // Determine whether this is a signature-polymorphic method.
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
192 if (cp_index >= _method_handle_invokers.length()) return;
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
193 int status = _method_handle_invokers[cp_index];
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
194 assert(status >= -1 && status <= 1, "oob tri-state");
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
195 if (status == 0) {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
196 if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() &&
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
197 MethodHandles::is_signature_polymorphic_name(SystemDictionary::MethodHandle_klass(),
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
198 _pool->name_ref_at(cp_index))) {
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
199 // we may need a resolved_refs entry for the appendix
6822
f6b0eb4e44cf 7200949: JSR 292: rubybench/bench/time/bench_base64.rb fails with jruby.jar not on boot class path
twisti
parents: 6725
diff changeset
200 add_invokedynamic_resolved_references_entries(cp_index, cache_index);
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
201 status = +1;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
202 } else {
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
203 status = -1;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
204 }
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
205 _method_handle_invokers[cp_index] = status;
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
206 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
207 // We use a special internal bytecode for such methods (if non-static).
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
208 // The basic reason for this is that such methods need an extra "appendix" argument
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
209 // to transmit the call site's intended call type.
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
210 if (status > 0) {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
211 (*opc) = (u1)Bytecodes::_invokehandle;
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
212 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
213 }
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
214 } else {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
215 // Do not need to look at cp_index.
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
216 if ((*opc) == (u1)Bytecodes::_invokehandle) {
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
217 (*opc) = (u1)Bytecodes::_invokevirtual;
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
218 // Ignore corner case of original _invokespecial instruction.
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
219 // This is safe because (a) the signature polymorphic method was final, and
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
220 // (b) the implementation of MethodHandle will not call invokespecial on it.
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
221 }
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
222 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
223 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
224
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
225
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
226 void Rewriter::rewrite_invokedynamic(address bcp, int offset, bool reverse) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
227 address p = bcp + offset;
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
228 assert(p[-1] == Bytecodes::_invokedynamic, "not invokedynamic bytecode");
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
229 if (!reverse) {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
230 int cp_index = Bytes::get_Java_u2(p);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
231 int cache_index = add_invokedynamic_cp_cache_entry(cp_index);
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
232 int resolved_index = add_invokedynamic_resolved_references_entries(cp_index, cache_index);
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
233 // Replace the trailing four bytes with a CPC index for the dynamic
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
234 // call site. Unlike other CPC entries, there is one per bytecode,
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
235 // not just one per distinct CP entry. In other words, the
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
236 // CPC-to-CP relation is many-to-one for invokedynamic entries.
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
237 // This means we must use a larger index size than u2 to address
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
238 // all these entries. That is the main reason invokedynamic
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
239 // must have a five-byte instruction format. (Of course, other JVM
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
240 // implementations can use the bytes for other purposes.)
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
241 // Note: We use native_u4 format exclusively for 4-byte indexes.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
242 Bytes::put_native_u4(p, ConstantPool::encode_invokedynamic_index(cache_index));
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
243 // add the bcp in case we need to patch this bytecode if we also find a
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
244 // invokespecial/InterfaceMethodref in the bytecode stream
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
245 _patch_invokedynamic_bcps->push(p);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
246 _patch_invokedynamic_refs->push(resolved_index);
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
247 } else {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
248 int cache_index = ConstantPool::decode_invokedynamic_index(
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
249 Bytes::get_native_u4(p));
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
250 // We will reverse the bytecode rewriting _after_ adjusting them.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
251 // Adjust the cache index by offset to the invokedynamic entries in the
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
252 // cpCache plus the delta if the invokedynamic bytecodes were adjusted.
17665
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
253 int adjustment = cp_cache_delta() + _first_iteration_cp_cache_limit;
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
254 int cp_index = invokedynamic_cp_cache_entry_pool_index(cache_index - adjustment);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
255 assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index");
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
256 // zero out 4 bytes
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
257 Bytes::put_Java_u4(p, 0);
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
258 Bytes::put_Java_u2(p, cp_index);
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
259 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
260 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
261
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
262 void Rewriter::patch_invokedynamic_bytecodes() {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
263 // If the end of the cp_cache is the same as after initializing with the
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
264 // cpool, nothing needs to be done. Invokedynamic bytecodes are at the
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
265 // correct offsets. ie. no invokespecials added
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
266 int delta = cp_cache_delta();
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
267 if (delta > 0) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
268 int length = _patch_invokedynamic_bcps->length();
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
269 assert(length == _patch_invokedynamic_refs->length(),
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
270 "lengths should match");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
271 for (int i = 0; i < length; i++) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
272 address p = _patch_invokedynamic_bcps->at(i);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
273 int cache_index = ConstantPool::decode_invokedynamic_index(
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
274 Bytes::get_native_u4(p));
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
275 Bytes::put_native_u4(p, ConstantPool::encode_invokedynamic_index(cache_index + delta));
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
276
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
277 // invokedynamic resolved references map also points to cp cache and must
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
278 // add delta to each.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
279 int resolved_index = _patch_invokedynamic_refs->at(i);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
280 for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) {
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
281 assert(_invokedynamic_references_map[resolved_index+entry] == cache_index,
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
282 "should be the same index");
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
283 _invokedynamic_references_map.at_put(resolved_index+entry,
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
284 cache_index + delta);
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
285 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
286 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
287 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
288 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
289
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
290
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
291 // Rewrite some ldc bytecodes to _fast_aldc
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
292 void Rewriter::maybe_rewrite_ldc(address bcp, int offset, bool is_wide,
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
293 bool reverse) {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
294 if (!reverse) {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
295 assert((*bcp) == (is_wide ? Bytecodes::_ldc_w : Bytecodes::_ldc), "not ldc bytecode");
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
296 address p = bcp + offset;
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
297 int cp_index = is_wide ? Bytes::get_Java_u2(p) : (u1)(*p);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
298 constantTag tag = _pool->tag_at(cp_index).value();
8104
f16e75e0cf11 8000797: NPG: is_pseudo_string_at() doesn't work
coleenp
parents: 7459
diff changeset
299 if (tag.is_method_handle() || tag.is_method_type() || tag.is_string()) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
300 int ref_index = cp_entry_to_resolved_references(cp_index);
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
301 if (is_wide) {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
302 (*bcp) = Bytecodes::_fast_aldc_w;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
303 assert(ref_index == (u2)ref_index, "index overflow");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
304 Bytes::put_native_u2(p, ref_index);
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
305 } else {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
306 (*bcp) = Bytecodes::_fast_aldc;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
307 assert(ref_index == (u1)ref_index, "index overflow");
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
308 (*p) = (u1)ref_index;
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
309 }
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
310 }
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
311 } else {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
312 Bytecodes::Code rewritten_bc =
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
313 (is_wide ? Bytecodes::_fast_aldc_w : Bytecodes::_fast_aldc);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
314 if ((*bcp) == rewritten_bc) {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
315 address p = bcp + offset;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
316 int ref_index = is_wide ? Bytes::get_native_u2(p) : (u1)(*p);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
317 int pool_index = resolved_references_entry_to_pool_index(ref_index);
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
318 if (is_wide) {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
319 (*bcp) = Bytecodes::_ldc_w;
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
320 assert(pool_index == (u2)pool_index, "index overflow");
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
321 Bytes::put_Java_u2(p, pool_index);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
322 } else {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
323 (*bcp) = Bytecodes::_ldc;
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
324 assert(pool_index == (u1)pool_index, "index overflow");
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
325 (*p) = (u1)pool_index;
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
326 }
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
327 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
328 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
329 }
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
330
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
331
0
a61af66fc99e Initial load
duke
parents:
diff changeset
332 // Rewrites a method given the index_map information
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
333 void Rewriter::scan_method(Method* method, bool reverse, bool* invokespecial_error) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
334
a61af66fc99e Initial load
duke
parents:
diff changeset
335 int nof_jsrs = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
336 bool has_monitor_bytecodes = false;
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 // We cannot tolerate a GC in this block, because we've
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
340 // cached the bytecodes in 'code_base'. If the Method*
0
a61af66fc99e Initial load
duke
parents:
diff changeset
341 // moves, the bytecodes will also move.
a61af66fc99e Initial load
duke
parents:
diff changeset
342 No_Safepoint_Verifier nsv;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 Bytecodes::Code c;
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345 // Bytecodes and their length
a61af66fc99e Initial load
duke
parents:
diff changeset
346 const address code_base = method->code_base();
a61af66fc99e Initial load
duke
parents:
diff changeset
347 const int code_length = method->code_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
348
a61af66fc99e Initial load
duke
parents:
diff changeset
349 int bc_length;
a61af66fc99e Initial load
duke
parents:
diff changeset
350 for (int bci = 0; bci < code_length; bci += bc_length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 address bcp = code_base + bci;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
352 int prefix_length = 0;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
353 c = (Bytecodes::Code)(*bcp);
a61af66fc99e Initial load
duke
parents:
diff changeset
354
a61af66fc99e Initial load
duke
parents:
diff changeset
355 // Since we have the code, see if we can get the length
a61af66fc99e Initial load
duke
parents:
diff changeset
356 // directly. Some more complicated bytecodes will report
a61af66fc99e Initial load
duke
parents:
diff changeset
357 // a length of zero, meaning we need to make another method
a61af66fc99e Initial load
duke
parents:
diff changeset
358 // call to calculate the length.
a61af66fc99e Initial load
duke
parents:
diff changeset
359 bc_length = Bytecodes::length_for(c);
a61af66fc99e Initial load
duke
parents:
diff changeset
360 if (bc_length == 0) {
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
361 bc_length = Bytecodes::length_at(method, bcp);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
362
a61af66fc99e Initial load
duke
parents:
diff changeset
363 // length_at will put us at the bytecode after the one modified
a61af66fc99e Initial load
duke
parents:
diff changeset
364 // by 'wide'. We don't currently examine any of the bytecodes
a61af66fc99e Initial load
duke
parents:
diff changeset
365 // modified by wide, but in case we do in the future...
a61af66fc99e Initial load
duke
parents:
diff changeset
366 if (c == Bytecodes::_wide) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
367 prefix_length = 1;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
368 c = (Bytecodes::Code)bcp[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
369 }
a61af66fc99e Initial load
duke
parents:
diff changeset
370 }
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 assert(bc_length != 0, "impossible bytecode length");
a61af66fc99e Initial load
duke
parents:
diff changeset
373
a61af66fc99e Initial load
duke
parents:
diff changeset
374 switch (c) {
a61af66fc99e Initial load
duke
parents:
diff changeset
375 case Bytecodes::_lookupswitch : {
a61af66fc99e Initial load
duke
parents:
diff changeset
376 #ifndef CC_INTERP
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
377 Bytecode_lookupswitch bc(method, bcp);
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
378 (*bcp) = (
2142
8012aa3ccede 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 2011
diff changeset
379 bc.number_of_pairs() < BinarySwitchThreshold
0
a61af66fc99e Initial load
duke
parents:
diff changeset
380 ? Bytecodes::_fast_linearswitch
a61af66fc99e Initial load
duke
parents:
diff changeset
381 : Bytecodes::_fast_binaryswitch
a61af66fc99e Initial load
duke
parents:
diff changeset
382 );
a61af66fc99e Initial load
duke
parents:
diff changeset
383 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
384 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
385 }
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
386 case Bytecodes::_fast_linearswitch:
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
387 case Bytecodes::_fast_binaryswitch: {
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
388 #ifndef CC_INTERP
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
389 (*bcp) = Bytecodes::_lookupswitch;
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
390 #endif
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
391 break;
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
392 }
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
393
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
394 case Bytecodes::_invokespecial : {
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
395 rewrite_invokespecial(bcp, prefix_length+1, reverse, invokespecial_error);
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
396 break;
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
397 }
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
398
0
a61af66fc99e Initial load
duke
parents:
diff changeset
399 case Bytecodes::_getstatic : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
400 case Bytecodes::_putstatic : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
401 case Bytecodes::_getfield : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
402 case Bytecodes::_putfield : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
403 case Bytecodes::_invokevirtual : // fall through
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
404 case Bytecodes::_invokestatic :
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
405 case Bytecodes::_invokeinterface:
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
406 case Bytecodes::_invokehandle : // if reverse=true
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
407 rewrite_member_reference(bcp, prefix_length+1, reverse);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
408 break;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
409 case Bytecodes::_invokedynamic:
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
410 rewrite_invokedynamic(bcp, prefix_length+1, reverse);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
411 break;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
412 case Bytecodes::_ldc:
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
413 case Bytecodes::_fast_aldc: // if reverse=true
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
414 maybe_rewrite_ldc(bcp, prefix_length+1, false, reverse);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
415 break;
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
416 case Bytecodes::_ldc_w:
6266
1d7922586cf6 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 3748
diff changeset
417 case Bytecodes::_fast_aldc_w: // if reverse=true
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
418 maybe_rewrite_ldc(bcp, prefix_length+1, true, reverse);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
419 break;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
420 case Bytecodes::_jsr : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
421 case Bytecodes::_jsr_w : nof_jsrs++; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
422 case Bytecodes::_monitorenter : // fall through
a61af66fc99e Initial load
duke
parents:
diff changeset
423 case Bytecodes::_monitorexit : has_monitor_bytecodes = true; break;
a61af66fc99e Initial load
duke
parents:
diff changeset
424 }
a61af66fc99e Initial load
duke
parents:
diff changeset
425 }
a61af66fc99e Initial load
duke
parents:
diff changeset
426 }
a61af66fc99e Initial load
duke
parents:
diff changeset
427
a61af66fc99e Initial load
duke
parents:
diff changeset
428 // Update access flags
a61af66fc99e Initial load
duke
parents:
diff changeset
429 if (has_monitor_bytecodes) {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 method->set_has_monitor_bytecodes();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 }
a61af66fc99e Initial load
duke
parents:
diff changeset
432
a61af66fc99e Initial load
duke
parents:
diff changeset
433 // The present of a jsr bytecode implies that the method might potentially
a61af66fc99e Initial load
duke
parents:
diff changeset
434 // have to be rewritten, so we run the oopMapGenerator on the method
a61af66fc99e Initial load
duke
parents:
diff changeset
435 if (nof_jsrs > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
436 method->set_has_jsrs();
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
437 // Second pass will revisit this method.
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
438 assert(method->has_jsrs(), "didn't we just set this?");
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
439 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
440 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
441
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
442 // After constant pool is created, revisit methods containing jsrs.
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
443 methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) {
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
444 ResourceMark rm(THREAD);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
445 ResolveOopMapConflicts romc(method);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
446 methodHandle original_method = method;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
447 method = romc.do_potential_rewrite(CHECK_(methodHandle()));
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
448 // Update monitor matching info.
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
449 if (romc.monitor_safe()) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
450 method->set_guaranteed_monitor_matching();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
451 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
452
a61af66fc99e Initial load
duke
parents:
diff changeset
453 return method;
a61af66fc99e Initial load
duke
parents:
diff changeset
454 }
a61af66fc99e Initial load
duke
parents:
diff changeset
455
17665
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
456 void Rewriter::rewrite_bytecodes(TRAPS) {
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
457 assert(_pool->cache() == NULL, "constant pool cache must not be set yet");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
458
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
459 // determine index maps for Method* rewriting
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
460 compute_index_maps();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
461
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
462 if (RegisterFinalizersAtInit && _klass->name() == vmSymbols::java_lang_Object()) {
856
75596850f863 6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents: 726
diff changeset
463 bool did_rewrite = false;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
464 int i = _methods->length();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
465 while (i-- > 0) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
466 Method* method = _methods->at(i);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
467 if (method->intrinsic_id() == vmIntrinsics::_Object_init) {
a61af66fc99e Initial load
duke
parents:
diff changeset
468 // rewrite the return bytecodes of Object.<init> to register the
a61af66fc99e Initial load
duke
parents:
diff changeset
469 // object for finalization if needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
470 methodHandle m(THREAD, method);
a61af66fc99e Initial load
duke
parents:
diff changeset
471 rewrite_Object_init(m, CHECK);
856
75596850f863 6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents: 726
diff changeset
472 did_rewrite = true;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
473 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
474 }
a61af66fc99e Initial load
duke
parents:
diff changeset
475 }
856
75596850f863 6862576: vmIntrinsics needs cleanup in order to support JSR 292 intrinsics
jrose
parents: 726
diff changeset
476 assert(did_rewrite, "must find Object::<init> to rewrite it");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
477 }
a61af66fc99e Initial load
duke
parents:
diff changeset
478
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
479 // rewrite methods, in two passes
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
480 int len = _methods->length();
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
481 bool invokespecial_error = false;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
482
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
483 for (int i = len-1; i >= 0; i--) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
484 Method* method = _methods->at(i);
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
485 scan_method(method, false, &invokespecial_error);
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
486 if (invokespecial_error) {
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
487 // If you get an error here, there is no reversing bytecodes
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
488 // This exception is stored for this class and no further attempt is
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
489 // made at verifying or rewriting.
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
490 THROW_MSG(vmSymbols::java_lang_InternalError(),
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
491 "This classfile overflows invokespecial for interfaces "
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
492 "and cannot be loaded");
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
493 return;
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
494 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
495 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
496
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
497 // May have to fix invokedynamic bytecodes if invokestatic/InterfaceMethodref
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
498 // entries had to be added.
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
499 patch_invokedynamic_bytecodes();
17665
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
500 }
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
501
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
502 void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) {
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
503 ResourceMark rm(THREAD);
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
504 Rewriter rw(klass, klass->constants(), klass->methods(), CHECK);
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
505 // (That's all, folks.)
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
506 }
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
507
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
508
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
509 Rewriter::Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, Array<Method*>* methods, TRAPS)
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
510 : _klass(klass),
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
511 _pool(cpool),
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
512 _methods(methods)
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
513 {
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
514
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
515 // Rewrite bytecodes - exception here exits.
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
516 rewrite_bytecodes(CHECK);
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
517
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
518 // Stress restoring bytecodes
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
519 if (StressRewriter) {
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
520 restore_bytecodes();
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
521 rewrite_bytecodes(CHECK);
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
522 }
13056
41cb10cbfb3c 8025937: assert(existing_f1 == NULL || existing_f1 == f1) failed: illegal field change
coleenp
parents: 8712
diff changeset
523
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
524 // allocate constant pool cache, now that we've seen all the bytecodes
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
525 make_constant_pool_cache(THREAD);
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
526
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
527 // Restore bytecodes to their unrewritten state if there are exceptions
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
528 // rewriting bytecodes or allocating the cpCache
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
529 if (HAS_PENDING_EXCEPTION) {
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
530 restore_bytecodes();
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
531 return;
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
532 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
533
7459
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
534 // Relocate after everything, but still do this under the is_rewritten flag,
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
535 // so methods with jsrs in custom class lists in aren't attempted to be
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
536 // rewritten in the RO section of the shared archive.
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
537 // Relocated bytecodes don't have to be restored, only the cp cache entries
17665
10c9507f544a 8033528: assert(0 <= i && i < length()) failed: index out of bounds
coleenp
parents: 13390
diff changeset
538 int len = _methods->length();
3748
d3b9f2be46ab 7033141: assert(has_cp_cache(i)) failed: oob
coleenp
parents: 2460
diff changeset
539 for (int i = len-1; i >= 0; i--) {
7459
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
540 methodHandle m(THREAD, _methods->at(i));
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
541
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 579
diff changeset
542 if (m->has_jsrs()) {
7459
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
543 m = rewrite_jsrs(m, THREAD);
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
544 // Restore bytecodes to their unrewritten state if there are exceptions
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
545 // relocating bytecodes. If some are relocated, that is ok because that
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
546 // doesn't affect constant pool to cpCache rewriting.
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
547 if (HAS_PENDING_EXCEPTION) {
13390
d61a1a166f44 8028347: Rewriter::scan_method asserts with array oob in RT_Baseline
coleenp
parents: 13056
diff changeset
548 restore_bytecodes();
7459
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
549 return;
cc6a617fffd2 8005494: SIGSEGV in Rewriter::relocate_and_link() when testing Weblogic with CompressedOops and KlassPtrs
coleenp
parents: 6822
diff changeset
550 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
551 // Method might have gotten rewritten.
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6266
diff changeset
552 methods->at_put(i, m());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
553 }
a61af66fc99e Initial load
duke
parents:
diff changeset
554 }
a61af66fc99e Initial load
duke
parents:
diff changeset
555 }