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 #include "incls/_precompiled.incl" 26 #include "incls/_javaCalls.cpp.incl" 27 28 // ----------------------------------------------------- 29 // Implementation of JavaCallWrapper 30 31 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) { 32 JavaThread* thread = (JavaThread *)THREAD; 33 bool clear_pending_exception = true; 34 35 guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code"); 36 assert(!thread->owns_locks(), "must release all locks when leaving VM"); 37 guarantee(!thread->is_Compiler_thread(), "cannot make java calls from the compiler"); 38 _result = result; 39 40 // Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub, 41 // since it can potentially block. 42 JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread); 43 44 // After this, we are official in JavaCode. This needs to be done before we change any of the thread local 45 // info, since we cannot find oops before the new information is set up completely. 46 ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_Java); | 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 #include "precompiled.hpp" 26 #include "classfile/systemDictionary.hpp" 27 #include "classfile/vmSymbols.hpp" 28 #include "code/nmethod.hpp" 29 #include "compiler/compileBroker.hpp" 30 #include "interpreter/interpreter.hpp" 31 #include "interpreter/linkResolver.hpp" 32 #include "memory/universe.inline.hpp" 33 #include "oops/oop.inline.hpp" 34 #include "prims/jniCheck.hpp" 35 #include "runtime/compilationPolicy.hpp" 36 #include "runtime/handles.inline.hpp" 37 #include "runtime/interfaceSupport.hpp" 38 #include "runtime/javaCalls.hpp" 39 #include "runtime/mutexLocker.hpp" 40 #include "runtime/signature.hpp" 41 #include "runtime/stubRoutines.hpp" 42 #ifdef TARGET_OS_FAMILY_linux 43 # include "thread_linux.inline.hpp" 44 #endif 45 #ifdef TARGET_OS_FAMILY_solaris 46 # include "thread_solaris.inline.hpp" 47 #endif 48 #ifdef TARGET_OS_FAMILY_windows 49 # include "thread_windows.inline.hpp" 50 #endif 51 52 // ----------------------------------------------------- 53 // Implementation of JavaCallWrapper 54 55 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) { 56 JavaThread* thread = (JavaThread *)THREAD; 57 bool clear_pending_exception = true; 58 59 guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code"); 60 assert(!thread->owns_locks(), "must release all locks when leaving VM"); 61 guarantee(!thread->is_Compiler_thread(), "cannot make java calls from the compiler"); 62 _result = result; 63 64 // Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub, 65 // since it can potentially block. 66 JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread); 67 68 // After this, we are official in JavaCode. This needs to be done before we change any of the thread local 69 // info, since we cannot find oops before the new information is set up completely. 70 ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_Java); |