Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/sparc/vm/interpreterRT_sparc.cpp
32285 views
/*1* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "interpreter/interpreter.hpp"26#include "interpreter/interpreterRuntime.hpp"27#include "memory/allocation.inline.hpp"28#include "memory/universe.inline.hpp"29#include "oops/method.hpp"30#include "oops/oop.inline.hpp"31#include "runtime/handles.inline.hpp"32#include "runtime/icache.hpp"33#include "runtime/interfaceSupport.hpp"34#include "runtime/signature.hpp"353637#define __ _masm->383940// Implementation of SignatureHandlerGenerator4142void InterpreterRuntime::SignatureHandlerGenerator::pass_word(int size_of_arg, int offset_in_arg) {43Argument jni_arg(jni_offset() + offset_in_arg, false);44Register Rtmp = O0;45__ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);4647__ store_argument(Rtmp, jni_arg);48}4950void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {51Argument jni_arg(jni_offset(), false);52Register Rtmp = O0;5354#ifdef _LP6455__ ldx(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp);56__ store_long_argument(Rtmp, jni_arg);57#else58__ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp);59__ store_argument(Rtmp, jni_arg);60__ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 0), Rtmp);61Argument successor(jni_arg.successor());62__ store_argument(Rtmp, successor);63#endif64}656667void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {68Argument jni_arg(jni_offset(), false);69#ifdef _LP6470FloatRegister Rtmp = F0;71__ ldf(FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);72__ store_float_argument(Rtmp, jni_arg);73#else74Register Rtmp = O0;75__ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);76__ store_argument(Rtmp, jni_arg);77#endif78}798081void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {82Argument jni_arg(jni_offset(), false);83#ifdef _LP6484FloatRegister Rtmp = F0;85__ ldf(FloatRegisterImpl::D, Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp);86__ store_double_argument(Rtmp, jni_arg);87#else88Register Rtmp = O0;89__ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp);90__ store_argument(Rtmp, jni_arg);91__ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp);92Argument successor(jni_arg.successor());93__ store_argument(Rtmp, successor);94#endif95}9697void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {98Argument jni_arg(jni_offset(), false);99Argument java_arg( offset(), true);100Register Rtmp1 = O0;101Register Rtmp2 = jni_arg.is_register() ? jni_arg.as_register() : O0;102Register Rtmp3 = G3_scratch;103104// the handle for a receiver will never be null105bool do_NULL_check = offset() != 0 || is_static();106107Address h_arg = Address(Llocals, Interpreter::local_offset_in_bytes(offset()));108__ ld_ptr(h_arg, Rtmp1);109if (!do_NULL_check) {110__ add(h_arg.base(), h_arg.disp(), Rtmp2);111} else {112if (Rtmp1 == Rtmp2)113__ tst(Rtmp1);114else __ addcc(G0, Rtmp1, Rtmp2); // optimize mov/test pair115Label L;116__ brx(Assembler::notZero, true, Assembler::pt, L);117__ delayed()->add(h_arg.base(), h_arg.disp(), Rtmp2);118__ bind(L);119}120__ store_ptr_argument(Rtmp2, jni_arg); // this is often a no-op121}122123124void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) {125126// generate code to handle arguments127iterate(fingerprint);128129// return result handler130AddressLiteral result_handler(Interpreter::result_handler(method()->result_type()));131__ sethi(result_handler, Lscratch);132__ retl();133__ delayed()->add(Lscratch, result_handler.low10(), Lscratch);134135__ flush();136}137138139// Implementation of SignatureHandlerLibrary140141void SignatureHandlerLibrary::pd_set_handler(address handler) {}142143144class SlowSignatureHandler: public NativeSignatureIterator {145private:146address _from;147intptr_t* _to;148intptr_t* _RegArgSignature; // Signature of first Arguments to be passed in Registers149uint _argcount;150151enum { // We need to differenciate float from non floats in reg args152non_float = 0,153float_sig = 1,154double_sig = 2,155long_sig = 3156};157158virtual void pass_int() {159*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));160_from -= Interpreter::stackElementSize;161add_signature( non_float );162}163164virtual void pass_object() {165// pass address of from166intptr_t *from_addr = (intptr_t*)(_from + Interpreter::local_offset_in_bytes(0));167*_to++ = (*from_addr == 0) ? NULL : (intptr_t) from_addr;168_from -= Interpreter::stackElementSize;169add_signature( non_float );170}171172#ifdef _LP64173virtual void pass_float() {174*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));175_from -= Interpreter::stackElementSize;176add_signature( float_sig );177}178179virtual void pass_double() {180*_to++ = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1));181_from -= 2*Interpreter::stackElementSize;182add_signature( double_sig );183}184185virtual void pass_long() {186_to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1));187_to += 1;188_from -= 2*Interpreter::stackElementSize;189add_signature( long_sig );190}191#else192// pass_double() is pass_long() and pass_float() only _LP64193virtual void pass_long() {194_to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1));195_to[1] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(0));196_to += 2;197_from -= 2*Interpreter::stackElementSize;198add_signature( non_float );199}200201virtual void pass_float() {202*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));203_from -= Interpreter::stackElementSize;204add_signature( non_float );205}206207#endif // _LP64208209virtual void add_signature( intptr_t sig_type ) {210if ( _argcount < (sizeof (intptr_t))*4 ) {211*_RegArgSignature |= (sig_type << (_argcount*2) );212_argcount++;213}214}215216217public:218SlowSignatureHandler(methodHandle method, address from, intptr_t* to, intptr_t *RegArgSig) : NativeSignatureIterator(method) {219_from = from;220_to = to;221_RegArgSignature = RegArgSig;222*_RegArgSignature = 0;223_argcount = method->is_static() ? 2 : 1;224}225};226227228IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(229JavaThread* thread,230Method* method,231intptr_t* from,232intptr_t* to ))233methodHandle m(thread, method);234assert(m->is_native(), "sanity check");235// handle arguments236// Warning: We use reg arg slot 00 temporarily to return the RegArgSignature237// back to the code that pops the arguments into the CPU registers238SlowSignatureHandler(m, (address)from, m->is_static() ? to+2 : to+1, to).iterate(UCONST64(-1));239// return result handler240return Interpreter::result_handler(m->result_type());241IRT_END242243244