Cleanup the code.
llvm-svn: 200851
diff --git a/vmkit/include/j3/j3codegen.h b/vmkit/include/j3/j3codegen.h
index ee0c872..bc76ce2 100644
--- a/vmkit/include/j3/j3codegen.h
+++ b/vmkit/include/j3/j3codegen.h
@@ -132,7 +132,6 @@
void monitorExit(llvm::Value* obj);
llvm::CallInst* isAssignableTo(llvm::Value* obj, J3ObjectType* type);
- void inlineCall(llvm::CallInst* call);
void instanceof(llvm::Value* obj, J3ObjectType* type);
void checkCast(llvm::Value* obj, J3ObjectType* type);
@@ -177,7 +176,6 @@
void selectExceptionNode(uint32_t idx);
void translate();
- void z_translate();
void initExceptionNode(J3ExceptionNode** pnode, uint32_t pc, J3ExceptionNode* node);
void addToExceptionNode(J3ExceptionNode* node, J3ExceptionEntry* entry);
diff --git a/vmkit/include/j3/j3object.h b/vmkit/include/j3/j3object.h
index 8ec9b8b..581d838 100644
--- a/vmkit/include/j3/j3object.h
+++ b/vmkit/include/j3/j3object.h
@@ -112,18 +112,17 @@
J3Object(); /* never directly allocate an object */
+ static bool isUnlocked(uintptr_t header) __attribute__((always_inline)) { return (header & 7) == 1; }
+ static bool isInflated(uintptr_t header) __attribute__((always_inline)) { return (header & 3) == 2; }
+ static bool isStackLocked(uintptr_t header) __attribute__((always_inline)) { return !(header & 3); }
+ static J3LockRecord* asLockRecord(uintptr_t header) __attribute__((always_inline)) { return (J3LockRecord*)header; }
+ static J3Monitor* asMonitor(uintptr_t header) __attribute__((always_inline)) { return (J3Monitor*)(header & ~3); }
+
bool isLockOwner();
J3Monitor* inflate();
uint32_t hashCode();
-
- static bool isUnlocked(uintptr_t header) { return (header & 7) == 1; }
- static bool isInflated(uintptr_t header) { return (header & 3) == 2; }
- static bool isStackLocked(uintptr_t header) { return !(header & 3); }
- static J3LockRecord* asLockRecord(uintptr_t header) { return (J3LockRecord*)header; }
- static J3Monitor* asMonitor(uintptr_t header) { return (J3Monitor*)(header & ~3); }
-
- void monitorEnter(J3LockRecord* lockRecord) __attribute__((always_inline));
- void monitorExit() __attribute__((always_inline));
+ void monitorEnter(J3LockRecord* lockRecord) __attribute__((always_inline));
+ void monitorExit() __attribute__((always_inline));
static J3Object* allocate(J3VirtualTable* vt, uintptr_t n);
static J3Object* doNew(J3Class* cl);
diff --git a/vmkit/include/vmkit/thread.h b/vmkit/include/vmkit/thread.h
index 3dc8d80..c6e7a54 100644
--- a/vmkit/include/vmkit/thread.h
+++ b/vmkit/include/vmkit/thread.h
@@ -33,9 +33,9 @@
VMKit* vm() { return _vm; }
- static uintptr_t getThreadMask();
- static Thread* get(void* ptr);
- static Thread* get();
+ static uintptr_t getThreadMask() __attribute__((always_inline));
+ static Thread* get(void* ptr) __attribute__((always_inline));
+ static Thread* get() __attribute__((always_inline));
bool registerSignal(int n, sa_action_t handler);
diff --git a/vmkit/lib/j3/vm/j3codegen.cc b/vmkit/lib/j3/vm/j3codegen.cc
index 8d76eb3..b759d29 100644
--- a/vmkit/lib/j3/vm/j3codegen.cc
+++ b/vmkit/lib/j3/vm/j3codegen.cc
@@ -357,7 +357,7 @@
J3Method* target = cl->methodAt(idx, 0);
if(J3Cst::isFinal(target->cl()->access()) || J3Cst::isFinal(target->cl()->access()))
- invoke(0, target, buildFunction(target)); /* do not remove this optimization */
+ invoke(0, target, buildFunction(target)); /* do not remove this optimization, mandatory for mmtk */
else {
J3Signature* type = target->signature();
llvm::Value* funcEntry = funcEntry = builder.getInt32(target->index());
@@ -536,11 +536,6 @@
vtType);
}
-void J3CodeGen::inlineCall(llvm::CallInst* call) {
- //llvm::InlineFunctionInfo ifi;
- //llvm::InlineFunction(call, ifi, 0);
-}
-
void J3CodeGen::instanceof(llvm::Value* obj, J3ObjectType* type) {
llvm::BasicBlock* after = forwardBranch("instanceof-after", codeReader->tell(), 0, 0);
llvm::BasicBlock* nok = newBB("instanceof-null");
@@ -557,7 +552,6 @@
llvm::CallInst* is = isAssignableTo(obj, type);
stack.push(builder.CreateZExt(is, builder.getInt32Ty()));
builder.CreateBr(after);
- inlineCall(is);
}
void J3CodeGen::checkCast(llvm::Value* obj, J3ObjectType* type) {
@@ -578,7 +572,6 @@
llvm::CallInst* is = isAssignableTo(obj, type);
builder.CreateCondBr(is, succeed, bbCheckCastFailed);
- inlineCall(is);
}
}
@@ -1558,39 +1551,6 @@
}
#endif
-void J3CodeGen::z_translate() {
- bbRet = newBB("ret");
- llvm::BasicBlock* landingPad = newBB("landing-pad");
- llvm::Value* val = builder.CreateIntToPtr(llvm::ConstantInt::get(uintPtrTy, (uintptr_t)0x42),
- vm->typeJ3ObjectPtr);
- builder.CreateInvoke(funcThrowException, bbRet, landingPad,
- builder.CreateBitCast(val, funcThrowException->getFunctionType()->getParamType(0)));
-
- builder.SetInsertPoint(landingPad);
- llvm::LandingPadInst *caughtResult = builder.CreateLandingPad(vm->typeGXXException,
- funcGXXPersonality,
- 1,
- "landing-pad");
- caughtResult->addClause(gvTypeInfo);
-
- llvm::Value* excp = builder.CreateBitCast(builder.CreateCall(funcCXABeginCatch,
- builder.CreateExtractValue(caughtResult, 0)),
- vm->typeJ3ObjectPtr);
-
- builder.CreateCall(funcCXAEndCatch);
-
- builder.CreateCall3(funcEchoDebugExecute,
- builder.getInt32(-1), /* just to see my first exception :) */
- buildString("catching exception %p!\n"),
- excp);
- builder.CreateBr(bbRet);
-
- builder.SetInsertPoint(bbRet);
- builder.CreateRetVoid();
-
- llvmFunction->dump();
-}
-
void J3CodeGen::generateJava() {
llvm::BasicBlock* entry = newBB("entry");
builder.SetInsertPoint(entry);
diff --git a/vmkit/lib/j3/vm/j3codegenexception.cc b/vmkit/lib/j3/vm/j3codegenexception.cc
index 8a079fc..ad369c2 100644
--- a/vmkit/lib/j3/vm/j3codegenexception.cc
+++ b/vmkit/lib/j3/vm/j3codegenexception.cc
@@ -59,7 +59,6 @@
llvm::CallInst* is = codeGen->isAssignableTo(codeGen->stack.top(0),
codeGen->cl->classAt(entry->catchType));
codeGen->builder.CreateCondBr(is, entry->bb, curCheck);
- codeGen->inlineCall(is);
} else {
codeGen->builder.CreateBr(entry->bb);
curCheck = 0;
diff --git a/vmkit/lib/vmkit/inliner.cc b/vmkit/lib/vmkit/inliner.cc
index 086f924..e223988 100644
--- a/vmkit/lib/vmkit/inliner.cc
+++ b/vmkit/lib/vmkit/inliner.cc
@@ -261,6 +261,6 @@
#endif
llvm::FunctionPass* createFunctionInlinerPass(CompilationUnit* compiler, bool onlyAlwaysInline) {
- return new FunctionInlinerPass(compiler, 25*256, onlyAlwaysInline); /* aka 25 instructions */
+ return new FunctionInlinerPass(compiler, 50*256, onlyAlwaysInline); /* aka 50 llvm instructions */
}
}