1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/cpu/zero/vm/interpreterRT_zero.hpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,134 @@ 1.4 +/* 1.5 + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright 2007, 2008 Red Hat, Inc. 1.7 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 + * 1.9 + * This code is free software; you can redistribute it and/or modify it 1.10 + * under the terms of the GNU General Public License version 2 only, as 1.11 + * published by the Free Software Foundation. 1.12 + * 1.13 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.14 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.15 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.16 + * version 2 for more details (a copy is included in the LICENSE file that 1.17 + * accompanied this code). 1.18 + * 1.19 + * You should have received a copy of the GNU General Public License version 1.20 + * 2 along with this work; if not, write to the Free Software Foundation, 1.21 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.22 + * 1.23 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.24 + * or visit www.oracle.com if you need additional information or have any 1.25 + * questions. 1.26 + * 1.27 + */ 1.28 + 1.29 +#ifndef CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP 1.30 +#define CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP 1.31 + 1.32 +#include "memory/allocation.hpp" 1.33 + 1.34 +class SignatureHandler { 1.35 + public: 1.36 + static SignatureHandler *from_handlerAddr(address handlerAddr) { 1.37 + return (SignatureHandler *) handlerAddr; 1.38 + } 1.39 + 1.40 + public: 1.41 + ffi_cif* cif() const { 1.42 + return (ffi_cif *) this; 1.43 + } 1.44 + 1.45 + int argument_count() const { 1.46 + return cif()->nargs; 1.47 + } 1.48 + 1.49 + ffi_type** argument_types() const { 1.50 + return (ffi_type**) (cif() + 1); 1.51 + } 1.52 + 1.53 + ffi_type* argument_type(int i) const { 1.54 + return argument_types()[i]; 1.55 + } 1.56 + 1.57 + ffi_type* result_type() const { 1.58 + return *(argument_types() + argument_count()); 1.59 + } 1.60 + 1.61 + protected: 1.62 + friend class InterpreterRuntime; 1.63 + friend class SignatureHandlerLibrary; 1.64 + 1.65 + void finalize(); 1.66 +}; 1.67 + 1.68 +class SignatureHandlerGeneratorBase : public NativeSignatureIterator { 1.69 + private: 1.70 + ffi_cif* _cif; 1.71 + 1.72 + protected: 1.73 + SignatureHandlerGeneratorBase(methodHandle method, ffi_cif *cif) 1.74 + : NativeSignatureIterator(method), _cif(cif) { 1.75 + _cif->nargs = 0; 1.76 + } 1.77 + 1.78 + ffi_cif *cif() const { 1.79 + return _cif; 1.80 + } 1.81 + 1.82 + public: 1.83 + void generate(uint64_t fingerprint); 1.84 + 1.85 + private: 1.86 + void pass_int(); 1.87 + void pass_long(); 1.88 + void pass_float(); 1.89 + void pass_double(); 1.90 + void pass_object(); 1.91 + 1.92 + private: 1.93 + void push(BasicType type); 1.94 + virtual void push(intptr_t value) = 0; 1.95 +}; 1.96 + 1.97 +class SignatureHandlerGenerator : public SignatureHandlerGeneratorBase { 1.98 + private: 1.99 + CodeBuffer* _cb; 1.100 + 1.101 + public: 1.102 + SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer) 1.103 + : SignatureHandlerGeneratorBase(method, (ffi_cif *) buffer->insts_end()), 1.104 + _cb(buffer) { 1.105 + _cb->set_insts_end((address) (cif() + 1)); 1.106 + } 1.107 + 1.108 + private: 1.109 + void push(intptr_t value) { 1.110 + intptr_t *dst = (intptr_t *) _cb->insts_end(); 1.111 + _cb->set_insts_end((address) (dst + 1)); 1.112 + *dst = value; 1.113 + } 1.114 +}; 1.115 + 1.116 +class SlowSignatureHandlerGenerator : public SignatureHandlerGeneratorBase { 1.117 + private: 1.118 + intptr_t *_dst; 1.119 + 1.120 + public: 1.121 + SlowSignatureHandlerGenerator(methodHandle method, intptr_t* buf) 1.122 + : SignatureHandlerGeneratorBase(method, (ffi_cif *) buf) { 1.123 + _dst = (intptr_t *) (cif() + 1); 1.124 + } 1.125 + 1.126 + private: 1.127 + void push(intptr_t value) { 1.128 + *(_dst++) = value; 1.129 + } 1.130 + 1.131 + public: 1.132 + SignatureHandler *handler() const { 1.133 + return (SignatureHandler *) cif(); 1.134 + } 1.135 +}; 1.136 + 1.137 +#endif // CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP