mgerdin@3619: /* mikael@6198: * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. mgerdin@3619: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. mgerdin@3619: * mgerdin@3619: * This code is free software; you can redistribute it and/or modify it mgerdin@3619: * under the terms of the GNU General Public License version 2 only, as mgerdin@3619: * published by the Free Software Foundation. mgerdin@3619: * mgerdin@3619: * This code is distributed in the hope that it will be useful, but WITHOUT mgerdin@3619: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or mgerdin@3619: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License mgerdin@3619: * version 2 for more details (a copy is included in the LICENSE file that mgerdin@3619: * accompanied this code). mgerdin@3619: * mgerdin@3619: * You should have received a copy of the GNU General Public License version mgerdin@3619: * 2 along with this work; if not, write to the Free Software Foundation, mgerdin@3619: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. mgerdin@3619: * mgerdin@3619: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA mgerdin@3619: * or visit www.oracle.com if you need additional information or have any mgerdin@3619: * questions. mgerdin@3619: * mgerdin@3619: */ mgerdin@3619: mgerdin@3619: #ifndef SHARE_VM_PRIMS_WHITEBOX_HPP mgerdin@3619: #define SHARE_VM_PRIMS_WHITEBOX_HPP mgerdin@3619: nloodin@3681: #include "prims/jni.h" nloodin@3681: nloodin@3681: #include "memory/allocation.hpp" nloodin@3681: #include "oops/oopsHierarchy.hpp" nloodin@3681: nloodin@3681: // Entry macro to transition from JNI to VM state. nloodin@3681: nloodin@3681: #define WB_ENTRY(result_type, header) JNI_ENTRY(result_type, header) nloodin@3681: #define WB_END JNI_END iignatyev@4592: #define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL nloodin@3681: ccheung@6347: #define CHECK_JNI_EXCEPTION_(env, value) \ ccheung@6347: do { \ ccheung@6347: JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \ ccheung@6347: if (HAS_PENDING_EXCEPTION) { \ ccheung@6347: CLEAR_PENDING_EXCEPTION; \ ccheung@6347: return(value); \ ccheung@6347: } \ ccheung@6346: } while (0) ccheung@6346: ccheung@6347: #define CHECK_JNI_EXCEPTION(env) \ ccheung@6347: do { \ ccheung@6347: JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \ ccheung@6347: if (HAS_PENDING_EXCEPTION) { \ ccheung@6347: CLEAR_PENDING_EXCEPTION; \ ccheung@6347: return; \ ccheung@6347: } \ ccheung@6346: } while (0) ccheung@6346: mgerdin@3619: class WhiteBox : public AllStatic { mgerdin@3619: private: mgerdin@3619: static bool _used; mgerdin@3619: public: mgerdin@3619: static bool used() { return _used; } mgerdin@3619: static void set_used() { _used = true; } nloodin@3681: static int offset_for_field(const char* field_name, oop object, nloodin@3681: Symbol* signature_symbol); nloodin@3681: static const char* lookup_jstring(const char* field_name, oop object); nloodin@3681: static bool lookup_bool(const char* field_name, oop object); mgerdin@3619: }; mgerdin@3619: nloodin@3681: nloodin@3681: mgerdin@3619: #endif // SHARE_VM_PRIMS_WHITEBOX_HPP