f785676f2a
all of the features in the current working draft of the upcoming C++ standard, provisionally named C++1y. The code generator's performance is greatly increased, and the loop auto-vectorizer is now enabled at -Os and -O2 in addition to -O3. The PowerPC backend has made several major improvements to code generation quality and compile time, and the X86, SPARC, ARM32, Aarch64 and SystemZ backends have all seen major feature work. Release notes for llvm and clang can be found here: <http://llvm.org/releases/3.4/docs/ReleaseNotes.html> <http://llvm.org/releases/3.4/tools/clang/docs/ReleaseNotes.html> MFC after: 1 month
93 lines
2.6 KiB
C++
93 lines
2.6 KiB
C++
//===- RemoteTarget.cpp - LLVM Remote process JIT execution --------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Implementation of the RemoteTarget class which executes JITed code in a
|
|
// separate address range from where it was built.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "RemoteTarget.h"
|
|
#include "RemoteTargetExternal.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/Support/DataTypes.h"
|
|
#include "llvm/Support/Memory.h"
|
|
#include <stdlib.h>
|
|
#include <string>
|
|
|
|
using namespace llvm;
|
|
|
|
// Static methods
|
|
RemoteTarget *RemoteTarget::createRemoteTarget() {
|
|
return new RemoteTarget;
|
|
}
|
|
|
|
RemoteTarget *RemoteTarget::createExternalRemoteTarget(std::string &ChildName) {
|
|
#ifdef LLVM_ON_UNIX
|
|
return new RemoteTargetExternal(ChildName);
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
bool RemoteTarget::hostSupportsExternalRemoteTarget() {
|
|
#ifdef LLVM_ON_UNIX
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
// Simulated remote execution
|
|
//
|
|
// This implementation will simply move generated code and data to a new memory
|
|
// location in the current executable and let it run from there.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool RemoteTarget::allocateSpace(size_t Size, unsigned Alignment,
|
|
uint64_t &Address) {
|
|
sys::MemoryBlock *Prev = Allocations.size() ? &Allocations.back() : NULL;
|
|
sys::MemoryBlock Mem = sys::Memory::AllocateRWX(Size, Prev, &ErrorMsg);
|
|
if (Mem.base() == NULL)
|
|
return true;
|
|
if ((uintptr_t)Mem.base() % Alignment) {
|
|
ErrorMsg = "unable to allocate sufficiently aligned memory";
|
|
return true;
|
|
}
|
|
Address = reinterpret_cast<uint64_t>(Mem.base());
|
|
return false;
|
|
}
|
|
|
|
bool RemoteTarget::loadData(uint64_t Address, const void *Data, size_t Size) {
|
|
memcpy ((void*)Address, Data, Size);
|
|
return false;
|
|
}
|
|
|
|
bool RemoteTarget::loadCode(uint64_t Address, const void *Data, size_t Size) {
|
|
memcpy ((void*)Address, Data, Size);
|
|
sys::MemoryBlock Mem((void*)Address, Size);
|
|
sys::Memory::setExecutable(Mem, &ErrorMsg);
|
|
return false;
|
|
}
|
|
|
|
bool RemoteTarget::executeCode(uint64_t Address, int &RetVal) {
|
|
int (*fn)(void) = (int(*)(void))Address;
|
|
RetVal = fn();
|
|
return false;
|
|
}
|
|
|
|
void RemoteTarget::create() {
|
|
}
|
|
|
|
void RemoteTarget::stop() {
|
|
for (unsigned i = 0, e = Allocations.size(); i != e; ++i)
|
|
sys::Memory::ReleaseRWX(Allocations[i]);
|
|
}
|