sharkNativeWrapper.cpp revision 1612
2362N/A * Copyright (c) 1999, 2007, 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 0N/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. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A#
include "incls/_precompiled.incl" 0N/A // Create the function // Create and push our stack frame // Create the oopmap. We use the one oopmap for every call site in // the wrapper, which results in the odd mild inefficiency but is a // damn sight easier to code. // Set up the oop_tmp slot if required: // - For static methods we use it to handlize the class argument // for the call, and to protect the same during slow path locks // - For methods returning oops, we use it to protect the return // value across safepoints or slow path unlocking. // Set up the monitor slot, for synchronized methods // Start building the argument list // First argument is the JNIEnv // For static methods, the second argument is the class // The oop_tmp slot is registered in the oopmap, // so we need to clear it. This is one of the // mild inefficiencies I mentioned earlier. // 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