src/cpu/ppc/vm/interpreterRT_ppc.cpp

Thu, 06 Mar 2014 10:55:28 -0800

author
goetz
date
Thu, 06 Mar 2014 10:55:28 -0800
changeset 6511
31e80afe3fed
parent 6458
ec28f9c041ff
child 6660
63c5920a038d
permissions
-rw-r--r--

8035647: PPC64: Support for elf v2 abi.
Summary: ELFv2 ABI used by the little endian PowerPC64 on Linux.
Reviewed-by: kvn
Contributed-by: asmundak@google.com

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2012, 2013 SAP AG. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     9  *
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    13  * version 2 for more details (a copy is included in the LICENSE file that
    14  * accompanied this code).
    15  *
    16  * You should have received a copy of the GNU General Public License version
    17  * 2 along with this work; if not, write to the Free Software Foundation,
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    19  *
    20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21  * or visit www.oracle.com if you need additional information or have any
    22  * questions.
    23  *
    24  */
    26 #include "precompiled.hpp"
    27 #include "interpreter/interpreter.hpp"
    28 #include "interpreter/interpreterRuntime.hpp"
    29 #include "memory/allocation.inline.hpp"
    30 #include "memory/universe.inline.hpp"
    31 #include "oops/method.hpp"
    32 #include "oops/oop.inline.hpp"
    33 #include "runtime/handles.inline.hpp"
    34 #include "runtime/icache.hpp"
    35 #include "runtime/interfaceSupport.hpp"
    36 #include "runtime/signature.hpp"
    38 #define __ _masm->
    40 // Access macros for Java and C arguments.
    41 // The first Java argument is at index -1.
    42 #define locals_j_arg_at(index)    (Interpreter::local_offset_in_bytes(index)), R18_locals
    43 // The first C argument is at index 0.
    44 #define sp_c_arg_at(index)        ((index)*wordSize + _abi(carg_1)), R1_SP
    46 // Implementation of SignatureHandlerGenerator
    48 void InterpreterRuntime::SignatureHandlerGenerator::pass_int() {
    49   Argument jni_arg(jni_offset());
    50   Register r = jni_arg.is_register() ? jni_arg.as_register() : R0;
    52   __ lwa(r, locals_j_arg_at(offset())); // sign extension of integer
    53   if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {
    54     __ std(r, sp_c_arg_at(jni_arg.number()));
    55   }
    56 }
    58 void InterpreterRuntime::SignatureHandlerGenerator::pass_long() {
    59   Argument jni_arg(jni_offset());
    60   Register r = jni_arg.is_register() ? jni_arg.as_register() : R0;
    62   __ ld(r, locals_j_arg_at(offset()+1)); // long resides in upper slot
    63   if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {
    64     __ std(r, sp_c_arg_at(jni_arg.number()));
    65   }
    66 }
    68 void InterpreterRuntime::SignatureHandlerGenerator::pass_float() {
    69   FloatRegister fp_reg = (_num_used_fp_arg_regs < 13/*max_fp_register_arguments*/)
    70                          ? as_FloatRegister((_num_used_fp_arg_regs++) + F1_ARG1->encoding())
    71                          : F0;
    73   __ lfs(fp_reg, locals_j_arg_at(offset()));
    74   if (DEBUG_ONLY(true ||) jni_offset() > 8) {
    75     __ stfs(fp_reg, sp_c_arg_at(jni_offset()));
    76   }
    77 }
    79 void InterpreterRuntime::SignatureHandlerGenerator::pass_double() {
    80   FloatRegister fp_reg = (_num_used_fp_arg_regs < 13/*max_fp_register_arguments*/)
    81                          ? as_FloatRegister((_num_used_fp_arg_regs++) + F1_ARG1->encoding())
    82                          : F0;
    84   __ lfd(fp_reg, locals_j_arg_at(offset()+1));
    85   if (DEBUG_ONLY(true ||) jni_offset() > 8) {
    86     __ stfd(fp_reg, sp_c_arg_at(jni_offset()));
    87   }
    88 }
    90 void InterpreterRuntime::SignatureHandlerGenerator::pass_object() {
    91   Argument jni_arg(jni_offset());
    92   Register r = jni_arg.is_register() ? jni_arg.as_register() : R11_scratch1;
    94   // The handle for a receiver will never be null.
    95   bool do_NULL_check = offset() != 0 || is_static();
    97   Label do_null;
    98   if (do_NULL_check) {
    99     __ ld(R0, locals_j_arg_at(offset()));
   100     __ cmpdi(CCR0, R0, 0);
   101     __ li(r, 0);
   102     __ beq(CCR0, do_null);
   103   }
   104   __ addir(r, locals_j_arg_at(offset()));
   105   __ bind(do_null);
   106   if (DEBUG_ONLY(true ||) !jni_arg.is_register()) {
   107     __ std(r, sp_c_arg_at(jni_arg.number()));
   108   }
   109 }
   111 void InterpreterRuntime::SignatureHandlerGenerator::generate(uint64_t fingerprint) {
   112 #if !defined(ABI_ELFv2)
   113   // Emit fd for current codebuffer. Needs patching!
   114   __ emit_fd();
   115 #endif
   117   // Generate code to handle arguments.
   118   iterate(fingerprint);
   120   // Return the result handler.
   121   __ load_const(R3_RET, AbstractInterpreter::result_handler(method()->result_type()));
   122   __ blr();
   124   __ flush();
   125 }
   127 #undef __
   129 // Implementation of SignatureHandlerLibrary
   131 void SignatureHandlerLibrary::pd_set_handler(address handler) {
   132 #if !defined(ABI_ELFv2)
   133   // patch fd here.
   134   FunctionDescriptor* fd = (FunctionDescriptor*) handler;
   136   fd->set_entry(handler + (int)sizeof(FunctionDescriptor));
   137   assert(fd->toc() == (address)0xcafe, "need to adjust TOC here");
   138 #endif
   139 }
   142 // Access function to get the signature.
   143 IRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method))
   144   methodHandle m(thread, method);
   145   assert(m->is_native(), "sanity check");
   146   Symbol *s = m->signature();
   147   return (address) s->base();
   148 IRT_END
   150 IRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method))
   151   methodHandle m(thread, method);
   152   assert(m->is_native(), "sanity check");
   153   return AbstractInterpreter::result_handler(m->result_type());
   154 IRT_END

mercurial