< prev index next >

src/hotspot/share/prims/nativeEntryPoint.cpp

Print this page

  1 /*
  2  * Copyright (c) 2020, 2025, 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  *

 25 #include "classfile/javaClasses.inline.hpp"
 26 #include "code/codeCache.hpp"
 27 #include "code/vmreg.hpp"
 28 #include "logging/logStream.hpp"
 29 #include "memory/resourceArea.hpp"
 30 #include "oops/oopCast.inline.hpp"
 31 #include "oops/typeArrayOop.inline.hpp"
 32 #include "prims/downcallLinker.hpp"
 33 #include "prims/foreignGlobals.inline.hpp"
 34 #include "runtime/interfaceSupport.inline.hpp"
 35 #include "runtime/jniHandles.inline.hpp"
 36 
 37 JNI_ENTRY(jlong, NEP_makeDowncallStub(JNIEnv* env, jclass _unused, jobject method_type, jobject jabi,
 38                                       jobjectArray arg_moves, jobjectArray ret_moves,
 39                                       jboolean needs_return_buffer, jint captured_state_mask,
 40                                       jboolean needs_transition))
 41   ResourceMark rm;
 42   const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi);
 43 
 44   oop type = JNIHandles::resolve(method_type);
 45   objArrayOop arg_moves_oop = oop_cast<objArrayOop>(JNIHandles::resolve(arg_moves));
 46   objArrayOop ret_moves_oop = oop_cast<objArrayOop>(JNIHandles::resolve(ret_moves));
 47   int pcount = java_lang_invoke_MethodType::ptype_count(type);
 48   int pslots = java_lang_invoke_MethodType::ptype_slot_count(type);
 49   BasicType* basic_type = NEW_RESOURCE_ARRAY(BasicType, pslots);
 50 
 51   GrowableArray<VMStorage> input_regs(pcount);
 52   for (int i = 0, bt_idx = 0; i < pcount; i++) {
 53     oop type_oop = java_lang_invoke_MethodType::ptype(type, i);
 54     BasicType bt = java_lang_Class::as_BasicType(type_oop);
 55     basic_type[bt_idx++] = bt;
 56     oop reg_oop = arg_moves_oop->obj_at(i);
 57     if (reg_oop != nullptr) {
 58       input_regs.push(ForeignGlobals::parse_vmstorage(reg_oop));
 59     }
 60 
 61     if (bt == BasicType::T_DOUBLE || bt == BasicType::T_LONG) {
 62       basic_type[bt_idx++] = T_VOID;
 63       // we only need these in the basic type
 64       // NativeCallingConvention ignores them, but they are needed
 65       // for JavaCallingConvention
 66     }

  1 /*
  2  * Copyright (c) 2020, 2026, 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  *

 25 #include "classfile/javaClasses.inline.hpp"
 26 #include "code/codeCache.hpp"
 27 #include "code/vmreg.hpp"
 28 #include "logging/logStream.hpp"
 29 #include "memory/resourceArea.hpp"
 30 #include "oops/oopCast.inline.hpp"
 31 #include "oops/typeArrayOop.inline.hpp"
 32 #include "prims/downcallLinker.hpp"
 33 #include "prims/foreignGlobals.inline.hpp"
 34 #include "runtime/interfaceSupport.inline.hpp"
 35 #include "runtime/jniHandles.inline.hpp"
 36 
 37 JNI_ENTRY(jlong, NEP_makeDowncallStub(JNIEnv* env, jclass _unused, jobject method_type, jobject jabi,
 38                                       jobjectArray arg_moves, jobjectArray ret_moves,
 39                                       jboolean needs_return_buffer, jint captured_state_mask,
 40                                       jboolean needs_transition))
 41   ResourceMark rm;
 42   const ABIDescriptor abi = ForeignGlobals::parse_abi_descriptor(jabi);
 43 
 44   oop type = JNIHandles::resolve(method_type);
 45   refArrayOop arg_moves_oop = oop_cast<refArrayOop>(JNIHandles::resolve(arg_moves));
 46   refArrayOop ret_moves_oop = oop_cast<refArrayOop>(JNIHandles::resolve(ret_moves));
 47   int pcount = java_lang_invoke_MethodType::ptype_count(type);
 48   int pslots = java_lang_invoke_MethodType::ptype_slot_count(type);
 49   BasicType* basic_type = NEW_RESOURCE_ARRAY(BasicType, pslots);
 50 
 51   GrowableArray<VMStorage> input_regs(pcount);
 52   for (int i = 0, bt_idx = 0; i < pcount; i++) {
 53     oop type_oop = java_lang_invoke_MethodType::ptype(type, i);
 54     BasicType bt = java_lang_Class::as_BasicType(type_oop);
 55     basic_type[bt_idx++] = bt;
 56     oop reg_oop = arg_moves_oop->obj_at(i);
 57     if (reg_oop != nullptr) {
 58       input_regs.push(ForeignGlobals::parse_vmstorage(reg_oop));
 59     }
 60 
 61     if (bt == BasicType::T_DOUBLE || bt == BasicType::T_LONG) {
 62       basic_type[bt_idx++] = T_VOID;
 63       // we only need these in the basic type
 64       // NativeCallingConvention ignores them, but they are needed
 65       // for JavaCallingConvention
 66     }
< prev index next >