Path: blob/master/src/hotspot/share/ci/ciNativeEntryPoint.cpp
40931 views
/*1* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "ci/ciClassList.hpp"26#include "ci/ciNativeEntryPoint.hpp"27#include "ci/ciUtilities.inline.hpp"28#include "ci/ciArray.hpp"29#include "classfile/javaClasses.hpp"30#include "oops/oop.inline.hpp"31#include "memory/allocation.hpp"3233VMReg* getVMRegArray(ciArray* array) {34assert(array->element_basic_type() == T_LONG, "Unexpected type");3536VMReg* out = NEW_ARENA_ARRAY(CURRENT_ENV->arena(), VMReg, array->length());3738for (int i = 0; i < array->length(); i++) {39ciConstant con = array->element_value(i);40VMReg reg = VMRegImpl::as_VMReg(con.as_long());41out[i] = reg;42}4344return out;45}4647ciNativeEntryPoint::ciNativeEntryPoint(instanceHandle h_i) : ciInstance(h_i), _name(NULL) {48// Copy name49oop name_str = jdk_internal_invoke_NativeEntryPoint::name(get_oop());50if (name_str != NULL) {51char* temp_name = java_lang_String::as_quoted_ascii(name_str);52size_t len = strlen(temp_name) + 1;53char* name = (char*)CURRENT_ENV->arena()->Amalloc(len);54strncpy(name, temp_name, len);55_name = name;56}5758_arg_moves = getVMRegArray(CURRENT_ENV->get_object(jdk_internal_invoke_NativeEntryPoint::argMoves(get_oop()))->as_array());59_ret_moves = getVMRegArray(CURRENT_ENV->get_object(jdk_internal_invoke_NativeEntryPoint::returnMoves(get_oop()))->as_array());60}6162jint ciNativeEntryPoint::shadow_space() const {63VM_ENTRY_MARK;64return jdk_internal_invoke_NativeEntryPoint::shadow_space(get_oop());65}6667VMReg* ciNativeEntryPoint::argMoves() const {68return _arg_moves;69}7071VMReg* ciNativeEntryPoint::returnMoves() const {72return _ret_moves;73}7475jboolean ciNativeEntryPoint::need_transition() const {76VM_ENTRY_MARK;77return jdk_internal_invoke_NativeEntryPoint::need_transition(get_oop());78}7980ciMethodType* ciNativeEntryPoint::method_type() const {81VM_ENTRY_MARK;82return CURRENT_ENV->get_object(jdk_internal_invoke_NativeEntryPoint::method_type(get_oop()))->as_method_type();83}8485const char* ciNativeEntryPoint::name() {86return _name;87}888990