[vmkit-commits] [vmkit] r137016 - in /vmkit/trunk: include/j3/LLVMMaterializer.h include/mvm/MethodInfo.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMMaterializer.cpp lib/J3/VMCore/Jnjvm.cpp tools/vmjc/vmjc.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sat Aug 6 02:01:01 PDT 2011
Author: geoffray
Date: Sat Aug 6 04:01:01 2011
New Revision: 137016
URL: http://llvm.org/viewvc/llvm-project?rev=137016&view=rev
Log:
Remove -load-bc and the lazy llvm jit compiler.
Removed:
vmkit/trunk/include/j3/LLVMMaterializer.h
vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp
Modified:
vmkit/trunk/include/mvm/MethodInfo.h
vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
vmkit/trunk/tools/vmjc/vmjc.cpp
Removed: vmkit/trunk/include/j3/LLVMMaterializer.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMMaterializer.h?rev=137015&view=auto
==============================================================================
--- vmkit/trunk/include/j3/LLVMMaterializer.h (original)
+++ vmkit/trunk/include/j3/LLVMMaterializer.h (removed)
@@ -1,74 +0,0 @@
-//===---------- LLVMMaterializer.h - LLVM Materializer for J3 -------------===//
-//
-// The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef J3_LLVM_MATERIALIZER_H
-#define J3_LLVM_MATERIALIZER_H
-
-#include <llvm/GVMaterializer.h>
-
-#include "j3/JavaJITCompiler.h"
-
-namespace j3 {
-
-class LLVMMaterializer;
-
-struct CallbackInfo {
- Class* cl;
- uint16 index;
- bool stat;
-
- CallbackInfo(Class* c, uint32 i, bool s) :
- cl(c), index(i), stat(s) {}
-
-};
-
-class JavaLLVMLazyJITCompiler : public JavaJITCompiler {
-private:
- std::map<llvm::Function*, CallbackInfo> callbacks;
- typedef std::map<llvm::Function*, CallbackInfo>::iterator callback_iterator;
-
-public:
- llvm::GVMaterializer* TheMaterializer;
-
- virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign,
- bool stat, llvm::BasicBlock* insert);
- virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side);
-
- virtual JavaCompiler* Create(const std::string& ModuleID) {
- return new JavaLLVMLazyJITCompiler(ModuleID);
- }
-
- JavaLLVMLazyJITCompiler(const std::string& ModuleID);
-
- virtual ~JavaLLVMLazyJITCompiler();
-
- virtual void* loadMethod(void* handle, const char* symbol);
-
- friend class LLVMMaterializer;
-};
-
-class LLVMMaterializer : public llvm::GVMaterializer {
-public:
-
- JavaLLVMLazyJITCompiler* Comp;
- llvm::Module* TheModule;
-
- LLVMMaterializer(llvm::Module* M, JavaLLVMLazyJITCompiler* C);
-
- virtual bool Materialize(llvm::GlobalValue *GV, std::string *ErrInfo = 0);
- virtual bool isMaterializable(const llvm::GlobalValue*) const;
- virtual bool isDematerializable(const llvm::GlobalValue*) const {
- return false;
- }
- virtual bool MaterializeModule(llvm::Module*, std::string*) { return true; }
-};
-
-} // End j3 namespace
-
-#endif
Modified: vmkit/trunk/include/mvm/MethodInfo.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/MethodInfo.h?rev=137016&r1=137015&r2=137016&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/MethodInfo.h (original)
+++ vmkit/trunk/include/mvm/MethodInfo.h Sat Aug 6 04:01:01 2011
@@ -31,12 +31,6 @@
static void scan(uintptr_t closure, FrameInfo* FI, void* ip, void* addr);
- static void* isStub(void* ip, void* addr) {
- bool isStub = ((unsigned char*)ip)[0] == 0xCE;
- if (isStub) ip = ((void**)addr)[2];
- return ip;
- }
-
static uint32_t FrameInfoSize(uint32_t NumOffsets) {
uint32_t FrameInfoSize = sizeof(FrameInfo) + (NumOffsets - 1) * sizeof(int16_t);
if (FrameInfoSize & 2) {
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=137016&r1=137015&r2=137016&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Aug 6 04:01:01 2011
@@ -35,7 +35,6 @@
#include "j3/JavaJITCompiler.h"
#include "j3/J3Intrinsics.h"
-#include "j3/LLVMMaterializer.h"
using namespace j3;
using namespace llvm;
@@ -408,14 +407,6 @@
: JavaJITCompiler(ModuleID) {}
-static llvm::cl::opt<bool> LLVMLazy("llvm-lazy",
- cl::desc("Use LLVM lazy stubs"),
- cl::init(false));
-
JavaJITCompiler* JavaJITCompiler::CreateCompiler(const std::string& ModuleID) {
- // This is called for the first compiler.
- if (LLVMLazy) {
- return new JavaLLVMLazyJITCompiler(ModuleID);
- }
return new JavaJ3LazyJITCompiler(ModuleID);
}
Removed: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=137015&view=auto
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (removed)
@@ -1,186 +0,0 @@
-//===-------- LLVMMaterializer.cpp - LLVM Materializer for J3 -------------===//
-//
-// The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Constants.h"
-#include "llvm/Module.h"
-#include "llvm/ExecutionEngine/ExecutionEngine.h"
-
-#include "mvm/JIT.h"
-
-#include "JavaAccess.h"
-#include "JavaClass.h"
-#include "JavaConstantPool.h"
-#include "JavaThread.h"
-#include "JavaTypes.h"
-#include "Jnjvm.h"
-
-#include "j3/J3Intrinsics.h"
-#include "j3/LLVMMaterializer.h"
-
-using namespace llvm;
-using namespace j3;
-
-
-JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID)
- : JavaJITCompiler(ModuleID) {
- TheMaterializer = new LLVMMaterializer(TheModule, this);
- executionEngine->DisableLazyCompilation(false);
-}
-
-JavaLLVMLazyJITCompiler::~JavaLLVMLazyJITCompiler() {
- // The module already destroys the materializer.
-}
-
-void* JavaLLVMLazyJITCompiler::loadMethod(void* handle, const char* symbol) {
- Function* F = mvm::MvmModule::globalModule->getFunction(symbol);
- if (F) {
- void* res = executionEngine->getPointerToFunctionOrStub(F);
- return res;
- }
-
- return JavaCompiler::loadMethod(handle, symbol);
-}
-
-uintptr_t JavaLLVMLazyJITCompiler::getPointerOrStub(JavaMethod& meth,
- int side) {
- LLVMMethodInfo* LMI = getMethodInfo(&meth);
- Function* func = LMI->getMethod();
- return (uintptr_t)executionEngine->getPointerToFunctionOrStub(func);
-}
-
-static JavaMethod* staticLookup(CallbackInfo& F) {
- Class* caller = F.cl;
- uint16 index = F.index;
- bool isStatic = F.stat;
- JavaConstantPool* ctpInfo = caller->getConstantPool();
-
- CommonClass* cl = 0;
- const UTF8* utf8 = 0;
- Signdef* sign = 0;
-
- ctpInfo->resolveMethod(index, cl, utf8, sign);
- UserClass* lookup = cl->isArray() ? cl->super : cl->asClass();
- JavaMethod* meth = lookup->lookupMethod(utf8, sign->keyName, isStatic, true,
- 0);
-
- assert(lookup->isInitializing() && "Class not ready");
-
- return meth;
-}
-
-
-Value* JavaLLVMLazyJITCompiler::addCallback(Class* cl, uint16 index,
- Signdef* sign, bool stat,
- BasicBlock* insert) {
-
- Function* F = 0;
- LLVMSignatureInfo* LSI = getSignatureInfo(sign);
- mvm::ThreadAllocator allocator;
-
- const UTF8* name = cl->name;
- char* key = (char*)allocator.Allocate(name->size + 16);
- for (sint32 i = 0; i < name->size; ++i)
- key[i] = name->elements[i];
- sprintf(key + name->size, "%d", index);
- F = TheModule->getFunction(key);
- if (F) return F;
-
- FunctionType* type = stat ? LSI->getStaticType() :
- LSI->getVirtualType();
-
- F = Function::Create(type, GlobalValue::ExternalWeakLinkage, key, TheModule);
-
- CallbackInfo A(cl, index, stat);
- callbacks.insert(std::make_pair(F, A));
-
- return F;
-}
-
-
-bool LLVMMaterializer::Materialize(GlobalValue *GV, std::string *ErrInfo) {
-
- Function* F = dyn_cast<Function>(GV);
- assert(F && "Not a function");
- if (F->getLinkage() == GlobalValue::ExternalLinkage) return false;
-
- // The caller of materializeFunction *must* always hold the JIT lock.
- // Because we are materializing a function here, we must release the
- // JIT lock and get the global vmkit lock to be thread-safe.
- // This prevents jitting the function while someone else is doing it.
- Comp->executionEngine->lock.release();
- mvm::MvmModule::protectIR();
-
- // Don't use hasNotBeenReadFromBitcode: materializeFunction is called
- // by the pass manager, and we don't want another thread to JIT the
- // function while all passes have not been run.
- if (!(F->isDeclaration())) {
- mvm::MvmModule::unprotectIR();
- // TODO: Is this still valid?
- // Reacquire and go back to the JIT function.
- // mvm::MvmModule::executionEngine->lock.acquire();
- return false;
- }
-
- if (Comp->executionEngine->getPointerToGlobalIfAvailable(F)) {
- mvm::MvmModule::unprotectIR();
- // TODO: Is this still valid?
- // Reacquire and go back to the JIT function.
- // mvm::MvmModule::executionEngine->lock.acquire();
- return false;
- }
-
- JavaMethod* meth = Comp->getJavaMethod(*F);
-
- if (!meth) {
- // It's a callback
- JavaLLVMLazyJITCompiler::callback_iterator I = Comp->callbacks.find(F);
- assert(I != Comp->callbacks.end() && "No callbacks found");
- meth = staticLookup(I->second);
- }
-
- void* val = meth->compiledPtr();
-
- if (isVirtual(meth->access)) {
- LLVMMethodInfo* LMI = Comp->getMethodInfo(meth);
- uint64_t offset = dyn_cast<ConstantInt>(LMI->getOffset())->getZExtValue();
- assert(meth->classDef->isResolved() && "Class not resolved");
-#if !defined(ISOLATE_SHARING) && !defined(SERVICE)
- assert(meth->classDef->isInitializing() && "Class not ready");
-#endif
- assert(meth->classDef->virtualVT && "Class has no VT");
- assert(meth->classDef->virtualTableSize > offset &&
- "The method's offset is greater than the virtual table size");
- ((void**)meth->classDef->virtualVT)[offset] = val;
- } else {
- assert(meth->classDef->isInitializing() && "Class not ready");
- }
-
- mvm::MvmModule::unprotectIR();
-
- // TODO: Is this still valid?
- // Reacquire to go back to the JIT function.
- // mvm::MvmModule::executionEngine->lock.acquire();
-
- if (F->isDeclaration())
- Comp->executionEngine->updateGlobalMapping(F, val);
-
- return false;
-}
-
-bool LLVMMaterializer::isMaterializable(const llvm::GlobalValue* GV) const {
- return GV->getLinkage() == GlobalValue::ExternalWeakLinkage;
-}
-
-
-LLVMMaterializer::LLVMMaterializer(
- llvm::Module* m, JavaLLVMLazyJITCompiler* C) {
- Comp = C;
- TheModule = m;
- m->setMaterializer(this);
-}
Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=137016&r1=137015&r2=137016&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Sat Aug 6 04:01:01 2011
@@ -1446,20 +1446,17 @@
}
void Jnjvm::printMethod(mvm::FrameInfo* FI, void* ip, void* addr) {
- void* new_ip = NULL;
- if (ip) new_ip = mvm::MethodInfoHelper::isStub(ip, addr);
if (FI->Metadata == NULL) {
mvm::MethodInfoHelper::print(ip, addr);
return;
}
JavaMethod* meth = (JavaMethod*)FI->Metadata;
- fprintf(stderr, "; %p (%p) in %s.%s (line %d, bytecode %d, code start %p)", new_ip, addr,
+ fprintf(stderr, "; %p (%p) in %s.%s (line %d, bytecode %d, code start %p)", ip, addr,
UTF8Buffer(meth->classDef->name).cString(),
UTF8Buffer(meth->name).cString(),
meth->lookupLineNumber(FI),
FI->SourceIndex, meth->code);
- if (ip != new_ip) fprintf(stderr, " (from stub)");
fprintf(stderr, "\n");
}
Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=137016&r1=137015&r2=137016&view=diff
==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Sat Aug 6 04:01:01 2011
@@ -109,23 +109,6 @@
cl::CommaSeparated);
-static cl::list<std::string>
-LoadBytecodeFiles("load-bc", cl::desc("Load bytecode file"), cl::ZeroOrMore,
- cl::CommaSeparated);
-
-static void loadBytecodeFile(const std::string& str) {
- SMDiagnostic Err;
- Module* M = ParseIRFile(str, Err, mvm::MvmModule::globalModule->getContext());
- if (M) {
- M->setTargetTriple(mvm::MvmModule::getHostTriple());
- Linker::LinkModules(mvm::MvmModule::globalModule, M, 0);
- delete M;
- } else {
- Err.Print("load bytecode", errs());
- }
-}
-
-
int main(int argc, char **argv) {
llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "vmkit .class -> .ll compiler\n");
@@ -141,11 +124,6 @@
mvm::MvmModule::initialise();
- for (std::vector<std::string>::iterator i = LoadBytecodeFiles.begin(),
- e = LoadBytecodeFiles.end(); i != e; ++i) {
- loadBytecodeFile(*i);
- }
-
JavaAOTCompiler* Comp = new JavaAOTCompiler("AOT");
mvm::Collector::initialise();
More information about the vmkit-commits
mailing list