0N/A/*
1472N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. 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 *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "interpreter/interpreter.hpp"
1879N/A#include "interpreter/interpreterRuntime.hpp"
1879N/A#include "memory/allocation.inline.hpp"
1879N/A#include "memory/universe.inline.hpp"
1879N/A#include "oops/methodOop.hpp"
1879N/A#include "oops/oop.inline.hpp"
1879N/A#include "runtime/handles.inline.hpp"
1879N/A#include "runtime/icache.hpp"
1879N/A#include "runtime/interfaceSupport.hpp"
1879N/A#include "runtime/signature.hpp"
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
1601N/Avoid InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
1601N/A move(offset(), jni_offset() + 1);
1601N/A}
1601N/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 virtual void pass_int() {
0N/A *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));
1426N/A _from -= Interpreter::stackElementSize;
0N/A }
0N/A
1601N/A virtual void pass_float() {
1601N/A *_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));
1601N/A _from -= Interpreter::stackElementSize;
1601N/A }
1601N/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 _to += 2;
1426N/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));
533N/A *_to++ = (*(intptr_t*)from_addr == 0) ? NULL_WORD : from_addr;
1426N/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