Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/cpu/zero/vm/interpreterRT_zero.cpp
32285 views
/*1* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.2* Copyright 2007, 2008, 2010 Red Hat, Inc.3* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.4*5* This code is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "interpreter/interpreter.hpp"27#include "interpreter/interpreterRuntime.hpp"28#include "memory/allocation.inline.hpp"29#include "memory/universe.inline.hpp"30#include "oops/method.hpp"31#include "oops/oop.inline.hpp"32#include "runtime/handles.inline.hpp"33#include "runtime/icache.hpp"34#include "runtime/interfaceSupport.hpp"35#include "runtime/signature.hpp"36#include "stack_zero.inline.hpp"3738void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_int() {39push(T_INT);40_cif->nargs++;41}4243void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_long() {44push(T_LONG);45_cif->nargs++;46}4748void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_float() {49push(T_FLOAT);50_cif->nargs++;51}5253void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_double() {54push(T_DOUBLE);55_cif->nargs++;56}5758void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_object() {59push(T_OBJECT);60_cif->nargs++;61}6263void InterpreterRuntime::SignatureHandlerGeneratorBase::push(BasicType type) {64ffi_type *ftype;65switch (type) {66case T_VOID:67ftype = &ffi_type_void;68break;6970case T_BOOLEAN:71ftype = &ffi_type_uint8;72break;7374case T_CHAR:75ftype = &ffi_type_uint16;76break;7778case T_BYTE:79ftype = &ffi_type_sint8;80break;8182case T_SHORT:83ftype = &ffi_type_sint16;84break;8586case T_INT:87ftype = &ffi_type_sint32;88break;8990case T_LONG:91ftype = &ffi_type_sint64;92break;9394case T_FLOAT:95ftype = &ffi_type_float;96break;9798case T_DOUBLE:99ftype = &ffi_type_double;100break;101102case T_OBJECT:103case T_ARRAY:104ftype = &ffi_type_pointer;105break;106107default:108ShouldNotReachHere();109}110push((intptr_t) ftype);111}112113// For fast signature handlers the "signature handler" is generated114// into a temporary buffer. It is then copied to its final location,115// and pd_set_handler is called on it. We have this two stage thing116// to accomodate this.117118void InterpreterRuntime::SignatureHandlerGeneratorBase::generate(119uint64_t fingerprint) {120121// Build the argument types list122pass_object();123if (method()->is_static())124pass_object();125iterate(fingerprint);126127// Tack on the result type128push(method()->result_type());129}130131void InterpreterRuntime::SignatureHandler::finalize() {132ffi_status status =133ffi_prep_cif(cif(),134FFI_DEFAULT_ABI,135argument_count(),136result_type(),137argument_types());138139assert(status == FFI_OK, "should be");140}141142IRT_ENTRY(address,143InterpreterRuntime::slow_signature_handler(JavaThread* thread,144Method* method,145intptr_t* unused1,146intptr_t* unused2))147ZeroStack *stack = thread->zero_stack();148149int required_words =150(align_size_up(sizeof(ffi_cif), wordSize) >> LogBytesPerWord) +151(method->is_static() ? 2 : 1) + method->size_of_parameters() + 1;152153stack->overflow_check(required_words, CHECK_NULL);154155intptr_t *buf = (intptr_t *) stack->alloc(required_words * wordSize);156SlowSignatureHandlerGenerator sshg(methodHandle(thread, method), buf);157sshg.generate(UCONST64(-1));158159SignatureHandler *handler = sshg.handler();160handler->finalize();161162return (address) handler;163IRT_END164165void SignatureHandlerLibrary::pd_set_handler(address handlerAddr) {166InterpreterRuntime::SignatureHandler *handler =167InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);168169handler->finalize();170}171172173