ciUtilities.hpp revision 1879:f95d63e2154a
1234285Sdim/* 2234285Sdim * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 3234285Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4234285Sdim * 5234285Sdim * This code is free software; you can redistribute it and/or modify it 6234285Sdim * under the terms of the GNU General Public License version 2 only, as 7234285Sdim * published by the Free Software Foundation. 8234285Sdim * 9234285Sdim * This code is distributed in the hope that it will be useful, but WITHOUT 10234285Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11234285Sdim * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12234285Sdim * version 2 for more details (a copy is included in the LICENSE file that 13234285Sdim * accompanied this code). 14234285Sdim * 15234285Sdim * You should have received a copy of the GNU General Public License version 16234285Sdim * 2 along with this work; if not, write to the Free Software Foundation, 17234285Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18234285Sdim * 19234285Sdim * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20234285Sdim * or visit www.oracle.com if you need additional information or have any 21234285Sdim * questions. 22234285Sdim * 23234285Sdim */ 24234285Sdim 25234285Sdim#ifndef SHARE_VM_CI_CIUTILITIES_HPP 26234285Sdim#define SHARE_VM_CI_CIUTILITIES_HPP 27234285Sdim 28234285Sdim#include "ci/ciEnv.hpp" 29234285Sdim#include "runtime/interfaceSupport.hpp" 30234285Sdim 31234285Sdim// The following routines and definitions are used internally in the 32234285Sdim// compiler interface. 33234285Sdim 34234285Sdim 35234285Sdim// Add a ci native entry wrapper? 36234285Sdim 37234285Sdim// Bring the compilation thread into the VM state. 38234285Sdim#define VM_ENTRY_MARK \ 39234285Sdim CompilerThread* thread=CompilerThread::current(); \ 40234285Sdim ThreadInVMfromNative __tiv(thread); \ 41234285Sdim ResetNoHandleMark rnhm; \ 42234285Sdim HandleMarkCleaner __hm(thread); \ 43234285Sdim Thread* THREAD = thread; \ 44234285Sdim debug_only(VMNativeEntryWrapper __vew;) 45234285Sdim 46234285Sdim 47234285Sdim 48234285Sdim// Bring the compilation thread into the VM state. No handle mark. 49234285Sdim#define VM_QUICK_ENTRY_MARK \ 50234285Sdim CompilerThread* thread=CompilerThread::current(); \ 51234285Sdim ThreadInVMfromNative __tiv(thread); \ 52234285Sdim/* \ 53234285Sdim * [TODO] The NoHandleMark line does nothing but declare a function prototype \ 54234285Sdim * The NoHandkeMark constructor is NOT executed. If the ()'s are \ 55234285Sdim * removed, causes the NoHandleMark assert to trigger. \ 56234285Sdim * debug_only(NoHandleMark __hm();) \ 57234285Sdim */ \ 58234285Sdim Thread* THREAD = thread; \ 59234285Sdim debug_only(VMNativeEntryWrapper __vew;) 60234285Sdim 61234285Sdim 62234285Sdim#define EXCEPTION_CONTEXT \ 63234285Sdim CompilerThread* thread=CompilerThread::current(); \ 64234285Sdim Thread* THREAD = thread; 65234285Sdim 66234285Sdim 67234285Sdim#define CURRENT_ENV \ 68234285Sdim ciEnv::current() 69234285Sdim 70234285Sdim// where current thread is THREAD 71234285Sdim#define CURRENT_THREAD_ENV \ 72234285Sdim ciEnv::current(thread) 73234285Sdim 74234285Sdim#define IS_IN_VM \ 75234285Sdim ciEnv::is_in_vm() 76234285Sdim 77234285Sdim#define ASSERT_IN_VM \ 78234285Sdim assert(IS_IN_VM, "must be in vm state"); 79234285Sdim 80234285Sdim#define GUARDED_VM_ENTRY(action) \ 81234285Sdim {if (IS_IN_VM) { action } else { VM_ENTRY_MARK; { action }}} 82234285Sdim 83234285Sdim// Redefine this later. 84234285Sdim#define KILL_COMPILE_ON_FATAL_(result) \ 85234285Sdim THREAD); \ 86234285Sdim if (HAS_PENDING_EXCEPTION) { \ 87234285Sdim if (PENDING_EXCEPTION->klass() == \ 88234285Sdim SystemDictionary::ThreadDeath_klass()) { \ 89234285Sdim /* Kill the compilation. */ \ 90234285Sdim fatal("unhandled ci exception"); \ 91234285Sdim return (result); \ 92234285Sdim } \ 93234285Sdim CLEAR_PENDING_EXCEPTION; \ 94234285Sdim return (result); \ 95234285Sdim } \ 96234285Sdim (0 97234285Sdim 98234285Sdim#define KILL_COMPILE_ON_ANY \ 99234285Sdim THREAD); \ 100234285Sdim if (HAS_PENDING_EXCEPTION) { \ 101234285Sdim fatal("unhandled ci exception"); \ 102234285Sdim CLEAR_PENDING_EXCEPTION; \ 103234285Sdim } \ 104234285Sdim(0 105234285Sdim 106234285Sdim 107234285Sdiminline const char* bool_to_str(bool b) { 108234285Sdim return ((b) ? "true" : "false"); 109234285Sdim} 110234285Sdim 111234285Sdimconst char* basictype_to_str(BasicType t); 112234285Sdimconst char basictype_to_char(BasicType t); 113234285Sdim 114234285Sdim#endif // SHARE_VM_CI_CIUTILITIES_HPP 115234285Sdim