Path: blob/master/src/hotspot/cpu/x86/interpreterRT_x86_32.cpp
41144 views
/*1* Copyright (c) 1998, 2021, 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/interp_masm.hpp"26#include "interpreter/interpreter.hpp"27#include "interpreter/interpreterRuntime.hpp"28#include "memory/allocation.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.inline.hpp"34#include "runtime/signature.hpp"353637#define __ _masm->383940// Implementation of SignatureHandlerGenerator41InterpreterRuntime::SignatureHandlerGenerator::SignatureHandlerGenerator(const methodHandle& method, CodeBuffer* buffer) :42NativeSignatureIterator(method) {43_masm = new MacroAssembler(buffer);44#ifdef AMD6445#ifdef _WIN6446_num_args = (method->is_static() ? 1 : 0);47_stack_offset = (Argument::n_int_register_parameters_c+1)* wordSize; // don't overwrite return address48#else49_num_int_args = (method->is_static() ? 1 : 0);50_num_fp_args = 0;51_stack_offset = wordSize; // don't overwrite return address52#endif // _WIN6453#endif // AMD6454}5556void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {57move(offset(), jni_offset() + 1);58}5960void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {61move(offset(), jni_offset() + 1);62}6364void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {65move(offset(), jni_offset() + 2);66move(offset() + 1, jni_offset() + 1);67}6869void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {70box (offset(), jni_offset() + 1);71}7273void InterpreterRuntime::SignatureHandlerGenerator::move(int from_offset, int to_offset) {74__ movl(temp(), Address(from(), Interpreter::local_offset_in_bytes(from_offset)));75__ movl(Address(to(), to_offset * wordSize), temp());76}777879void InterpreterRuntime::SignatureHandlerGenerator::box(int from_offset, int to_offset) {80__ lea(temp(), Address(from(), Interpreter::local_offset_in_bytes(from_offset)));81__ cmpptr(Address(from(), Interpreter::local_offset_in_bytes(from_offset)), (int32_t)NULL_WORD); // do not use temp() to avoid AGI82Label L;83__ jcc(Assembler::notZero, L);84__ movptr(temp(), NULL_WORD);85__ bind(L);86__ movptr(Address(to(), to_offset * wordSize), temp());87}888990void InterpreterRuntime::SignatureHandlerGenerator::generate( uint64_t fingerprint) {91// generate code to handle arguments92iterate(fingerprint);93// return result handler94__ lea(rax,95ExternalAddress((address)Interpreter::result_handler(method()->result_type())));96// return97__ ret(0);98__ flush();99}100101102Register InterpreterRuntime::SignatureHandlerGenerator::from() { return rdi; }103Register InterpreterRuntime::SignatureHandlerGenerator::to() { return rsp; }104Register InterpreterRuntime::SignatureHandlerGenerator::temp() { return rcx; }105106107// Implementation of SignatureHandlerLibrary108109void SignatureHandlerLibrary::pd_set_handler(address handler) {}110111class SlowSignatureHandler: public NativeSignatureIterator {112private:113address _from;114intptr_t* _to;115116virtual void pass_int() {117*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));118_from -= Interpreter::stackElementSize;119}120121virtual void pass_float() {122*_to++ = *(jint *)(_from+Interpreter::local_offset_in_bytes(0));123_from -= Interpreter::stackElementSize;124}125126virtual void pass_long() {127_to[0] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(1));128_to[1] = *(intptr_t*)(_from+Interpreter::local_offset_in_bytes(0));129_to += 2;130_from -= 2*Interpreter::stackElementSize;131}132133virtual void pass_object() {134// pass address of from135intptr_t from_addr = (intptr_t)(_from + Interpreter::local_offset_in_bytes(0));136*_to++ = (*(intptr_t*)from_addr == 0) ? NULL_WORD : from_addr;137_from -= Interpreter::stackElementSize;138}139140public:141SlowSignatureHandler(const methodHandle& method, address from, intptr_t* to) :142NativeSignatureIterator(method) {143_from = from;144_to = to + (is_static() ? 2 : 1);145}146};147148JRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(JavaThread* current, Method* method, intptr_t* from, intptr_t* to))149methodHandle m(current, (Method*)method);150assert(m->is_native(), "sanity check");151// handle arguments152SlowSignatureHandler(m, (address)from, to + 1).iterate((uint64_t)CONST64(-1));153// return result handler154return Interpreter::result_handler(m->result_type());155JRT_END156157158