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