src/cpu/zero/vm/interpreterRT_zero.hpp

Thu, 27 May 2010 19:08:38 -0700

author
trims
date
Thu, 27 May 2010 19:08:38 -0700
changeset 1907
c18cbe5936b8
parent 1445
354d3184f6b2
child 2200
a222fcfba398
permissions
-rw-r--r--

6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair

     1 /*
     2  * Copyright (c) 2003, 2005, 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 class SignatureHandler {
    27  public:
    28   static SignatureHandler *from_handlerAddr(address handlerAddr) {
    29     return (SignatureHandler *) handlerAddr;
    30   }
    32  public:
    33   ffi_cif* cif() const {
    34     return (ffi_cif *) this;
    35   }
    37   int argument_count() const {
    38     return cif()->nargs;
    39   }
    41   ffi_type** argument_types() const {
    42     return (ffi_type**) (cif() + 1);
    43   }
    45   ffi_type* argument_type(int i) const {
    46     return argument_types()[i];
    47   }
    49   ffi_type* result_type() const {
    50     return *(argument_types() + argument_count());
    51   }
    53  protected:
    54   friend class InterpreterRuntime;
    55   friend class SignatureHandlerLibrary;
    57   void finalize();
    58 };
    60 class SignatureHandlerGeneratorBase : public NativeSignatureIterator {
    61  private:
    62   ffi_cif* _cif;
    64  protected:
    65   SignatureHandlerGeneratorBase(methodHandle method, ffi_cif *cif)
    66     : NativeSignatureIterator(method), _cif(cif) {
    67     _cif->nargs = 0;
    68   }
    70   ffi_cif *cif() const {
    71     return _cif;
    72   }
    74  public:
    75   void generate(uint64_t fingerprint);
    77  private:
    78   void pass_int();
    79   void pass_long();
    80   void pass_float();
    81   void pass_double();
    82   void pass_object();
    84  private:
    85   void push(BasicType type);
    86   virtual void push(intptr_t value) = 0;
    87 };
    89 class SignatureHandlerGenerator : public SignatureHandlerGeneratorBase {
    90  private:
    91   CodeBuffer* _cb;
    93  public:
    94   SignatureHandlerGenerator(methodHandle method, CodeBuffer* buffer)
    95     : SignatureHandlerGeneratorBase(method, (ffi_cif *) buffer->code_end()),
    96       _cb(buffer) {
    97     _cb->set_code_end((address) (cif() + 1));
    98   }
   100  private:
   101   void push(intptr_t value) {
   102     intptr_t *dst = (intptr_t *) _cb->code_end();
   103     _cb->set_code_end((address) (dst + 1));
   104     *dst = value;
   105   }
   106 };
   108 class SlowSignatureHandlerGenerator : public SignatureHandlerGeneratorBase {
   109  private:
   110   intptr_t *_dst;
   112  public:
   113   SlowSignatureHandlerGenerator(methodHandle method, intptr_t* buf)
   114     : SignatureHandlerGeneratorBase(method, (ffi_cif *) buf) {
   115     _dst = (intptr_t *) (cif() + 1);
   116   }
   118  private:
   119   void push(intptr_t value) {
   120     *(_dst++) = value;
   121   }
   123  public:
   124   SignatureHandler *handler() const {
   125     return (SignatureHandler *) cif();
   126   }
   127 };

mercurial