comparison src/share/vm/ci/ciEnv.cpp @ 6948:e522a00b91aa

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
author Doug Simon <doug.simon@oracle.com>
date Mon, 12 Nov 2012 23:14:12 +0100
parents c38f13903fdf 18fb7da42534
children 2cb439954abf
comparison
equal deleted inserted replaced
6711:ae13cc658b80 6948:e522a00b91aa
1 /* 1 /*
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
26 #include "ci/ciConstant.hpp" 26 #include "ci/ciConstant.hpp"
27 #include "ci/ciEnv.hpp" 27 #include "ci/ciEnv.hpp"
28 #include "ci/ciField.hpp" 28 #include "ci/ciField.hpp"
29 #include "ci/ciInstance.hpp" 29 #include "ci/ciInstance.hpp"
30 #include "ci/ciInstanceKlass.hpp" 30 #include "ci/ciInstanceKlass.hpp"
31 #include "ci/ciInstanceKlassKlass.hpp"
32 #include "ci/ciMethod.hpp" 31 #include "ci/ciMethod.hpp"
33 #include "ci/ciNullObject.hpp" 32 #include "ci/ciNullObject.hpp"
34 #include "ci/ciObjArrayKlassKlass.hpp"
35 #include "ci/ciTypeArrayKlassKlass.hpp"
36 #include "ci/ciUtilities.hpp" 33 #include "ci/ciUtilities.hpp"
37 #include "classfile/systemDictionary.hpp" 34 #include "classfile/systemDictionary.hpp"
38 #include "classfile/vmSymbols.hpp" 35 #include "classfile/vmSymbols.hpp"
39 #include "code/scopeDesc.hpp" 36 #include "code/scopeDesc.hpp"
40 #include "compiler/compileBroker.hpp" 37 #include "compiler/compileBroker.hpp"
43 #include "gc_interface/collectedHeap.inline.hpp" 40 #include "gc_interface/collectedHeap.inline.hpp"
44 #include "interpreter/linkResolver.hpp" 41 #include "interpreter/linkResolver.hpp"
45 #include "memory/allocation.inline.hpp" 42 #include "memory/allocation.inline.hpp"
46 #include "memory/oopFactory.hpp" 43 #include "memory/oopFactory.hpp"
47 #include "memory/universe.inline.hpp" 44 #include "memory/universe.inline.hpp"
48 #include "oops/methodDataOop.hpp" 45 #include "oops/methodData.hpp"
49 #include "oops/objArrayKlass.hpp" 46 #include "oops/objArrayKlass.hpp"
50 #include "oops/oop.inline.hpp" 47 #include "oops/oop.inline.hpp"
51 #include "oops/oop.inline2.hpp" 48 #include "oops/oop.inline2.hpp"
52 #include "prims/jvmtiExport.hpp" 49 #include "prims/jvmtiExport.hpp"
53 #include "runtime/init.hpp" 50 #include "runtime/init.hpp"
65 // 62 //
66 // This class is the top level broker for requests from the compiler 63 // This class is the top level broker for requests from the compiler
67 // to the VM. 64 // to the VM.
68 65
69 ciObject* ciEnv::_null_object_instance; 66 ciObject* ciEnv::_null_object_instance;
70 ciMethodKlass* ciEnv::_method_klass_instance;
71 ciKlassKlass* ciEnv::_klass_klass_instance;
72 ciInstanceKlassKlass* ciEnv::_instance_klass_klass_instance;
73 ciTypeArrayKlassKlass* ciEnv::_type_array_klass_klass_instance;
74 ciObjArrayKlassKlass* ciEnv::_obj_array_klass_klass_instance;
75 67
76 #define WK_KLASS_DEFN(name, ignore_s, ignore_o) ciInstanceKlass* ciEnv::_##name = NULL; 68 #define WK_KLASS_DEFN(name, ignore_s, ignore_o) ciInstanceKlass* ciEnv::_##name = NULL;
77 WK_KLASSES_DO(WK_KLASS_DEFN) 69 WK_KLASSES_DO(WK_KLASS_DEFN)
78 #undef WK_KLASS_DEFN 70 #undef WK_KLASS_DEFN
79 71
103 _dependencies = NULL; 95 _dependencies = NULL;
104 _failure_reason = NULL; 96 _failure_reason = NULL;
105 _compilable = MethodCompilable; 97 _compilable = MethodCompilable;
106 _break_at_compile = false; 98 _break_at_compile = false;
107 _compiler_data = NULL; 99 _compiler_data = NULL;
108 //#ifndef PRODUCT 100 #ifndef PRODUCT
109 // assert(!firstEnv, "not initialized properly"); 101 assert(!firstEnv, "not initialized properly");
110 //#endif /* !PRODUCT */ 102 #endif /* !PRODUCT */
111 103
112 _system_dictionary_modification_counter = system_dictionary_modification_counter; 104 _system_dictionary_modification_counter = system_dictionary_modification_counter;
113 _num_inlined_bytecodes = 0; 105 _num_inlined_bytecodes = 0;
114 assert(task == NULL || compiler_thread->task() == task, "sanity"); 106 assert(task == NULL || compiler_thread->task() == task, "sanity");
115 _task = task; 107 _task = task;
146 138
147 ciEnv::ciEnv(Arena* arena) { 139 ciEnv::ciEnv(Arena* arena) {
148 ASSERT_IN_VM; 140 ASSERT_IN_VM;
149 141
150 // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. 142 // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
143 #ifdef GRAAL
151 JavaThread* current_thread = JavaThread::current(); 144 JavaThread* current_thread = JavaThread::current();
145 #else
146 CompilerThread* current_thread = CompilerThread::current();
147 #endif
152 assert(current_thread->env() == NULL, "must be"); 148 assert(current_thread->env() == NULL, "must be");
153 current_thread->set_env(this); 149 current_thread->set_env(this);
154 assert(ciEnv::current() == this, "sanity"); 150 assert(ciEnv::current() == this, "sanity");
155 151
156 _oop_recorder = NULL; 152 _oop_recorder = NULL;
158 _dependencies = NULL; 154 _dependencies = NULL;
159 _failure_reason = NULL; 155 _failure_reason = NULL;
160 _compilable = MethodCompilable_never; 156 _compilable = MethodCompilable_never;
161 _break_at_compile = false; 157 _break_at_compile = false;
162 _compiler_data = NULL; 158 _compiler_data = NULL;
163 //#ifndef PRODUCT 159 #ifndef PRODUCT
164 // assert(firstEnv, "must be first"); 160 #ifndef GRAAL
165 // firstEnv = false; 161 assert(firstEnv, "must be first");
166 //#endif /* !PRODUCT */ 162 firstEnv = false;
163 #endif
164 #endif /* !PRODUCT */
167 165
168 _system_dictionary_modification_counter = 0; 166 _system_dictionary_modification_counter = 0;
169 _num_inlined_bytecodes = 0; 167 _num_inlined_bytecodes = 0;
170 _task = NULL; 168 _task = NULL;
171 _log = NULL; 169 _log = NULL;
183 // Assertions ensure that these instances are not accessed before 181 // Assertions ensure that these instances are not accessed before
184 // their initialization. 182 // their initialization.
185 183
186 assert(Universe::is_fully_initialized(), "must be"); 184 assert(Universe::is_fully_initialized(), "must be");
187 185
188 oop o = Universe::null_ptr_exception_instance(); 186 _NullPointerException_instance = NULL;
189 assert(o != NULL, "should have been initialized"); 187 _ArithmeticException_instance = NULL;
190 _NullPointerException_instance = get_object(o)->as_instance();
191 o = Universe::arithmetic_exception_instance();
192 assert(o != NULL, "should have been initialized");
193 _ArithmeticException_instance = get_object(o)->as_instance();
194
195 _ArrayIndexOutOfBoundsException_instance = NULL; 188 _ArrayIndexOutOfBoundsException_instance = NULL;
196 _ArrayStoreException_instance = NULL; 189 _ArrayStoreException_instance = NULL;
197 _ClassCastException_instance = NULL; 190 _ClassCastException_instance = NULL;
198 _the_null_string = NULL; 191 _the_null_string = NULL;
199 _the_min_jint_string = NULL; 192 _the_min_jint_string = NULL;
200 } 193 }
201 194
202 ciEnv::~ciEnv() { 195 ciEnv::~ciEnv() {
196 #ifdef GRAAL
203 _factory->remove_symbols(); 197 _factory->remove_symbols();
204 JavaThread::current()->set_env(NULL); 198 JavaThread::current()->set_env(NULL);
199 #else
200 CompilerThread* current_thread = CompilerThread::current();
201 _factory->remove_symbols();
202 // Need safepoint to clear the env on the thread. RedefineClasses might
203 // be reading it.
204 GUARDED_VM_ENTRY(current_thread->set_env(NULL);)
205 #endif
205 } 206 }
206 207
207 // ------------------------------------------------------------------ 208 // ------------------------------------------------------------------
208 // Cache Jvmti state 209 // Cache Jvmti state
209 void ciEnv::cache_jvmti_state() { 210 void ciEnv::cache_jvmti_state() {
235 // helper for lazy exception creation 236 // helper for lazy exception creation
236 ciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) { 237 ciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) {
237 VM_ENTRY_MARK; 238 VM_ENTRY_MARK;
238 if (handle == NULL) { 239 if (handle == NULL) {
239 // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance. 240 // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance.
240 klassOop k = SystemDictionary::find(name, Handle(), Handle(), THREAD); 241 Klass* k = SystemDictionary::find(name, Handle(), Handle(), THREAD);
241 jobject objh = NULL; 242 jobject objh = NULL;
242 if (!HAS_PENDING_EXCEPTION && k != NULL) { 243 if (!HAS_PENDING_EXCEPTION && k != NULL) {
243 oop obj = instanceKlass::cast(k)->allocate_permanent_instance(THREAD); 244 oop obj = InstanceKlass::cast(k)->allocate_instance(THREAD);
244 if (!HAS_PENDING_EXCEPTION) 245 if (!HAS_PENDING_EXCEPTION)
245 objh = JNIHandles::make_global(obj); 246 objh = JNIHandles::make_global(obj);
246 } 247 }
247 if (HAS_PENDING_EXCEPTION) { 248 if (HAS_PENDING_EXCEPTION) {
248 CLEAR_PENDING_EXCEPTION; 249 CLEAR_PENDING_EXCEPTION;
252 } 253 }
253 oop obj = JNIHandles::resolve(handle); 254 oop obj = JNIHandles::resolve(handle);
254 return obj == NULL? NULL: get_object(obj)->as_instance(); 255 return obj == NULL? NULL: get_object(obj)->as_instance();
255 } 256 }
256 257
257 // ------------------------------------------------------------------
258 // ciEnv::ArrayIndexOutOfBoundsException_instance, etc.
259 ciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() { 258 ciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() {
260 if (_ArrayIndexOutOfBoundsException_instance == NULL) { 259 if (_ArrayIndexOutOfBoundsException_instance == NULL) {
261 _ArrayIndexOutOfBoundsException_instance 260 _ArrayIndexOutOfBoundsException_instance
262 = get_or_create_exception(_ArrayIndexOutOfBoundsException_handle, 261 = get_or_create_exception(_ArrayIndexOutOfBoundsException_handle,
263 vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); 262 vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
297 return _the_min_jint_string; 296 return _the_min_jint_string;
298 } 297 }
299 298
300 // ------------------------------------------------------------------ 299 // ------------------------------------------------------------------
301 // ciEnv::get_method_from_handle 300 // ciEnv::get_method_from_handle
302 ciMethod* ciEnv::get_method_from_handle(jobject method) { 301 ciMethod* ciEnv::get_method_from_handle(Method* method) {
303 VM_ENTRY_MARK; 302 VM_ENTRY_MARK;
304 return get_object(JNIHandles::resolve(method))->as_method(); 303 return get_metadata(method)->as_method();
305 } 304 }
306
307 // ------------------------------------------------------------------
308 // ciEnv::make_array
309 ciArray* ciEnv::make_system_array(GrowableArray<ciObject*>* objects) {
310 VM_ENTRY_MARK;
311 int length = objects->length();
312 objArrayOop a = oopFactory::new_system_objArray(length, THREAD);
313 if (HAS_PENDING_EXCEPTION) {
314 CLEAR_PENDING_EXCEPTION;
315 record_out_of_memory_failure();
316 return NULL;
317 }
318 for (int i = 0; i < length; i++) {
319 a->obj_at_put(i, objects->at(i)->get_oop());
320 }
321 assert(a->is_perm(), "");
322 return get_object(a)->as_array();
323 }
324
325 305
326 // ------------------------------------------------------------------ 306 // ------------------------------------------------------------------
327 // ciEnv::array_element_offset_in_bytes 307 // ciEnv::array_element_offset_in_bytes
328 int ciEnv::array_element_offset_in_bytes(ciArray* a_h, ciObject* o_h) { 308 int ciEnv::array_element_offset_in_bytes(ciArray* a_h, ciObject* o_h) {
329 VM_ENTRY_MARK; 309 VM_ENTRY_MARK;
340 320
341 // ------------------------------------------------------------------ 321 // ------------------------------------------------------------------
342 // ciEnv::check_klass_accessiblity 322 // ciEnv::check_klass_accessiblity
343 // 323 //
344 // Note: the logic of this method should mirror the logic of 324 // Note: the logic of this method should mirror the logic of
345 // constantPoolOopDesc::verify_constant_pool_resolve. 325 // ConstantPool::verify_constant_pool_resolve.
346 bool ciEnv::check_klass_accessibility(ciKlass* accessing_klass, 326 bool ciEnv::check_klass_accessibility(ciKlass* accessing_klass,
347 klassOop resolved_klass) { 327 Klass* resolved_klass) {
348 if (accessing_klass == NULL || !accessing_klass->is_loaded()) { 328 if (accessing_klass == NULL || !accessing_klass->is_loaded()) {
349 return true; 329 return true;
350 } 330 }
351 if (accessing_klass->is_obj_array()) { 331 if (accessing_klass->is_obj_array_klass()) {
352 accessing_klass = accessing_klass->as_obj_array_klass()->base_element_klass(); 332 accessing_klass = accessing_klass->as_obj_array_klass()->base_element_klass();
353 } 333 }
354 if (!accessing_klass->is_instance_klass()) { 334 if (!accessing_klass->is_instance_klass()) {
355 return true; 335 return true;
356 } 336 }
357 337
358 if (resolved_klass->klass_part()->oop_is_objArray()) { 338 if (resolved_klass->oop_is_objArray()) {
359 // Find the element klass, if this is an array. 339 // Find the element klass, if this is an array.
360 resolved_klass = objArrayKlass::cast(resolved_klass)->bottom_klass(); 340 resolved_klass = ObjArrayKlass::cast(resolved_klass)->bottom_klass();
361 } 341 }
362 if (resolved_klass->klass_part()->oop_is_instance()) { 342 if (resolved_klass->oop_is_instance()) {
363 return Reflection::verify_class_access(accessing_klass->get_klassOop(), 343 return Reflection::verify_class_access(accessing_klass->get_Klass(),
364 resolved_klass, 344 resolved_klass,
365 true); 345 true);
366 } 346 }
367 return true; 347 return true;
368 } 348 }
413 } 393 }
414 KlassHandle found_klass; 394 KlassHandle found_klass;
415 { 395 {
416 ttyUnlocker ttyul; // release tty lock to avoid ordering problems 396 ttyUnlocker ttyul; // release tty lock to avoid ordering problems
417 MutexLocker ml(Compile_lock); 397 MutexLocker ml(Compile_lock);
418 klassOop kls; 398 Klass* kls;
419 if (!require_local) { 399 if (!require_local) {
420 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, 400 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
421 KILL_COMPILE_ON_FATAL_(fail_type)); 401 KILL_COMPILE_ON_FATAL_(fail_type));
422 } else { 402 } else {
423 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, 403 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
454 434
455 if (found_klass() == NULL && !cpool.is_null() && cpool->has_preresolution()) { 435 if (found_klass() == NULL && !cpool.is_null() && cpool->has_preresolution()) {
456 // Look inside the constant pool for pre-resolved class entries. 436 // Look inside the constant pool for pre-resolved class entries.
457 for (int i = cpool->length() - 1; i >= 1; i--) { 437 for (int i = cpool->length() - 1; i >= 1; i--) {
458 if (cpool->tag_at(i).is_klass()) { 438 if (cpool->tag_at(i).is_klass()) {
459 klassOop kls = cpool->resolved_klass_at(i); 439 Klass* kls = cpool->resolved_klass_at(i);
460 if (Klass::cast(kls)->name() == sym) { 440 if (Klass::cast(kls)->name() == sym) {
461 found_klass = KlassHandle(THREAD, kls); 441 found_klass = KlassHandle(THREAD, kls);
462 break; 442 break;
463 } 443 }
464 } 444 }
465 } 445 }
466 } 446 }
467 447
468 if (found_klass() != NULL) { 448 if (found_klass() != NULL) {
469 // Found it. Build a CI handle. 449 // Found it. Build a CI handle.
470 return get_object(found_klass())->as_klass(); 450 return get_klass(found_klass());
471 } 451 }
472 452
473 if (require_local) return NULL; 453 if (require_local) return NULL;
474 454
475 // Not yet loaded into the VM, or not governed by loader constraints. 455 // Not yet loaded into the VM, or not governed by loader constraints.
495 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool, 475 ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
496 int index, 476 int index,
497 bool& is_accessible, 477 bool& is_accessible,
498 ciInstanceKlass* accessor) { 478 ciInstanceKlass* accessor) {
499 EXCEPTION_CONTEXT; 479 EXCEPTION_CONTEXT;
500 KlassHandle klass(THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index)); 480 KlassHandle klass; // = NULL;
501 Symbol* klass_name = NULL; 481 Symbol* klass_name = NULL;
482
483 if (cpool->tag_at(index).is_symbol()) {
484 klass_name = cpool->symbol_at(index);
485 } else {
486 // Check if it's resolved if it's not a symbol constant pool entry.
487 klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index));
488
502 if (klass.is_null()) { 489 if (klass.is_null()) {
503 // The klass has not been inserted into the constant pool. 490 // The klass has not been inserted into the constant pool.
504 // Try to look it up by name. 491 // Try to look it up by name.
505 { 492 {
506 // We have to lock the cpool to keep the oop from being resolved 493 // We have to lock the cpool to keep the oop from being resolved
507 // while we are accessing it. 494 // while we are accessing it.
508 ObjectLocker ol(cpool, THREAD); 495 MonitorLockerEx ml(cpool->lock());
509
510 constantTag tag = cpool->tag_at(index); 496 constantTag tag = cpool->tag_at(index);
511 if (tag.is_klass()) { 497 if (tag.is_klass()) {
512 // The klass has been inserted into the constant pool 498 // The klass has been inserted into the constant pool
513 // very recently. 499 // very recently.
514 klass = KlassHandle(THREAD, cpool->resolved_klass_at(index)); 500 klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
515 } else if (tag.is_symbol()) {
516 klass_name = cpool->symbol_at(index);
517 } else { 501 } else {
518 assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag"); 502 assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
519 klass_name = cpool->unresolved_klass_at(index); 503 klass_name = cpool->unresolved_klass_at(index);
520 } 504 }
521 } 505 }
506 }
522 } 507 }
523 508
524 if (klass.is_null()) { 509 if (klass.is_null()) {
525 // Not found in constant pool. Use the name to do the lookup. 510 // Not found in constant pool. Use the name to do the lookup.
526 ciKlass* k = get_klass_by_name_impl(accessor, 511 ciKlass* k = get_klass_by_name_impl(accessor,
534 get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) { 519 get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) {
535 // Loaded only remotely. Not linked yet. 520 // Loaded only remotely. Not linked yet.
536 is_accessible = false; 521 is_accessible = false;
537 } else { 522 } else {
538 // Linked locally, and we must also check public/private, etc. 523 // Linked locally, and we must also check public/private, etc.
539 is_accessible = check_klass_accessibility(accessor, k->get_klassOop()); 524 is_accessible = check_klass_accessibility(accessor, k->get_Klass());
540 } 525 }
541 return k; 526 return k;
542 } 527 }
543 528
544 // Check for prior unloaded klass. The SystemDictionary's answers 529 // Check for prior unloaded klass. The SystemDictionary's answers
545 // can vary over time but the compiler needs consistency. 530 // can vary over time but the compiler needs consistency.
546 ciSymbol* name = get_symbol(klass()->klass_part()->name()); 531 ciSymbol* name = get_symbol(klass()->name());
547 ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name); 532 ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
548 if (unloaded_klass != NULL) { 533 if (unloaded_klass != NULL) {
549 is_accessible = false; 534 is_accessible = false;
550 return unloaded_klass; 535 return unloaded_klass;
551 } 536 }
552 537
553 // It is known to be accessible, since it was found in the constant pool. 538 // It is known to be accessible, since it was found in the constant pool.
554 is_accessible = true; 539 is_accessible = true;
555 return get_object(klass())->as_klass(); 540 return get_klass(klass());
556 } 541 }
557 542
558 // ------------------------------------------------------------------ 543 // ------------------------------------------------------------------
559 // ciEnv::get_klass_by_index 544 // ciEnv::get_klass_by_index
560 // 545 //
576 bool ignore_will_link; 561 bool ignore_will_link;
577 EXCEPTION_CONTEXT; 562 EXCEPTION_CONTEXT;
578 int index = pool_index; 563 int index = pool_index;
579 if (cache_index >= 0) { 564 if (cache_index >= 0) {
580 assert(index < 0, "only one kind of index at a time"); 565 assert(index < 0, "only one kind of index at a time");
581 ConstantPoolCacheEntry* cpc_entry = cpool->cache()->entry_at(cache_index); 566 oop obj = cpool->resolved_references()->obj_at(cache_index);
582 index = cpc_entry->constant_pool_index();
583 oop obj = cpc_entry->f1_as_instance();
584 if (obj != NULL) { 567 if (obj != NULL) {
585 assert(obj->is_instance() || obj->is_array(), "must be a Java reference");
586 ciObject* ciobj = get_object(obj); 568 ciObject* ciobj = get_object(obj);
587 return ciConstant(T_OBJECT, ciobj); 569 return ciConstant(T_OBJECT, ciobj);
588 } 570 }
571 index = cpool->object_to_cp_index(cache_index);
589 } 572 }
590 constantTag tag = cpool->tag_at(index); 573 constantTag tag = cpool->tag_at(index);
591 if (tag.is_int()) { 574 if (tag.is_int()) {
592 return ciConstant(T_INT, (jint)cpool->int_at(index)); 575 return ciConstant(T_INT, (jint)cpool->int_at(index));
593 } else if (tag.is_long()) { 576 } else if (tag.is_long()) {
594 return ciConstant((jlong)cpool->long_at(index)); 577 return ciConstant((jlong)cpool->long_at(index));
595 } else if (tag.is_float()) { 578 } else if (tag.is_float()) {
596 return ciConstant((jfloat)cpool->float_at(index)); 579 return ciConstant((jfloat)cpool->float_at(index));
597 } else if (tag.is_double()) { 580 } else if (tag.is_double()) {
598 return ciConstant((jdouble)cpool->double_at(index)); 581 return ciConstant((jdouble)cpool->double_at(index));
599 } else if (tag.is_string() || tag.is_unresolved_string()) { 582 } else if (tag.is_string()) {
600 oop string = NULL; 583 oop string = NULL;
584 assert(cache_index >= 0, "should have a cache index");
601 if (cpool->is_pseudo_string_at(index)) { 585 if (cpool->is_pseudo_string_at(index)) {
602 string = cpool->pseudo_string_at(index); 586 string = cpool->pseudo_string_at(index, cache_index);
603 } else { 587 } else {
604 string = cpool->string_at(index, THREAD); 588 string = cpool->string_at(index, cache_index, THREAD);
605 if (HAS_PENDING_EXCEPTION) { 589 if (HAS_PENDING_EXCEPTION) {
606 CLEAR_PENDING_EXCEPTION; 590 CLEAR_PENDING_EXCEPTION;
607 record_out_of_memory_failure(); 591 record_out_of_memory_failure();
608 return ciConstant(); 592 return ciConstant();
609 } 593 }
622 assert (klass->is_instance_klass() || klass->is_array_klass(), 606 assert (klass->is_instance_klass() || klass->is_array_klass(),
623 "must be an instance or array klass "); 607 "must be an instance or array klass ");
624 return ciConstant(T_OBJECT, klass->java_mirror()); 608 return ciConstant(T_OBJECT, klass->java_mirror());
625 } else if (tag.is_object()) { 609 } else if (tag.is_object()) {
626 oop obj = cpool->object_at(index); 610 oop obj = cpool->object_at(index);
627 assert(obj->is_instance() || obj->is_array(), "must be a Java reference");
628 ciObject* ciobj = get_object(obj); 611 ciObject* ciobj = get_object(obj);
629 return ciConstant(T_OBJECT, ciobj); 612 return ciConstant(T_OBJECT, ciobj);
630 } else if (tag.is_method_type()) { 613 } else if (tag.is_method_type()) {
631 // must execute Java code to link this CP entry into cache[i].f1 614 // must execute Java code to link this CP entry into cache[i].f1
632 ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index)); 615 ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));
694 // ------------------------------------------------------------------ 677 // ------------------------------------------------------------------
695 // ciEnv::lookup_method 678 // ciEnv::lookup_method
696 // 679 //
697 // Perform an appropriate method lookup based on accessor, holder, 680 // Perform an appropriate method lookup based on accessor, holder,
698 // name, signature, and bytecode. 681 // name, signature, and bytecode.
699 methodOop ciEnv::lookup_method(instanceKlass* accessor, 682 Method* ciEnv::lookup_method(InstanceKlass* accessor,
700 instanceKlass* holder, 683 InstanceKlass* holder,
701 Symbol* name, 684 Symbol* name,
702 Symbol* sig, 685 Symbol* sig,
703 Bytecodes::Code bc) { 686 Bytecodes::Code bc) {
704 EXCEPTION_CONTEXT; 687 EXCEPTION_CONTEXT;
705 KlassHandle h_accessor(THREAD, accessor); 688 KlassHandle h_accessor(THREAD, accessor);
736 // ciEnv::get_method_by_index_impl 719 // ciEnv::get_method_by_index_impl
737 ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool, 720 ciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool,
738 int index, Bytecodes::Code bc, 721 int index, Bytecodes::Code bc,
739 ciInstanceKlass* accessor) { 722 ciInstanceKlass* accessor) {
740 if (bc == Bytecodes::_invokedynamic) { 723 if (bc == Bytecodes::_invokedynamic) {
741 ConstantPoolCacheEntry* secondary_entry = cpool->cache()->secondary_entry_at(index); 724 ConstantPoolCacheEntry* cpce = cpool->invokedynamic_cp_cache_entry_at(index);
742 const bool is_resolved = !secondary_entry->is_f1_null(); 725 bool is_resolved = !cpce->is_f1_null();
743 // FIXME: code generation could allow for null (unlinked) call site 726 // FIXME: code generation could allow for null (unlinked) call site
744 // The call site could be made patchable as follows: 727 // The call site could be made patchable as follows:
745 // Load the appendix argument from the constant pool. 728 // Load the appendix argument from the constant pool.
746 // Test the appendix argument and jump to a known deopt routine if it is null. 729 // Test the appendix argument and jump to a known deopt routine if it is null.
747 // Jump through a patchable call site, which is initially a deopt routine. 730 // Jump through a patchable call site, which is initially a deopt routine.
748 // Patch the call site to the nmethod entry point of the static compiled lambda form. 731 // Patch the call site to the nmethod entry point of the static compiled lambda form.
749 // As with other two-component call sites, both values must be independently verified. 732 // As with other two-component call sites, both values must be independently verified.
750 733
751 if (is_resolved) { 734 if (is_resolved) {
752 // Get the invoker methodOop and the extra argument from the constant pool. 735 // Get the invoker Method* from the constant pool.
753 methodOop adapter = secondary_entry->f2_as_vfinal_method(); 736 // (The appendix argument, if any, will be noted in the method's signature.)
754 return get_object(adapter)->as_method(); 737 Method* adapter = cpce->f1_as_method();
738 return get_method(adapter);
755 } 739 }
756 740
757 // Fake a method that is equivalent to a declared method. 741 // Fake a method that is equivalent to a declared method.
758 ciInstanceKlass* holder = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass(); 742 ciInstanceKlass* holder = get_instance_klass(SystemDictionary::MethodHandle_klass());
759 ciSymbol* name = ciSymbol::invokeBasic_name(); 743 ciSymbol* name = ciSymbol::invokeBasic_name();
760 ciSymbol* signature = get_symbol(cpool->signature_ref_at(index)); 744 ciSymbol* signature = get_symbol(cpool->signature_ref_at(index));
761 return get_unloaded_method(holder, name, signature, accessor); 745 return get_unloaded_method(holder, name, signature, accessor);
762 } else { 746 } else {
763 const int holder_index = cpool->klass_ref_index_at(index); 747 const int holder_index = cpool->klass_ref_index_at(index);
769 Symbol* name_sym = cpool->name_ref_at(index); 753 Symbol* name_sym = cpool->name_ref_at(index);
770 Symbol* sig_sym = cpool->signature_ref_at(index); 754 Symbol* sig_sym = cpool->signature_ref_at(index);
771 755
772 if (cpool->has_preresolution() 756 if (cpool->has_preresolution()
773 || (holder == ciEnv::MethodHandle_klass() && 757 || (holder == ciEnv::MethodHandle_klass() &&
774 MethodHandles::is_signature_polymorphic_name(holder->get_klassOop(), name_sym))) { 758 MethodHandles::is_signature_polymorphic_name(holder->get_Klass(), name_sym))) {
775 // Short-circuit lookups for JSR 292-related call sites. 759 // Short-circuit lookups for JSR 292-related call sites.
776 // That is, do not rely only on name-based lookups, because they may fail 760 // That is, do not rely only on name-based lookups, because they may fail
777 // if the names are not resolvable in the boot class loader (7056328). 761 // if the names are not resolvable in the boot class loader (7056328).
778 switch (bc) { 762 switch (bc) {
779 case Bytecodes::_invokevirtual: 763 case Bytecodes::_invokevirtual:
780 case Bytecodes::_invokeinterface: 764 case Bytecodes::_invokeinterface:
781 case Bytecodes::_invokespecial: 765 case Bytecodes::_invokespecial:
782 case Bytecodes::_invokestatic: 766 case Bytecodes::_invokestatic:
783 { 767 {
784 methodOop m = constantPoolOopDesc::method_at_if_loaded(cpool, index); 768 Method* m = ConstantPool::method_at_if_loaded(cpool, index);
785 if (m != NULL) { 769 if (m != NULL) {
786 return get_object(m)->as_method(); 770 return get_method(m);
787 } 771 }
788 } 772 }
789 break; 773 break;
790 } 774 }
791 } 775 }
792 776
793 if (holder_is_accessible) { // Our declared holder is loaded. 777 if (holder_is_accessible) { // Our declared holder is loaded.
794 instanceKlass* lookup = declared_holder->get_instanceKlass(); 778 InstanceKlass* lookup = declared_holder->get_instanceKlass();
795 methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc); 779 Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
796 if (m != NULL && 780 if (m != NULL &&
797 (bc == Bytecodes::_invokestatic 781 (bc == Bytecodes::_invokestatic
798 ? instanceKlass::cast(m->method_holder())->is_not_initialized() 782 ? InstanceKlass::cast(m->method_holder())->is_not_initialized()
799 : !instanceKlass::cast(m->method_holder())->is_loaded())) { 783 : !InstanceKlass::cast(m->method_holder())->is_loaded())) {
800 m = NULL; 784 m = NULL;
801 } 785 }
802 if (m != NULL) { 786 if (m != NULL) {
803 // We found the method. 787 // We found the method.
804 return get_object(m)->as_method(); 788 return get_method(m);
805 } 789 }
806 } 790 }
807 791
808 // Either the declared holder was not loaded, or the method could 792 // Either the declared holder was not loaded, or the method could
809 // not be found. Create a dummy ciMethod to represent the failed 793 // not be found. Create a dummy ciMethod to represent the failed
883 // First, check non-klass dependencies as we might return early and 867 // First, check non-klass dependencies as we might return early and
884 // not check klass dependencies if the system dictionary 868 // not check klass dependencies if the system dictionary
885 // modification counter hasn't changed (see below). 869 // modification counter hasn't changed (see below).
886 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) { 870 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
887 if (deps.is_klass_type()) continue; // skip klass dependencies 871 if (deps.is_klass_type()) continue; // skip klass dependencies
888 klassOop witness = deps.check_dependency(); 872 Klass* witness = deps.check_dependency();
889 if (witness != NULL) { 873 if (witness != NULL) {
890 record_failure("invalid non-klass dependency"); 874 record_failure("invalid non-klass dependency");
891 return; 875 return;
892 } 876 }
893 } 877 }
904 if (!counter_changed && !verify_deps) return; 888 if (!counter_changed && !verify_deps) return;
905 889
906 int klass_violations = 0; 890 int klass_violations = 0;
907 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) { 891 for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
908 if (!deps.is_klass_type()) continue; // skip non-klass dependencies 892 if (!deps.is_klass_type()) continue; // skip non-klass dependencies
909 klassOop witness = deps.check_dependency(); 893 Klass* witness = deps.check_dependency();
910 if (witness != NULL) { 894 if (witness != NULL) {
911 klass_violations++; 895 klass_violations++;
912 if (!counter_changed) { 896 if (!counter_changed) {
913 // Dependence failed but counter didn't change. Log a message 897 // Dependence failed but counter didn't change. Log a message
914 // describing what failed and allow the assert at the end to 898 // describing what failed and allow the assert at the end to
946 OopMapSet* oop_map_set, 930 OopMapSet* oop_map_set,
947 ExceptionHandlerTable* handler_table, 931 ExceptionHandlerTable* handler_table,
948 ImplicitExceptionTable* inc_table, 932 ImplicitExceptionTable* inc_table,
949 AbstractCompiler* compiler, 933 AbstractCompiler* compiler,
950 int comp_level, 934 int comp_level,
951 bool has_unsafe_access) { 935 bool has_unsafe_access,
936 bool has_wide_vectors) {
952 VM_ENTRY_MARK; 937 VM_ENTRY_MARK;
953 nmethod* nm = NULL; 938 nmethod* nm = NULL;
954 { 939 {
955 // To prevent compile queue updates. 940 // To prevent compile queue updates.
956 MutexLocker locker(MethodCompileQueue_lock, THREAD); 941 MutexLocker locker(MethodCompileQueue_lock, THREAD);
989 974
990 // Check for {class loads, evolution, breakpoints, ...} during compilation 975 // Check for {class loads, evolution, breakpoints, ...} during compilation
991 validate_compile_task_dependencies(target); 976 validate_compile_task_dependencies(target);
992 } 977 }
993 978
994 methodHandle method(THREAD, target->get_methodOop()); 979 methodHandle method(THREAD, target->get_Method());
995 980
996 if (failing()) { 981 if (failing()) {
997 // While not a true deoptimization, it is a preemptive decompile. 982 // While not a true deoptimization, it is a preemptive decompile.
998 methodDataOop mdo = method()->method_data(); 983 MethodData* mdo = method()->method_data();
999 if (mdo != NULL) { 984 if (mdo != NULL) {
1000 mdo->inc_decompile_count(); 985 mdo->inc_decompile_count();
1001 } 986 }
1002 987
1003 // All buffers in the CodeBuffer are allocated in the CodeCache. 988 // All buffers in the CodeBuffer are allocated in the CodeCache.
1041 MutexUnlocker locker(MethodCompileQueue_lock); 1026 MutexUnlocker locker(MethodCompileQueue_lock);
1042 CompileBroker::handle_full_code_cache(); 1027 CompileBroker::handle_full_code_cache();
1043 } 1028 }
1044 } else { 1029 } else {
1045 nm->set_has_unsafe_access(has_unsafe_access); 1030 nm->set_has_unsafe_access(has_unsafe_access);
1031 nm->set_has_wide_vectors(has_wide_vectors);
1046 1032
1047 // Record successful registration. 1033 // Record successful registration.
1048 // (Put nm into the task handle *before* publishing to the Java heap.) 1034 // (Put nm into the task handle *before* publishing to the Java heap.)
1049 if (task() != NULL) task()->set_code(nm); 1035 if (task() != NULL) task()->set_code(nm);
1050 1036
1079 tty->print_cr("Installing osr method (%d) %s @ %d", 1065 tty->print_cr("Installing osr method (%d) %s @ %d",
1080 comp_level, 1066 comp_level,
1081 method_name, 1067 method_name,
1082 entry_bci); 1068 entry_bci);
1083 } 1069 }
1084 instanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); 1070 InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
1085 1071
1086 } 1072 }
1087 } 1073 }
1088 } 1074 }
1089 // JVMTI -- compiled method notification (must be done outside lock) 1075 // JVMTI -- compiled method notification (must be done outside lock)
1150 if (new_compilable > _compilable) { 1136 if (new_compilable > _compilable) {
1151 if (log() != NULL) { 1137 if (log() != NULL) {
1152 if (all_tiers) { 1138 if (all_tiers) {
1153 log()->elem("method_not_compilable"); 1139 log()->elem("method_not_compilable");
1154 } else { 1140 } else {
1155 log()->elem("method_not_compilable_at_tier"); 1141 log()->elem("method_not_compilable_at_tier level='%d'",
1142 current()->task()->comp_level());
1156 } 1143 }
1157 } 1144 }
1158 _compilable = new_compilable; 1145 _compilable = new_compilable;
1159 1146
1160 // Reset failure reason; this one is more important. 1147 // Reset failure reason; this one is more important.