sharkNativeWrapper.cpp revision 2223
2362N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * Copyright 2009, 2010 Red Hat, Inc. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 2362N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A // Create the function 0N/A // Get our arguments 0N/A // Create and push our stack frame 0N/A // Create the oopmap. We use the one oopmap for every call site in 0N/A // the wrapper, which results in the odd mild inefficiency but is a 0N/A // damn sight easier to code. 0N/A // Set up the oop_tmp slot if required: 0N/A // - For static methods we use it to handlize the class argument 0N/A // for the call, and to protect the same during slow path locks 0N/A // (if synchronized). 0N/A // - For methods returning oops, we use it to protect the return 0N/A // value across safepoints or slow path unlocking. 0N/A // Set up the monitor slot, for synchronized methods 0N/A // Start building the argument list 0N/A // First argument is the JNIEnv 5255N/A // For static methods, the second argument is the class 0N/A // The oop_tmp slot is registered in the oopmap, 0N/A // so we need to clear it. This is one of the 0N/A // mild inefficiencies I mentioned earlier. 0N/A // Parse the arguments // The oopmap is now complete, and everything is written // into the frame except the PC. // Set up the Java frame anchor // Change the thread state to _thread_in_native // Start the transition back to _thread_in_Java // Make sure new state is visible in the GC thread // Handle safepoint operations, pending suspend requests, // and pending asynchronous exceptions. // Finally we can change the thread state to _thread_in_Java // Clear the frame anchor // If there is a pending exception then we can just unwind and // return. It seems totally wrong that unlocking is skipped here // but apparently the template interpreter does this so we do too. // If the result was an oop then unbox it before // releasing the handle it might be protected by