| 1 | /* | 
| 2 |  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. | 
| 3 |  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 
| 4 |  * | 
| 5 |  * This code is free software; you can redistribute it and/or modify it | 
| 6 |  * under the terms of the GNU General Public License version 2 only, as | 
| 7 |  * published by the Free Software Foundation. | 
| 8 |  * | 
| 9 |  * This code is distributed in the hope that it will be useful, but WITHOUT | 
| 10 |  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 
| 11 |  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License | 
| 12 |  * version 2 for more details (a copy is included in the LICENSE file that | 
| 13 |  * accompanied this code). | 
| 14 |  * | 
| 15 |  * You should have received a copy of the GNU General Public License version | 
| 16 |  * 2 along with this work; if not, write to the Free Software Foundation, | 
| 17 |  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | 
| 18 |  * | 
| 19 |  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | 
| 20 |  * or visit www.oracle.com if you need additional information or have any | 
| 21 |  * questions. | 
| 22 |  * | 
| 23 |  */ | 
| 24 |  | 
| 25 | #ifndef SHARE_CI_CIUTILITIES_INLINE_HPP | 
| 26 | #define SHARE_CI_CIUTILITIES_INLINE_HPP | 
| 27 |  | 
| 28 | #include "ci/ciUtilities.hpp" | 
| 29 | #include "runtime/interfaceSupport.inline.hpp" | 
| 30 |  | 
| 31 | // Add a ci native entry wrapper? | 
| 32 |  | 
| 33 | // Bring the compilation thread into the VM state. | 
| 34 | #define VM_ENTRY_MARK                       \ | 
| 35 |   CompilerThread* thread=CompilerThread::current(); \ | 
| 36 |   ThreadInVMfromNative __tiv(thread);       \ | 
| 37 |   ResetNoHandleMark rnhm;                   \ | 
| 38 |   HandleMarkCleaner __hm(thread);           \ | 
| 39 |   Thread* THREAD = thread;                  \ | 
| 40 |   debug_only(VMNativeEntryWrapper __vew;) | 
| 41 |  | 
| 42 |  | 
| 43 |  | 
| 44 | // Bring the compilation thread into the VM state.  No handle mark. | 
| 45 | #define VM_QUICK_ENTRY_MARK                 \ | 
| 46 |   CompilerThread* thread=CompilerThread::current(); \ | 
| 47 |   ThreadInVMfromNative __tiv(thread);       \ | 
| 48 | /*                                          \ | 
| 49 |  * [TODO] The NoHandleMark line does nothing but declare a function prototype \ | 
| 50 |  * The NoHandkeMark constructor is NOT executed. If the ()'s are   \ | 
| 51 |  * removed, causes the NoHandleMark assert to trigger. \ | 
| 52 |  * debug_only(NoHandleMark __hm();)         \ | 
| 53 |  */                                         \ | 
| 54 |   Thread* THREAD = thread;                  \ | 
| 55 |   debug_only(VMNativeEntryWrapper __vew;) | 
| 56 |  | 
| 57 |  | 
| 58 | #define EXCEPTION_CONTEXT \ | 
| 59 |   CompilerThread* thread=CompilerThread::current(); \ | 
| 60 |   Thread* THREAD = thread; | 
| 61 |  | 
| 62 |  | 
| 63 | #define GUARDED_VM_ENTRY(action)            \ | 
| 64 |   {if (IS_IN_VM) { action } else { VM_ENTRY_MARK; { action }}} | 
| 65 |  | 
| 66 | #define GUARDED_VM_QUICK_ENTRY(action)      \ | 
| 67 |   {if (IS_IN_VM) { action } else { VM_QUICK_ENTRY_MARK; { action }}} | 
| 68 |  | 
| 69 | // Redefine this later. | 
| 70 | #define KILL_COMPILE_ON_FATAL_(result)           \ | 
| 71 |   THREAD);                                       \ | 
| 72 |   if (HAS_PENDING_EXCEPTION) {                   \ | 
| 73 |     if (PENDING_EXCEPTION->klass() ==            \ | 
| 74 |         SystemDictionary::ThreadDeath_klass()) { \ | 
| 75 |       /* Kill the compilation. */                \ | 
| 76 |       fatal("unhandled ci exception");           \ | 
| 77 |       return (result);                           \ | 
| 78 |     }                                            \ | 
| 79 |     CLEAR_PENDING_EXCEPTION;                     \ | 
| 80 |     return (result);                             \ | 
| 81 |   }                                              \ | 
| 82 |   (void)(0 | 
| 83 |  | 
| 84 | #define KILL_COMPILE_ON_ANY                      \ | 
| 85 |   THREAD);                                       \ | 
| 86 |   if (HAS_PENDING_EXCEPTION) {                   \ | 
| 87 |     fatal("unhandled ci exception");             \ | 
| 88 |     CLEAR_PENDING_EXCEPTION;                     \ | 
| 89 |   }                                              \ | 
| 90 | (void)(0 | 
| 91 |  | 
| 92 | #endif // SHARE_CI_CIUTILITIES_INLINE_HPP | 
| 93 |  |