Print this page
rev 1021 : 6858164: invokedynamic code needs some cleanup (post-6655638)
Note: The bug ID for this change set was erroneously used to call for review of 6815692.
Summary: Fix several crashers, remove needless paths for boxed-style bootstrap method call, refactor & simplify APIs for rewriter constantPoolOop, remove sun.dyn.CallSiteImpl
Reviewed-by: ?
rev 1025 : imported patch indy.compiler.patch
rev 1026 : imported patch indy.compiler.inline.patch
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/ci/ciEnv.cpp
+++ new/src/share/vm/ci/ciEnv.cpp
1 1 /*
2 2 * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 #include "incls/_precompiled.incl"
26 26 #include "incls/_ciEnv.cpp.incl"
27 27
28 28 // ciEnv
29 29 //
30 30 // This class is the top level broker for requests from the compiler
31 31 // to the VM.
32 32
33 33 ciObject* ciEnv::_null_object_instance;
34 34 ciMethodKlass* ciEnv::_method_klass_instance;
35 35 ciSymbolKlass* ciEnv::_symbol_klass_instance;
36 36 ciKlassKlass* ciEnv::_klass_klass_instance;
37 37 ciInstanceKlassKlass* ciEnv::_instance_klass_klass_instance;
38 38 ciTypeArrayKlassKlass* ciEnv::_type_array_klass_klass_instance;
39 39 ciObjArrayKlassKlass* ciEnv::_obj_array_klass_klass_instance;
40 40
41 41 ciInstanceKlass* ciEnv::_ArrayStoreException;
42 42 ciInstanceKlass* ciEnv::_Class;
43 43 ciInstanceKlass* ciEnv::_ClassCastException;
44 44 ciInstanceKlass* ciEnv::_InvokeDynamic;
45 45 ciInstanceKlass* ciEnv::_Object;
46 46 ciInstanceKlass* ciEnv::_Throwable;
47 47 ciInstanceKlass* ciEnv::_Thread;
48 48 ciInstanceKlass* ciEnv::_OutOfMemoryError;
49 49 ciInstanceKlass* ciEnv::_String;
50 50
51 51 ciSymbol* ciEnv::_unloaded_cisymbol = NULL;
52 52 ciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = NULL;
53 53 ciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = NULL;
54 54
55 55 jobject ciEnv::_ArrayIndexOutOfBoundsException_handle = NULL;
56 56 jobject ciEnv::_ArrayStoreException_handle = NULL;
57 57 jobject ciEnv::_ClassCastException_handle = NULL;
58 58
59 59 #ifndef PRODUCT
60 60 static bool firstEnv = true;
61 61 #endif /* PRODUCT */
62 62
63 63 // ------------------------------------------------------------------
64 64 // ciEnv::ciEnv
65 65 ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) {
66 66 VM_ENTRY_MARK;
67 67
68 68 // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
69 69 thread->set_env(this);
70 70 assert(ciEnv::current() == this, "sanity");
71 71
72 72 _oop_recorder = NULL;
73 73 _debug_info = NULL;
74 74 _dependencies = NULL;
75 75 _failure_reason = NULL;
76 76 _compilable = MethodCompilable;
77 77 _break_at_compile = false;
78 78 _compiler_data = NULL;
79 79 #ifndef PRODUCT
80 80 assert(!firstEnv, "not initialized properly");
81 81 #endif /* !PRODUCT */
82 82
83 83 _system_dictionary_modification_counter = system_dictionary_modification_counter;
84 84 _num_inlined_bytecodes = 0;
85 85 assert(task == NULL || thread->task() == task, "sanity");
86 86 _task = task;
87 87 _log = NULL;
88 88
89 89 // Temporary buffer for creating symbols and such.
90 90 _name_buffer = NULL;
91 91 _name_buffer_len = 0;
92 92
93 93 _arena = &_ciEnv_arena;
94 94 _factory = new (_arena) ciObjectFactory(_arena, 128);
95 95
96 96 // Preload commonly referenced system ciObjects.
97 97
98 98 // During VM initialization, these instances have not yet been created.
99 99 // Assertions ensure that these instances are not accessed before
100 100 // their initialization.
101 101
102 102 assert(Universe::is_fully_initialized(), "should be complete");
103 103
104 104 oop o = Universe::null_ptr_exception_instance();
105 105 assert(o != NULL, "should have been initialized");
106 106 _NullPointerException_instance = get_object(o)->as_instance();
107 107 o = Universe::arithmetic_exception_instance();
108 108 assert(o != NULL, "should have been initialized");
109 109 _ArithmeticException_instance = get_object(o)->as_instance();
110 110
111 111 _ArrayIndexOutOfBoundsException_instance = NULL;
112 112 _ArrayStoreException_instance = NULL;
113 113 _ClassCastException_instance = NULL;
114 114 }
115 115
116 116 ciEnv::ciEnv(Arena* arena) {
117 117 ASSERT_IN_VM;
118 118
119 119 // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
120 120 CompilerThread* current_thread = CompilerThread::current();
121 121 assert(current_thread->env() == NULL, "must be");
122 122 current_thread->set_env(this);
123 123 assert(ciEnv::current() == this, "sanity");
124 124
125 125 _oop_recorder = NULL;
126 126 _debug_info = NULL;
127 127 _dependencies = NULL;
128 128 _failure_reason = NULL;
129 129 _compilable = MethodCompilable_never;
130 130 _break_at_compile = false;
131 131 _compiler_data = NULL;
132 132 #ifndef PRODUCT
133 133 assert(firstEnv, "must be first");
134 134 firstEnv = false;
135 135 #endif /* !PRODUCT */
136 136
137 137 _system_dictionary_modification_counter = 0;
138 138 _num_inlined_bytecodes = 0;
139 139 _task = NULL;
140 140 _log = NULL;
141 141
142 142 // Temporary buffer for creating symbols and such.
143 143 _name_buffer = NULL;
144 144 _name_buffer_len = 0;
145 145
146 146 _arena = arena;
147 147 _factory = new (_arena) ciObjectFactory(_arena, 128);
148 148
149 149 // Preload commonly referenced system ciObjects.
150 150
151 151 // During VM initialization, these instances have not yet been created.
152 152 // Assertions ensure that these instances are not accessed before
153 153 // their initialization.
154 154
155 155 assert(Universe::is_fully_initialized(), "must be");
156 156
157 157 oop o = Universe::null_ptr_exception_instance();
158 158 assert(o != NULL, "should have been initialized");
159 159 _NullPointerException_instance = get_object(o)->as_instance();
160 160 o = Universe::arithmetic_exception_instance();
161 161 assert(o != NULL, "should have been initialized");
162 162 _ArithmeticException_instance = get_object(o)->as_instance();
163 163
164 164 _ArrayIndexOutOfBoundsException_instance = NULL;
165 165 _ArrayStoreException_instance = NULL;
166 166 _ClassCastException_instance = NULL;
167 167 }
168 168
169 169 ciEnv::~ciEnv() {
170 170 CompilerThread* current_thread = CompilerThread::current();
171 171 current_thread->set_env(NULL);
172 172 }
173 173
174 174 // ------------------------------------------------------------------
175 175 // Cache Jvmti state
176 176 void ciEnv::cache_jvmti_state() {
177 177 VM_ENTRY_MARK;
178 178 // Get Jvmti capabilities under lock to get consistant values.
179 179 MutexLocker mu(JvmtiThreadState_lock);
180 180 _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
181 181 _jvmti_can_examine_or_deopt_anywhere = JvmtiExport::can_examine_or_deopt_anywhere();
182 182 _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables();
183 183 _jvmti_can_post_exceptions = JvmtiExport::can_post_exceptions();
184 184 }
185 185
186 186 // ------------------------------------------------------------------
187 187 // Cache DTrace flags
188 188 void ciEnv::cache_dtrace_flags() {
189 189 // Need lock?
190 190 _dtrace_extended_probes = ExtendedDTraceProbes;
191 191 if (_dtrace_extended_probes) {
192 192 _dtrace_monitor_probes = true;
193 193 _dtrace_method_probes = true;
194 194 _dtrace_alloc_probes = true;
195 195 } else {
196 196 _dtrace_monitor_probes = DTraceMonitorProbes;
197 197 _dtrace_method_probes = DTraceMethodProbes;
198 198 _dtrace_alloc_probes = DTraceAllocProbes;
199 199 }
200 200 }
201 201
202 202 // ------------------------------------------------------------------
203 203 // helper for lazy exception creation
204 204 ciInstance* ciEnv::get_or_create_exception(jobject& handle, symbolHandle name) {
205 205 VM_ENTRY_MARK;
206 206 if (handle == NULL) {
207 207 // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance.
208 208 klassOop k = SystemDictionary::find(name, Handle(), Handle(), THREAD);
209 209 jobject objh = NULL;
210 210 if (!HAS_PENDING_EXCEPTION && k != NULL) {
211 211 oop obj = instanceKlass::cast(k)->allocate_permanent_instance(THREAD);
212 212 if (!HAS_PENDING_EXCEPTION)
213 213 objh = JNIHandles::make_global(obj);
214 214 }
215 215 if (HAS_PENDING_EXCEPTION) {
216 216 CLEAR_PENDING_EXCEPTION;
217 217 } else {
218 218 handle = objh;
219 219 }
220 220 }
221 221 oop obj = JNIHandles::resolve(handle);
222 222 return obj == NULL? NULL: get_object(obj)->as_instance();
223 223 }
224 224
225 225 // ------------------------------------------------------------------
226 226 // ciEnv::ArrayIndexOutOfBoundsException_instance, etc.
227 227 ciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() {
228 228 if (_ArrayIndexOutOfBoundsException_instance == NULL) {
229 229 _ArrayIndexOutOfBoundsException_instance
230 230 = get_or_create_exception(_ArrayIndexOutOfBoundsException_handle,
231 231 vmSymbolHandles::java_lang_ArrayIndexOutOfBoundsException());
232 232 }
233 233 return _ArrayIndexOutOfBoundsException_instance;
234 234 }
235 235 ciInstance* ciEnv::ArrayStoreException_instance() {
236 236 if (_ArrayStoreException_instance == NULL) {
237 237 _ArrayStoreException_instance
238 238 = get_or_create_exception(_ArrayStoreException_handle,
239 239 vmSymbolHandles::java_lang_ArrayStoreException());
240 240 }
241 241 return _ArrayStoreException_instance;
242 242 }
243 243 ciInstance* ciEnv::ClassCastException_instance() {
244 244 if (_ClassCastException_instance == NULL) {
245 245 _ClassCastException_instance
246 246 = get_or_create_exception(_ClassCastException_handle,
247 247 vmSymbolHandles::java_lang_ClassCastException());
248 248 }
249 249 return _ClassCastException_instance;
250 250 }
251 251
252 252 // ------------------------------------------------------------------
253 253 // ciEnv::get_method_from_handle
254 254 ciMethod* ciEnv::get_method_from_handle(jobject method) {
255 255 VM_ENTRY_MARK;
256 256 return get_object(JNIHandles::resolve(method))->as_method();
257 257 }
258 258
259 259 // ------------------------------------------------------------------
260 260 // ciEnv::make_array
261 261 ciArray* ciEnv::make_system_array(GrowableArray<ciObject*>* objects) {
262 262 VM_ENTRY_MARK;
263 263 int length = objects->length();
264 264 objArrayOop a = oopFactory::new_system_objArray(length, THREAD);
265 265 if (HAS_PENDING_EXCEPTION) {
266 266 CLEAR_PENDING_EXCEPTION;
267 267 record_out_of_memory_failure();
268 268 return NULL;
269 269 }
270 270 for (int i = 0; i < length; i++) {
271 271 a->obj_at_put(i, objects->at(i)->get_oop());
272 272 }
273 273 assert(a->is_perm(), "");
274 274 return get_object(a)->as_array();
275 275 }
276 276
277 277
278 278 // ------------------------------------------------------------------
279 279 // ciEnv::array_element_offset_in_bytes
280 280 int ciEnv::array_element_offset_in_bytes(ciArray* a_h, ciObject* o_h) {
281 281 VM_ENTRY_MARK;
282 282 objArrayOop a = (objArrayOop)a_h->get_oop();
283 283 assert(a->is_objArray(), "");
284 284 int length = a->length();
285 285 oop o = o_h->get_oop();
286 286 for (int i = 0; i < length; i++) {
287 287 if (a->obj_at(i) == o) return i;
288 288 }
289 289 return -1;
290 290 }
291 291
292 292
293 293 // ------------------------------------------------------------------
294 294 // ciEnv::check_klass_accessiblity
295 295 //
296 296 // Note: the logic of this method should mirror the logic of
297 297 // constantPoolOopDesc::verify_constant_pool_resolve.
298 298 bool ciEnv::check_klass_accessibility(ciKlass* accessing_klass,
299 299 klassOop resolved_klass) {
300 300 if (accessing_klass == NULL || !accessing_klass->is_loaded()) {
301 301 return true;
302 302 }
303 303 if (accessing_klass->is_obj_array()) {
304 304 accessing_klass = accessing_klass->as_obj_array_klass()->base_element_klass();
305 305 }
306 306 if (!accessing_klass->is_instance_klass()) {
307 307 return true;
308 308 }
309 309
310 310 if (resolved_klass->klass_part()->oop_is_objArray()) {
311 311 // Find the element klass, if this is an array.
312 312 resolved_klass = objArrayKlass::cast(resolved_klass)->bottom_klass();
313 313 }
314 314 if (resolved_klass->klass_part()->oop_is_instance()) {
315 315 return Reflection::verify_class_access(accessing_klass->get_klassOop(),
316 316 resolved_klass,
317 317 true);
318 318 }
319 319 return true;
320 320 }
321 321
322 322 // ------------------------------------------------------------------
323 323 // ciEnv::get_klass_by_name_impl
324 324 ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
325 325 ciSymbol* name,
326 326 bool require_local) {
327 327 ASSERT_IN_VM;
328 328 EXCEPTION_CONTEXT;
329 329
330 330 // Now we need to check the SystemDictionary
331 331 symbolHandle sym(THREAD, name->get_symbolOop());
332 332 if (sym->byte_at(0) == 'L' &&
333 333 sym->byte_at(sym->utf8_length()-1) == ';') {
334 334 // This is a name from a signature. Strip off the trimmings.
335 335 sym = oopFactory::new_symbol_handle(sym->as_utf8()+1,
336 336 sym->utf8_length()-2,
337 337 KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
338 338 name = get_object(sym())->as_symbol();
339 339 }
340 340
341 341 // Check for prior unloaded klass. The SystemDictionary's answers
342 342 // can vary over time but the compiler needs consistency.
343 343 ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name);
344 344 if (unloaded_klass != NULL) {
345 345 if (require_local) return NULL;
346 346 return unloaded_klass;
347 347 }
348 348
349 349 Handle loader(THREAD, (oop)NULL);
350 350 Handle domain(THREAD, (oop)NULL);
351 351 if (accessing_klass != NULL) {
352 352 loader = Handle(THREAD, accessing_klass->loader());
353 353 domain = Handle(THREAD, accessing_klass->protection_domain());
354 354 }
355 355
356 356 // setup up the proper type to return on OOM
357 357 ciKlass* fail_type;
358 358 if (sym->byte_at(0) == '[') {
359 359 fail_type = _unloaded_ciobjarrayklass;
360 360 } else {
361 361 fail_type = _unloaded_ciinstance_klass;
362 362 }
363 363 klassOop found_klass;
364 364 if (!require_local) {
365 365 found_klass =
366 366 SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
367 367 KILL_COMPILE_ON_FATAL_(fail_type));
368 368 } else {
369 369 found_klass =
370 370 SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
371 371 KILL_COMPILE_ON_FATAL_(fail_type));
372 372 }
373 373
374 374 if (found_klass != NULL) {
375 375 // Found it. Build a CI handle.
376 376 return get_object(found_klass)->as_klass();
377 377 }
378 378
379 379 // If we fail to find an array klass, look again for its element type.
380 380 // The element type may be available either locally or via constraints.
381 381 // In either case, if we can find the element type in the system dictionary,
382 382 // we must build an array type around it. The CI requires array klasses
383 383 // to be loaded if their element klasses are loaded, except when memory
384 384 // is exhausted.
385 385 if (sym->byte_at(0) == '[' &&
386 386 (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
387 387 // We have an unloaded array.
388 388 // Build it on the fly if the element class exists.
389 389 symbolOop elem_sym = oopFactory::new_symbol(sym->as_utf8()+1,
390 390 sym->utf8_length()-1,
391 391 KILL_COMPILE_ON_FATAL_(fail_type));
392 392 // Get element ciKlass recursively.
393 393 ciKlass* elem_klass =
394 394 get_klass_by_name_impl(accessing_klass,
395 395 get_object(elem_sym)->as_symbol(),
396 396 require_local);
397 397 if (elem_klass != NULL && elem_klass->is_loaded()) {
398 398 // Now make an array for it
399 399 return ciObjArrayKlass::make_impl(elem_klass);
400 400 }
401 401 }
402 402
403 403 if (require_local) return NULL;
404 404 // Not yet loaded into the VM, or not governed by loader constraints.
405 405 // Make a CI representative for it.
406 406 return get_unloaded_klass(accessing_klass, name);
407 407 }
408 408
409 409 // ------------------------------------------------------------------
410 410 // ciEnv::get_klass_by_name
411 411 ciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
412 412 ciSymbol* klass_name,
↓ open down ↓ |
412 lines elided |
↑ open up ↑ |
413 413 bool require_local) {
414 414 GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
415 415 klass_name,
416 416 require_local);)
417 417 }
418 418
419 419 // ------------------------------------------------------------------
420 420 // ciEnv::get_klass_by_index_impl
421 421 //
422 422 // Implementation of get_klass_by_index.
423 -ciKlass* ciEnv::get_klass_by_index_impl(ciInstanceKlass* accessor,
423 +ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
424 424 int index,
425 - bool& is_accessible) {
426 - assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
425 + bool& is_accessible,
426 + ciInstanceKlass* accessor) {
427 427 EXCEPTION_CONTEXT;
428 - constantPoolHandle cpool(THREAD, accessor->get_instanceKlass()->constants());
429 428 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
430 429 symbolHandle klass_name;
431 430 if (klass.is_null()) {
432 431 // The klass has not been inserted into the constant pool.
433 432 // Try to look it up by name.
434 433 {
435 434 // We have to lock the cpool to keep the oop from being resolved
436 435 // while we are accessing it.
437 436 ObjectLocker ol(cpool, THREAD);
438 437
439 438 constantTag tag = cpool->tag_at(index);
440 439 if (tag.is_klass()) {
441 440 // The klass has been inserted into the constant pool
442 441 // very recently.
443 442 klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
444 443 } else if (tag.is_symbol()) {
445 444 klass_name = symbolHandle(THREAD, cpool->symbol_at(index));
446 445 } else {
447 446 assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
448 447 klass_name = symbolHandle(THREAD, cpool->unresolved_klass_at(index));
449 448 }
450 449 }
451 450 }
452 451
453 452 if (klass.is_null()) {
454 453 // Not found in constant pool. Use the name to do the lookup.
455 454 ciKlass* k = get_klass_by_name_impl(accessor,
456 455 get_object(klass_name())->as_symbol(),
457 456 false);
458 457 // Calculate accessibility the hard way.
459 458 if (!k->is_loaded()) {
460 459 is_accessible = false;
461 460 } else if (k->loader() != accessor->loader() &&
462 461 get_klass_by_name_impl(accessor, k->name(), true) == NULL) {
463 462 // Loaded only remotely. Not linked yet.
464 463 is_accessible = false;
465 464 } else {
466 465 // Linked locally, and we must also check public/private, etc.
467 466 is_accessible = check_klass_accessibility(accessor, k->get_klassOop());
468 467 }
469 468 return k;
470 469 }
471 470
472 471 // Check for prior unloaded klass. The SystemDictionary's answers
473 472 // can vary over time but the compiler needs consistency.
474 473 ciSymbol* name = get_object(klass()->klass_part()->name())->as_symbol();
475 474 ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
476 475 if (unloaded_klass != NULL) {
477 476 is_accessible = false;
478 477 return unloaded_klass;
479 478 }
↓ open down ↓ |
41 lines elided |
↑ open up ↑ |
480 479
481 480 // It is known to be accessible, since it was found in the constant pool.
482 481 is_accessible = true;
483 482 return get_object(klass())->as_klass();
484 483 }
485 484
486 485 // ------------------------------------------------------------------
487 486 // ciEnv::get_klass_by_index
488 487 //
489 488 // Get a klass from the constant pool.
490 -ciKlass* ciEnv::get_klass_by_index(ciInstanceKlass* accessor,
489 +ciKlass* ciEnv::get_klass_by_index(constantPoolHandle cpool,
491 490 int index,
492 - bool& is_accessible) {
493 - GUARDED_VM_ENTRY(return get_klass_by_index_impl(accessor, index, is_accessible);)
491 + bool& is_accessible,
492 + ciInstanceKlass* accessor) {
493 + GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
494 494 }
495 495
496 496 // ------------------------------------------------------------------
497 497 // ciEnv::get_constant_by_index_impl
498 498 //
499 499 // Implementation of get_constant_by_index().
500 -ciConstant ciEnv::get_constant_by_index_impl(ciInstanceKlass* accessor,
501 - int index) {
500 +ciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
501 + int index,
502 + ciInstanceKlass* accessor) {
502 503 EXCEPTION_CONTEXT;
503 - instanceKlass* ik_accessor = accessor->get_instanceKlass();
504 - assert(ik_accessor->is_linked(), "must be linked before accessing constant pool");
505 - constantPoolOop cpool = ik_accessor->constants();
506 504 constantTag tag = cpool->tag_at(index);
507 505 if (tag.is_int()) {
508 506 return ciConstant(T_INT, (jint)cpool->int_at(index));
509 507 } else if (tag.is_long()) {
510 508 return ciConstant((jlong)cpool->long_at(index));
511 509 } else if (tag.is_float()) {
512 510 return ciConstant((jfloat)cpool->float_at(index));
513 511 } else if (tag.is_double()) {
514 512 return ciConstant((jdouble)cpool->double_at(index));
515 513 } else if (tag.is_string() || tag.is_unresolved_string()) {
516 514 oop string = NULL;
517 515 if (cpool->is_pseudo_string_at(index)) {
518 516 string = cpool->pseudo_string_at(index);
519 517 } else {
520 518 string = cpool->string_at(index, THREAD);
521 519 if (HAS_PENDING_EXCEPTION) {
522 520 CLEAR_PENDING_EXCEPTION;
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
523 521 record_out_of_memory_failure();
524 522 return ciConstant();
525 523 }
526 524 }
527 525 ciObject* constant = get_object(string);
528 526 assert (constant->is_instance(), "must be an instance, or not? ");
529 527 return ciConstant(T_OBJECT, constant);
530 528 } else if (tag.is_klass() || tag.is_unresolved_klass()) {
531 529 // 4881222: allow ldc to take a class type
532 530 bool ignore;
533 - ciKlass* klass = get_klass_by_index_impl(accessor, index, ignore);
531 + ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore, accessor);
534 532 if (HAS_PENDING_EXCEPTION) {
535 533 CLEAR_PENDING_EXCEPTION;
536 534 record_out_of_memory_failure();
537 535 return ciConstant();
538 536 }
539 537 assert (klass->is_instance_klass() || klass->is_array_klass(),
540 538 "must be an instance or array klass ");
541 539 return ciConstant(T_OBJECT, klass);
540 + } else if (tag.is_object()) {
541 + oop obj = cpool->object_at(index);
542 + assert(obj->is_instance(), "must be an instance");
543 + ciObject* ciobj = get_object(obj);
544 + return ciConstant(T_OBJECT, ciobj);
542 545 } else {
543 546 ShouldNotReachHere();
544 547 return ciConstant();
545 548 }
546 549 }
547 550
548 551 // ------------------------------------------------------------------
549 552 // ciEnv::is_unresolved_string_impl
550 553 //
551 554 // Implementation of is_unresolved_string().
552 555 bool ciEnv::is_unresolved_string_impl(instanceKlass* accessor, int index) const {
553 556 EXCEPTION_CONTEXT;
554 557 assert(accessor->is_linked(), "must be linked before accessing constant pool");
555 558 constantPoolOop cpool = accessor->constants();
556 559 constantTag tag = cpool->tag_at(index);
557 560 return tag.is_unresolved_string();
558 561 }
559 562
560 563 // ------------------------------------------------------------------
561 564 // ciEnv::is_unresolved_klass_impl
562 565 //
563 566 // Implementation of is_unresolved_klass().
564 567 bool ciEnv::is_unresolved_klass_impl(instanceKlass* accessor, int index) const {
565 568 EXCEPTION_CONTEXT;
566 569 assert(accessor->is_linked(), "must be linked before accessing constant pool");
567 570 constantPoolOop cpool = accessor->constants();
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
568 571 constantTag tag = cpool->tag_at(index);
569 572 return tag.is_unresolved_klass();
570 573 }
571 574
572 575 // ------------------------------------------------------------------
573 576 // ciEnv::get_constant_by_index
574 577 //
575 578 // Pull a constant out of the constant pool. How appropriate.
576 579 //
577 580 // Implementation note: this query is currently in no way cached.
578 -ciConstant ciEnv::get_constant_by_index(ciInstanceKlass* accessor,
579 - int index) {
580 - GUARDED_VM_ENTRY(return get_constant_by_index_impl(accessor, index); )
581 +ciConstant ciEnv::get_constant_by_index(constantPoolHandle cpool,
582 + int index,
583 + ciInstanceKlass* accessor) {
584 + GUARDED_VM_ENTRY(return get_constant_by_index_impl(cpool, index, accessor);)
581 585 }
582 586
583 587 // ------------------------------------------------------------------
584 588 // ciEnv::is_unresolved_string
585 589 //
586 590 // Check constant pool
587 591 //
588 592 // Implementation note: this query is currently in no way cached.
589 593 bool ciEnv::is_unresolved_string(ciInstanceKlass* accessor,
590 - int index) const {
594 + int index) const {
591 595 GUARDED_VM_ENTRY(return is_unresolved_string_impl(accessor->get_instanceKlass(), index); )
592 596 }
593 597
594 598 // ------------------------------------------------------------------
595 599 // ciEnv::is_unresolved_klass
596 600 //
597 601 // Check constant pool
598 602 //
599 603 // Implementation note: this query is currently in no way cached.
600 604 bool ciEnv::is_unresolved_klass(ciInstanceKlass* accessor,
601 - int index) const {
605 + int index) const {
602 606 GUARDED_VM_ENTRY(return is_unresolved_klass_impl(accessor->get_instanceKlass(), index); )
603 607 }
604 608
605 609 // ------------------------------------------------------------------
606 610 // ciEnv::get_field_by_index_impl
607 611 //
608 612 // Implementation of get_field_by_index.
609 613 //
610 614 // Implementation note: the results of field lookups are cached
611 615 // in the accessor klass.
612 616 ciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor,
613 617 int index) {
614 618 ciConstantPoolCache* cache = accessor->field_cache();
615 619 if (cache == NULL) {
616 620 ciField* field = new (arena()) ciField(accessor, index);
617 621 return field;
618 622 } else {
619 623 ciField* field = (ciField*)cache->get(index);
620 624 if (field == NULL) {
621 625 field = new (arena()) ciField(accessor, index);
622 626 cache->insert(index, field);
623 627 }
624 628 return field;
625 629 }
626 630 }
627 631
628 632 // ------------------------------------------------------------------
629 633 // ciEnv::get_field_by_index
630 634 //
631 635 // Get a field by index from a klass's constant pool.
632 636 ciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor,
633 637 int index) {
634 638 GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);)
635 639 }
636 640
637 641 // ------------------------------------------------------------------
638 642 // ciEnv::lookup_method
639 643 //
640 644 // Perform an appropriate method lookup based on accessor, holder,
641 645 // name, signature, and bytecode.
642 646 methodOop ciEnv::lookup_method(instanceKlass* accessor,
643 647 instanceKlass* holder,
644 648 symbolOop name,
645 649 symbolOop sig,
646 650 Bytecodes::Code bc) {
647 651 EXCEPTION_CONTEXT;
648 652 KlassHandle h_accessor(THREAD, accessor);
649 653 KlassHandle h_holder(THREAD, holder);
650 654 symbolHandle h_name(THREAD, name);
651 655 symbolHandle h_sig(THREAD, sig);
652 656 LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
653 657 methodHandle dest_method;
654 658 switch (bc) {
655 659 case Bytecodes::_invokestatic:
656 660 dest_method =
657 661 LinkResolver::resolve_static_call_or_null(h_holder, h_name, h_sig, h_accessor);
658 662 break;
659 663 case Bytecodes::_invokespecial:
660 664 dest_method =
661 665 LinkResolver::resolve_special_call_or_null(h_holder, h_name, h_sig, h_accessor);
662 666 break;
663 667 case Bytecodes::_invokeinterface:
664 668 dest_method =
665 669 LinkResolver::linktime_resolve_interface_method_or_null(h_holder, h_name, h_sig,
666 670 h_accessor, true);
667 671 break;
668 672 case Bytecodes::_invokevirtual:
669 673 dest_method =
670 674 LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, h_name, h_sig,
671 675 h_accessor, true);
↓ open down ↓ |
60 lines elided |
↑ open up ↑ |
672 676 break;
673 677 default: ShouldNotReachHere();
674 678 }
675 679
676 680 return dest_method();
677 681 }
678 682
679 683
680 684 // ------------------------------------------------------------------
681 685 // ciEnv::get_method_by_index_impl
682 -ciMethod* ciEnv::get_method_by_index_impl(ciInstanceKlass* accessor,
683 - int index, Bytecodes::Code bc) {
684 - // Get the method's declared holder.
685 -
686 - assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
687 - constantPoolHandle cpool = accessor->get_instanceKlass()->constants();
686 +ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool,
687 + int index, Bytecodes::Code bc,
688 + ciInstanceKlass* accessor) {
688 689 int holder_index = cpool->klass_ref_index_at(index);
689 690 bool holder_is_accessible;
690 - ciKlass* holder = get_klass_by_index_impl(accessor, holder_index, holder_is_accessible);
691 + ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
691 692 ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
692 693
693 694 // Get the method's name and signature.
694 695 symbolOop name_sym = cpool->name_ref_at(index);
695 696 symbolOop sig_sym = cpool->signature_ref_at(index);
696 697
697 698 if (holder_is_accessible) { // Our declared holder is loaded.
698 699 instanceKlass* lookup = declared_holder->get_instanceKlass();
699 700 methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
700 701 if (m != NULL) {
701 702 // We found the method.
702 703 return get_object(m)->as_method();
703 704 }
704 705 }
705 706
706 707 // Either the declared holder was not loaded, or the method could
707 708 // not be found. Create a dummy ciMethod to represent the failed
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
708 709 // lookup.
709 710
710 711 return get_unloaded_method(declared_holder,
711 712 get_object(name_sym)->as_symbol(),
712 713 get_object(sig_sym)->as_symbol());
713 714 }
714 715
715 716
716 717 // ------------------------------------------------------------------
717 718 // ciEnv::get_fake_invokedynamic_method_impl
718 -ciMethod* ciEnv::get_fake_invokedynamic_method_impl(ciInstanceKlass* accessor,
719 +ciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
719 720 int index, Bytecodes::Code bc) {
720 721 assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic");
721 - assert(accessor->get_instanceKlass()->is_linked(), "must be linked before accessing constant pool");
722 - constantPoolHandle cpool = accessor->get_instanceKlass()->constants();
723 722
724 723 // Get the CallSite from the constant pool cache.
725 724 ConstantPoolCacheEntry* cpc_entry = cpool->cache()->secondary_entry_at(index);
726 725 assert(cpc_entry != NULL && cpc_entry->is_secondary_entry(), "sanity");
727 726 Handle call_site = cpc_entry->f1();
728 727
729 728 // Call site might not be linked yet.
730 729 if (call_site.is_null()) {
731 730 ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
732 731 ciSymbol* sig_sym = get_object(cpool->signature_ref_at(index))->as_symbol();
733 732 return get_unloaded_method(mh_klass, ciSymbol::invoke_name(), sig_sym);
734 733 }
735 734
736 735 // Get the methodOop from the CallSite.
737 736 methodOop method_oop = (methodOop) java_dyn_CallSite::vmmethod(call_site());
738 737 assert(method_oop != NULL, "sanity");
739 738 assert(method_oop->is_method_handle_invoke(), "consistent");
740 739
741 740 return get_object(method_oop)->as_method();
742 741 }
743 742
744 743
745 744 // ------------------------------------------------------------------
746 745 // ciEnv::get_instance_klass_for_declared_method_holder
747 746 ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* method_holder) {
748 747 // For the case of <array>.clone(), the method holder can be a ciArrayKlass
749 748 // instead of a ciInstanceKlass. For that case simply pretend that the
750 749 // declared holder is Object.clone since that's where the call will bottom out.
751 750 // A more correct fix would trickle out through many interfaces in CI,
752 751 // requiring ciInstanceKlass* to become ciKlass* and many more places would
753 752 // require checks to make sure the expected type was found. Given that this
754 753 // only occurs for clone() the more extensive fix seems like overkill so
755 754 // instead we simply smear the array type into Object.
756 755 if (method_holder->is_instance_klass()) {
757 756 return method_holder->as_instance_klass();
758 757 } else if (method_holder->is_array_klass()) {
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
759 758 return current()->Object_klass();
760 759 } else {
761 760 ShouldNotReachHere();
762 761 }
763 762 return NULL;
764 763 }
765 764
766 765
767 766 // ------------------------------------------------------------------
768 767 // ciEnv::get_method_by_index
769 -ciMethod* ciEnv::get_method_by_index(ciInstanceKlass* accessor,
770 - int index, Bytecodes::Code bc) {
768 +ciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool,
769 + int index, Bytecodes::Code bc,
770 + ciInstanceKlass* accessor) {
771 771 if (bc == Bytecodes::_invokedynamic) {
772 - GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(accessor, index, bc);)
772 + GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc);)
773 773 } else {
774 - GUARDED_VM_ENTRY(return get_method_by_index_impl(accessor, index, bc);)
774 + GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);)
775 775 }
776 776 }
777 777
778 778
779 779 // ------------------------------------------------------------------
780 780 // ciEnv::name_buffer
781 781 char *ciEnv::name_buffer(int req_len) {
782 782 if (_name_buffer_len < req_len) {
783 783 if (_name_buffer == NULL) {
784 784 _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
785 785 _name_buffer_len = req_len;
786 786 } else {
787 787 _name_buffer =
788 788 (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
789 789 _name_buffer_len = req_len;
790 790 }
791 791 }
792 792 return _name_buffer;
793 793 }
794 794
795 795 // ------------------------------------------------------------------
796 796 // ciEnv::is_in_vm
797 797 bool ciEnv::is_in_vm() {
798 798 return JavaThread::current()->thread_state() == _thread_in_vm;
799 799 }
800 800
801 801 bool ciEnv::system_dictionary_modification_counter_changed() {
802 802 return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
803 803 }
804 804
805 805 // ------------------------------------------------------------------
806 806 // ciEnv::check_for_system_dictionary_modification
807 807 // Check for changes to the system dictionary during compilation
808 808 // class loads, evolution, breakpoints
809 809 void ciEnv::check_for_system_dictionary_modification(ciMethod* target) {
810 810 if (failing()) return; // no need for further checks
811 811
812 812 // Dependencies must be checked when the system dictionary changes.
813 813 // If logging is enabled all violated dependences will be recorded in
814 814 // the log. In debug mode check dependencies even if the system
815 815 // dictionary hasn't changed to verify that no invalid dependencies
816 816 // were inserted. Any violated dependences in this case are dumped to
817 817 // the tty.
818 818
819 819 bool counter_changed = system_dictionary_modification_counter_changed();
820 820 bool test_deps = counter_changed;
821 821 DEBUG_ONLY(test_deps = true);
822 822 if (!test_deps) return;
823 823
824 824 bool print_failures = false;
825 825 DEBUG_ONLY(print_failures = !counter_changed);
826 826
827 827 bool keep_going = (print_failures || xtty != NULL);
828 828
829 829 int violated = 0;
830 830
831 831 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
832 832 klassOop witness = deps.check_dependency();
833 833 if (witness != NULL) {
834 834 ++violated;
835 835 if (print_failures) deps.print_dependency(witness, /*verbose=*/ true);
836 836 // If there's no log and we're not sanity-checking, we're done.
837 837 if (!keep_going) break;
838 838 }
839 839 }
840 840
841 841 if (violated != 0) {
842 842 assert(counter_changed, "failed dependencies, but counter didn't change");
843 843 record_failure("concurrent class loading");
844 844 }
845 845 }
846 846
847 847 // ------------------------------------------------------------------
848 848 // ciEnv::register_method
849 849 void ciEnv::register_method(ciMethod* target,
850 850 int entry_bci,
851 851 CodeOffsets* offsets,
852 852 int orig_pc_offset,
853 853 CodeBuffer* code_buffer,
854 854 int frame_words,
855 855 OopMapSet* oop_map_set,
856 856 ExceptionHandlerTable* handler_table,
857 857 ImplicitExceptionTable* inc_table,
858 858 AbstractCompiler* compiler,
859 859 int comp_level,
860 860 bool has_debug_info,
861 861 bool has_unsafe_access) {
862 862 VM_ENTRY_MARK;
863 863 nmethod* nm = NULL;
864 864 {
865 865 // To prevent compile queue updates.
866 866 MutexLocker locker(MethodCompileQueue_lock, THREAD);
867 867
868 868 // Prevent SystemDictionary::add_to_hierarchy from running
869 869 // and invalidating our dependencies until we install this method.
870 870 MutexLocker ml(Compile_lock);
871 871
872 872 // Change in Jvmti state may invalidate compilation.
873 873 if (!failing() &&
874 874 ( (!jvmti_can_hotswap_or_post_breakpoint() &&
875 875 JvmtiExport::can_hotswap_or_post_breakpoint()) ||
876 876 (!jvmti_can_examine_or_deopt_anywhere() &&
877 877 JvmtiExport::can_examine_or_deopt_anywhere()) ||
878 878 (!jvmti_can_access_local_variables() &&
879 879 JvmtiExport::can_access_local_variables()) ||
880 880 (!jvmti_can_post_exceptions() &&
881 881 JvmtiExport::can_post_exceptions()) )) {
882 882 record_failure("Jvmti state change invalidated dependencies");
883 883 }
884 884
885 885 // Change in DTrace flags may invalidate compilation.
886 886 if (!failing() &&
887 887 ( (!dtrace_extended_probes() && ExtendedDTraceProbes) ||
888 888 (!dtrace_method_probes() && DTraceMethodProbes) ||
889 889 (!dtrace_alloc_probes() && DTraceAllocProbes) )) {
890 890 record_failure("DTrace flags change invalidated dependencies");
891 891 }
892 892
893 893 if (!failing()) {
894 894 if (log() != NULL) {
895 895 // Log the dependencies which this compilation declares.
896 896 dependencies()->log_all_dependencies();
897 897 }
898 898
899 899 // Encode the dependencies now, so we can check them right away.
900 900 dependencies()->encode_content_bytes();
901 901
902 902 // Check for {class loads, evolution, breakpoints} during compilation
903 903 check_for_system_dictionary_modification(target);
904 904 }
905 905
906 906 methodHandle method(THREAD, target->get_methodOop());
907 907
908 908 if (failing()) {
909 909 // While not a true deoptimization, it is a preemptive decompile.
910 910 methodDataOop mdo = method()->method_data();
911 911 if (mdo != NULL) {
912 912 mdo->inc_decompile_count();
913 913 }
914 914
915 915 // All buffers in the CodeBuffer are allocated in the CodeCache.
916 916 // If the code buffer is created on each compile attempt
917 917 // as in C2, then it must be freed.
918 918 code_buffer->free_blob();
919 919 return;
920 920 }
921 921
922 922 assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
923 923 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
924 924
925 925 nm = nmethod::new_nmethod(method,
926 926 compile_id(),
927 927 entry_bci,
928 928 offsets,
929 929 orig_pc_offset,
930 930 debug_info(), dependencies(), code_buffer,
931 931 frame_words, oop_map_set,
932 932 handler_table, inc_table,
933 933 compiler, comp_level);
934 934
935 935 // Free codeBlobs
936 936 code_buffer->free_blob();
937 937
938 938 // stress test 6243940 by immediately making the method
939 939 // non-entrant behind the system's back. This has serious
940 940 // side effects on the code cache and is not meant for
941 941 // general stress testing
942 942 if (nm != NULL && StressNonEntrant) {
943 943 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
944 944 NativeJump::patch_verified_entry(nm->entry_point(), nm->verified_entry_point(),
945 945 SharedRuntime::get_handle_wrong_method_stub());
946 946 }
947 947
948 948 if (nm == NULL) {
949 949 // The CodeCache is full. Print out warning and disable compilation.
950 950 record_failure("code cache is full");
951 951 UseInterpreter = true;
952 952 if (UseCompiler || AlwaysCompileLoopMethods ) {
953 953 #ifndef PRODUCT
954 954 warning("CodeCache is full. Compiler has been disabled");
955 955 if (CompileTheWorld || ExitOnFullCodeCache) {
956 956 before_exit(JavaThread::current());
957 957 exit_globals(); // will delete tty
958 958 vm_direct_exit(CompileTheWorld ? 0 : 1);
959 959 }
960 960 #endif
961 961 UseCompiler = false;
962 962 AlwaysCompileLoopMethods = false;
963 963 }
964 964 } else {
965 965 NOT_PRODUCT(nm->set_has_debug_info(has_debug_info); )
966 966 nm->set_has_unsafe_access(has_unsafe_access);
967 967
968 968 // Record successful registration.
969 969 // (Put nm into the task handle *before* publishing to the Java heap.)
970 970 if (task() != NULL) task()->set_code(nm);
971 971
972 972 if (entry_bci == InvocationEntryBci) {
973 973 #ifdef TIERED
974 974 // If there is an old version we're done with it
975 975 nmethod* old = method->code();
976 976 if (TraceMethodReplacement && old != NULL) {
977 977 ResourceMark rm;
978 978 char *method_name = method->name_and_sig_as_C_string();
979 979 tty->print_cr("Replacing method %s", method_name);
980 980 }
981 981 if (old != NULL ) {
982 982 old->make_not_entrant();
983 983 }
984 984 #endif // TIERED
985 985 if (TraceNMethodInstalls ) {
986 986 ResourceMark rm;
987 987 char *method_name = method->name_and_sig_as_C_string();
988 988 ttyLocker ttyl;
989 989 tty->print_cr("Installing method (%d) %s ",
990 990 comp_level,
991 991 method_name);
992 992 }
993 993 // Allow the code to be executed
994 994 method->set_code(method, nm);
995 995 } else {
996 996 if (TraceNMethodInstalls ) {
997 997 ResourceMark rm;
998 998 char *method_name = method->name_and_sig_as_C_string();
999 999 ttyLocker ttyl;
1000 1000 tty->print_cr("Installing osr method (%d) %s @ %d",
1001 1001 comp_level,
1002 1002 method_name,
1003 1003 entry_bci);
1004 1004 }
1005 1005 instanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
1006 1006
1007 1007 }
1008 1008 }
1009 1009 }
1010 1010 // JVMTI -- compiled method notification (must be done outside lock)
1011 1011 if (nm != NULL) {
1012 1012 nm->post_compiled_method_load_event();
1013 1013 }
1014 1014
1015 1015 }
1016 1016
1017 1017
1018 1018 // ------------------------------------------------------------------
1019 1019 // ciEnv::find_system_klass
1020 1020 ciKlass* ciEnv::find_system_klass(ciSymbol* klass_name) {
1021 1021 VM_ENTRY_MARK;
1022 1022 return get_klass_by_name_impl(NULL, klass_name, false);
1023 1023 }
1024 1024
1025 1025 // ------------------------------------------------------------------
1026 1026 // ciEnv::comp_level
1027 1027 int ciEnv::comp_level() {
1028 1028 if (task() == NULL) return CompLevel_full_optimization;
1029 1029 return task()->comp_level();
1030 1030 }
1031 1031
1032 1032 // ------------------------------------------------------------------
1033 1033 // ciEnv::compile_id
1034 1034 uint ciEnv::compile_id() {
1035 1035 if (task() == NULL) return 0;
1036 1036 return task()->compile_id();
1037 1037 }
1038 1038
1039 1039 // ------------------------------------------------------------------
1040 1040 // ciEnv::notice_inlined_method()
1041 1041 void ciEnv::notice_inlined_method(ciMethod* method) {
1042 1042 _num_inlined_bytecodes += method->code_size();
1043 1043 }
1044 1044
1045 1045 // ------------------------------------------------------------------
1046 1046 // ciEnv::num_inlined_bytecodes()
1047 1047 int ciEnv::num_inlined_bytecodes() const {
1048 1048 return _num_inlined_bytecodes;
1049 1049 }
1050 1050
1051 1051 // ------------------------------------------------------------------
1052 1052 // ciEnv::record_failure()
1053 1053 void ciEnv::record_failure(const char* reason) {
1054 1054 if (log() != NULL) {
1055 1055 log()->elem("failure reason='%s'", reason);
1056 1056 }
1057 1057 if (_failure_reason == NULL) {
1058 1058 // Record the first failure reason.
1059 1059 _failure_reason = reason;
1060 1060 }
1061 1061 }
1062 1062
1063 1063 // ------------------------------------------------------------------
1064 1064 // ciEnv::record_method_not_compilable()
1065 1065 void ciEnv::record_method_not_compilable(const char* reason, bool all_tiers) {
1066 1066 int new_compilable =
1067 1067 all_tiers ? MethodCompilable_never : MethodCompilable_not_at_tier ;
1068 1068
1069 1069 // Only note transitions to a worse state
1070 1070 if (new_compilable > _compilable) {
1071 1071 if (log() != NULL) {
1072 1072 if (all_tiers) {
1073 1073 log()->elem("method_not_compilable");
1074 1074 } else {
1075 1075 log()->elem("method_not_compilable_at_tier");
1076 1076 }
1077 1077 }
1078 1078 _compilable = new_compilable;
1079 1079
1080 1080 // Reset failure reason; this one is more important.
1081 1081 _failure_reason = NULL;
1082 1082 record_failure(reason);
1083 1083 }
1084 1084 }
1085 1085
1086 1086 // ------------------------------------------------------------------
1087 1087 // ciEnv::record_out_of_memory_failure()
1088 1088 void ciEnv::record_out_of_memory_failure() {
1089 1089 // If memory is low, we stop compiling methods.
1090 1090 record_method_not_compilable("out of memory");
1091 1091 }
↓ open down ↓ |
307 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX