src/cpu/zero/vm/interpreterRT_zero.hpp

Wed, 22 Jan 2014 17:42:23 -0800

author
kvn
date
Wed, 22 Jan 2014 17:42:23 -0800
changeset 6503
a9becfeecd1b
parent 2314
f95d63e2154a
child 6876
710a3c8b516e
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2007, 2008 Red Hat, Inc.
     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 #ifndef CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP
    27 #define CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP
    29 #include "memory/allocation.hpp"
    31 class SignatureHandler {
    32  public:
    33   static SignatureHandler *from_handlerAddr(address handlerAddr) {
    34     return (SignatureHandler *) handlerAddr;
    35   }
    37  public:
    38   ffi_cif* cif() const {
    39     return (ffi_cif *) this;
    40   }
    42   int argument_count() const {
    43     return cif()->nargs;
    44   }
    46   ffi_type** argument_types() const {
    47     return (ffi_type**) (cif() + 1);
    48   }
    50   ffi_type* argument_type(int i) const {
    51     return argument_types()[i];
    52   }
    54   ffi_type* result_type() const {
    55     return *(argument_types() + argument_count());
    56   }
    58  protected:
    59   friend class InterpreterRuntime;
    60   friend class SignatureHandlerLibrary;
    62   void finalize();
    63 };
    65 class SignatureHandlerGeneratorBase : public NativeSignatureIterator {
    66  private:
    67   ffi_cif* _cif;
    69  protected:
    70   SignatureHandlerGeneratorBase(methodHandle method, ffi_cif *cif)
    71     : NativeSignatureIterator(method), _cif(cif) {
    72     _cif->nargs = 0;
    73   }
    75   ffi_cif *cif() const {
    76     return _cif;
    77   }
    79  public:
    80   void generate(uint64_t fingerprint);
    82  private:
    83   void pass_int();
    84   void pass_long();
    85   void pass_float();
    86   void pass_double();
    87   void pass_object();
    89  private:
    90   void push(BasicType type);
    91   virtual void push(intptr_t value) = 0;
    92 };
    94 class SignatureHandlerGenerator : public SignatureHandlerGeneratorBase {
    95  private:
    96   CodeBuffer* _cb;
    98  public:
    99   SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer)
   100     : SignatureHandlerGeneratorBase(method, (ffi_cif *) buffer->insts_end()),
   101       _cb(buffer) {
   102     _cb->set_insts_end((address) (cif() + 1));
   103   }
   105  private:
   106   void push(intptr_t value) {
   107     intptr_t *dst = (intptr_t *) _cb->insts_end();
   108     _cb->set_insts_end((address) (dst + 1));
   109     *dst = value;
   110   }
   111 };
   113 class SlowSignatureHandlerGenerator : public SignatureHandlerGeneratorBase {
   114  private:
   115   intptr_t *_dst;
   117  public:
   118   SlowSignatureHandlerGenerator(methodHandle method, intptr_t* buf)
   119     : SignatureHandlerGeneratorBase(method, (ffi_cif *) buf) {
   120     _dst = (intptr_t *) (cif() + 1);
   121   }
   123  private:
   124   void push(intptr_t value) {
   125     *(_dst++) = value;
   126   }
   128  public:
   129   SignatureHandler *handler() const {
   130     return (SignatureHandler *) cif();
   131   }
   132 };
   134 #endif // CPU_ZERO_VM_INTERPRETERRT_ZERO_HPP

mercurial