Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/ppc/vm/interpreterRT_ppc.cpp
32285 views
/*1* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.2* Copyright 2012, 2013 SAP AG. 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/interpreter.hpp"28#include "interpreter/interpreterRuntime.hpp"29#include "memory/allocation.inline.hpp"30#include "memory/universe.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.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 + _abi(carg_1)), R1_SP4546// Implementation of SignatureHandlerGenerator4748void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {49Argument jni_arg(jni_offset());50Register r = jni_arg.is_register() ? jni_arg.as_register() : R0;5152__ lwa(r, locals_j_arg_at(offset())); // sign extension of integer53if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {54__ std(r, sp_c_arg_at(jni_arg.number()));55}56}5758void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {59Argument jni_arg(jni_offset());60Register r = jni_arg.is_register() ? jni_arg.as_register() : R0;6162__ ld(r, locals_j_arg_at(offset()+1)); // long resides in upper slot63if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {64__ std(r, sp_c_arg_at(jni_arg.number()));65}66}6768void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {69FloatRegister fp_reg = (_num_used_fp_arg_regs < 13/*max_fp_register_arguments*/)70? as_FloatRegister((_num_used_fp_arg_regs++) + F1_ARG1->encoding())71: F0;7273__ lfs(fp_reg, locals_j_arg_at(offset()));74if (DEBUG_ONLY(true ||) jni_offset() > 8) {75__ stfs(fp_reg, sp_c_arg_at(jni_offset()));76}77}7879void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {80FloatRegister fp_reg = (_num_used_fp_arg_regs < 13/*max_fp_register_arguments*/)81? as_FloatRegister((_num_used_fp_arg_regs++) + F1_ARG1->encoding())82: F0;8384__ lfd(fp_reg, locals_j_arg_at(offset()+1));85if (DEBUG_ONLY(true ||) jni_offset() > 8) {86__ stfd(fp_reg, sp_c_arg_at(jni_offset()));87}88}8990void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {91Argument jni_arg(jni_offset());92Register r = jni_arg.is_register() ? jni_arg.as_register() : R11_scratch1;9394// The handle for a receiver will never be null.95bool do_NULL_check = offset() != 0 || is_static();9697Label do_null;98if (do_NULL_check) {99__ ld(R0, locals_j_arg_at(offset()));100__ cmpdi(CCR0, R0, 0);101__ li(r, 0);102__ beq(CCR0, do_null);103}104__ addir(r, locals_j_arg_at(offset()));105__ bind(do_null);106if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {107__ std(r, sp_c_arg_at(jni_arg.number()));108}109}110111void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) {112#if !defined(ABI_ELFv2)113// Emit fd for current codebuffer. Needs patching!114__ emit_fd();115#endif116117// Generate code to handle arguments.118iterate(fingerprint);119120// Return the result handler.121__ load_const(R3_RET, AbstractInterpreter::result_handler(method()->result_type()));122__ blr();123124__ flush();125}126127#undef __128129// Implementation of SignatureHandlerLibrary130131void SignatureHandlerLibrary::pd_set_handler(address handler) {132#if !defined(ABI_ELFv2)133// patch fd here.134FunctionDescriptor* fd = (FunctionDescriptor*) handler;135136fd->set_entry(handler + (int)sizeof(FunctionDescriptor));137assert(fd->toc() == (address)0xcafe, "need to adjust TOC here");138#endif139}140141142// Access function to get the signature.143IRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method))144methodHandle m(thread, method);145assert(m->is_native(), "sanity check");146Symbol *s = m->signature();147return (address) s->base();148IRT_END149150IRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method))151methodHandle m(thread, method);152assert(m->is_native(), "sanity check");153return AbstractInterpreter::result_handler(m->result_type());154IRT_END155156157