src/share/vm/shark/sharkMemoryManager.hpp

Wed, 11 Aug 2010 05:51:21 -0700

author
twisti
date
Wed, 11 Aug 2010 05:51:21 -0700
changeset 2047
d2ede61b7a12
child 2314
f95d63e2154a
permissions
-rw-r--r--

6976186: integrate Shark HotSpot changes
Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure.
Reviewed-by: kvn, twisti
Contributed-by: Gary Benson <gbenson@redhat.com>

     1 /*
     2  * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2009 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 // SharkMemoryManager wraps the LLVM JIT Memory Manager.  We could use
    27 // this to run our own memory allocation policies, but for now all we
    28 // use it for is figuring out where the resulting native code ended up.
    30 class SharkMemoryManager : public llvm::JITMemoryManager {
    31  public:
    32   SharkMemoryManager()
    33     : _mm(llvm::JITMemoryManager::CreateDefaultMemManager()) {}
    35  private:
    36   llvm::JITMemoryManager* _mm;
    38  private:
    39   llvm::JITMemoryManager* mm() const {
    40     return _mm;
    41   }
    43  private:
    44   std::map<const llvm::Function*, SharkEntry*> _entry_map;
    46  public:
    47   void set_entry_for_function(const llvm::Function* function,
    48                               SharkEntry*           entry) {
    49     _entry_map[function] = entry;
    50   }
    51   SharkEntry* get_entry_for_function(const llvm::Function* function) {
    52     return _entry_map[function];
    53   }
    55  public:
    56   void AllocateGOT();
    57   unsigned char* getGOTBase() const;
    58   unsigned char* allocateStub(const llvm::GlobalValue* F,
    59                               unsigned StubSize,
    60                               unsigned Alignment);
    61   unsigned char* startFunctionBody(const llvm::Function* F,
    62                                    uintptr_t& ActualSize);
    63   void endFunctionBody(const llvm::Function* F,
    64                        unsigned char* FunctionStart,
    65                        unsigned char* FunctionEnd);
    66   unsigned char* startExceptionTable(const llvm::Function* F,
    67                                      uintptr_t& ActualSize);
    68   void endExceptionTable(const llvm::Function* F,
    69                          unsigned char* TableStart,
    70                          unsigned char* TableEnd,
    71                          unsigned char* FrameRegister);
    72 #if SHARK_LLVM_VERSION < 27
    73   void* getDlsymTable() const;
    74   void SetDlsymTable(void *ptr);
    75 #endif
    76   void setPoisonMemory(bool);
    77   uint8_t* allocateGlobal(uintptr_t, unsigned int);
    78   void setMemoryWritable();
    79   void setMemoryExecutable();
    80 #if SHARK_LLVM_VERSION >= 27
    81   void deallocateExceptionTable(void *ptr);
    82   void deallocateFunctionBody(void *ptr);
    83 #else
    84   void deallocateMemForFunction(const llvm::Function* F);
    85 #endif
    86   unsigned char *allocateSpace(intptr_t Size,
    87                                unsigned int Alignment);
    88 };

mercurial