src/hotspot/share/shark/sharkMemoryManager.cpp
author jdv
Mon, 06 Nov 2017 13:11:51 +0530
changeset 47716 c9181704b389
parent 47216 71c04702a3d5
permissions -rw-r--r--
8189702: Broken links in javadoc for Adobe TIFF related documents Reviewed-by: prr, bpb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
     2
 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     3
 * Copyright 2009 Red Hat, Inc.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     5
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     8
 * published by the Free Software Foundation.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
     9
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    14
 * accompanied this code).
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    15
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    19
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    22
 * questions.
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    23
 *
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    24
 */
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    25
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    26
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    27
#include "shark/llvmHeaders.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    28
#include "shark/sharkEntry.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6187
diff changeset
    29
#include "shark/sharkMemoryManager.hpp"
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    30
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    31
using namespace llvm;
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    32
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    33
void SharkMemoryManager::AllocateGOT() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    34
  mm()->AllocateGOT();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    35
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    36
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    37
unsigned char* SharkMemoryManager::getGOTBase() const {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    38
  return mm()->getGOTBase();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    39
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    40
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    41
unsigned char* SharkMemoryManager::allocateStub(const GlobalValue* F,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    42
                                                unsigned StubSize,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    43
                                                unsigned Alignment) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    44
  return mm()->allocateStub(F, StubSize, Alignment);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    45
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    46
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    47
unsigned char* SharkMemoryManager::startFunctionBody(const Function* F,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    48
                                                     uintptr_t& ActualSize) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    49
  return mm()->startFunctionBody(F, ActualSize);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    50
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    51
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    52
void SharkMemoryManager::endFunctionBody(const Function* F,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    53
                                         unsigned char* FunctionStart,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    54
                                         unsigned char* FunctionEnd) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    55
  mm()->endFunctionBody(F, FunctionStart, FunctionEnd);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    56
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    57
  SharkEntry *entry = get_entry_for_function(F);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    58
  if (entry != NULL)
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    59
    entry->set_code_limit(FunctionEnd);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    60
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    61
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    62
void SharkMemoryManager::setMemoryWritable() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    63
  mm()->setMemoryWritable();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    64
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    65
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    66
void SharkMemoryManager::setMemoryExecutable() {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    67
  mm()->setMemoryExecutable();
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    68
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    69
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    70
void SharkMemoryManager::deallocateFunctionBody(void *ptr) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    71
  mm()->deallocateFunctionBody(ptr);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    72
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    73
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    74
uint8_t* SharkMemoryManager::allocateGlobal(uintptr_t Size,
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    75
                                            unsigned int Alignment) {
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    76
  return mm()->allocateGlobal(Size, Alignment);
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    77
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    78
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
    79
void* SharkMemoryManager::getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
    80
  return mm()->getPointerToNamedFunction(Name, AbortOnFailure);
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    81
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    82
23196
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    83
void SharkMemoryManager::setPoisonMemory(bool poison) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    84
  mm()->setPoisonMemory(poison);
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    85
}
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    86
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    87
unsigned char *SharkMemoryManager::allocateSpace(intptr_t Size,
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    88
                                                 unsigned int Alignment) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    89
  return mm()->allocateSpace(Size, Alignment);
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    90
}
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    91
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    92
#if SHARK_LLVM_VERSION <= 32
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
    93
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
    94
uint8_t* SharkMemoryManager::allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
    95
  return mm()->allocateCodeSection(Size, Alignment, SectionID);
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
    96
}
14622
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
    97
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
    98
uint8_t* SharkMemoryManager::allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID) {
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
    99
  return mm()->allocateDataSection(Size, Alignment, SectionID);
8e94e4186d35 8003868: fix shark for latest HotSpot and LLVM
twisti
parents: 7397
diff changeset
   100
}
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   101
23196
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   102
void SharkMemoryManager::deallocateExceptionTable(void *ptr) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   103
  mm()->deallocateExceptionTable(ptr);
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   104
}
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   105
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   106
unsigned char* SharkMemoryManager::startExceptionTable(const Function* F,
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   107
                                                       uintptr_t& ActualSize) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   108
  return mm()->startExceptionTable(F, ActualSize);
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   109
}
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   110
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   111
void SharkMemoryManager::endExceptionTable(const Function* F,
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   112
                                           unsigned char* TableStart,
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   113
                                           unsigned char* TableEnd,
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   114
                                           unsigned char* FrameRegister) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   115
  mm()->endExceptionTable(F, TableStart, TableEnd, FrameRegister);
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   116
}
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   117
23196
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   118
#else
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   119
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   120
uint8_t *SharkMemoryManager::allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   121
    return mm()->allocateCodeSection(Size, Alignment, SectionID, SectionName);
6187
4fa7845f7c14 6976186: integrate Shark HotSpot changes
twisti
parents:
diff changeset
   122
}
23196
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   123
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   124
uint8_t* SharkMemoryManager::allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName, bool IsReadOnly) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   125
  return mm()->allocateDataSection(Size, Alignment, SectionID, SectionName, IsReadOnly);
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   126
}
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   127
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   128
bool SharkMemoryManager::finalizeMemory(std::string *ErrMsg) {
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   129
    return mm()->finalizeMemory(ErrMsg);
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   130
}
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   131
7fb201976e8b 8036619: Shark: add LLVM 3.4 support
neugens
parents: 14622
diff changeset
   132
#endif