duke@435: /* xdono@772: * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: #include "incls/_precompiled.incl" duke@435: #include "incls/_interpreterRT_x86_32.cpp.incl" duke@435: duke@435: duke@435: #define __ _masm-> duke@435: duke@435: duke@435: // Implementation of SignatureHandlerGenerator duke@435: void InterpreterRuntime::SignatureHandlerGenerator::pass_int() { duke@435: move(offset(), jni_offset() + 1); duke@435: } duke@435: duke@435: void InterpreterRuntime::SignatureHandlerGenerator::pass_long() { duke@435: move(offset(), jni_offset() + 2); duke@435: move(offset() + 1, jni_offset() + 1); duke@435: } duke@435: duke@435: void InterpreterRuntime::SignatureHandlerGenerator::pass_object() { duke@435: box (offset(), jni_offset() + 1); duke@435: } duke@435: duke@435: void InterpreterRuntime::SignatureHandlerGenerator::move(int from_offset, int to_offset) { duke@435: __ movl(temp(), Address(from(), Interpreter::local_offset_in_bytes(from_offset))); duke@435: __ movl(Address(to(), to_offset * wordSize), temp()); duke@435: } duke@435: duke@435: duke@435: void InterpreterRuntime::SignatureHandlerGenerator::box(int from_offset, int to_offset) { never@739: __ lea(temp(), Address(from(), Interpreter::local_offset_in_bytes(from_offset))); never@739: __ cmpptr(Address(from(), Interpreter::local_offset_in_bytes(from_offset)), (int32_t)NULL_WORD); // do not use temp() to avoid AGI duke@435: Label L; duke@435: __ jcc(Assembler::notZero, L); never@739: __ movptr(temp(), ((int32_t)NULL_WORD)); duke@435: __ bind(L); never@739: __ movptr(Address(to(), to_offset * wordSize), temp()); duke@435: } duke@435: duke@435: duke@435: void InterpreterRuntime::SignatureHandlerGenerator::generate( uint64_t fingerprint) { duke@435: // generate code to handle arguments duke@435: iterate(fingerprint); duke@435: // return result handler duke@435: __ lea(rax, duke@435: ExternalAddress((address)Interpreter::result_handler(method()->result_type()))); duke@435: // return duke@435: __ ret(0); duke@435: __ flush(); duke@435: } duke@435: duke@435: duke@435: Register InterpreterRuntime::SignatureHandlerGenerator::from() { return rdi; } duke@435: Register InterpreterRuntime::SignatureHandlerGenerator::to() { return rsp; } duke@435: Register InterpreterRuntime::SignatureHandlerGenerator::temp() { return rcx; } duke@435: duke@435: duke@435: // Implementation of SignatureHandlerLibrary duke@435: duke@435: void SignatureHandlerLibrary::pd_set_handler(address handler) {} duke@435: duke@435: class SlowSignatureHandler: public NativeSignatureIterator { duke@435: private: duke@435: address _from; duke@435: intptr_t* _to; duke@435: duke@435: #ifdef ASSERT duke@435: void verify_tag(frame::Tag t) { duke@435: assert(!TaggedStackInterpreter || duke@435: *(intptr_t*)(_from+Interpreter::local_tag_offset_in_bytes(0)) == t, "wrong tag"); duke@435: } duke@435: #endif // ASSERT duke@435: duke@435: virtual void pass_int() { duke@435: *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0)); duke@435: debug_only(verify_tag(frame::TagValue)); duke@435: _from -= Interpreter::stackElementSize(); duke@435: } duke@435: duke@435: virtual void pass_long() { duke@435: _to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1)); duke@435: _to[1] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(0)); duke@435: debug_only(verify_tag(frame::TagValue)); duke@435: _to += 2; duke@435: _from -= 2*Interpreter::stackElementSize(); duke@435: } duke@435: duke@435: virtual void pass_object() { duke@435: // pass address of from duke@435: intptr_t from_addr = (intptr_t)(_from + Interpreter::local_offset_in_bytes(0)); duke@435: *_to++ = (*(intptr_t*)from_addr == 0) ? NULL : from_addr; duke@435: debug_only(verify_tag(frame::TagReference)); duke@435: _from -= Interpreter::stackElementSize(); duke@435: } duke@435: duke@435: public: duke@435: SlowSignatureHandler(methodHandle method, address from, intptr_t* to) : duke@435: NativeSignatureIterator(method) { duke@435: _from = from; duke@435: _to = to + (is_static() ? 2 : 1); duke@435: } duke@435: }; duke@435: duke@435: IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(JavaThread* thread, methodOopDesc* method, intptr_t* from, intptr_t* to)) duke@435: methodHandle m(thread, (methodOop)method); duke@435: assert(m->is_native(), "sanity check"); duke@435: // handle arguments duke@435: SlowSignatureHandler(m, (address)from, to + 1).iterate(UCONST64(-1)); duke@435: // return result handler duke@435: return Interpreter::result_handler(m->result_type()); duke@435: IRT_END