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