[vmkit-commits] [vmkit] r198218 - Lazily allocate the llvm type of a Java method.

Gael Thomas gael.thomas at lip6.fr
Mon Dec 30 08:49:31 PST 2013


Author: gthomas
Date: Mon Dec 30 10:49:31 2013
New Revision: 198218

URL: http://llvm.org/viewvc/llvm-project?rev=198218&view=rev
Log:
Lazily allocate the llvm type of a Java method.

Modified:
    vmkit/branches/mcjit/include/j3/j3method.h
    vmkit/branches/mcjit/lib/j3/vm/j3method.cc

Modified: vmkit/branches/mcjit/include/j3/j3method.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=198218&r1=198217&r2=198218&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3method.h (original)
+++ vmkit/branches/mcjit/include/j3/j3method.h Mon Dec 30 10:49:31 2013
@@ -28,15 +28,15 @@ namespace j3 {
 	class J3ObjectHandle;
 
 	class J3MethodType : public vmkit::PermanentObject {
-		llvm::FunctionType* _llvmType;
-		J3Type*             _out;
-		uint32_t            _nbIns;
-		J3Type*             _ins[1];
+		llvm::FunctionType* volatile _llvmType;
+		J3Type*                      _out;
+		uint32_t                     _nbIns;
+		J3Type*                      _ins[1];
 
 	public:
 		J3MethodType(J3Type** args, size_t nbArgs);
 
-		llvm::FunctionType* llvmType() { return _llvmType; }
+		llvm::FunctionType* llvmType();
 		uint32_t            nbIns() { return _nbIns; }
 		J3Type*             out() { return _out; }
 		J3Type*             ins(uint32_t idx) { return _ins[idx]; }

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=198218&r1=198217&r2=198218&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Mon Dec 30 10:49:31 2013
@@ -26,10 +26,16 @@ J3MethodType::J3MethodType(J3Type** args
 	_nbIns = nbArgs-1;
 	memcpy(_ins, args, (nbArgs-1)*sizeof(J3Type*));
 			
-	std::vector<llvm::Type*> in;
-	for(uint32_t i=0; i<nbIns(); i++)
-		in.push_back(ins(i)->llvmType());
-	_llvmType = llvm::FunctionType::get(out()->llvmType(), in, 0);
+}
+
+llvm::FunctionType* J3MethodType::llvmType() {
+	if(!_llvmType) {
+		std::vector<llvm::Type*> in;
+		for(uint32_t i=0; i<nbIns(); i++)
+			in.push_back(ins(i)->llvmType());
+		_llvmType = llvm::FunctionType::get(out()->llvmType(), in, 0);
+	}
+	return _llvmType;
 }
 
 J3Method::J3Method(uint16_t access, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) :





More information about the vmkit-commits mailing list