[vmkit-commits] [vmkit] r198294 - Only generate caller gate on demand
Gael Thomas
gael.thomas at lip6.fr
Thu Jan 2 01:37:27 PST 2014
Author: gthomas
Date: Thu Jan 2 03:37:27 2014
New Revision: 198294
URL: http://llvm.org/viewvc/llvm-project?rev=198294&view=rev
Log:
Only generate caller gate on demand
Modified:
vmkit/branches/mcjit/include/j3/j3codegen.h
vmkit/branches/mcjit/include/j3/j3method.h
vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
vmkit/branches/mcjit/lib/j3/vm/j3method.cc
vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc
Modified: vmkit/branches/mcjit/include/j3/j3codegen.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegen.h?rev=198294&r1=198293&r2=198294&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3codegen.h (original)
+++ vmkit/branches/mcjit/include/j3/j3codegen.h Thu Jan 2 03:37:27 2014
@@ -176,13 +176,13 @@ namespace j3 {
llvm::Function* patchPoint64;
llvm::Function* patchPointVoid;
- J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* method);
+ J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* method, bool withMethod, bool withCaller);
~J3CodeGen();
void* operator new(size_t n, vmkit::BumpAllocator* _allocator);
void operator delete(void* ptr);
public:
- static void translate(J3Method* method);
+ static void translate(J3Method* method, bool withMethod=1, bool withCaller=1);
};
}
Modified: vmkit/branches/mcjit/include/j3/j3method.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=198294&r1=198293&r2=198294&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3method.h (original)
+++ vmkit/branches/mcjit/include/j3/j3method.h Thu Jan 2 03:37:27 2014
@@ -118,7 +118,7 @@ namespace j3 {
J3Value invokeVirtual(J3ObjectHandle* obj, J3Value* args);
J3Value invokeVirtual(J3ObjectHandle* obj, va_list va);
- void* fnPtr();
+ void* fnPtr(bool withCaller);
void* functionPointerOrStaticTrampoline();
void* functionPointerOrVirtualTrampoline();
Modified: vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc?rev=198294&r1=198293&r2=198294&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Thu Jan 2 03:37:27 2014
@@ -28,7 +28,7 @@ using namespace j3;
#define _onEndPoint() ({ if(onEndPoint()) return; })
-J3CodeGen::J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* m) :
+J3CodeGen::J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* m, bool withMethod, bool withCaller) :
exceptions(this) {
allocator = _allocator;
@@ -94,26 +94,30 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
->CreateIntToPtr(llvm::ConstantInt::get(uintPtrTy, (uintptr_t)0),
vm->typeJ3ObjectPtr);
- if(J3Cst::isNative(method->access()))
- generateNative();
- else
- generateJava();
+ if(withMethod) {
+ if(J3Cst::isNative(method->access()))
+ generateNative();
+ else
+ generateJava();
- if(vm->options()->debugTranslate > 3)
- llvmFunction->dump();
+ if(vm->options()->debugTranslate > 3)
+ llvmFunction->dump();
+ }
- if(!methodType->llvmSignature()->caller())
+ if(withCaller && !methodType->llvmSignature()->caller())
methodType->llvmSignature()->generateCallerIR(this, module, "generic-caller");
loader->compileModule(module);
- void* fnPtr = (void*)loader->ee()->getFunctionAddress(llvmFunction->getName().data());
- if(!methodType->llvmSignature()->caller()) {
+ if(withCaller && !methodType->llvmSignature()->caller()) {
J3LLVMSignature::function_t caller = (J3LLVMSignature::function_t)loader->ee()->getFunctionAddress("generic-caller");
methodType->llvmSignature()->_caller = caller;
}
- method->markCompiled(llvmFunction, fnPtr);
+ if(withMethod) {
+ void* fnPtr = (void*)loader->ee()->getFunctionAddress(llvmFunction->getName().data());
+ method->markCompiled(llvmFunction, fnPtr);
+ }
}
J3CodeGen::~J3CodeGen() {
@@ -126,11 +130,11 @@ void* J3CodeGen::operator new(size_t n,
void J3CodeGen::operator delete(void* ptr) {
}
-void J3CodeGen::translate(J3Method* method) {
+void J3CodeGen::translate(J3Method* method, bool withMethod, bool withCaller) {
method->cl()->loader()->vm()->lockCompiler();
vmkit::BumpAllocator* allocator = vmkit::BumpAllocator::create();
- delete new(allocator) J3CodeGen(allocator, method);
+ delete new(allocator) J3CodeGen(allocator, method, withMethod, withCaller);
vmkit::BumpAllocator::destroy(allocator);
method->cl()->loader()->vm()->unlockCompiler();
Modified: vmkit/branches/mcjit/lib/j3/vm/j3method.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=198294&r1=198293&r2=198294&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Thu Jan 2 03:37:27 2014
@@ -50,7 +50,7 @@ void J3Method::markCompiled(llvm::Functi
_fnPtr = fnPtr;
}
-void* J3Method::fnPtr() {
+void* J3Method::fnPtr(bool withCaller) {
if(!isCompiled()) {
//fprintf(stderr, "materializing: %ls::%ls%ls\n", this, cl()->name()->cStr(), name()->cStr(), sign()->cStr());
if(!isResolved()) {
@@ -62,7 +62,7 @@ void* J3Method::fnPtr() {
J3::noSuchMethodError(L"unable to find method", cl(), name(), sign());
}
- J3CodeGen::translate(this);
+ J3CodeGen::translate(this, 1, withCaller);
}
return _fnPtr;
@@ -115,10 +115,13 @@ J3Method* J3Method::resolve(J3ObjectHand
J3Value J3Method::internalInvoke(bool statically, J3Value* inArgs) {
J3Method* target = statically ? this : resolve(inArgs[0].valObject);
- void* fn = fnPtr();
+ void* fn = fnPtr(1);
//fprintf(stderr, "Internal invoke %ls::%ls%ls\n", target->cl()->name()->cStr(), target->name()->cStr(), target->sign()->cStr());
+ if(!methodType()->llvmSignature()->caller())
+ J3CodeGen::translate(this, 0, 1);
+
J3Value res = methodType()->llvmSignature()->caller()(fn, inArgs);
return res;
Modified: vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc?rev=198294&r1=198293&r2=198294&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3trampoline.cc Thu Jan 2 03:37:27 2014
@@ -16,7 +16,7 @@ void* J3Trampoline::interfaceTrampoline(
void* res;
if(desc->nbMethods == 1) {
- res = desc->methods[0]->fnPtr();
+ res = desc->methods[0]->fnPtr(0);
handle->vt()->_interfaceMethodTable[index] = res;
} else
J3::internalError(L"implement me: interface Trampoline with collision");
@@ -27,7 +27,7 @@ void* J3Trampoline::interfaceTrampoline(
}
void* J3Trampoline::staticTrampoline(J3Object* obj, J3Method* target) {
- return target->fnPtr();
+ return target->fnPtr(0);
}
void* J3Trampoline::virtualTrampoline(J3Object* obj, J3Method* target) {
@@ -36,7 +36,7 @@ void* J3Trampoline::virtualTrampoline(J3
J3ObjectType* cl = handle->vt()->type()->asObjectType();
J3Method* impl = cl == target->cl() ? target : cl->findVirtualMethod(target->name(), target->sign());
- void* res = impl->fnPtr();
+ void* res = impl->fnPtr(0);
handle->vt()->virtualMethods()[impl->index()] = res;
J3Thread::get()->restore(prev);
More information about the vmkit-commits
mailing list