aoqi@0: /* aoqi@0: * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_CI_CIUTILITIES_HPP aoqi@0: #define SHARE_VM_CI_CIUTILITIES_HPP aoqi@0: aoqi@0: #include "ci/ciEnv.hpp" aoqi@0: #include "runtime/interfaceSupport.hpp" aoqi@0: aoqi@0: // The following routines and definitions are used internally in the aoqi@0: // compiler interface. aoqi@0: aoqi@0: aoqi@0: // Add a ci native entry wrapper? aoqi@0: aoqi@0: // Bring the compilation thread into the VM state. aoqi@0: #define VM_ENTRY_MARK \ aoqi@0: CompilerThread* thread=CompilerThread::current(); \ aoqi@0: ThreadInVMfromNative __tiv(thread); \ aoqi@0: ResetNoHandleMark rnhm; \ aoqi@0: HandleMarkCleaner __hm(thread); \ aoqi@0: Thread* THREAD = thread; \ aoqi@0: debug_only(VMNativeEntryWrapper __vew;) aoqi@0: aoqi@0: aoqi@0: aoqi@0: // Bring the compilation thread into the VM state. No handle mark. aoqi@0: #define VM_QUICK_ENTRY_MARK \ aoqi@0: CompilerThread* thread=CompilerThread::current(); \ aoqi@0: ThreadInVMfromNative __tiv(thread); \ aoqi@0: /* \ aoqi@0: * [TODO] The NoHandleMark line does nothing but declare a function prototype \ aoqi@0: * The NoHandkeMark constructor is NOT executed. If the ()'s are \ aoqi@0: * removed, causes the NoHandleMark assert to trigger. \ aoqi@0: * debug_only(NoHandleMark __hm();) \ aoqi@0: */ \ aoqi@0: Thread* THREAD = thread; \ aoqi@0: debug_only(VMNativeEntryWrapper __vew;) aoqi@0: aoqi@0: aoqi@0: #define EXCEPTION_CONTEXT \ aoqi@0: CompilerThread* thread=CompilerThread::current(); \ aoqi@0: Thread* THREAD = thread; aoqi@0: aoqi@0: aoqi@0: #define CURRENT_ENV \ aoqi@0: ciEnv::current() aoqi@0: aoqi@0: // where current thread is THREAD aoqi@0: #define CURRENT_THREAD_ENV \ aoqi@0: ciEnv::current(thread) aoqi@0: aoqi@0: #define IS_IN_VM \ aoqi@0: ciEnv::is_in_vm() aoqi@0: aoqi@0: #define ASSERT_IN_VM \ aoqi@0: assert(IS_IN_VM, "must be in vm state"); aoqi@0: aoqi@0: #define GUARDED_VM_ENTRY(action) \ aoqi@0: {if (IS_IN_VM) { action } else { VM_ENTRY_MARK; { action }}} aoqi@0: aoqi@0: #define GUARDED_VM_QUICK_ENTRY(action) \ aoqi@0: {if (IS_IN_VM) { action } else { VM_QUICK_ENTRY_MARK; { action }}} aoqi@0: aoqi@0: // Redefine this later. aoqi@0: #define KILL_COMPILE_ON_FATAL_(result) \ aoqi@0: THREAD); \ aoqi@0: if (HAS_PENDING_EXCEPTION) { \ aoqi@0: if (PENDING_EXCEPTION->klass() == \ aoqi@0: SystemDictionary::ThreadDeath_klass()) { \ aoqi@0: /* Kill the compilation. */ \ aoqi@0: fatal("unhandled ci exception"); \ aoqi@0: return (result); \ aoqi@0: } \ aoqi@0: CLEAR_PENDING_EXCEPTION; \ aoqi@0: return (result); \ aoqi@0: } \ aoqi@0: (void)(0 aoqi@0: aoqi@0: #define KILL_COMPILE_ON_ANY \ aoqi@0: THREAD); \ aoqi@0: if (HAS_PENDING_EXCEPTION) { \ aoqi@0: fatal("unhandled ci exception"); \ aoqi@0: CLEAR_PENDING_EXCEPTION; \ aoqi@0: } \ aoqi@0: (void)(0 aoqi@0: aoqi@0: aoqi@0: inline const char* bool_to_str(bool b) { aoqi@0: return ((b) ? "true" : "false"); aoqi@0: } aoqi@0: aoqi@0: const char* basictype_to_str(BasicType t); aoqi@0: const char basictype_to_char(BasicType t); aoqi@0: aoqi@0: #endif // SHARE_VM_CI_CIUTILITIES_HPP