src/cpu/zero/vm/interpreterRT_zero.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * Copyright 2007, 2008, 2010 Red Hat, Inc.
aoqi@0 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 5 *
aoqi@0 6 * This code is free software; you can redistribute it and/or modify it
aoqi@0 7 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 8 * published by the Free Software Foundation.
aoqi@0 9 *
aoqi@0 10 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 13 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 14 * accompanied this code).
aoqi@0 15 *
aoqi@0 16 * You should have received a copy of the GNU General Public License version
aoqi@0 17 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 19 *
aoqi@0 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 21 * or visit www.oracle.com if you need additional information or have any
aoqi@0 22 * questions.
aoqi@0 23 *
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 #include "precompiled.hpp"
aoqi@0 27 #include "interpreter/interpreter.hpp"
aoqi@0 28 #include "interpreter/interpreterRuntime.hpp"
aoqi@0 29 #include "memory/allocation.inline.hpp"
aoqi@0 30 #include "memory/universe.inline.hpp"
aoqi@0 31 #include "oops/method.hpp"
aoqi@0 32 #include "oops/oop.inline.hpp"
aoqi@0 33 #include "runtime/handles.inline.hpp"
aoqi@0 34 #include "runtime/icache.hpp"
aoqi@0 35 #include "runtime/interfaceSupport.hpp"
aoqi@0 36 #include "runtime/signature.hpp"
aoqi@0 37 #include "stack_zero.inline.hpp"
aoqi@0 38
aoqi@0 39 void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_int() {
aoqi@0 40 push(T_INT);
aoqi@0 41 _cif->nargs++;
aoqi@0 42 }
aoqi@0 43
aoqi@0 44 void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_long() {
aoqi@0 45 push(T_LONG);
aoqi@0 46 _cif->nargs++;
aoqi@0 47 }
aoqi@0 48
aoqi@0 49 void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_float() {
aoqi@0 50 push(T_FLOAT);
aoqi@0 51 _cif->nargs++;
aoqi@0 52 }
aoqi@0 53
aoqi@0 54 void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_double() {
aoqi@0 55 push(T_DOUBLE);
aoqi@0 56 _cif->nargs++;
aoqi@0 57 }
aoqi@0 58
aoqi@0 59 void InterpreterRuntime::SignatureHandlerGeneratorBase::pass_object() {
aoqi@0 60 push(T_OBJECT);
aoqi@0 61 _cif->nargs++;
aoqi@0 62 }
aoqi@0 63
aoqi@0 64 void InterpreterRuntime::SignatureHandlerGeneratorBase::push(BasicType type) {
aoqi@0 65 ffi_type *ftype;
aoqi@0 66 switch (type) {
aoqi@0 67 case T_VOID:
aoqi@0 68 ftype = &ffi_type_void;
aoqi@0 69 break;
aoqi@0 70
aoqi@0 71 case T_BOOLEAN:
aoqi@0 72 ftype = &ffi_type_uint8;
aoqi@0 73 break;
aoqi@0 74
aoqi@0 75 case T_CHAR:
aoqi@0 76 ftype = &ffi_type_uint16;
aoqi@0 77 break;
aoqi@0 78
aoqi@0 79 case T_BYTE:
aoqi@0 80 ftype = &ffi_type_sint8;
aoqi@0 81 break;
aoqi@0 82
aoqi@0 83 case T_SHORT:
aoqi@0 84 ftype = &ffi_type_sint16;
aoqi@0 85 break;
aoqi@0 86
aoqi@0 87 case T_INT:
aoqi@0 88 ftype = &ffi_type_sint32;
aoqi@0 89 break;
aoqi@0 90
aoqi@0 91 case T_LONG:
aoqi@0 92 ftype = &ffi_type_sint64;
aoqi@0 93 break;
aoqi@0 94
aoqi@0 95 case T_FLOAT:
aoqi@0 96 ftype = &ffi_type_float;
aoqi@0 97 break;
aoqi@0 98
aoqi@0 99 case T_DOUBLE:
aoqi@0 100 ftype = &ffi_type_double;
aoqi@0 101 break;
aoqi@0 102
aoqi@0 103 case T_OBJECT:
aoqi@0 104 case T_ARRAY:
aoqi@0 105 ftype = &ffi_type_pointer;
aoqi@0 106 break;
aoqi@0 107
aoqi@0 108 default:
aoqi@0 109 ShouldNotReachHere();
aoqi@0 110 }
aoqi@0 111 push((intptr_t) ftype);
aoqi@0 112 }
aoqi@0 113
aoqi@0 114 // For fast signature handlers the "signature handler" is generated
aoqi@0 115 // into a temporary buffer. It is then copied to its final location,
aoqi@0 116 // and pd_set_handler is called on it. We have this two stage thing
aoqi@0 117 // to accomodate this.
aoqi@0 118
aoqi@0 119 void InterpreterRuntime::SignatureHandlerGeneratorBase::generate(
aoqi@0 120 uint64_t fingerprint) {
aoqi@0 121
aoqi@0 122 // Build the argument types list
aoqi@0 123 pass_object();
aoqi@0 124 if (method()->is_static())
aoqi@0 125 pass_object();
aoqi@0 126 iterate(fingerprint);
aoqi@0 127
aoqi@0 128 // Tack on the result type
aoqi@0 129 push(method()->result_type());
aoqi@0 130 }
aoqi@0 131
aoqi@0 132 void InterpreterRuntime::SignatureHandler::finalize() {
aoqi@0 133 ffi_status status =
aoqi@0 134 ffi_prep_cif(cif(),
aoqi@0 135 FFI_DEFAULT_ABI,
aoqi@0 136 argument_count(),
aoqi@0 137 result_type(),
aoqi@0 138 argument_types());
aoqi@0 139
aoqi@0 140 assert(status == FFI_OK, "should be");
aoqi@0 141 }
aoqi@0 142
aoqi@0 143 IRT_ENTRY(address,
aoqi@0 144 InterpreterRuntime::slow_signature_handler(JavaThread* thread,
aoqi@0 145 Method* method,
aoqi@0 146 intptr_t* unused1,
aoqi@0 147 intptr_t* unused2))
aoqi@0 148 ZeroStack *stack = thread->zero_stack();
aoqi@0 149
aoqi@0 150 int required_words =
aoqi@0 151 (align_size_up(sizeof(ffi_cif), wordSize) >> LogBytesPerWord) +
aoqi@0 152 (method->is_static() ? 2 : 1) + method->size_of_parameters() + 1;
aoqi@0 153
aoqi@0 154 stack->overflow_check(required_words, CHECK_NULL);
aoqi@0 155
aoqi@0 156 intptr_t *buf = (intptr_t *) stack->alloc(required_words * wordSize);
aoqi@0 157 SlowSignatureHandlerGenerator sshg(methodHandle(thread, method), buf);
aoqi@0 158 sshg.generate(UCONST64(-1));
aoqi@0 159
aoqi@0 160 SignatureHandler *handler = sshg.handler();
aoqi@0 161 handler->finalize();
aoqi@0 162
aoqi@0 163 return (address) handler;
aoqi@0 164 IRT_END
aoqi@0 165
aoqi@0 166 void SignatureHandlerLibrary::pd_set_handler(address handlerAddr) {
aoqi@0 167 InterpreterRuntime::SignatureHandler *handler =
aoqi@0 168 InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);
aoqi@0 169
aoqi@0 170 handler->finalize();
aoqi@0 171 }

mercurial