ciEnv.cpp revision 2273
0N/A/*
2273N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "ci/ciConstant.hpp"
1879N/A#include "ci/ciEnv.hpp"
1879N/A#include "ci/ciField.hpp"
1879N/A#include "ci/ciInstance.hpp"
1879N/A#include "ci/ciInstanceKlass.hpp"
1879N/A#include "ci/ciInstanceKlassKlass.hpp"
1879N/A#include "ci/ciMethod.hpp"
1879N/A#include "ci/ciNullObject.hpp"
1879N/A#include "ci/ciObjArrayKlassKlass.hpp"
1879N/A#include "ci/ciTypeArrayKlassKlass.hpp"
1879N/A#include "ci/ciUtilities.hpp"
1879N/A#include "classfile/systemDictionary.hpp"
1879N/A#include "classfile/vmSymbols.hpp"
1879N/A#include "code/scopeDesc.hpp"
1879N/A#include "compiler/compileBroker.hpp"
1879N/A#include "compiler/compileLog.hpp"
1879N/A#include "compiler/compilerOracle.hpp"
1879N/A#include "gc_interface/collectedHeap.inline.hpp"
1879N/A#include "interpreter/linkResolver.hpp"
1879N/A#include "memory/allocation.inline.hpp"
1879N/A#include "memory/oopFactory.hpp"
1879N/A#include "memory/universe.inline.hpp"
1879N/A#include "oops/methodDataOop.hpp"
1879N/A#include "oops/objArrayKlass.hpp"
1879N/A#include "oops/oop.inline.hpp"
1879N/A#include "oops/oop.inline2.hpp"
1879N/A#include "prims/jvmtiExport.hpp"
1879N/A#include "runtime/init.hpp"
1879N/A#include "runtime/reflection.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
1879N/A#include "utilities/dtrace.hpp"
1879N/A#ifdef COMPILER1
1879N/A#include "c1/c1_Runtime1.hpp"
1879N/A#endif
1879N/A#ifdef COMPILER2
1879N/A#include "opto/runtime.hpp"
1879N/A#endif
0N/A
0N/A// ciEnv
0N/A//
0N/A// This class is the top level broker for requests from the compiler
0N/A// to the VM.
0N/A
0N/AciObject* ciEnv::_null_object_instance;
0N/AciMethodKlass* ciEnv::_method_klass_instance;
0N/AciKlassKlass* ciEnv::_klass_klass_instance;
0N/AciInstanceKlassKlass* ciEnv::_instance_klass_klass_instance;
0N/AciTypeArrayKlassKlass* ciEnv::_type_array_klass_klass_instance;
0N/AciObjArrayKlassKlass* ciEnv::_obj_array_klass_klass_instance;
0N/A
1142N/A#define WK_KLASS_DEFN(name, ignore_s, ignore_o) ciInstanceKlass* ciEnv::_##name = NULL;
1142N/AWK_KLASSES_DO(WK_KLASS_DEFN)
1142N/A#undef WK_KLASS_DEFN
0N/A
0N/AciSymbol* ciEnv::_unloaded_cisymbol = NULL;
0N/AciInstanceKlass* ciEnv::_unloaded_ciinstance_klass = NULL;
0N/AciObjArrayKlass* ciEnv::_unloaded_ciobjarrayklass = NULL;
0N/A
0N/Ajobject ciEnv::_ArrayIndexOutOfBoundsException_handle = NULL;
0N/Ajobject ciEnv::_ArrayStoreException_handle = NULL;
0N/Ajobject ciEnv::_ClassCastException_handle = NULL;
0N/A
0N/A#ifndef PRODUCT
0N/Astatic bool firstEnv = true;
0N/A#endif /* PRODUCT */
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::ciEnv
0N/AciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) {
0N/A VM_ENTRY_MARK;
0N/A
0N/A // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
0N/A thread->set_env(this);
0N/A assert(ciEnv::current() == this, "sanity");
0N/A
0N/A _oop_recorder = NULL;
0N/A _debug_info = NULL;
0N/A _dependencies = NULL;
0N/A _failure_reason = NULL;
0N/A _compilable = MethodCompilable;
0N/A _break_at_compile = false;
0N/A _compiler_data = NULL;
0N/A#ifndef PRODUCT
0N/A assert(!firstEnv, "not initialized properly");
0N/A#endif /* !PRODUCT */
0N/A
0N/A _system_dictionary_modification_counter = system_dictionary_modification_counter;
0N/A _num_inlined_bytecodes = 0;
0N/A assert(task == NULL || thread->task() == task, "sanity");
0N/A _task = task;
0N/A _log = NULL;
0N/A
0N/A // Temporary buffer for creating symbols and such.
0N/A _name_buffer = NULL;
0N/A _name_buffer_len = 0;
0N/A
0N/A _arena = &_ciEnv_arena;
0N/A _factory = new (_arena) ciObjectFactory(_arena, 128);
0N/A
0N/A // Preload commonly referenced system ciObjects.
0N/A
0N/A // During VM initialization, these instances have not yet been created.
0N/A // Assertions ensure that these instances are not accessed before
0N/A // their initialization.
0N/A
0N/A assert(Universe::is_fully_initialized(), "should be complete");
0N/A
0N/A oop o = Universe::null_ptr_exception_instance();
0N/A assert(o != NULL, "should have been initialized");
0N/A _NullPointerException_instance = get_object(o)->as_instance();
0N/A o = Universe::arithmetic_exception_instance();
0N/A assert(o != NULL, "should have been initialized");
0N/A _ArithmeticException_instance = get_object(o)->as_instance();
0N/A
0N/A _ArrayIndexOutOfBoundsException_instance = NULL;
0N/A _ArrayStoreException_instance = NULL;
0N/A _ClassCastException_instance = NULL;
1080N/A _the_null_string = NULL;
1080N/A _the_min_jint_string = NULL;
0N/A}
0N/A
0N/AciEnv::ciEnv(Arena* arena) {
0N/A ASSERT_IN_VM;
0N/A
0N/A // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc.
0N/A CompilerThread* current_thread = CompilerThread::current();
0N/A assert(current_thread->env() == NULL, "must be");
0N/A current_thread->set_env(this);
0N/A assert(ciEnv::current() == this, "sanity");
0N/A
0N/A _oop_recorder = NULL;
0N/A _debug_info = NULL;
0N/A _dependencies = NULL;
0N/A _failure_reason = NULL;
0N/A _compilable = MethodCompilable_never;
0N/A _break_at_compile = false;
0N/A _compiler_data = NULL;
0N/A#ifndef PRODUCT
0N/A assert(firstEnv, "must be first");
0N/A firstEnv = false;
0N/A#endif /* !PRODUCT */
0N/A
0N/A _system_dictionary_modification_counter = 0;
0N/A _num_inlined_bytecodes = 0;
0N/A _task = NULL;
0N/A _log = NULL;
0N/A
0N/A // Temporary buffer for creating symbols and such.
0N/A _name_buffer = NULL;
0N/A _name_buffer_len = 0;
0N/A
0N/A _arena = arena;
0N/A _factory = new (_arena) ciObjectFactory(_arena, 128);
0N/A
0N/A // Preload commonly referenced system ciObjects.
0N/A
0N/A // During VM initialization, these instances have not yet been created.
0N/A // Assertions ensure that these instances are not accessed before
0N/A // their initialization.
0N/A
0N/A assert(Universe::is_fully_initialized(), "must be");
0N/A
0N/A oop o = Universe::null_ptr_exception_instance();
0N/A assert(o != NULL, "should have been initialized");
0N/A _NullPointerException_instance = get_object(o)->as_instance();
0N/A o = Universe::arithmetic_exception_instance();
0N/A assert(o != NULL, "should have been initialized");
0N/A _ArithmeticException_instance = get_object(o)->as_instance();
0N/A
0N/A _ArrayIndexOutOfBoundsException_instance = NULL;
0N/A _ArrayStoreException_instance = NULL;
0N/A _ClassCastException_instance = NULL;
1080N/A _the_null_string = NULL;
1080N/A _the_min_jint_string = NULL;
0N/A}
0N/A
0N/AciEnv::~ciEnv() {
0N/A CompilerThread* current_thread = CompilerThread::current();
2062N/A _factory->remove_symbols();
0N/A current_thread->set_env(NULL);
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
780N/A// Cache Jvmti state
780N/Avoid ciEnv::cache_jvmti_state() {
780N/A VM_ENTRY_MARK;
780N/A // Get Jvmti capabilities under lock to get consistant values.
780N/A MutexLocker mu(JvmtiThreadState_lock);
780N/A _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint();
780N/A _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables();
1213N/A _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions();
780N/A}
780N/A
780N/A// ------------------------------------------------------------------
780N/A// Cache DTrace flags
780N/Avoid ciEnv::cache_dtrace_flags() {
780N/A // Need lock?
780N/A _dtrace_extended_probes = ExtendedDTraceProbes;
780N/A if (_dtrace_extended_probes) {
780N/A _dtrace_monitor_probes = true;
780N/A _dtrace_method_probes = true;
780N/A _dtrace_alloc_probes = true;
780N/A } else {
780N/A _dtrace_monitor_probes = DTraceMonitorProbes;
780N/A _dtrace_method_probes = DTraceMethodProbes;
780N/A _dtrace_alloc_probes = DTraceAllocProbes;
780N/A }
780N/A}
780N/A
780N/A// ------------------------------------------------------------------
0N/A// helper for lazy exception creation
2062N/AciInstance* ciEnv::get_or_create_exception(jobject& handle, Symbol* name) {
0N/A VM_ENTRY_MARK;
0N/A if (handle == NULL) {
0N/A // Cf. universe.cpp, creation of Universe::_null_ptr_exception_instance.
0N/A klassOop k = SystemDictionary::find(name, Handle(), Handle(), THREAD);
0N/A jobject objh = NULL;
0N/A if (!HAS_PENDING_EXCEPTION && k != NULL) {
0N/A oop obj = instanceKlass::cast(k)->allocate_permanent_instance(THREAD);
0N/A if (!HAS_PENDING_EXCEPTION)
0N/A objh = JNIHandles::make_global(obj);
0N/A }
0N/A if (HAS_PENDING_EXCEPTION) {
0N/A CLEAR_PENDING_EXCEPTION;
0N/A } else {
0N/A handle = objh;
0N/A }
0N/A }
0N/A oop obj = JNIHandles::resolve(handle);
0N/A return obj == NULL? NULL: get_object(obj)->as_instance();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::ArrayIndexOutOfBoundsException_instance, etc.
0N/AciInstance* ciEnv::ArrayIndexOutOfBoundsException_instance() {
0N/A if (_ArrayIndexOutOfBoundsException_instance == NULL) {
0N/A _ArrayIndexOutOfBoundsException_instance
0N/A = get_or_create_exception(_ArrayIndexOutOfBoundsException_handle,
2062N/A vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
0N/A }
0N/A return _ArrayIndexOutOfBoundsException_instance;
0N/A}
0N/AciInstance* ciEnv::ArrayStoreException_instance() {
0N/A if (_ArrayStoreException_instance == NULL) {
0N/A _ArrayStoreException_instance
0N/A = get_or_create_exception(_ArrayStoreException_handle,
2062N/A vmSymbols::java_lang_ArrayStoreException());
0N/A }
0N/A return _ArrayStoreException_instance;
0N/A}
0N/AciInstance* ciEnv::ClassCastException_instance() {
0N/A if (_ClassCastException_instance == NULL) {
0N/A _ClassCastException_instance
0N/A = get_or_create_exception(_ClassCastException_handle,
2062N/A vmSymbols::java_lang_ClassCastException());
0N/A }
0N/A return _ClassCastException_instance;
0N/A}
0N/A
1080N/AciInstance* ciEnv::the_null_string() {
1080N/A if (_the_null_string == NULL) {
1080N/A VM_ENTRY_MARK;
1080N/A _the_null_string = get_object(Universe::the_null_string())->as_instance();
1080N/A }
1080N/A return _the_null_string;
1080N/A}
1080N/A
1080N/AciInstance* ciEnv::the_min_jint_string() {
1080N/A if (_the_min_jint_string == NULL) {
1080N/A VM_ENTRY_MARK;
1080N/A _the_min_jint_string = get_object(Universe::the_min_jint_string())->as_instance();
1080N/A }
1080N/A return _the_min_jint_string;
1080N/A}
1080N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_method_from_handle
0N/AciMethod* ciEnv::get_method_from_handle(jobject method) {
0N/A VM_ENTRY_MARK;
0N/A return get_object(JNIHandles::resolve(method))->as_method();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::make_array
989N/AciArray* ciEnv::make_system_array(GrowableArray<ciObject*>* objects) {
0N/A VM_ENTRY_MARK;
0N/A int length = objects->length();
0N/A objArrayOop a = oopFactory::new_system_objArray(length, THREAD);
0N/A if (HAS_PENDING_EXCEPTION) {
0N/A CLEAR_PENDING_EXCEPTION;
0N/A record_out_of_memory_failure();
0N/A return NULL;
0N/A }
0N/A for (int i = 0; i < length; i++) {
0N/A a->obj_at_put(i, objects->at(i)->get_oop());
0N/A }
0N/A assert(a->is_perm(), "");
0N/A return get_object(a)->as_array();
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::array_element_offset_in_bytes
0N/Aint ciEnv::array_element_offset_in_bytes(ciArray* a_h, ciObject* o_h) {
0N/A VM_ENTRY_MARK;
0N/A objArrayOop a = (objArrayOop)a_h->get_oop();
0N/A assert(a->is_objArray(), "");
0N/A int length = a->length();
0N/A oop o = o_h->get_oop();
0N/A for (int i = 0; i < length; i++) {
0N/A if (a->obj_at(i) == o) return i;
0N/A }
0N/A return -1;
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::check_klass_accessiblity
0N/A//
0N/A// Note: the logic of this method should mirror the logic of
0N/A// constantPoolOopDesc::verify_constant_pool_resolve.
0N/Abool ciEnv::check_klass_accessibility(ciKlass* accessing_klass,
0N/A klassOop resolved_klass) {
0N/A if (accessing_klass == NULL || !accessing_klass->is_loaded()) {
0N/A return true;
0N/A }
0N/A if (accessing_klass->is_obj_array()) {
0N/A accessing_klass = accessing_klass->as_obj_array_klass()->base_element_klass();
0N/A }
0N/A if (!accessing_klass->is_instance_klass()) {
0N/A return true;
0N/A }
0N/A
0N/A if (resolved_klass->klass_part()->oop_is_objArray()) {
0N/A // Find the element klass, if this is an array.
0N/A resolved_klass = objArrayKlass::cast(resolved_klass)->bottom_klass();
0N/A }
0N/A if (resolved_klass->klass_part()->oop_is_instance()) {
0N/A return Reflection::verify_class_access(accessing_klass->get_klassOop(),
0N/A resolved_klass,
0N/A true);
0N/A }
0N/A return true;
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_klass_by_name_impl
0N/AciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass,
0N/A ciSymbol* name,
0N/A bool require_local) {
0N/A ASSERT_IN_VM;
0N/A EXCEPTION_CONTEXT;
0N/A
0N/A // Now we need to check the SystemDictionary
2062N/A Symbol* sym = name->get_symbol();
0N/A if (sym->byte_at(0) == 'L' &&
0N/A sym->byte_at(sym->utf8_length()-1) == ';') {
0N/A // This is a name from a signature. Strip off the trimmings.
2062N/A // Call recursive to keep scope of strippedsym.
2062N/A TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
2062N/A sym->utf8_length()-2,
2062N/A KILL_COMPILE_ON_FATAL_(_unloaded_ciinstance_klass));
2062N/A ciSymbol* strippedname = get_symbol(strippedsym);
2062N/A return get_klass_by_name_impl(accessing_klass, strippedname, require_local);
0N/A }
0N/A
0N/A // Check for prior unloaded klass. The SystemDictionary's answers
0N/A // can vary over time but the compiler needs consistency.
0N/A ciKlass* unloaded_klass = check_get_unloaded_klass(accessing_klass, name);
0N/A if (unloaded_klass != NULL) {
0N/A if (require_local) return NULL;
0N/A return unloaded_klass;
0N/A }
0N/A
0N/A Handle loader(THREAD, (oop)NULL);
0N/A Handle domain(THREAD, (oop)NULL);
0N/A if (accessing_klass != NULL) {
0N/A loader = Handle(THREAD, accessing_klass->loader());
0N/A domain = Handle(THREAD, accessing_klass->protection_domain());
0N/A }
0N/A
0N/A // setup up the proper type to return on OOM
0N/A ciKlass* fail_type;
0N/A if (sym->byte_at(0) == '[') {
0N/A fail_type = _unloaded_ciobjarrayklass;
0N/A } else {
0N/A fail_type = _unloaded_ciinstance_klass;
0N/A }
2032N/A KlassHandle found_klass;
2116N/A {
2135N/A ttyUnlocker ttyul; // release tty lock to avoid ordering problems
2116N/A MutexLocker ml(Compile_lock);
2116N/A klassOop kls;
2116N/A if (!require_local) {
2116N/A kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader,
2116N/A KILL_COMPILE_ON_FATAL_(fail_type));
2116N/A } else {
2116N/A kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain,
2116N/A KILL_COMPILE_ON_FATAL_(fail_type));
2116N/A }
2032N/A found_klass = KlassHandle(THREAD, kls);
0N/A }
0N/A
0N/A // If we fail to find an array klass, look again for its element type.
0N/A // The element type may be available either locally or via constraints.
0N/A // In either case, if we can find the element type in the system dictionary,
0N/A // we must build an array type around it. The CI requires array klasses
0N/A // to be loaded if their element klasses are loaded, except when memory
0N/A // is exhausted.
0N/A if (sym->byte_at(0) == '[' &&
0N/A (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
0N/A // We have an unloaded array.
0N/A // Build it on the fly if the element class exists.
2062N/A TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
2062N/A sym->utf8_length()-1,
2062N/A KILL_COMPILE_ON_FATAL_(fail_type));
2062N/A
0N/A // Get element ciKlass recursively.
0N/A ciKlass* elem_klass =
0N/A get_klass_by_name_impl(accessing_klass,
2062N/A get_symbol(elem_sym),
0N/A require_local);
0N/A if (elem_klass != NULL && elem_klass->is_loaded()) {
0N/A // Now make an array for it
0N/A return ciObjArrayKlass::make_impl(elem_klass);
0N/A }
0N/A }
0N/A
2032N/A if (found_klass() != NULL) {
0N/A // Found it. Build a CI handle.
2032N/A return get_object(found_klass())->as_klass();
0N/A }
0N/A
0N/A if (require_local) return NULL;
0N/A // Not yet loaded into the VM, or not governed by loader constraints.
0N/A // Make a CI representative for it.
0N/A return get_unloaded_klass(accessing_klass, name);
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_klass_by_name
0N/AciKlass* ciEnv::get_klass_by_name(ciKlass* accessing_klass,
0N/A ciSymbol* klass_name,
0N/A bool require_local) {
0N/A GUARDED_VM_ENTRY(return get_klass_by_name_impl(accessing_klass,
0N/A klass_name,
0N/A require_local);)
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_klass_by_index_impl
0N/A//
0N/A// Implementation of get_klass_by_index.
1138N/AciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
0N/A int index,
1138N/A bool& is_accessible,
1138N/A ciInstanceKlass* accessor) {
0N/A EXCEPTION_CONTEXT;
0N/A KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
2062N/A Symbol* klass_name = NULL;
0N/A if (klass.is_null()) {
0N/A // The klass has not been inserted into the constant pool.
0N/A // Try to look it up by name.
0N/A {
0N/A // We have to lock the cpool to keep the oop from being resolved
0N/A // while we are accessing it.
0N/A ObjectLocker ol(cpool, THREAD);
0N/A
0N/A constantTag tag = cpool->tag_at(index);
0N/A if (tag.is_klass()) {
0N/A // The klass has been inserted into the constant pool
0N/A // very recently.
0N/A klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
0N/A } else if (tag.is_symbol()) {
2062N/A klass_name = cpool->symbol_at(index);
0N/A } else {
0N/A assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
2062N/A klass_name = cpool->unresolved_klass_at(index);
0N/A }
0N/A }
0N/A }
0N/A
0N/A if (klass.is_null()) {
0N/A // Not found in constant pool. Use the name to do the lookup.
0N/A ciKlass* k = get_klass_by_name_impl(accessor,
2062N/A get_symbol(klass_name),
0N/A false);
0N/A // Calculate accessibility the hard way.
0N/A if (!k->is_loaded()) {
0N/A is_accessible = false;
0N/A } else if (k->loader() != accessor->loader() &&
0N/A get_klass_by_name_impl(accessor, k->name(), true) == NULL) {
0N/A // Loaded only remotely. Not linked yet.
0N/A is_accessible = false;
0N/A } else {
0N/A // Linked locally, and we must also check public/private, etc.
0N/A is_accessible = check_klass_accessibility(accessor, k->get_klassOop());
0N/A }
0N/A return k;
0N/A }
0N/A
0N/A // Check for prior unloaded klass. The SystemDictionary's answers
0N/A // can vary over time but the compiler needs consistency.
2062N/A ciSymbol* name = get_symbol(klass()->klass_part()->name());
0N/A ciKlass* unloaded_klass = check_get_unloaded_klass(accessor, name);
0N/A if (unloaded_klass != NULL) {
0N/A is_accessible = false;
0N/A return unloaded_klass;
0N/A }
0N/A
0N/A // It is known to be accessible, since it was found in the constant pool.
0N/A is_accessible = true;
0N/A return get_object(klass())->as_klass();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_klass_by_index
0N/A//
0N/A// Get a klass from the constant pool.
1138N/AciKlass* ciEnv::get_klass_by_index(constantPoolHandle cpool,
0N/A int index,
1138N/A bool& is_accessible,
1138N/A ciInstanceKlass* accessor) {
1138N/A GUARDED_VM_ENTRY(return get_klass_by_index_impl(cpool, index, is_accessible, accessor);)
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_constant_by_index_impl
0N/A//
0N/A// Implementation of get_constant_by_index().
1138N/AciConstant ciEnv::get_constant_by_index_impl(constantPoolHandle cpool,
1522N/A int pool_index, int cache_index,
1138N/A ciInstanceKlass* accessor) {
1522N/A bool ignore_will_link;
0N/A EXCEPTION_CONTEXT;
1522N/A int index = pool_index;
1522N/A if (cache_index >= 0) {
1522N/A assert(index < 0, "only one kind of index at a time");
1522N/A ConstantPoolCacheEntry* cpc_entry = cpool->cache()->entry_at(cache_index);
1522N/A index = cpc_entry->constant_pool_index();
1522N/A oop obj = cpc_entry->f1();
1522N/A if (obj != NULL) {
1522N/A assert(obj->is_instance(), "must be an instance");
1522N/A ciObject* ciobj = get_object(obj);
1522N/A return ciConstant(T_OBJECT, ciobj);
1522N/A }
1522N/A }
0N/A constantTag tag = cpool->tag_at(index);
0N/A if (tag.is_int()) {
0N/A return ciConstant(T_INT, (jint)cpool->int_at(index));
0N/A } else if (tag.is_long()) {
0N/A return ciConstant((jlong)cpool->long_at(index));
0N/A } else if (tag.is_float()) {
0N/A return ciConstant((jfloat)cpool->float_at(index));
0N/A } else if (tag.is_double()) {
0N/A return ciConstant((jdouble)cpool->double_at(index));
0N/A } else if (tag.is_string() || tag.is_unresolved_string()) {
431N/A oop string = NULL;
431N/A if (cpool->is_pseudo_string_at(index)) {
431N/A string = cpool->pseudo_string_at(index);
431N/A } else {
431N/A string = cpool->string_at(index, THREAD);
431N/A if (HAS_PENDING_EXCEPTION) {
431N/A CLEAR_PENDING_EXCEPTION;
431N/A record_out_of_memory_failure();
431N/A return ciConstant();
431N/A }
0N/A }
0N/A ciObject* constant = get_object(string);
0N/A assert (constant->is_instance(), "must be an instance, or not? ");
0N/A return ciConstant(T_OBJECT, constant);
0N/A } else if (tag.is_klass() || tag.is_unresolved_klass()) {
0N/A // 4881222: allow ldc to take a class type
1522N/A ciKlass* klass = get_klass_by_index_impl(cpool, index, ignore_will_link, accessor);
0N/A if (HAS_PENDING_EXCEPTION) {
0N/A CLEAR_PENDING_EXCEPTION;
0N/A record_out_of_memory_failure();
0N/A return ciConstant();
0N/A }
0N/A assert (klass->is_instance_klass() || klass->is_array_klass(),
0N/A "must be an instance or array klass ");
1522N/A return ciConstant(T_OBJECT, klass->java_mirror());
1138N/A } else if (tag.is_object()) {
1138N/A oop obj = cpool->object_at(index);
1138N/A assert(obj->is_instance(), "must be an instance");
1138N/A ciObject* ciobj = get_object(obj);
1138N/A return ciConstant(T_OBJECT, ciobj);
1522N/A } else if (tag.is_method_type()) {
1522N/A // must execute Java code to link this CP entry into cache[i].f1
2062N/A ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index));
1522N/A ciObject* ciobj = get_unloaded_method_type_constant(signature);
1522N/A return ciConstant(T_OBJECT, ciobj);
1522N/A } else if (tag.is_method_handle()) {
1522N/A // must execute Java code to link this CP entry into cache[i].f1
1522N/A int ref_kind = cpool->method_handle_ref_kind_at(index);
1522N/A int callee_index = cpool->method_handle_klass_index_at(index);
1522N/A ciKlass* callee = get_klass_by_index_impl(cpool, callee_index, ignore_will_link, accessor);
2062N/A ciSymbol* name = get_symbol(cpool->method_handle_name_ref_at(index));
2062N/A ciSymbol* signature = get_symbol(cpool->method_handle_signature_ref_at(index));
1522N/A ciObject* ciobj = get_unloaded_method_handle_constant(callee, name, signature, ref_kind);
1522N/A return ciConstant(T_OBJECT, ciobj);
0N/A } else {
0N/A ShouldNotReachHere();
0N/A return ciConstant();
0N/A }
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_constant_by_index
0N/A//
0N/A// Pull a constant out of the constant pool. How appropriate.
0N/A//
0N/A// Implementation note: this query is currently in no way cached.
1138N/AciConstant ciEnv::get_constant_by_index(constantPoolHandle cpool,
1522N/A int pool_index, int cache_index,
1138N/A ciInstanceKlass* accessor) {
1522N/A GUARDED_VM_ENTRY(return get_constant_by_index_impl(cpool, pool_index, cache_index, accessor);)
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_field_by_index_impl
0N/A//
0N/A// Implementation of get_field_by_index.
0N/A//
0N/A// Implementation note: the results of field lookups are cached
0N/A// in the accessor klass.
0N/AciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor,
0N/A int index) {
0N/A ciConstantPoolCache* cache = accessor->field_cache();
0N/A if (cache == NULL) {
0N/A ciField* field = new (arena()) ciField(accessor, index);
0N/A return field;
0N/A } else {
0N/A ciField* field = (ciField*)cache->get(index);
0N/A if (field == NULL) {
0N/A field = new (arena()) ciField(accessor, index);
0N/A cache->insert(index, field);
0N/A }
0N/A return field;
0N/A }
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_field_by_index
0N/A//
0N/A// Get a field by index from a klass's constant pool.
0N/AciField* ciEnv::get_field_by_index(ciInstanceKlass* accessor,
0N/A int index) {
0N/A GUARDED_VM_ENTRY(return get_field_by_index_impl(accessor, index);)
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::lookup_method
0N/A//
0N/A// Perform an appropriate method lookup based on accessor, holder,
0N/A// name, signature, and bytecode.
0N/AmethodOop ciEnv::lookup_method(instanceKlass* accessor,
0N/A instanceKlass* holder,
2062N/A Symbol* name,
2062N/A Symbol* sig,
0N/A Bytecodes::Code bc) {
0N/A EXCEPTION_CONTEXT;
0N/A KlassHandle h_accessor(THREAD, accessor);
0N/A KlassHandle h_holder(THREAD, holder);
0N/A LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
0N/A methodHandle dest_method;
0N/A switch (bc) {
0N/A case Bytecodes::_invokestatic:
0N/A dest_method =
2062N/A LinkResolver::resolve_static_call_or_null(h_holder, name, sig, h_accessor);
0N/A break;
0N/A case Bytecodes::_invokespecial:
0N/A dest_method =
2062N/A LinkResolver::resolve_special_call_or_null(h_holder, name, sig, h_accessor);
0N/A break;
0N/A case Bytecodes::_invokeinterface:
0N/A dest_method =
2062N/A LinkResolver::linktime_resolve_interface_method_or_null(h_holder, name, sig,
0N/A h_accessor, true);
0N/A break;
0N/A case Bytecodes::_invokevirtual:
0N/A dest_method =
2062N/A LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, name, sig,
0N/A h_accessor, true);
0N/A break;
0N/A default: ShouldNotReachHere();
0N/A }
0N/A
0N/A return dest_method();
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_method_by_index_impl
1138N/AciMethod* ciEnv::get_method_by_index_impl(constantPoolHandle cpool,
1138N/A int index, Bytecodes::Code bc,
1138N/A ciInstanceKlass* accessor) {
0N/A int holder_index = cpool->klass_ref_index_at(index);
0N/A bool holder_is_accessible;
1138N/A ciKlass* holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
0N/A ciInstanceKlass* declared_holder = get_instance_klass_for_declared_method_holder(holder);
0N/A
0N/A // Get the method's name and signature.
2062N/A Symbol* name_sym = cpool->name_ref_at(index);
2062N/A Symbol* sig_sym = cpool->signature_ref_at(index);
0N/A
0N/A if (holder_is_accessible) { // Our declared holder is loaded.
0N/A instanceKlass* lookup = declared_holder->get_instanceKlass();
0N/A methodOop m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
0N/A if (m != NULL) {
0N/A // We found the method.
0N/A return get_object(m)->as_method();
0N/A }
0N/A }
0N/A
0N/A // Either the declared holder was not loaded, or the method could
0N/A // not be found. Create a dummy ciMethod to represent the failed
0N/A // lookup.
0N/A
0N/A return get_unloaded_method(declared_holder,
2062N/A get_symbol(name_sym),
2062N/A get_symbol(sig_sym));
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
1137N/A// ciEnv::get_fake_invokedynamic_method_impl
1138N/AciMethod* ciEnv::get_fake_invokedynamic_method_impl(constantPoolHandle cpool,
1137N/A int index, Bytecodes::Code bc) {
1427N/A // Compare the following logic with InterpreterRuntime::resolve_invokedynamic.
1137N/A assert(bc == Bytecodes::_invokedynamic, "must be invokedynamic");
1137N/A
1427N/A bool is_resolved = cpool->cache()->main_entry_at(index)->is_resolved(bc);
1427N/A if (is_resolved && (oop) cpool->cache()->secondary_entry_at(index)->f1() == NULL)
1427N/A // FIXME: code generation could allow for null (unlinked) call site
1427N/A is_resolved = false;
1137N/A
1427N/A // Call site might not be resolved yet. We could create a real invoker method from the
1427N/A // compiler, but it is simpler to stop the code path here with an unlinked method.
1427N/A if (!is_resolved) {
1137N/A ciInstanceKlass* mh_klass = get_object(SystemDictionary::MethodHandle_klass())->as_instance_klass();
2062N/A ciSymbol* sig_sym = get_symbol(cpool->signature_ref_at(index));
1427N/A return get_unloaded_method(mh_klass, ciSymbol::invokeExact_name(), sig_sym);
1137N/A }
1137N/A
1427N/A // Get the invoker methodOop from the constant pool.
1582N/A oop f1_value = cpool->cache()->main_entry_at(index)->f1();
1582N/A methodOop signature_invoker = methodOop(f1_value);
1427N/A assert(signature_invoker != NULL && signature_invoker->is_method() && signature_invoker->is_method_handle_invoke(),
1427N/A "correct result from LinkResolver::resolve_invokedynamic");
1137N/A
1427N/A return get_object(signature_invoker)->as_method();
1137N/A}
1137N/A
1137N/A
1137N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_instance_klass_for_declared_method_holder
0N/AciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* method_holder) {
0N/A // For the case of <array>.clone(), the method holder can be a ciArrayKlass
0N/A // instead of a ciInstanceKlass. For that case simply pretend that the
0N/A // declared holder is Object.clone since that's where the call will bottom out.
0N/A // A more correct fix would trickle out through many interfaces in CI,
0N/A // requiring ciInstanceKlass* to become ciKlass* and many more places would
0N/A // require checks to make sure the expected type was found. Given that this
0N/A // only occurs for clone() the more extensive fix seems like overkill so
0N/A // instead we simply smear the array type into Object.
0N/A if (method_holder->is_instance_klass()) {
0N/A return method_holder->as_instance_klass();
0N/A } else if (method_holder->is_array_klass()) {
0N/A return current()->Object_klass();
0N/A } else {
0N/A ShouldNotReachHere();
0N/A }
0N/A return NULL;
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::get_method_by_index
1138N/AciMethod* ciEnv::get_method_by_index(constantPoolHandle cpool,
1138N/A int index, Bytecodes::Code bc,
1138N/A ciInstanceKlass* accessor) {
1137N/A if (bc == Bytecodes::_invokedynamic) {
1138N/A GUARDED_VM_ENTRY(return get_fake_invokedynamic_method_impl(cpool, index, bc);)
1137N/A } else {
1138N/A GUARDED_VM_ENTRY(return get_method_by_index_impl(cpool, index, bc, accessor);)
1137N/A }
0N/A}
0N/A
1137N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::name_buffer
0N/Achar *ciEnv::name_buffer(int req_len) {
0N/A if (_name_buffer_len < req_len) {
0N/A if (_name_buffer == NULL) {
0N/A _name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
0N/A _name_buffer_len = req_len;
0N/A } else {
0N/A _name_buffer =
0N/A (char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
0N/A _name_buffer_len = req_len;
0N/A }
0N/A }
0N/A return _name_buffer;
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::is_in_vm
0N/Abool ciEnv::is_in_vm() {
0N/A return JavaThread::current()->thread_state() == _thread_in_vm;
0N/A}
0N/A
0N/Abool ciEnv::system_dictionary_modification_counter_changed() {
0N/A return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::check_for_system_dictionary_modification
0N/A// Check for changes to the system dictionary during compilation
0N/A// class loads, evolution, breakpoints
0N/Avoid ciEnv::check_for_system_dictionary_modification(ciMethod* target) {
0N/A if (failing()) return; // no need for further checks
0N/A
0N/A // Dependencies must be checked when the system dictionary changes.
0N/A // If logging is enabled all violated dependences will be recorded in
0N/A // the log. In debug mode check dependencies even if the system
0N/A // dictionary hasn't changed to verify that no invalid dependencies
0N/A // were inserted. Any violated dependences in this case are dumped to
0N/A // the tty.
0N/A
0N/A bool counter_changed = system_dictionary_modification_counter_changed();
0N/A bool test_deps = counter_changed;
0N/A DEBUG_ONLY(test_deps = true);
0N/A if (!test_deps) return;
0N/A
0N/A bool print_failures = false;
0N/A DEBUG_ONLY(print_failures = !counter_changed);
0N/A
0N/A bool keep_going = (print_failures || xtty != NULL);
0N/A
0N/A int violated = 0;
0N/A
0N/A for (Dependencies::DepStream deps(dependencies()); deps.next(); ) {
0N/A klassOop witness = deps.check_dependency();
0N/A if (witness != NULL) {
0N/A ++violated;
0N/A if (print_failures) deps.print_dependency(witness, /*verbose=*/ true);
0N/A // If there's no log and we're not sanity-checking, we're done.
0N/A if (!keep_going) break;
0N/A }
0N/A }
0N/A
0N/A if (violated != 0) {
0N/A assert(counter_changed, "failed dependencies, but counter didn't change");
0N/A record_failure("concurrent class loading");
0N/A }
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::register_method
0N/Avoid ciEnv::register_method(ciMethod* target,
0N/A int entry_bci,
0N/A CodeOffsets* offsets,
0N/A int orig_pc_offset,
0N/A CodeBuffer* code_buffer,
0N/A int frame_words,
0N/A OopMapSet* oop_map_set,
0N/A ExceptionHandlerTable* handler_table,
0N/A ImplicitExceptionTable* inc_table,
0N/A AbstractCompiler* compiler,
0N/A int comp_level,
0N/A bool has_debug_info,
0N/A bool has_unsafe_access) {
0N/A VM_ENTRY_MARK;
0N/A nmethod* nm = NULL;
0N/A {
0N/A // To prevent compile queue updates.
0N/A MutexLocker locker(MethodCompileQueue_lock, THREAD);
0N/A
0N/A // Prevent SystemDictionary::add_to_hierarchy from running
0N/A // and invalidating our dependencies until we install this method.
0N/A MutexLocker ml(Compile_lock);
0N/A
780N/A // Change in Jvmti state may invalidate compilation.
780N/A if (!failing() &&
780N/A ( (!jvmti_can_hotswap_or_post_breakpoint() &&
780N/A JvmtiExport::can_hotswap_or_post_breakpoint()) ||
780N/A (!jvmti_can_access_local_variables() &&
780N/A JvmtiExport::can_access_local_variables()) ||
1213N/A (!jvmti_can_post_on_exceptions() &&
1213N/A JvmtiExport::can_post_on_exceptions()) )) {
780N/A record_failure("Jvmti state change invalidated dependencies");
0N/A }
0N/A
780N/A // Change in DTrace flags may invalidate compilation.
780N/A if (!failing() &&
780N/A ( (!dtrace_extended_probes() && ExtendedDTraceProbes) ||
780N/A (!dtrace_method_probes() && DTraceMethodProbes) ||
780N/A (!dtrace_alloc_probes() && DTraceAllocProbes) )) {
780N/A record_failure("DTrace flags change invalidated dependencies");
780N/A }
0N/A
780N/A if (!failing()) {
780N/A if (log() != NULL) {
780N/A // Log the dependencies which this compilation declares.
780N/A dependencies()->log_all_dependencies();
780N/A }
780N/A
780N/A // Encode the dependencies now, so we can check them right away.
780N/A dependencies()->encode_content_bytes();
780N/A
780N/A // Check for {class loads, evolution, breakpoints} during compilation
780N/A check_for_system_dictionary_modification(target);
780N/A }
0N/A
0N/A methodHandle method(THREAD, target->get_methodOop());
0N/A
0N/A if (failing()) {
0N/A // While not a true deoptimization, it is a preemptive decompile.
0N/A methodDataOop mdo = method()->method_data();
0N/A if (mdo != NULL) {
0N/A mdo->inc_decompile_count();
0N/A }
0N/A
0N/A // All buffers in the CodeBuffer are allocated in the CodeCache.
0N/A // If the code buffer is created on each compile attempt
0N/A // as in C2, then it must be freed.
0N/A code_buffer->free_blob();
0N/A return;
0N/A }
0N/A
0N/A assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
0N/A assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
0N/A
0N/A nm = nmethod::new_nmethod(method,
0N/A compile_id(),
0N/A entry_bci,
0N/A offsets,
0N/A orig_pc_offset,
0N/A debug_info(), dependencies(), code_buffer,
0N/A frame_words, oop_map_set,
0N/A handler_table, inc_table,
0N/A compiler, comp_level);
0N/A
0N/A // Free codeBlobs
0N/A code_buffer->free_blob();
0N/A
0N/A // stress test 6243940 by immediately making the method
0N/A // non-entrant behind the system's back. This has serious
0N/A // side effects on the code cache and is not meant for
0N/A // general stress testing
0N/A if (nm != NULL && StressNonEntrant) {
0N/A MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
0N/A NativeJump::patch_verified_entry(nm->entry_point(), nm->verified_entry_point(),
0N/A SharedRuntime::get_handle_wrong_method_stub());
0N/A }
0N/A
0N/A if (nm == NULL) {
0N/A // The CodeCache is full. Print out warning and disable compilation.
0N/A record_failure("code cache is full");
1202N/A {
1202N/A MutexUnlocker ml(Compile_lock);
1202N/A MutexUnlocker locker(MethodCompileQueue_lock);
1202N/A CompileBroker::handle_full_code_cache();
0N/A }
0N/A } else {
0N/A NOT_PRODUCT(nm->set_has_debug_info(has_debug_info); )
0N/A nm->set_has_unsafe_access(has_unsafe_access);
0N/A
0N/A // Record successful registration.
0N/A // (Put nm into the task handle *before* publishing to the Java heap.)
0N/A if (task() != NULL) task()->set_code(nm);
0N/A
0N/A if (entry_bci == InvocationEntryBci) {
1703N/A if (TieredCompilation) {
1703N/A // If there is an old version we're done with it
1703N/A nmethod* old = method->code();
1703N/A if (TraceMethodReplacement && old != NULL) {
1703N/A ResourceMark rm;
1703N/A char *method_name = method->name_and_sig_as_C_string();
1703N/A tty->print_cr("Replacing method %s", method_name);
1703N/A }
1703N/A if (old != NULL ) {
1703N/A old->make_not_entrant();
1703N/A }
0N/A }
0N/A if (TraceNMethodInstalls ) {
0N/A ResourceMark rm;
0N/A char *method_name = method->name_and_sig_as_C_string();
0N/A ttyLocker ttyl;
0N/A tty->print_cr("Installing method (%d) %s ",
0N/A comp_level,
0N/A method_name);
0N/A }
0N/A // Allow the code to be executed
0N/A method->set_code(method, nm);
0N/A } else {
0N/A if (TraceNMethodInstalls ) {
0N/A ResourceMark rm;
0N/A char *method_name = method->name_and_sig_as_C_string();
0N/A ttyLocker ttyl;
0N/A tty->print_cr("Installing osr method (%d) %s @ %d",
0N/A comp_level,
0N/A method_name,
0N/A entry_bci);
0N/A }
0N/A instanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
0N/A
0N/A }
0N/A }
0N/A }
0N/A // JVMTI -- compiled method notification (must be done outside lock)
0N/A if (nm != NULL) {
0N/A nm->post_compiled_method_load_event();
0N/A }
0N/A
0N/A}
0N/A
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::find_system_klass
0N/AciKlass* ciEnv::find_system_klass(ciSymbol* klass_name) {
0N/A VM_ENTRY_MARK;
0N/A return get_klass_by_name_impl(NULL, klass_name, false);
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::comp_level
0N/Aint ciEnv::comp_level() {
1703N/A if (task() == NULL) return CompLevel_highest_tier;
0N/A return task()->comp_level();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::compile_id
0N/Auint ciEnv::compile_id() {
0N/A if (task() == NULL) return 0;
0N/A return task()->compile_id();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::notice_inlined_method()
0N/Avoid ciEnv::notice_inlined_method(ciMethod* method) {
0N/A _num_inlined_bytecodes += method->code_size();
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::num_inlined_bytecodes()
0N/Aint ciEnv::num_inlined_bytecodes() const {
0N/A return _num_inlined_bytecodes;
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::record_failure()
0N/Avoid ciEnv::record_failure(const char* reason) {
0N/A if (log() != NULL) {
0N/A log()->elem("failure reason='%s'", reason);
0N/A }
0N/A if (_failure_reason == NULL) {
0N/A // Record the first failure reason.
0N/A _failure_reason = reason;
0N/A }
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::record_method_not_compilable()
0N/Avoid ciEnv::record_method_not_compilable(const char* reason, bool all_tiers) {
0N/A int new_compilable =
0N/A all_tiers ? MethodCompilable_never : MethodCompilable_not_at_tier ;
0N/A
0N/A // Only note transitions to a worse state
0N/A if (new_compilable > _compilable) {
0N/A if (log() != NULL) {
0N/A if (all_tiers) {
0N/A log()->elem("method_not_compilable");
0N/A } else {
0N/A log()->elem("method_not_compilable_at_tier");
0N/A }
0N/A }
0N/A _compilable = new_compilable;
0N/A
0N/A // Reset failure reason; this one is more important.
0N/A _failure_reason = NULL;
0N/A record_failure(reason);
0N/A }
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// ciEnv::record_out_of_memory_failure()
0N/Avoid ciEnv::record_out_of_memory_failure() {
0N/A // If memory is low, we stop compiling methods.
0N/A record_method_not_compilable("out of memory");
0N/A}