Path: blob/master/src/hotspot/cpu/ppc/interpreterRT_ppc.cpp
40930 views
/*1* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.2* Copyright (c) 2012, 2013 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/assembler.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/method.hpp"32#include "oops/oop.inline.hpp"33#include "runtime/handles.inline.hpp"34#include "runtime/icache.hpp"35#include "runtime/interfaceSupport.inline.hpp"36#include "runtime/signature.hpp"3738#define __ _masm->3940// Access macros for Java and C arguments.41// The first Java argument is at index -1.42#define locals_j_arg_at(index) (Interpreter::local_offset_in_bytes(index)), R18_locals43// The first C argument is at index 0.44#define sp_c_arg_at(index) ((index)*wordSize + _abi0(carg_1)), R1_SP4546// Implementation of SignatureHandlerGenerator4748InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator(49const methodHandle& method, CodeBuffer* buffer) : NativeSignatureIterator(method) {50_masm = new MacroAssembler(buffer);51_num_used_fp_arg_regs = 0;52}5354void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {55Argument jni_arg(jni_offset());56Register r = jni_arg.is_register() ? jni_arg.as_register() : R0;5758__ lwa(r, locals_j_arg_at(offset())); // sign extension of integer59if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {60__ std(r, sp_c_arg_at(jni_arg.number()));61}62}6364void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {65Argument jni_arg(jni_offset());66Register r = jni_arg.is_register() ? jni_arg.as_register() : R0;6768__ ld(r, locals_j_arg_at(offset()+1)); // long resides in upper slot69if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {70__ std(r, sp_c_arg_at(jni_arg.number()));71}72}7374void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {75FloatRegister fp_reg = (_num_used_fp_arg_regs < 13/*max_fp_register_arguments*/)76? as_FloatRegister((_num_used_fp_arg_regs++) + F1_ARG1->encoding())77: F0;7879__ lfs(fp_reg, locals_j_arg_at(offset()));80if (DEBUG_ONLY(true ||) jni_offset() > 8) {81__ stfs(fp_reg, sp_c_arg_at(jni_offset()));82}83}8485void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {86FloatRegister fp_reg = (_num_used_fp_arg_regs < 13/*max_fp_register_arguments*/)87? as_FloatRegister((_num_used_fp_arg_regs++) + F1_ARG1->encoding())88: F0;8990__ lfd(fp_reg, locals_j_arg_at(offset()+1));91if (DEBUG_ONLY(true ||) jni_offset() > 8) {92__ stfd(fp_reg, sp_c_arg_at(jni_offset()));93}94}9596void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {97Argument jni_arg(jni_offset());98Register r = jni_arg.is_register() ? jni_arg.as_register() : R11_scratch1;99100// The handle for a receiver will never be null.101bool do_NULL_check = offset() != 0 || is_static();102103Label do_null;104if (do_NULL_check) {105__ ld(R0, locals_j_arg_at(offset()));106__ cmpdi(CCR0, R0, 0);107__ li(r, 0);108__ beq(CCR0, do_null);109}110__ addir(r, locals_j_arg_at(offset()));111__ bind(do_null);112if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {113__ std(r, sp_c_arg_at(jni_arg.number()));114}115}116117void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) {118#if !defined(ABI_ELFv2)119// Emit fd for current codebuffer. Needs patching!120__ emit_fd();121#endif122123// Generate code to handle arguments.124iterate(fingerprint);125126// Return the result handler.127__ load_const(R3_RET, AbstractInterpreter::result_handler(method()->result_type()));128__ blr();129130__ flush();131}132133#undef __134135// Implementation of SignatureHandlerLibrary136137void SignatureHandlerLibrary::pd_set_handler(address handler) {138#if !defined(ABI_ELFv2)139// patch fd here.140FunctionDescriptor* fd = (FunctionDescriptor*) handler;141142fd->set_entry(handler + (int)sizeof(FunctionDescriptor));143assert(fd->toc() == (address)0xcafe, "need to adjust TOC here");144#endif145}146147148// Access function to get the signature.149JRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* current, Method* method))150methodHandle m(current, method);151assert(m->is_native(), "sanity check");152Symbol *s = m->signature();153return (address) s->base();154JRT_END155156JRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* current, Method* method))157methodHandle m(current, method);158assert(m->is_native(), "sanity check");159return AbstractInterpreter::result_handler(m->result_type());160JRT_END161162163