author | alanb |
Thu, 17 Mar 2016 19:04:01 +0000 | |
changeset 36508 | 5f9eee6b383b |
parent 35606 | d873b64009cc |
child 37248 | 11a660dbbb8e |
child 36822 | cdc493d7bc9a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27706
diff
changeset
|
2 |
* Copyright (c) 1999, 2015, 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:
5420
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5420
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:
5420
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "ci/ciConstant.hpp" |
|
27 |
#include "ci/ciEnv.hpp" |
|
28 |
#include "ci/ciField.hpp" |
|
29 |
#include "ci/ciInstance.hpp" |
|
30 |
#include "ci/ciInstanceKlass.hpp" |
|
31 |
#include "ci/ciMethod.hpp" |
|
32 |
#include "ci/ciNullObject.hpp" |
|
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
33 |
#include "ci/ciReplay.hpp" |
7397 | 34 |
#include "ci/ciUtilities.hpp" |
35 |
#include "classfile/systemDictionary.hpp" |
|
36 |
#include "classfile/vmSymbols.hpp" |
|
26796 | 37 |
#include "code/codeCache.hpp" |
7397 | 38 |
#include "code/scopeDesc.hpp" |
39 |
#include "compiler/compileBroker.hpp" |
|
40 |
#include "compiler/compileLog.hpp" |
|
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
31019
diff
changeset
|
41 |
#include "compiler/disassembler.hpp" |
30764 | 42 |
#include "gc/shared/collectedHeap.inline.hpp" |
7397 | 43 |
#include "interpreter/linkResolver.hpp" |
44 |
#include "memory/allocation.inline.hpp" |
|
45 |
#include "memory/oopFactory.hpp" |
|
46 |
#include "memory/universe.inline.hpp" |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
47 |
#include "oops/methodData.hpp" |
7397 | 48 |
#include "oops/objArrayKlass.hpp" |
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27706
diff
changeset
|
49 |
#include "oops/objArrayOop.inline.hpp" |
7397 | 50 |
#include "oops/oop.inline.hpp" |
51 |
#include "prims/jvmtiExport.hpp" |
|
52 |
#include "runtime/init.hpp" |
|
53 |
#include "runtime/reflection.hpp" |
|
54 |
#include "runtime/sharedRuntime.hpp" |
|
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
23496
diff
changeset
|
55 |
#include "runtime/thread.inline.hpp" |
27706
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
56 |
#include "trace/tracing.hpp" |
7397 | 57 |
#include "utilities/dtrace.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
14490
diff
changeset
|
58 |
#include "utilities/macros.hpp" |
7397 | 59 |
#ifdef COMPILER1 |
60 |
#include "c1/c1_Runtime1.hpp" |
|
61 |
#endif |
|
62 |
#ifdef COMPILER2 |
|
63 |
#include "opto/runtime.hpp" |
|
64 |
#endif |
|
1 | 65 |
|
66 |
// ciEnv |
|
67 |
// |
|
68 |
// This class is the top level broker for requests from the compiler |
|
69 |
// to the VM. |
|
70 |
||
71 |
ciObject* ciEnv::_null_object_instance; |
|
72 |
||
4571 | 73 |
#define WK_KLASS_DEFN(name, ignore_s, ignore_o) ciInstanceKlass* ciEnv::_##name = NULL; |
74 |
WK_KLASSES_DO(WK_KLASS_DEFN) |
|
75 |
#undef WK_KLASS_DEFN |
|
1 | 76 |
|
77 |
ciSymbol* ciEnv::_unloaded_cisymbol = NULL; |
|
78 |
ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = NULL; |
|
79 |
ciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = NULL; |
|
80 |
||
81 |
jobject ciEnv::_ArrayIndexOutOfBoundsException_handle = NULL; |
|
82 |
jobject ciEnv::_ArrayStoreException_handle = NULL; |
|
83 |
jobject ciEnv::_ClassCastException_handle = NULL; |
|
84 |
||
85 |
#ifndef PRODUCT |
|
86 |
static bool firstEnv = true; |
|
87 |
#endif /* PRODUCT */ |
|
88 |
||
89 |
// ------------------------------------------------------------------ |
|
90 |
// ciEnv::ciEnv |
|
25946 | 91 |
ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) |
92 |
: _ciEnv_arena(mtCompiler) { |
|
1 | 93 |
VM_ENTRY_MARK; |
94 |
||
95 |
// Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. |
|
96 |
thread->set_env(this); |
|
97 |
assert(ciEnv::current() == this, "sanity"); |
|
98 |
||
99 |
_oop_recorder = NULL; |
|
100 |
_debug_info = NULL; |
|
101 |
_dependencies = NULL; |
|
102 |
_failure_reason = NULL; |
|
103 |
_compilable = MethodCompilable; |
|
104 |
_break_at_compile = false; |
|
105 |
_compiler_data = NULL; |
|
106 |
#ifndef PRODUCT |
|
107 |
assert(!firstEnv, "not initialized properly"); |
|
108 |
#endif /* !PRODUCT */ |
|
109 |
||
110 |
_system_dictionary_modification_counter = system_dictionary_modification_counter; |
|
111 |
_num_inlined_bytecodes = 0; |
|
112 |
assert(task == NULL || thread->task() == task, "sanity"); |
|
113 |
_task = task; |
|
114 |
_log = NULL; |
|
115 |
||
116 |
// Temporary buffer for creating symbols and such. |
|
117 |
_name_buffer = NULL; |
|
118 |
_name_buffer_len = 0; |
|
119 |
||
120 |
_arena = &_ciEnv_arena; |
|
121 |
_factory = new (_arena) ciObjectFactory(_arena, 128); |
|
122 |
||
123 |
// Preload commonly referenced system ciObjects. |
|
124 |
||
125 |
// During VM initialization, these instances have not yet been created. |
|
126 |
// Assertions ensure that these instances are not accessed before |
|
127 |
// their initialization. |
|
128 |
||
129 |
assert(Universe::is_fully_initialized(), "should be complete"); |
|
130 |
||
131 |
oop o = Universe::null_ptr_exception_instance(); |
|
132 |
assert(o != NULL, "should have been initialized"); |
|
133 |
_NullPointerException_instance = get_object(o)->as_instance(); |
|
134 |
o = Universe::arithmetic_exception_instance(); |
|
135 |
assert(o != NULL, "should have been initialized"); |
|
136 |
_ArithmeticException_instance = get_object(o)->as_instance(); |
|
137 |
||
138 |
_ArrayIndexOutOfBoundsException_instance = NULL; |
|
139 |
_ArrayStoreException_instance = NULL; |
|
140 |
_ClassCastException_instance = NULL; |
|
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
141 |
_the_null_string = NULL; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
142 |
_the_min_jint_string = NULL; |
22893
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
143 |
|
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
144 |
_jvmti_can_hotswap_or_post_breakpoint = false; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
145 |
_jvmti_can_access_local_variables = false; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
146 |
_jvmti_can_post_on_exceptions = false; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
147 |
_jvmti_can_pop_frame = false; |
1 | 148 |
} |
149 |
||
25946 | 150 |
ciEnv::ciEnv(Arena* arena) : _ciEnv_arena(mtCompiler) { |
1 | 151 |
ASSERT_IN_VM; |
152 |
||
153 |
// Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. |
|
154 |
CompilerThread* current_thread = CompilerThread::current(); |
|
155 |
assert(current_thread->env() == NULL, "must be"); |
|
156 |
current_thread->set_env(this); |
|
157 |
assert(ciEnv::current() == this, "sanity"); |
|
158 |
||
159 |
_oop_recorder = NULL; |
|
160 |
_debug_info = NULL; |
|
161 |
_dependencies = NULL; |
|
162 |
_failure_reason = NULL; |
|
163 |
_compilable = MethodCompilable_never; |
|
164 |
_break_at_compile = false; |
|
165 |
_compiler_data = NULL; |
|
166 |
#ifndef PRODUCT |
|
167 |
assert(firstEnv, "must be first"); |
|
168 |
firstEnv = false; |
|
169 |
#endif /* !PRODUCT */ |
|
170 |
||
171 |
_system_dictionary_modification_counter = 0; |
|
172 |
_num_inlined_bytecodes = 0; |
|
173 |
_task = NULL; |
|
174 |
_log = NULL; |
|
175 |
||
176 |
// Temporary buffer for creating symbols and such. |
|
177 |
_name_buffer = NULL; |
|
178 |
_name_buffer_len = 0; |
|
179 |
||
180 |
_arena = arena; |
|
181 |
_factory = new (_arena) ciObjectFactory(_arena, 128); |
|
182 |
||
183 |
// Preload commonly referenced system ciObjects. |
|
184 |
||
185 |
// During VM initialization, these instances have not yet been created. |
|
186 |
// Assertions ensure that these instances are not accessed before |
|
187 |
// their initialization. |
|
188 |
||
189 |
assert(Universe::is_fully_initialized(), "must be"); |
|
190 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
191 |
_NullPointerException_instance = NULL; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
192 |
_ArithmeticException_instance = NULL; |
1 | 193 |
_ArrayIndexOutOfBoundsException_instance = NULL; |
194 |
_ArrayStoreException_instance = NULL; |
|
195 |
_ClassCastException_instance = NULL; |
|
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
196 |
_the_null_string = NULL; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
197 |
_the_min_jint_string = NULL; |
22893
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
198 |
|
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
199 |
_jvmti_can_hotswap_or_post_breakpoint = false; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
200 |
_jvmti_can_access_local_variables = false; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
201 |
_jvmti_can_post_on_exceptions = false; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
202 |
_jvmti_can_pop_frame = false; |
1 | 203 |
} |
204 |
||
205 |
ciEnv::~ciEnv() { |
|
206 |
CompilerThread* current_thread = CompilerThread::current(); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
207 |
_factory->remove_symbols(); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
208 |
// Need safepoint to clear the env on the thread. RedefineClasses might |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
209 |
// be reading it. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
210 |
GUARDED_VM_ENTRY(current_thread->set_env(NULL);) |
1 | 211 |
} |
212 |
||
213 |
// ------------------------------------------------------------------ |
|
2867
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
214 |
// Cache Jvmti state |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
215 |
void ciEnv::cache_jvmti_state() { |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
216 |
VM_ENTRY_MARK; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
217 |
// Get Jvmti capabilities under lock to get consistant values. |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
218 |
MutexLocker mu(JvmtiThreadState_lock); |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
219 |
_jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint(); |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
220 |
_jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables(); |
4761
bdb7375a1fee
6902182: 4/4 Starting with jdwp agent should not incur performance penalty
dcubed
parents:
4571
diff
changeset
|
221 |
_jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions(); |
22893
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
222 |
_jvmti_can_pop_frame = JvmtiExport::can_pop_frame(); |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
223 |
} |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
224 |
|
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
225 |
bool ciEnv::should_retain_local_variables() const { |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
226 |
return _jvmti_can_access_local_variables || _jvmti_can_pop_frame; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
227 |
} |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
228 |
|
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
229 |
bool ciEnv::jvmti_state_changed() const { |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
230 |
if (!_jvmti_can_access_local_variables && |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
231 |
JvmtiExport::can_access_local_variables()) { |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
232 |
return true; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
233 |
} |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
234 |
if (!_jvmti_can_hotswap_or_post_breakpoint && |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
235 |
JvmtiExport::can_hotswap_or_post_breakpoint()) { |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
236 |
return true; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
237 |
} |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
238 |
if (!_jvmti_can_post_on_exceptions && |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
239 |
JvmtiExport::can_post_on_exceptions()) { |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
240 |
return true; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
241 |
} |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
242 |
if (!_jvmti_can_pop_frame && |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
243 |
JvmtiExport::can_pop_frame()) { |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
244 |
return true; |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
245 |
} |
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
246 |
return false; |
2867
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
247 |
} |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
248 |
|
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
249 |
// ------------------------------------------------------------------ |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
250 |
// Cache DTrace flags |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
251 |
void ciEnv::cache_dtrace_flags() { |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
252 |
// Need lock? |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
253 |
_dtrace_extended_probes = ExtendedDTraceProbes; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
254 |
if (_dtrace_extended_probes) { |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
255 |
_dtrace_monitor_probes = true; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
256 |
_dtrace_method_probes = true; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
257 |
_dtrace_alloc_probes = true; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
258 |
} else { |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
259 |
_dtrace_monitor_probes = DTraceMonitorProbes; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
260 |
_dtrace_method_probes = DTraceMethodProbes; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
261 |
_dtrace_alloc_probes = DTraceAllocProbes; |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
262 |
} |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
263 |
} |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
264 |
|
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
265 |
// ------------------------------------------------------------------ |
1 | 266 |
// helper for lazy exception creation |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
267 |
ciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) { |
1 | 268 |
VM_ENTRY_MARK; |
269 |
if (handle == NULL) { |
|
270 |
// Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
271 |
Klass* k = SystemDictionary::find(name, Handle(), Handle(), THREAD); |
1 | 272 |
jobject objh = NULL; |
273 |
if (!HAS_PENDING_EXCEPTION && k != NULL) { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
274 |
oop obj = InstanceKlass::cast(k)->allocate_instance(THREAD); |
1 | 275 |
if (!HAS_PENDING_EXCEPTION) |
276 |
objh = JNIHandles::make_global(obj); |
|
277 |
} |
|
278 |
if (HAS_PENDING_EXCEPTION) { |
|
279 |
CLEAR_PENDING_EXCEPTION; |
|
280 |
} else { |
|
281 |
handle = objh; |
|
282 |
} |
|
283 |
} |
|
284 |
oop obj = JNIHandles::resolve(handle); |
|
285 |
return obj == NULL? NULL: get_object(obj)->as_instance(); |
|
286 |
} |
|
287 |
||
288 |
ciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() { |
|
289 |
if (_ArrayIndexOutOfBoundsException_instance == NULL) { |
|
290 |
_ArrayIndexOutOfBoundsException_instance |
|
291 |
= get_or_create_exception(_ArrayIndexOutOfBoundsException_handle, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
292 |
vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); |
1 | 293 |
} |
294 |
return _ArrayIndexOutOfBoundsException_instance; |
|
295 |
} |
|
296 |
ciInstance* ciEnv::ArrayStoreException_instance() { |
|
297 |
if (_ArrayStoreException_instance == NULL) { |
|
298 |
_ArrayStoreException_instance |
|
299 |
= get_or_create_exception(_ArrayStoreException_handle, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
300 |
vmSymbols::java_lang_ArrayStoreException()); |
1 | 301 |
} |
302 |
return _ArrayStoreException_instance; |
|
303 |
} |
|
304 |
ciInstance* ciEnv::ClassCastException_instance() { |
|
305 |
if (_ClassCastException_instance == NULL) { |
|
306 |
_ClassCastException_instance |
|
307 |
= get_or_create_exception(_ClassCastException_handle, |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
308 |
vmSymbols::java_lang_ClassCastException()); |
1 | 309 |
} |
310 |
return _ClassCastException_instance; |
|
311 |
} |
|
312 |
||
4450
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
313 |
ciInstance* ciEnv::the_null_string() { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
314 |
if (_the_null_string == NULL) { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
315 |
VM_ENTRY_MARK; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
316 |
_the_null_string = get_object(Universe::the_null_string())->as_instance(); |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
317 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
318 |
return _the_null_string; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
319 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
320 |
|
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
321 |
ciInstance* ciEnv::the_min_jint_string() { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
322 |
if (_the_min_jint_string == NULL) { |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
323 |
VM_ENTRY_MARK; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
324 |
_the_min_jint_string = get_object(Universe::the_min_jint_string())->as_instance(); |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
325 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
326 |
return _the_min_jint_string; |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
327 |
} |
6d700b859b3e
6892658: C2 should optimize some stringbuilder patterns
never
parents:
4429
diff
changeset
|
328 |
|
1 | 329 |
// ------------------------------------------------------------------ |
330 |
// ciEnv::get_method_from_handle |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
331 |
ciMethod* ciEnv::get_method_from_handle(Method* method) { |
1 | 332 |
VM_ENTRY_MARK; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
333 |
return get_metadata(method)->as_method(); |
1 | 334 |
} |
335 |
||
336 |
// ------------------------------------------------------------------ |
|
337 |
// ciEnv::array_element_offset_in_bytes |
|
338 |
int ciEnv::array_element_offset_in_bytes(ciArray* a_h, ciObject* o_h) { |
|
339 |
VM_ENTRY_MARK; |
|
340 |
objArrayOop a = (objArrayOop)a_h->get_oop(); |
|
341 |
assert(a->is_objArray(), ""); |
|
342 |
int length = a->length(); |
|
343 |
oop o = o_h->get_oop(); |
|
344 |
for (int i = 0; i < length; i++) { |
|
345 |
if (a->obj_at(i) == o) return i; |
|
346 |
} |
|
347 |
return -1; |
|
348 |
} |
|
349 |
||
350 |
||
351 |
// ------------------------------------------------------------------ |
|
352 |
// ciEnv::check_klass_accessiblity |
|
353 |
// |
|
354 |
// Note: the logic of this method should mirror the logic of |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
355 |
// ConstantPool::verify_constant_pool_resolve. |
1 | 356 |
bool ciEnv::check_klass_accessibility(ciKlass* accessing_klass, |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
357 |
Klass* resolved_klass) { |
1 | 358 |
if (accessing_klass == NULL || !accessing_klass->is_loaded()) { |
359 |
return true; |
|
360 |
} |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
361 |
if (accessing_klass->is_obj_array_klass()) { |
1 | 362 |
accessing_klass = accessing_klass->as_obj_array_klass()->base_element_klass(); |
363 |
} |
|
364 |
if (!accessing_klass->is_instance_klass()) { |
|
365 |
return true; |
|
366 |
} |
|
367 |
||
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33593
diff
changeset
|
368 |
if (resolved_klass->is_objArray_klass()) { |
1 | 369 |
// Find the element klass, if this is an array. |
13952
e3cf184080bc
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
13883
diff
changeset
|
370 |
resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass(); |
1 | 371 |
} |
33611
9abd65805e19
8139203: Consistent naming for klass type predicates
coleenp
parents:
33593
diff
changeset
|
372 |
if (resolved_klass->is_instance_klass()) { |
36508 | 373 |
return (Reflection::verify_class_access(accessing_klass->get_Klass(), |
374 |
resolved_klass, |
|
375 |
true) == Reflection::ACCESS_OK); |
|
1 | 376 |
} |
377 |
return true; |
|
378 |
} |
|
379 |
||
380 |
// ------------------------------------------------------------------ |
|
381 |
// ciEnv::get_klass_by_name_impl |
|
382 |
ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31019
diff
changeset
|
383 |
const constantPoolHandle& cpool, |
1 | 384 |
ciSymbol* name, |
385 |
bool require_local) { |
|
386 |
ASSERT_IN_VM; |
|
387 |
EXCEPTION_CONTEXT; |
|
388 |
||
389 |
// Now we need to check the SystemDictionary |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
390 |
Symbol* sym = name->get_symbol(); |
1 | 391 |
if (sym->byte_at(0) == 'L' && |
392 |
sym->byte_at(sym->utf8_length()-1) == ';') { |
|
393 |
// This is a name from a signature. Strip off the trimmings. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
394 |
// Call recursive to keep scope of strippedsym. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
395 |
TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
396 |
sym->utf8_length()-2, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
397 |
KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass)); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
398 |
ciSymbol* strippedname = get_symbol(strippedsym); |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
399 |
return get_klass_by_name_impl(accessing_klass, cpool, strippedname, require_local); |
1 | 400 |
} |
401 |
||
402 |
// Check for prior unloaded klass. The SystemDictionary's answers |
|
403 |
// can vary over time but the compiler needs consistency. |
|
404 |
ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name); |
|
405 |
if (unloaded_klass != NULL) { |
|
406 |
if (require_local) return NULL; |
|
407 |
return unloaded_klass; |
|
408 |
} |
|
409 |
||
410 |
Handle loader(THREAD, (oop)NULL); |
|
411 |
Handle domain(THREAD, (oop)NULL); |
|
412 |
if (accessing_klass != NULL) { |
|
413 |
loader = Handle(THREAD, accessing_klass->loader()); |
|
414 |
domain = Handle(THREAD, accessing_klass->protection_domain()); |
|
415 |
} |
|
416 |
||
417 |
// setup up the proper type to return on OOM |
|
418 |
ciKlass* fail_type; |
|
419 |
if (sym->byte_at(0) == '[') { |
|
420 |
fail_type = _unloaded_ciobjarrayklass; |
|
421 |
} else { |
|
422 |
fail_type = _unloaded_ciinstance_klass; |
|
423 |
} |
|
7918
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7397
diff
changeset
|
424 |
KlassHandle found_klass; |
8314
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
425 |
{ |
8333
11a7f6fc6419
7021531: lock ordering problems after fix for 6354181
never
parents:
8314
diff
changeset
|
426 |
ttyUnlocker ttyul; // release tty lock to avoid ordering problems |
8314
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
427 |
MutexLocker ml(Compile_lock); |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
428 |
Klass* kls; |
8314
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
429 |
if (!require_local) { |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
430 |
kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
431 |
KILL_COMPILE_ON_FATAL_(fail_type)); |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
432 |
} else { |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
433 |
kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
434 |
KILL_COMPILE_ON_FATAL_(fail_type)); |
057b1c20fd7e
6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111"
never
parents:
8076
diff
changeset
|
435 |
} |
7918
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7397
diff
changeset
|
436 |
found_klass = KlassHandle(THREAD, kls); |
1 | 437 |
} |
438 |
||
439 |
// If we fail to find an array klass, look again for its element type. |
|
440 |
// The element type may be available either locally or via constraints. |
|
441 |
// In either case, if we can find the element type in the system dictionary, |
|
442 |
// we must build an array type around it. The CI requires array klasses |
|
443 |
// to be loaded if their element klasses are loaded, except when memory |
|
444 |
// is exhausted. |
|
445 |
if (sym->byte_at(0) == '[' && |
|
446 |
(sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) { |
|
447 |
// We have an unloaded array. |
|
448 |
// Build it on the fly if the element class exists. |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
449 |
TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
450 |
sym->utf8_length()-1, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
451 |
KILL_COMPILE_ON_FATAL_(fail_type)); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
452 |
|
1 | 453 |
// Get element ciKlass recursively. |
454 |
ciKlass* elem_klass = |
|
455 |
get_klass_by_name_impl(accessing_klass, |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
456 |
cpool, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
457 |
get_symbol(elem_sym), |
1 | 458 |
require_local); |
459 |
if (elem_klass != NULL && elem_klass->is_loaded()) { |
|
460 |
// Now make an array for it |
|
461 |
return ciObjArrayKlass::make_impl(elem_klass); |
|
462 |
} |
|
463 |
} |
|
464 |
||
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
465 |
if (found_klass() == NULL && !cpool.is_null() && cpool->has_preresolution()) { |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
466 |
// Look inside the constant pool for pre-resolved class entries. |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
467 |
for (int i = cpool->length() - 1; i >= 1; i--) { |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
468 |
if (cpool->tag_at(i).is_klass()) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
469 |
Klass* kls = cpool->resolved_klass_at(i); |
14488 | 470 |
if (kls->name() == sym) { |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
471 |
found_klass = KlassHandle(THREAD, kls); |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
472 |
break; |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
473 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
474 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
475 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
476 |
} |
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
477 |
|
7918
ce1e4ae77aea
7012505: BreakpointWithFullGC.sh fails with Internal Error (src/share/vm/oops/methodOop.cpp:220)
kamg
parents:
7397
diff
changeset
|
478 |
if (found_klass() != NULL) { |
1 | 479 |
// Found it. Build a CI handle. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
480 |
return get_klass(found_klass()); |
1 | 481 |
} |
482 |
||
483 |
if (require_local) return NULL; |
|
10734
065435337883
7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents:
10564
diff
changeset
|
484 |
|
1 | 485 |
// Not yet loaded into the VM, or not governed by loader constraints. |
486 |
// Make a CI representative for it. |
|
487 |
return get_unloaded_klass(accessing_klass, name); |
|
488 |
} |
|
489 |
||
490 |
// ------------------------------------------------------------------ |
|
491 |
// ciEnv::get_klass_by_name |
|
492 |
ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass, |
|
493 |
ciSymbol* klass_name, |
|
494 |
bool require_local) { |
|
495 |
GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass, |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
496 |
constantPoolHandle(), |
1 | 497 |
klass_name, |
498 |
require_local);) |
|
499 |
} |
|
500 |
||
501 |
// ------------------------------------------------------------------ |
|
502 |
// ciEnv::get_klass_by_index_impl |
|
503 |
// |
|
504 |
// Implementation of get_klass_by_index. |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31019
diff
changeset
|
505 |
ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool, |
1 | 506 |
int index, |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
507 |
bool& is_accessible, |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
508 |
ciInstanceKlass* accessor) { |
1 | 509 |
EXCEPTION_CONTEXT; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
510 |
KlassHandle klass; // = NULL; |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
511 |
Symbol* klass_name = NULL; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
512 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
513 |
if (cpool->tag_at(index).is_symbol()) { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
514 |
klass_name = cpool->symbol_at(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
515 |
} else { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
516 |
// Check if it's resolved if it's not a symbol constant pool entry. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
517 |
klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); |
25325 | 518 |
// Try to look it up by name. |
1 | 519 |
if (klass.is_null()) { |
25325 | 520 |
klass_name = cpool->klass_name_at(index); |
1 | 521 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
522 |
} |
1 | 523 |
|
524 |
if (klass.is_null()) { |
|
525 |
// Not found in constant pool. Use the name to do the lookup. |
|
526 |
ciKlass* k = get_klass_by_name_impl(accessor, |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
527 |
cpool, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
528 |
get_symbol(klass_name), |
1 | 529 |
false); |
530 |
// Calculate accessibility the hard way. |
|
531 |
if (!k->is_loaded()) { |
|
532 |
is_accessible = false; |
|
533 |
} else if (k->loader() != accessor->loader() && |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
534 |
get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) { |
1 | 535 |
// Loaded only remotely. Not linked yet. |
536 |
is_accessible = false; |
|
537 |
} else { |
|
538 |
// Linked locally, and we must also check public/private, etc. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
539 |
is_accessible = check_klass_accessibility(accessor, k->get_Klass()); |
1 | 540 |
} |
541 |
return k; |
|
542 |
} |
|
543 |
||
544 |
// Check for prior unloaded klass. The SystemDictionary's answers |
|
545 |
// can vary over time but the compiler needs consistency. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
546 |
ciSymbol* name = get_symbol(klass()->name()); |
1 | 547 |
ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name); |
548 |
if (unloaded_klass != NULL) { |
|
549 |
is_accessible = false; |
|
550 |
return unloaded_klass; |
|
551 |
} |
|
552 |
||
553 |
// It is known to be accessible, since it was found in the constant pool. |
|
554 |
is_accessible = true; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
555 |
return get_klass(klass()); |
1 | 556 |
} |
557 |
||
558 |
// ------------------------------------------------------------------ |
|
559 |
// ciEnv::get_klass_by_index |
|
560 |
// |
|
561 |
// Get a klass from the constant pool. |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31019
diff
changeset
|
562 |
ciKlass* ciEnv::get_klass_by_index(const constantPoolHandle& cpool, |
1 | 563 |
int index, |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
564 |
bool& is_accessible, |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
565 |
ciInstanceKlass* accessor) { |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
566 |
GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);) |
1 | 567 |
} |
568 |
||
569 |
// ------------------------------------------------------------------ |
|
570 |
// ciEnv::get_constant_by_index_impl |
|
571 |
// |
|
572 |
// Implementation of get_constant_by_index(). |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31019
diff
changeset
|
573 |
ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool, |
5882 | 574 |
int pool_index, int cache_index, |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
575 |
ciInstanceKlass* accessor) { |
5882 | 576 |
bool ignore_will_link; |
1 | 577 |
EXCEPTION_CONTEXT; |
5882 | 578 |
int index = pool_index; |
579 |
if (cache_index >= 0) { |
|
580 |
assert(index < 0, "only one kind of index at a time"); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
581 |
oop obj = cpool->resolved_references()->obj_at(cache_index); |
5882 | 582 |
if (obj != NULL) { |
583 |
ciObject* ciobj = get_object(obj); |
|
26944
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
584 |
if (ciobj->is_array()) { |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
585 |
return ciConstant(T_ARRAY, ciobj); |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
586 |
} else { |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
587 |
assert(ciobj->is_instance(), "should be an instance"); |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
588 |
return ciConstant(T_OBJECT, ciobj); |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
589 |
} |
5882 | 590 |
} |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
591 |
index = cpool->object_to_cp_index(cache_index); |
5882 | 592 |
} |
1 | 593 |
constantTag tag = cpool->tag_at(index); |
594 |
if (tag.is_int()) { |
|
595 |
return ciConstant(T_INT, (jint)cpool->int_at(index)); |
|
596 |
} else if (tag.is_long()) { |
|
597 |
return ciConstant((jlong)cpool->long_at(index)); |
|
598 |
} else if (tag.is_float()) { |
|
599 |
return ciConstant((jfloat)cpool->float_at(index)); |
|
600 |
} else if (tag.is_double()) { |
|
601 |
return ciConstant((jdouble)cpool->double_at(index)); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
602 |
} else if (tag.is_string()) { |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
603 |
oop string = NULL; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
604 |
assert(cache_index >= 0, "should have a cache index"); |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
605 |
if (cpool->is_pseudo_string_at(index)) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
606 |
string = cpool->pseudo_string_at(index, cache_index); |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
607 |
} else { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
608 |
string = cpool->string_at(index, cache_index, THREAD); |
1550
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
609 |
if (HAS_PENDING_EXCEPTION) { |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
610 |
CLEAR_PENDING_EXCEPTION; |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
611 |
record_out_of_memory_failure(); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
612 |
return ciConstant(); |
be2fc37a817f
6653858: dynamic languages need to be able to load anonymous classes
jrose
parents:
1
diff
changeset
|
613 |
} |
1 | 614 |
} |
615 |
ciObject* constant = get_object(string); |
|
26944
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
616 |
if (constant->is_array()) { |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
617 |
return ciConstant(T_ARRAY, constant); |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
618 |
} else { |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
619 |
assert (constant->is_instance(), "must be an instance, or not? "); |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
620 |
return ciConstant(T_OBJECT, constant); |
d515f86283be
8058828: Wrong ciConstant type for arrays from ConstantPool::_resolved_reference
vlivanov
parents:
26796
diff
changeset
|
621 |
} |
1 | 622 |
} else if (tag.is_klass() || tag.is_unresolved_klass()) { |
623 |
// 4881222: allow ldc to take a class type |
|
5882 | 624 |
ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore_will_link, accessor); |
1 | 625 |
if (HAS_PENDING_EXCEPTION) { |
626 |
CLEAR_PENDING_EXCEPTION; |
|
627 |
record_out_of_memory_failure(); |
|
628 |
return ciConstant(); |
|
629 |
} |
|
630 |
assert (klass->is_instance_klass() || klass->is_array_klass(), |
|
631 |
"must be an instance or array klass "); |
|
5882 | 632 |
return ciConstant(T_OBJECT, klass->java_mirror()); |
633 |
} else if (tag.is_method_type()) { |
|
634 |
// must execute Java code to link this CP entry into cache[i].f1 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
635 |
ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index)); |
5882 | 636 |
ciObject* ciobj = get_unloaded_method_type_constant(signature); |
637 |
return ciConstant(T_OBJECT, ciobj); |
|
638 |
} else if (tag.is_method_handle()) { |
|
639 |
// must execute Java code to link this CP entry into cache[i].f1 |
|
640 |
int ref_kind = cpool->method_handle_ref_kind_at(index); |
|
641 |
int callee_index = cpool->method_handle_klass_index_at(index); |
|
642 |
ciKlass* callee = get_klass_by_index_impl(cpool, callee_index, ignore_will_link, accessor); |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
643 |
ciSymbol* name = get_symbol(cpool->method_handle_name_ref_at(index)); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
644 |
ciSymbol* signature = get_symbol(cpool->method_handle_signature_ref_at(index)); |
5882 | 645 |
ciObject* ciobj = get_unloaded_method_handle_constant(callee, name, signature, ref_kind); |
646 |
return ciConstant(T_OBJECT, ciobj); |
|
1 | 647 |
} else { |
648 |
ShouldNotReachHere(); |
|
649 |
return ciConstant(); |
|
650 |
} |
|
651 |
} |
|
652 |
||
653 |
// ------------------------------------------------------------------ |
|
654 |
// ciEnv::get_constant_by_index |
|
655 |
// |
|
656 |
// Pull a constant out of the constant pool. How appropriate. |
|
657 |
// |
|
658 |
// Implementation note: this query is currently in no way cached. |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31019
diff
changeset
|
659 |
ciConstant ciEnv::get_constant_by_index(const constantPoolHandle& cpool, |
5882 | 660 |
int pool_index, int cache_index, |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
661 |
ciInstanceKlass* accessor) { |
5882 | 662 |
GUARDED_VM_ENTRY(return get_constant_by_index_impl(cpool, pool_index, cache_index, accessor);) |
1 | 663 |
} |
664 |
||
665 |
// ------------------------------------------------------------------ |
|
666 |
// ciEnv::get_field_by_index_impl |
|
667 |
// |
|
668 |
// Implementation of get_field_by_index. |
|
669 |
// |
|
670 |
// Implementation note: the results of field lookups are cached |
|
671 |
// in the accessor klass. |
|
672 |
ciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor, |
|
673 |
int index) { |
|
674 |
ciConstantPoolCache* cache = accessor->field_cache(); |
|
675 |
if (cache == NULL) { |
|
676 |
ciField* field = new (arena()) ciField(accessor, index); |
|
677 |
return field; |
|
678 |
} else { |
|
679 |
ciField* field = (ciField*)cache->get(index); |
|
680 |
if (field == NULL) { |
|
681 |
field = new (arena()) ciField(accessor, index); |
|
682 |
cache->insert(index, field); |
|
683 |
} |
|
684 |
return field; |
|
685 |
} |
|
686 |
} |
|
687 |
||
688 |
// ------------------------------------------------------------------ |
|
689 |
// ciEnv::get_field_by_index |
|
690 |
// |
|
691 |
// Get a field by index from a klass's constant pool. |
|
692 |
ciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor, |
|
693 |
int index) { |
|
694 |
GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);) |
|
695 |
} |
|
696 |
||
697 |
// ------------------------------------------------------------------ |
|
698 |
// ciEnv::lookup_method |
|
699 |
// |
|
700 |
// Perform an appropriate method lookup based on accessor, holder, |
|
701 |
// name, signature, and bytecode. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
702 |
Method* ciEnv::lookup_method(InstanceKlass* accessor, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
703 |
InstanceKlass* holder, |
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
704 |
Symbol* name, |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7918
diff
changeset
|
705 |
Symbol* sig, |
34238 | 706 |
Bytecodes::Code bc) { |
1 | 707 |
EXCEPTION_CONTEXT; |
708 |
KlassHandle h_accessor(THREAD, accessor); |
|
709 |
KlassHandle h_holder(THREAD, holder); |
|
710 |
LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL)); |
|
711 |
methodHandle dest_method; |
|
34238 | 712 |
LinkInfo link_info(h_holder, name, sig, h_accessor, /*check_access*/true); |
1 | 713 |
switch (bc) { |
714 |
case Bytecodes::_invokestatic: |
|
715 |
dest_method = |
|
31019 | 716 |
LinkResolver::resolve_static_call_or_null(link_info); |
1 | 717 |
break; |
718 |
case Bytecodes::_invokespecial: |
|
719 |
dest_method = |
|
31019 | 720 |
LinkResolver::resolve_special_call_or_null(link_info); |
1 | 721 |
break; |
722 |
case Bytecodes::_invokeinterface: |
|
723 |
dest_method = |
|
31019 | 724 |
LinkResolver::linktime_resolve_interface_method_or_null(link_info); |
1 | 725 |
break; |
726 |
case Bytecodes::_invokevirtual: |
|
727 |
dest_method = |
|
31019 | 728 |
LinkResolver::linktime_resolve_virtual_method_or_null(link_info); |
1 | 729 |
break; |
730 |
default: ShouldNotReachHere(); |
|
731 |
} |
|
732 |
||
733 |
return dest_method(); |
|
734 |
} |
|
735 |
||
736 |
||
737 |
// ------------------------------------------------------------------ |
|
738 |
// ciEnv::get_method_by_index_impl |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31019
diff
changeset
|
739 |
ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool, |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
740 |
int index, Bytecodes::Code bc, |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
741 |
ciInstanceKlass* accessor) { |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
742 |
if (bc == Bytecodes::_invokedynamic) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
743 |
ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
744 |
bool is_resolved = !cpce->is_f1_null(); |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
745 |
// FIXME: code generation could allow for null (unlinked) call site |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
746 |
// The call site could be made patchable as follows: |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
747 |
// Load the appendix argument from the constant pool. |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
748 |
// Test the appendix argument and jump to a known deopt routine if it is null. |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
749 |
// Jump through a patchable call site, which is initially a deopt routine. |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
750 |
// Patch the call site to the nmethod entry point of the static compiled lambda form. |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
751 |
// As with other two-component call sites, both values must be independently verified. |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
752 |
|
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
753 |
if (is_resolved) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
754 |
// Get the invoker Method* from the constant pool. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
755 |
// (The appendix argument, if any, will be noted in the method's signature.) |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
756 |
Method* adapter = cpce->f1_as_method(); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
757 |
return get_method(adapter); |
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
758 |
} |
1 | 759 |
|
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
760 |
// Fake a method that is equivalent to a declared method. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
761 |
ciInstanceKlass* holder = get_instance_klass(SystemDictionary::MethodHandle_klass()); |
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10734
diff
changeset
|
762 |
ciSymbol* name = ciSymbol::invokeBasic_name(); |
10734
065435337883
7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents:
10564
diff
changeset
|
763 |
ciSymbol* signature = get_symbol(cpool->signature_ref_at(index)); |
065435337883
7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
twisti
parents:
10564
diff
changeset
|
764 |
return get_unloaded_method(holder, name, signature, accessor); |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
765 |
} else { |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
766 |
const int holder_index = cpool->klass_ref_index_at(index); |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
767 |
bool holder_is_accessible; |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
768 |
ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor); |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
769 |
ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder); |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
770 |
|
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
771 |
// Get the method's name and signature. |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
772 |
Symbol* name_sym = cpool->name_ref_at(index); |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
773 |
Symbol* sig_sym = cpool->signature_ref_at(index); |
4566
b363f6ef4068
6829187: compiler optimizations required for JSR 292
twisti
parents:
4450
diff
changeset
|
774 |
|
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
775 |
if (cpool->has_preresolution() |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
776 |
|| (holder == ciEnv::MethodHandle_klass() && |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
777 |
MethodHandles::is_signature_polymorphic_name(holder->get_Klass(), name_sym))) { |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
778 |
// Short-circuit lookups for JSR 292-related call sites. |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
779 |
// That is, do not rely only on name-based lookups, because they may fail |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
780 |
// if the names are not resolvable in the boot class loader (7056328). |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
781 |
switch (bc) { |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
782 |
case Bytecodes::_invokevirtual: |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
783 |
case Bytecodes::_invokeinterface: |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
784 |
case Bytecodes::_invokespecial: |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
785 |
case Bytecodes::_invokestatic: |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
786 |
{ |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
787 |
Method* m = ConstantPool::method_at_if_loaded(cpool, index); |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
788 |
if (m != NULL) { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
789 |
return get_method(m); |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
790 |
} |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
791 |
} |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
792 |
break; |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
793 |
} |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
794 |
} |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
795 |
|
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
796 |
if (holder_is_accessible) { // Our declared holder is loaded. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
797 |
InstanceKlass* lookup = declared_holder->get_instanceKlass(); |
34238 | 798 |
Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc); |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
799 |
if (m != NULL && |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
800 |
(bc == Bytecodes::_invokestatic |
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
13974
diff
changeset
|
801 |
? m->method_holder()->is_not_initialized() |
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
13974
diff
changeset
|
802 |
: !m->method_holder()->is_loaded())) { |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
803 |
m = NULL; |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
804 |
} |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
805 |
#ifdef ASSERT |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
806 |
if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
807 |
m = NULL; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
808 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
809 |
#endif |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
810 |
if (m != NULL) { |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
811 |
// We found the method. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
812 |
return get_method(m); |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
813 |
} |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
814 |
} |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
815 |
|
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
816 |
// Either the declared holder was not loaded, or the method could |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
817 |
// not be found. Create a dummy ciMethod to represent the failed |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
818 |
// lookup. |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
819 |
ciSymbol* name = get_symbol(name_sym); |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
820 |
ciSymbol* signature = get_symbol(sig_sym); |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
821 |
return get_unloaded_method(declared_holder, name, signature, accessor); |
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
822 |
} |
4566
b363f6ef4068
6829187: compiler optimizations required for JSR 292
twisti
parents:
4450
diff
changeset
|
823 |
} |
b363f6ef4068
6829187: compiler optimizations required for JSR 292
twisti
parents:
4450
diff
changeset
|
824 |
|
b363f6ef4068
6829187: compiler optimizations required for JSR 292
twisti
parents:
4450
diff
changeset
|
825 |
|
b363f6ef4068
6829187: compiler optimizations required for JSR 292
twisti
parents:
4450
diff
changeset
|
826 |
// ------------------------------------------------------------------ |
1 | 827 |
// ciEnv::get_instance_klass_for_declared_method_holder |
828 |
ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* method_holder) { |
|
829 |
// For the case of <array>.clone(), the method holder can be a ciArrayKlass |
|
830 |
// instead of a ciInstanceKlass. For that case simply pretend that the |
|
831 |
// declared holder is Object.clone since that's where the call will bottom out. |
|
832 |
// A more correct fix would trickle out through many interfaces in CI, |
|
833 |
// requiring ciInstanceKlass* to become ciKlass* and many more places would |
|
834 |
// require checks to make sure the expected type was found. Given that this |
|
835 |
// only occurs for clone() the more extensive fix seems like overkill so |
|
836 |
// instead we simply smear the array type into Object. |
|
16378
453b42d22a85
8009565: [partfait] Null pointer deference in hotspot/src/share/vm/ci/ciEnv.cpp
morris
parents:
15799
diff
changeset
|
837 |
guarantee(method_holder != NULL, "no method holder"); |
1 | 838 |
if (method_holder->is_instance_klass()) { |
839 |
return method_holder->as_instance_klass(); |
|
840 |
} else if (method_holder->is_array_klass()) { |
|
841 |
return current()->Object_klass(); |
|
842 |
} else { |
|
843 |
ShouldNotReachHere(); |
|
844 |
} |
|
845 |
return NULL; |
|
846 |
} |
|
847 |
||
848 |
||
849 |
// ------------------------------------------------------------------ |
|
850 |
// ciEnv::get_method_by_index |
|
33593
60764a78fa5c
8140274: methodHandles and constantPoolHandles should be passed as const references
coleenp
parents:
31019
diff
changeset
|
851 |
ciMethod* ciEnv::get_method_by_index(const constantPoolHandle& cpool, |
4567
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
852 |
int index, Bytecodes::Code bc, |
7fc02fbe5c7a
6893268: additional dynamic language related optimizations in C2
twisti
parents:
4566
diff
changeset
|
853 |
ciInstanceKlass* accessor) { |
13522
5ad4627e792a
7192406: JSR 292: C2 needs exact return type information for invokedynamic and invokehandle call sites
twisti
parents:
13391
diff
changeset
|
854 |
GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);) |
1 | 855 |
} |
856 |
||
4566
b363f6ef4068
6829187: compiler optimizations required for JSR 292
twisti
parents:
4450
diff
changeset
|
857 |
|
1 | 858 |
// ------------------------------------------------------------------ |
859 |
// ciEnv::name_buffer |
|
860 |
char *ciEnv::name_buffer(int req_len) { |
|
861 |
if (_name_buffer_len < req_len) { |
|
862 |
if (_name_buffer == NULL) { |
|
863 |
_name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len); |
|
864 |
_name_buffer_len = req_len; |
|
865 |
} else { |
|
866 |
_name_buffer = |
|
867 |
(char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len); |
|
868 |
_name_buffer_len = req_len; |
|
869 |
} |
|
870 |
} |
|
871 |
return _name_buffer; |
|
872 |
} |
|
873 |
||
874 |
// ------------------------------------------------------------------ |
|
875 |
// ciEnv::is_in_vm |
|
876 |
bool ciEnv::is_in_vm() { |
|
877 |
return JavaThread::current()->thread_state() == _thread_in_vm; |
|
878 |
} |
|
879 |
||
880 |
bool ciEnv::system_dictionary_modification_counter_changed() { |
|
881 |
return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications(); |
|
882 |
} |
|
883 |
||
884 |
// ------------------------------------------------------------------ |
|
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
885 |
// ciEnv::validate_compile_task_dependencies |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
886 |
// |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
887 |
// Check for changes during compilation (e.g. class loads, evolution, |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
888 |
// breakpoints, call site invalidation). |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
889 |
void ciEnv::validate_compile_task_dependencies(ciMethod* target) { |
1 | 890 |
if (failing()) return; // no need for further checks |
891 |
||
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
892 |
// First, check non-klass dependencies as we might return early and |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
893 |
// not check klass dependencies if the system dictionary |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
894 |
// modification counter hasn't changed (see below). |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
895 |
for (Dependencies::DepStream deps(dependencies()); deps.next(); ) { |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
896 |
if (deps.is_klass_type()) continue; // skip klass dependencies |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
897 |
Klass* witness = deps.check_dependency(); |
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
898 |
if (witness != NULL) { |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
899 |
record_failure("invalid non-klass dependency"); |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
900 |
return; |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
901 |
} |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
902 |
} |
1 | 903 |
|
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
904 |
// Klass dependencies must be checked when the system dictionary |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
905 |
// changes. If logging is enabled all violated dependences will be |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
906 |
// recorded in the log. In debug mode check dependencies even if |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
907 |
// the system dictionary hasn't changed to verify that no invalid |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
908 |
// dependencies were inserted. Any violated dependences in this |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
909 |
// case are dumped to the tty. |
1 | 910 |
bool counter_changed = system_dictionary_modification_counter_changed(); |
911 |
||
10564 | 912 |
bool verify_deps = trueInDebug; |
913 |
if (!counter_changed && !verify_deps) return; |
|
914 |
||
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
915 |
int klass_violations = 0; |
1 | 916 |
for (Dependencies::DepStream deps(dependencies()); deps.next(); ) { |
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
917 |
if (!deps.is_klass_type()) continue; // skip non-klass dependencies |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
918 |
Klass* witness = deps.check_dependency(); |
1 | 919 |
if (witness != NULL) { |
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
920 |
klass_violations++; |
10564 | 921 |
if (!counter_changed) { |
922 |
// Dependence failed but counter didn't change. Log a message |
|
923 |
// describing what failed and allow the assert at the end to |
|
924 |
// trigger. |
|
925 |
deps.print_dependency(witness); |
|
926 |
} else if (xtty == NULL) { |
|
927 |
// If we're not logging then a single violation is sufficient, |
|
928 |
// otherwise we want to log all the dependences which were |
|
929 |
// violated. |
|
930 |
break; |
|
931 |
} |
|
1 | 932 |
} |
933 |
} |
|
934 |
||
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
935 |
if (klass_violations != 0) { |
10564 | 936 |
#ifdef ASSERT |
937 |
if (!counter_changed && !PrintCompilation) { |
|
938 |
// Print out the compile task that failed |
|
26587 | 939 |
_task->print_tty(); |
10564 | 940 |
} |
941 |
#endif |
|
1 | 942 |
assert(counter_changed, "failed dependencies, but counter didn't change"); |
943 |
record_failure("concurrent class loading"); |
|
944 |
} |
|
945 |
} |
|
946 |
||
947 |
// ------------------------------------------------------------------ |
|
948 |
// ciEnv::register_method |
|
949 |
void ciEnv::register_method(ciMethod* target, |
|
950 |
int entry_bci, |
|
951 |
CodeOffsets* offsets, |
|
952 |
int orig_pc_offset, |
|
953 |
CodeBuffer* code_buffer, |
|
954 |
int frame_words, |
|
955 |
OopMapSet* oop_map_set, |
|
956 |
ExceptionHandlerTable* handler_table, |
|
957 |
ImplicitExceptionTable* inc_table, |
|
958 |
AbstractCompiler* compiler, |
|
13883
6979b9850feb
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
13728
diff
changeset
|
959 |
bool has_unsafe_access, |
23491 | 960 |
bool has_wide_vectors, |
961 |
RTMState rtm_state) { |
|
1 | 962 |
VM_ENTRY_MARK; |
963 |
nmethod* nm = NULL; |
|
964 |
{ |
|
965 |
// To prevent compile queue updates. |
|
966 |
MutexLocker locker(MethodCompileQueue_lock, THREAD); |
|
967 |
||
968 |
// Prevent SystemDictionary::add_to_hierarchy from running |
|
969 |
// and invalidating our dependencies until we install this method. |
|
21572
9cd0dd352fcd
8023037: Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie
vlivanov
parents:
21079
diff
changeset
|
970 |
// No safepoints are allowed. Otherwise, class redefinition can occur in between. |
1 | 971 |
MutexLocker ml(Compile_lock); |
35492
c8c0273e6b91
8146690: Make all classes in GC follow the naming convention.
david
parents:
34238
diff
changeset
|
972 |
NoSafepointVerifier nsv; |
1 | 973 |
|
2867
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
974 |
// Change in Jvmti state may invalidate compilation. |
22893
e3a2b513713a
8035493: JVMTI PopFrame capability must instruct compilers not to prune locals
mgronlun
parents:
22243
diff
changeset
|
975 |
if (!failing() && jvmti_state_changed()) { |
2867
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
976 |
record_failure("Jvmti state change invalidated dependencies"); |
1 | 977 |
} |
978 |
||
2867
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
979 |
// Change in DTrace flags may invalidate compilation. |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
980 |
if (!failing() && |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
981 |
( (!dtrace_extended_probes() && ExtendedDTraceProbes) || |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
982 |
(!dtrace_method_probes() && DTraceMethodProbes) || |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
983 |
(!dtrace_alloc_probes() && DTraceAllocProbes) )) { |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
984 |
record_failure("DTrace flags change invalidated dependencies"); |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
985 |
} |
1 | 986 |
|
2867
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
987 |
if (!failing()) { |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
988 |
if (log() != NULL) { |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
989 |
// Log the dependencies which this compilation declares. |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
990 |
dependencies()->log_all_dependencies(); |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
991 |
} |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
992 |
|
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
993 |
// Encode the dependencies now, so we can check them right away. |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
994 |
dependencies()->encode_content_bytes(); |
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
995 |
|
10503
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
996 |
// Check for {class loads, evolution, breakpoints, ...} during compilation |
04b74421bdea
7083184: JSR 292: don't store context class argument with call site dependencies
twisti
parents:
10008
diff
changeset
|
997 |
validate_compile_task_dependencies(target); |
2867
69187054225f
6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents:
1623
diff
changeset
|
998 |
} |
1 | 999 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
1000 |
methodHandle method(THREAD, target->get_Method()); |
1 | 1001 |
|
23491 | 1002 |
#if INCLUDE_RTM_OPT |
1003 |
if (!failing() && (rtm_state != NoRTM) && |
|
1004 |
(method()->method_data() != NULL) && |
|
1005 |
(method()->method_data()->rtm_state() != rtm_state)) { |
|
1006 |
// Preemptive decompile if rtm state was changed. |
|
1007 |
record_failure("RTM state change invalidated rtm code"); |
|
1008 |
} |
|
1009 |
#endif |
|
1010 |
||
1 | 1011 |
if (failing()) { |
1012 |
// While not a true deoptimization, it is a preemptive decompile. |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13522
diff
changeset
|
1013 |
MethodData* mdo = method()->method_data(); |
1 | 1014 |
if (mdo != NULL) { |
1015 |
mdo->inc_decompile_count(); |
|
1016 |
} |
|
1017 |
||
1018 |
// All buffers in the CodeBuffer are allocated in the CodeCache. |
|
1019 |
// If the code buffer is created on each compile attempt |
|
1020 |
// as in C2, then it must be freed. |
|
1021 |
code_buffer->free_blob(); |
|
1022 |
return; |
|
1023 |
} |
|
1024 |
||
1025 |
assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry"); |
|
1026 |
assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry"); |
|
1027 |
||
1028 |
nm = nmethod::new_nmethod(method, |
|
1029 |
compile_id(), |
|
1030 |
entry_bci, |
|
1031 |
offsets, |
|
1032 |
orig_pc_offset, |
|
1033 |
debug_info(), dependencies(), code_buffer, |
|
1034 |
frame_words, oop_map_set, |
|
1035 |
handler_table, inc_table, |
|
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
31019
diff
changeset
|
1036 |
compiler, task()->comp_level()); |
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
31019
diff
changeset
|
1037 |
|
1 | 1038 |
// Free codeBlobs |
1039 |
code_buffer->free_blob(); |
|
1040 |
||
21727
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1041 |
if (nm != NULL) { |
1 | 1042 |
nm->set_has_unsafe_access(has_unsafe_access); |
13883
6979b9850feb
7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents:
13728
diff
changeset
|
1043 |
nm->set_has_wide_vectors(has_wide_vectors); |
23496
bfdd90c07bf8
8038286: nm->set_rtm_state() should be called after (nm != NULL) check
kvn
parents:
23491
diff
changeset
|
1044 |
#if INCLUDE_RTM_OPT |
bfdd90c07bf8
8038286: nm->set_rtm_state() should be called after (nm != NULL) check
kvn
parents:
23491
diff
changeset
|
1045 |
nm->set_rtm_state(rtm_state); |
bfdd90c07bf8
8038286: nm->set_rtm_state() should be called after (nm != NULL) check
kvn
parents:
23491
diff
changeset
|
1046 |
#endif |
1 | 1047 |
|
1048 |
// Record successful registration. |
|
1049 |
// (Put nm into the task handle *before* publishing to the Java heap.) |
|
21727
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1050 |
if (task() != NULL) { |
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1051 |
task()->set_code(nm); |
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1052 |
} |
1 | 1053 |
|
1054 |
if (entry_bci == InvocationEntryBci) { |
|
6453 | 1055 |
if (TieredCompilation) { |
1056 |
// If there is an old version we're done with it |
|
1057 |
nmethod* old = method->code(); |
|
1058 |
if (TraceMethodReplacement && old != NULL) { |
|
1059 |
ResourceMark rm; |
|
1060 |
char *method_name = method->name_and_sig_as_C_string(); |
|
1061 |
tty->print_cr("Replacing method %s", method_name); |
|
1062 |
} |
|
21572
9cd0dd352fcd
8023037: Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie
vlivanov
parents:
21079
diff
changeset
|
1063 |
if (old != NULL) { |
6453 | 1064 |
old->make_not_entrant(); |
1065 |
} |
|
1 | 1066 |
} |
21572
9cd0dd352fcd
8023037: Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie
vlivanov
parents:
21079
diff
changeset
|
1067 |
if (TraceNMethodInstalls) { |
1 | 1068 |
ResourceMark rm; |
1069 |
char *method_name = method->name_and_sig_as_C_string(); |
|
1070 |
ttyLocker ttyl; |
|
1071 |
tty->print_cr("Installing method (%d) %s ", |
|
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
31019
diff
changeset
|
1072 |
task()->comp_level(), |
1 | 1073 |
method_name); |
1074 |
} |
|
1075 |
// Allow the code to be executed |
|
1076 |
method->set_code(method, nm); |
|
1077 |
} else { |
|
21572
9cd0dd352fcd
8023037: Race between ciEnv::register_method and nmethod::make_not_entrant_or_zombie
vlivanov
parents:
21079
diff
changeset
|
1078 |
if (TraceNMethodInstalls) { |
1 | 1079 |
ResourceMark rm; |
1080 |
char *method_name = method->name_and_sig_as_C_string(); |
|
1081 |
ttyLocker ttyl; |
|
1082 |
tty->print_cr("Installing osr method (%d) %s @ %d", |
|
33451
0712796e4039
8137167: JEP165: Compiler Control: Implementation task
neliasso
parents:
31019
diff
changeset
|
1083 |
task()->comp_level(), |
1 | 1084 |
method_name, |
1085 |
entry_bci); |
|
1086 |
} |
|
14391
df0a1573d5bd
8000725: NPG: method_holder() and pool_holder() and pool_holder field should be InstanceKlass
coleenp
parents:
13974
diff
changeset
|
1087 |
method->method_holder()->add_osr_nmethod(nm); |
1 | 1088 |
} |
1089 |
} |
|
21727
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1090 |
} // safepoints are allowed again |
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1091 |
|
1 | 1092 |
if (nm != NULL) { |
21727
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1093 |
// JVMTI -- compiled method notification (must be done outside lock) |
1 | 1094 |
nm->post_compiled_method_load_event(); |
21727
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1095 |
} else { |
27420
04e6f914cce1
8046809: vm/mlvm/meth/stress/compiler/deoptimize CodeCache is full.
anoll
parents:
26944
diff
changeset
|
1096 |
// The CodeCache is full. |
21727
4a5fc611c9a7
8028306: nsk stress tests, CodeCache fills, then safepoint asserts
anoll
parents:
21572
diff
changeset
|
1097 |
record_failure("code cache is full"); |
1 | 1098 |
} |
1099 |
} |
|
1100 |
||
1101 |
||
1102 |
// ------------------------------------------------------------------ |
|
1103 |
// ciEnv::find_system_klass |
|
1104 |
ciKlass* ciEnv::find_system_klass(ciSymbol* klass_name) { |
|
1105 |
VM_ENTRY_MARK; |
|
10008
d84de97ad847
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
9328
diff
changeset
|
1106 |
return get_klass_by_name_impl(NULL, constantPoolHandle(), klass_name, false); |
1 | 1107 |
} |
1108 |
||
1109 |
// ------------------------------------------------------------------ |
|
1110 |
// ciEnv::comp_level |
|
1111 |
int ciEnv::comp_level() { |
|
6453 | 1112 |
if (task() == NULL) return CompLevel_highest_tier; |
1 | 1113 |
return task()->comp_level(); |
1114 |
} |
|
1115 |
||
1116 |
// ------------------------------------------------------------------ |
|
1117 |
// ciEnv::compile_id |
|
1118 |
uint ciEnv::compile_id() { |
|
1119 |
if (task() == NULL) return 0; |
|
1120 |
return task()->compile_id(); |
|
1121 |
} |
|
1122 |
||
1123 |
// ------------------------------------------------------------------ |
|
1124 |
// ciEnv::notice_inlined_method() |
|
1125 |
void ciEnv::notice_inlined_method(ciMethod* method) { |
|
13391
30245956af37
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
10734
diff
changeset
|
1126 |
_num_inlined_bytecodes += method->code_size_for_inlining(); |
1 | 1127 |
} |
1128 |
||
1129 |
// ------------------------------------------------------------------ |
|
1130 |
// ciEnv::num_inlined_bytecodes() |
|
1131 |
int ciEnv::num_inlined_bytecodes() const { |
|
1132 |
return _num_inlined_bytecodes; |
|
1133 |
} |
|
1134 |
||
1135 |
// ------------------------------------------------------------------ |
|
1136 |
// ciEnv::record_failure() |
|
1137 |
void ciEnv::record_failure(const char* reason) { |
|
1138 |
if (_failure_reason == NULL) { |
|
1139 |
// Record the first failure reason. |
|
1140 |
_failure_reason = reason; |
|
1141 |
} |
|
1142 |
} |
|
1143 |
||
27706
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1144 |
void ciEnv::report_failure(const char* reason) { |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1145 |
// Create and fire JFR event |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1146 |
EventCompilerFailure event; |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1147 |
if (event.should_commit()) { |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1148 |
event.set_compileID(compile_id()); |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1149 |
event.set_failure(reason); |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1150 |
event.commit(); |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1151 |
} |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1152 |
} |
3f10f4ac2bd6
8065339: Failed compilation does not always trigger a JFR event 'CompilerFailure'
thartmann
parents:
27420
diff
changeset
|
1153 |
|
1 | 1154 |
// ------------------------------------------------------------------ |
1155 |
// ciEnv::record_method_not_compilable() |
|
1156 |
void ciEnv::record_method_not_compilable(const char* reason, bool all_tiers) { |
|
1157 |
int new_compilable = |
|
1158 |
all_tiers ? MethodCompilable_never : MethodCompilable_not_at_tier ; |
|
1159 |
||
1160 |
// Only note transitions to a worse state |
|
1161 |
if (new_compilable > _compilable) { |
|
1162 |
if (log() != NULL) { |
|
1163 |
if (all_tiers) { |
|
1164 |
log()->elem("method_not_compilable"); |
|
1165 |
} else { |
|
13964 | 1166 |
log()->elem("method_not_compilable_at_tier level='%d'", |
1167 |
current()->task()->comp_level()); |
|
1 | 1168 |
} |
1169 |
} |
|
1170 |
_compilable = new_compilable; |
|
1171 |
||
1172 |
// Reset failure reason; this one is more important. |
|
1173 |
_failure_reason = NULL; |
|
1174 |
record_failure(reason); |
|
1175 |
} |
|
1176 |
} |
|
1177 |
||
1178 |
// ------------------------------------------------------------------ |
|
1179 |
// ciEnv::record_out_of_memory_failure() |
|
1180 |
void ciEnv::record_out_of_memory_failure() { |
|
1181 |
// If memory is low, we stop compiling methods. |
|
1182 |
record_method_not_compilable("out of memory"); |
|
1183 |
} |
|
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1184 |
|
19710
2f8ca425504e
7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents:
17134
diff
changeset
|
1185 |
ciInstance* ciEnv::unloaded_ciinstance() { |
2f8ca425504e
7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents:
17134
diff
changeset
|
1186 |
GUARDED_VM_ENTRY(return _factory->get_unloaded_object_constant();) |
2f8ca425504e
7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents:
17134
diff
changeset
|
1187 |
} |
2f8ca425504e
7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents:
17134
diff
changeset
|
1188 |
|
20692
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1189 |
// ------------------------------------------------------------------ |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1190 |
// ciEnv::dump_replay_data* |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1191 |
|
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1192 |
// Don't change thread state and acquire any locks. |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1193 |
// Safe to call from VM error reporter. |
22243 | 1194 |
|
1195 |
void ciEnv::dump_compile_data(outputStream* out) { |
|
1196 |
CompileTask* task = this->task(); |
|
1197 |
Method* method = task->method(); |
|
1198 |
int entry_bci = task->osr_bci(); |
|
1199 |
int comp_level = task->comp_level(); |
|
1200 |
out->print("compile %s %s %s %d %d", |
|
1201 |
method->klass_name()->as_quoted_ascii(), |
|
1202 |
method->name()->as_quoted_ascii(), |
|
1203 |
method->signature()->as_quoted_ascii(), |
|
1204 |
entry_bci, comp_level); |
|
1205 |
if (compiler_data() != NULL) { |
|
1206 |
if (is_c2_compile(comp_level)) { // C2 or Shark |
|
1207 |
#ifdef COMPILER2 |
|
1208 |
// Dump C2 inlining data. |
|
1209 |
((Compile*)compiler_data())->dump_inline_data(out); |
|
1210 |
#endif |
|
1211 |
} else if (is_c1_compile(comp_level)) { // C1 |
|
1212 |
#ifdef COMPILER1 |
|
1213 |
// Dump C1 inlining data. |
|
1214 |
((Compilation*)compiler_data())->dump_inline_data(out); |
|
1215 |
#endif |
|
1216 |
} |
|
1217 |
} |
|
1218 |
out->cr(); |
|
1219 |
} |
|
1220 |
||
20692
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1221 |
void ciEnv::dump_replay_data_unsafe(outputStream* out) { |
15471
41f75023e6a6
8006410: allocating without ResourceMark when CompileCommand was specified
vlivanov
parents:
14490
diff
changeset
|
1222 |
ResourceMark rm; |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1223 |
#if INCLUDE_JVMTI |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1224 |
out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1225 |
out->print_cr("JvmtiExport can_hotswap_or_post_breakpoint %d", _jvmti_can_hotswap_or_post_breakpoint); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1226 |
out->print_cr("JvmtiExport can_post_on_exceptions %d", _jvmti_can_post_on_exceptions); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1227 |
#endif // INCLUDE_JVMTI |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1228 |
|
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1229 |
GrowableArray<ciMetadata*>* objects = _factory->get_ci_metadata(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1230 |
out->print_cr("# %d ciObject found", objects->length()); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1231 |
for (int i = 0; i < objects->length(); i++) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1232 |
objects->at(i)->dump_replay_data(out); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1233 |
} |
22243 | 1234 |
dump_compile_data(out); |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1235 |
out->flush(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14391
diff
changeset
|
1236 |
} |
20692
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1237 |
|
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1238 |
void ciEnv::dump_replay_data(outputStream* out) { |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1239 |
GUARDED_VM_ENTRY( |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1240 |
MutexLocker ml(Compile_lock); |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1241 |
dump_replay_data_unsafe(out); |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1242 |
) |
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19710
diff
changeset
|
1243 |
} |
22243 | 1244 |
|
1245 |
void ciEnv::dump_replay_data(int compile_id) { |
|
1246 |
static char buffer[O_BUFLEN]; |
|
1247 |
int ret = jio_snprintf(buffer, O_BUFLEN, "replay_pid%p_compid%d.log", os::current_process_id(), compile_id); |
|
1248 |
if (ret > 0) { |
|
1249 |
int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); |
|
1250 |
if (fd != -1) { |
|
1251 |
FILE* replay_data_file = os::open(fd, "w"); |
|
1252 |
if (replay_data_file != NULL) { |
|
1253 |
fileStream replay_data_stream(replay_data_file, /*need_close=*/true); |
|
1254 |
dump_replay_data(&replay_data_stream); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
1255 |
tty->print_cr("# Compiler replay data is saved as: %s", buffer); |
22243 | 1256 |
} else { |
1257 |
tty->print_cr("# Can't open file to dump replay data."); |
|
1258 |
} |
|
1259 |
} |
|
1260 |
} |
|
1261 |
} |
|
1262 |
||
1263 |
void ciEnv::dump_inline_data(int compile_id) { |
|
1264 |
static char buffer[O_BUFLEN]; |
|
1265 |
int ret = jio_snprintf(buffer, O_BUFLEN, "inline_pid%p_compid%d.log", os::current_process_id(), compile_id); |
|
1266 |
if (ret > 0) { |
|
1267 |
int fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); |
|
1268 |
if (fd != -1) { |
|
1269 |
FILE* inline_data_file = os::open(fd, "w"); |
|
1270 |
if (inline_data_file != NULL) { |
|
1271 |
fileStream replay_data_stream(inline_data_file, /*need_close=*/true); |
|
1272 |
GUARDED_VM_ENTRY( |
|
1273 |
MutexLocker ml(Compile_lock); |
|
1274 |
dump_compile_data(&replay_data_stream); |
|
1275 |
) |
|
1276 |
replay_data_stream.flush(); |
|
1277 |
tty->print("# Compiler inline data is saved as: "); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
1278 |
tty->print_cr("%s", buffer); |
22243 | 1279 |
} else { |
1280 |
tty->print_cr("# Can't open file to dump inline data."); |
|
1281 |
} |
|
1282 |
} |
|
1283 |
} |
|
1284 |
} |