|
| 1 | +/* |
| 2 | + * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * Copyright (c) 2019, Arm Limited. All rights reserved. |
| 4 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 5 | + * |
| 6 | + * This code is free software; you can redistribute it and/or modify it |
| 7 | + * under the terms of the GNU General Public License version 2 only, as |
| 8 | + * published by the Free Software Foundation. |
| 9 | + * |
| 10 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 11 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 14 | + * accompanied this code). |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License version |
| 17 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 18 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | + * |
| 20 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 21 | + * or visit www.oracle.com if you need additional information or have any |
| 22 | + * questions. |
| 23 | + */ |
| 24 | + |
| 25 | +#include "precompiled.hpp" |
| 26 | +#include "runtime/jniHandles.hpp" |
| 27 | +#include "runtime/jniHandles.inline.hpp" |
| 28 | +#include "oops/typeArrayOop.inline.hpp" |
| 29 | +#include "prims/foreign_globals.hpp" |
| 30 | +#include "prims/foreign_globals.inline.hpp" |
| 31 | + |
| 32 | +bool ABIDescriptor::is_volatile_reg(Register reg) const { |
| 33 | + return _integer_argument_registers.contains(reg) |
| 34 | + || _integer_additional_volatile_registers.contains(reg); |
| 35 | +} |
| 36 | + |
| 37 | +bool ABIDescriptor::is_volatile_reg(FloatRegister reg) const { |
| 38 | + return _vector_argument_registers.contains(reg) |
| 39 | + || _vector_additional_volatile_registers.contains(reg); |
| 40 | +} |
| 41 | + |
| 42 | +#define INTEGER_TYPE 0 |
| 43 | +#define VECTOR_TYPE 1 |
| 44 | + |
| 45 | +const ABIDescriptor ForeignGlobals::parse_abi_descriptor_impl(jobject jabi) const { |
| 46 | + oop abi_oop = JNIHandles::resolve_non_null(jabi); |
| 47 | + ABIDescriptor abi; |
| 48 | + |
| 49 | + objArrayOop inputStorage = cast<objArrayOop>(abi_oop->obj_field(ABI.inputStorage_offset)); |
| 50 | + loadArray(inputStorage, INTEGER_TYPE, abi._integer_argument_registers, as_Register); |
| 51 | + loadArray(inputStorage, VECTOR_TYPE, abi._vector_argument_registers, as_FloatRegister); |
| 52 | + |
| 53 | + objArrayOop outputStorage = cast<objArrayOop>(abi_oop->obj_field(ABI.outputStorage_offset)); |
| 54 | + loadArray(outputStorage, INTEGER_TYPE, abi._integer_return_registers, as_Register); |
| 55 | + loadArray(outputStorage, VECTOR_TYPE, abi._vector_return_registers, as_FloatRegister); |
| 56 | + |
| 57 | + objArrayOop volatileStorage = cast<objArrayOop>(abi_oop->obj_field(ABI.volatileStorage_offset)); |
| 58 | + loadArray(volatileStorage, INTEGER_TYPE, abi._integer_additional_volatile_registers, as_Register); |
| 59 | + loadArray(volatileStorage, VECTOR_TYPE, abi._vector_additional_volatile_registers, as_FloatRegister); |
| 60 | + |
| 61 | + abi._stack_alignment_bytes = abi_oop->int_field(ABI.stackAlignment_offset); |
| 62 | + abi._shadow_space_bytes = abi_oop->int_field(ABI.shadowSpace_offset); |
| 63 | + |
| 64 | + return abi; |
| 65 | +} |
| 66 | + |
| 67 | +const BufferLayout ForeignGlobals::parse_buffer_layout_impl(jobject jlayout) const { |
| 68 | + oop layout_oop = JNIHandles::resolve_non_null(jlayout); |
| 69 | + BufferLayout layout; |
| 70 | + |
| 71 | + layout.stack_args_bytes = layout_oop->long_field(BL.stack_args_bytes_offset); |
| 72 | + layout.stack_args = layout_oop->long_field(BL.stack_args_offset); |
| 73 | + layout.arguments_next_pc = layout_oop->long_field(BL.arguments_next_pc_offset); |
| 74 | + |
| 75 | + typeArrayOop input_offsets = cast<typeArrayOop>(layout_oop->obj_field(BL.input_type_offsets_offset)); |
| 76 | + layout.arguments_integer = (size_t) input_offsets->long_at(INTEGER_TYPE); |
| 77 | + layout.arguments_vector = (size_t) input_offsets->long_at(VECTOR_TYPE); |
| 78 | + |
| 79 | + typeArrayOop output_offsets = cast<typeArrayOop>(layout_oop->obj_field(BL.output_type_offsets_offset)); |
| 80 | + layout.returns_integer = (size_t) output_offsets->long_at(INTEGER_TYPE); |
| 81 | + layout.returns_vector = (size_t) output_offsets->long_at(VECTOR_TYPE); |
| 82 | + |
| 83 | + layout.buffer_size = layout_oop->long_field(BL.size_offset); |
| 84 | + |
| 85 | + return layout; |
| 86 | +} |
0 commit comments