1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/cpu/sparc/vm/interpreterRT_sparc.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,242 @@ 1.4 +/* 1.5 + * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "interpreter/interpreter.hpp" 1.30 +#include "interpreter/interpreterRuntime.hpp" 1.31 +#include "memory/allocation.inline.hpp" 1.32 +#include "memory/universe.inline.hpp" 1.33 +#include "oops/method.hpp" 1.34 +#include "oops/oop.inline.hpp" 1.35 +#include "runtime/handles.inline.hpp" 1.36 +#include "runtime/icache.hpp" 1.37 +#include "runtime/interfaceSupport.hpp" 1.38 +#include "runtime/signature.hpp" 1.39 + 1.40 + 1.41 +#define __ _masm-> 1.42 + 1.43 + 1.44 +// Implementation of SignatureHandlerGenerator 1.45 + 1.46 +void InterpreterRuntime::SignatureHandlerGenerator::pass_word(int size_of_arg, int offset_in_arg) { 1.47 + Argument jni_arg(jni_offset() + offset_in_arg, false); 1.48 + Register Rtmp = O0; 1.49 + __ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); 1.50 + 1.51 + __ store_argument(Rtmp, jni_arg); 1.52 +} 1.53 + 1.54 +void InterpreterRuntime::SignatureHandlerGenerator::pass_long() { 1.55 + Argument jni_arg(jni_offset(), false); 1.56 + Register Rtmp = O0; 1.57 + 1.58 +#ifdef _LP64 1.59 + __ ldx(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); 1.60 + __ store_long_argument(Rtmp, jni_arg); 1.61 +#else 1.62 + __ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); 1.63 + __ store_argument(Rtmp, jni_arg); 1.64 + __ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 0), Rtmp); 1.65 + Argument successor(jni_arg.successor()); 1.66 + __ store_argument(Rtmp, successor); 1.67 +#endif 1.68 +} 1.69 + 1.70 + 1.71 +void InterpreterRuntime::SignatureHandlerGenerator::pass_float() { 1.72 + Argument jni_arg(jni_offset(), false); 1.73 +#ifdef _LP64 1.74 + FloatRegister Rtmp = F0; 1.75 + __ ldf(FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); 1.76 + __ store_float_argument(Rtmp, jni_arg); 1.77 +#else 1.78 + Register Rtmp = O0; 1.79 + __ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); 1.80 + __ store_argument(Rtmp, jni_arg); 1.81 +#endif 1.82 +} 1.83 + 1.84 + 1.85 +void InterpreterRuntime::SignatureHandlerGenerator::pass_double() { 1.86 + Argument jni_arg(jni_offset(), false); 1.87 +#ifdef _LP64 1.88 + FloatRegister Rtmp = F0; 1.89 + __ ldf(FloatRegisterImpl::D, Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); 1.90 + __ store_double_argument(Rtmp, jni_arg); 1.91 +#else 1.92 + Register Rtmp = O0; 1.93 + __ ld(Llocals, Interpreter::local_offset_in_bytes(offset() + 1), Rtmp); 1.94 + __ store_argument(Rtmp, jni_arg); 1.95 + __ ld(Llocals, Interpreter::local_offset_in_bytes(offset()), Rtmp); 1.96 + Argument successor(jni_arg.successor()); 1.97 + __ store_argument(Rtmp, successor); 1.98 +#endif 1.99 +} 1.100 + 1.101 +void InterpreterRuntime::SignatureHandlerGenerator::pass_object() { 1.102 + Argument jni_arg(jni_offset(), false); 1.103 + Argument java_arg( offset(), true); 1.104 + Register Rtmp1 = O0; 1.105 + Register Rtmp2 = jni_arg.is_register() ? jni_arg.as_register() : O0; 1.106 + Register Rtmp3 = G3_scratch; 1.107 + 1.108 + // the handle for a receiver will never be null 1.109 + bool do_NULL_check = offset() != 0 || is_static(); 1.110 + 1.111 + Address h_arg = Address(Llocals, Interpreter::local_offset_in_bytes(offset())); 1.112 + __ ld_ptr(h_arg, Rtmp1); 1.113 + if (!do_NULL_check) { 1.114 + __ add(h_arg.base(), h_arg.disp(), Rtmp2); 1.115 + } else { 1.116 + if (Rtmp1 == Rtmp2) 1.117 + __ tst(Rtmp1); 1.118 + else __ addcc(G0, Rtmp1, Rtmp2); // optimize mov/test pair 1.119 + Label L; 1.120 + __ brx(Assembler::notZero, true, Assembler::pt, L); 1.121 + __ delayed()->add(h_arg.base(), h_arg.disp(), Rtmp2); 1.122 + __ bind(L); 1.123 + } 1.124 + __ store_ptr_argument(Rtmp2, jni_arg); // this is often a no-op 1.125 +} 1.126 + 1.127 + 1.128 +void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) { 1.129 + 1.130 + // generate code to handle arguments 1.131 + iterate(fingerprint); 1.132 + 1.133 + // return result handler 1.134 + AddressLiteral result_handler(Interpreter::result_handler(method()->result_type())); 1.135 + __ sethi(result_handler, Lscratch); 1.136 + __ retl(); 1.137 + __ delayed()->add(Lscratch, result_handler.low10(), Lscratch); 1.138 + 1.139 + __ flush(); 1.140 +} 1.141 + 1.142 + 1.143 +// Implementation of SignatureHandlerLibrary 1.144 + 1.145 +void SignatureHandlerLibrary::pd_set_handler(address handler) {} 1.146 + 1.147 + 1.148 +class SlowSignatureHandler: public NativeSignatureIterator { 1.149 + private: 1.150 + address _from; 1.151 + intptr_t* _to; 1.152 + intptr_t* _RegArgSignature; // Signature of first Arguments to be passed in Registers 1.153 + uint _argcount; 1.154 + 1.155 + enum { // We need to differenciate float from non floats in reg args 1.156 + non_float = 0, 1.157 + float_sig = 1, 1.158 + double_sig = 2, 1.159 + long_sig = 3 1.160 + }; 1.161 + 1.162 + virtual void pass_int() { 1.163 + *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); 1.164 + _from -= Interpreter::stackElementSize; 1.165 + add_signature( non_float ); 1.166 + } 1.167 + 1.168 + virtual void pass_object() { 1.169 + // pass address of from 1.170 + intptr_t *from_addr = (intptr_t*)(_from + Interpreter::local_offset_in_bytes(0)); 1.171 + *_to++ = (*from_addr == 0) ? NULL : (intptr_t) from_addr; 1.172 + _from -= Interpreter::stackElementSize; 1.173 + add_signature( non_float ); 1.174 + } 1.175 + 1.176 +#ifdef _LP64 1.177 + virtual void pass_float() { 1.178 + *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); 1.179 + _from -= Interpreter::stackElementSize; 1.180 + add_signature( float_sig ); 1.181 + } 1.182 + 1.183 + virtual void pass_double() { 1.184 + *_to++ = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); 1.185 + _from -= 2*Interpreter::stackElementSize; 1.186 + add_signature( double_sig ); 1.187 + } 1.188 + 1.189 + virtual void pass_long() { 1.190 + _to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); 1.191 + _to += 1; 1.192 + _from -= 2*Interpreter::stackElementSize; 1.193 + add_signature( long_sig ); 1.194 + } 1.195 +#else 1.196 + // pass_double() is pass_long() and pass_float() only _LP64 1.197 + virtual void pass_long() { 1.198 + _to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); 1.199 + _to[1] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(0)); 1.200 + _to += 2; 1.201 + _from -= 2*Interpreter::stackElementSize; 1.202 + add_signature( non_float ); 1.203 + } 1.204 + 1.205 + virtual void pass_float() { 1.206 + *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); 1.207 + _from -= Interpreter::stackElementSize; 1.208 + add_signature( non_float ); 1.209 + } 1.210 + 1.211 +#endif // _LP64 1.212 + 1.213 + virtual void add_signature( intptr_t sig_type ) { 1.214 + if ( _argcount < (sizeof (intptr_t))*4 ) { 1.215 + *_RegArgSignature |= (sig_type << (_argcount*2) ); 1.216 + _argcount++; 1.217 + } 1.218 + } 1.219 + 1.220 + 1.221 + public: 1.222 + SlowSignatureHandler(methodHandle method, address from, intptr_t* to, intptr_t *RegArgSig) : NativeSignatureIterator(method) { 1.223 + _from = from; 1.224 + _to = to; 1.225 + _RegArgSignature = RegArgSig; 1.226 + *_RegArgSignature = 0; 1.227 + _argcount = method->is_static() ? 2 : 1; 1.228 + } 1.229 +}; 1.230 + 1.231 + 1.232 +IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler( 1.233 + JavaThread* thread, 1.234 + Method* method, 1.235 + intptr_t* from, 1.236 + intptr_t* to )) 1.237 + methodHandle m(thread, method); 1.238 + assert(m->is_native(), "sanity check"); 1.239 + // handle arguments 1.240 + // Warning: We use reg arg slot 00 temporarily to return the RegArgSignature 1.241 + // back to the code that pops the arguments into the CPU registers 1.242 + SlowSignatureHandler(m, (address)from, m->is_static() ? to+2 : to+1, to).iterate(UCONST64(-1)); 1.243 + // return result handler 1.244 + return Interpreter::result_handler(m->result_type()); 1.245 +IRT_END