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