Path: blob/master/src/hotspot/cpu/s390/interpreterRT_s390.cpp
40930 views
/*1* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2016 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "asm/macroAssembler.inline.hpp"27#include "interpreter/interp_masm.hpp"28#include "interpreter/interpreter.hpp"29#include "interpreter/interpreterRuntime.hpp"30#include "memory/allocation.inline.hpp"31#include "oops/oop.inline.hpp"32#include "runtime/handles.inline.hpp"33#include "runtime/icache.hpp"34#include "runtime/interfaceSupport.inline.hpp"35#include "runtime/signature.hpp"3637// Access macros for Java and C arguments.38// First Java argument is at index-1.39#define locals_j_arg_at(index) Address(Z_R1/*locals*/, in_ByteSize((-(index)*wordSize)))4041#define __ _masm->4243static int sp_c_int_arg_offset(int arg_nr, int fp_arg_nr) {44int int_arg_nr = arg_nr-fp_arg_nr;4546// arg_nr, fp_arg_nr start with 1 => int_arg_nr starts with 047if (int_arg_nr < 5) {48return int_arg_nr * wordSize + _z_abi(carg_1);49}50int offset = int_arg_nr - 5 + (fp_arg_nr > 4 ? fp_arg_nr - 4 : 0);51return offset * wordSize + _z_abi(remaining_cargs);52}5354static int sp_c_fp_arg_offset(int arg_nr, int fp_arg_nr) {55int int_arg_nr = arg_nr-fp_arg_nr;5657// Arg_nr, fp_arg_nr start with 1 => int_arg_nr starts with 0.58if (fp_arg_nr < 5) {59return (fp_arg_nr - 1 ) * wordSize + _z_abi(cfarg_1);60}61int offset = fp_arg_nr - 5 + (int_arg_nr > 4 ? int_arg_nr - 4 : 0);62return offset * wordSize + _z_abi(remaining_cargs);63}6465// Implementation of SignatureHandlerGenerator66InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator(67const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {68_masm = new MacroAssembler(buffer);69_fp_arg_nr = 0;70}7172void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {73int int_arg_nr = jni_offset() - _fp_arg_nr;74Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ?75as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0;7677__ z_lgf(r, locals_j_arg_at(offset()));78if (DEBUG_ONLY(true ||) int_arg_nr >= 5) {79__ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);80}81}8283void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {84int int_arg_nr = jni_offset() - _fp_arg_nr;85Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ?86as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0;8788__ z_lg(r, locals_j_arg_at(offset() + 1)); // Long resides in upper slot.89if (DEBUG_ONLY(true ||) int_arg_nr >= 5) {90__ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);91}92}9394void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {95FloatRegister fp_reg = (_fp_arg_nr < 4/*max_fp_register_arguments*/) ?96as_FloatRegister((_fp_arg_nr * 2) + Z_FARG1->encoding()) : Z_F1;97_fp_arg_nr++;98__ z_ley(fp_reg, locals_j_arg_at(offset()));99if (DEBUG_ONLY(true ||) _fp_arg_nr > 4) {100__ z_ste(fp_reg, sp_c_fp_arg_offset(jni_offset(), _fp_arg_nr) + 4, Z_SP);101}102}103104void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {105FloatRegister fp_reg = (_fp_arg_nr < 4/*max_fp_register_arguments*/) ?106as_FloatRegister((_fp_arg_nr*2) + Z_FARG1->encoding()) : Z_F1;107_fp_arg_nr++;108__ z_ldy(fp_reg, locals_j_arg_at(offset()+1));109if (DEBUG_ONLY(true ||) _fp_arg_nr > 4) {110__ z_std(fp_reg, sp_c_fp_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);111}112}113114void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {115int int_arg_nr = jni_offset() - _fp_arg_nr;116Register r = (int_arg_nr < 5 /*max_int_register_arguments*/) ?117as_Register(int_arg_nr) + Z_ARG1->encoding() : Z_R0;118119// The handle for a receiver will never be null.120bool do_NULL_check = offset() != 0 || is_static();121122Label do_null;123if (do_NULL_check) {124__ clear_reg(r, true, false);125__ load_and_test_long(Z_R0, locals_j_arg_at(offset()));126__ z_bre(do_null);127}128__ add2reg(r, -offset() * wordSize, Z_R1 /* locals */);129__ bind(do_null);130if (DEBUG_ONLY(true ||) int_arg_nr >= 5) {131__ z_stg(r, sp_c_int_arg_offset(jni_offset(), _fp_arg_nr), Z_SP);132}133}134135136void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) {137__ z_lgr(Z_R1, Z_ARG1); // Z_R1 is used in locals_j_arg_at(index) macro.138139// Generate code to handle arguments.140iterate(fingerprint);141__ load_const_optimized(Z_RET, AbstractInterpreter::result_handler(method()->result_type()));142__ z_br(Z_R14);143__ flush();144}145146#undef __147148// Implementation of SignatureHandlerLibrary149150void SignatureHandlerLibrary::pd_set_handler(address handler) {}151152JRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* current, Method* method))153methodHandle m(current, method);154assert(m->is_native(), "sanity check");155Symbol *s = m->signature();156return (address) s->base();157JRT_END158159JRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* current, Method* method))160methodHandle m(current, method);161assert(m->is_native(), "sanity check");162return AbstractInterpreter::result_handler(m->result_type());163JRT_END164165166