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