[vmkit-commits] [vmkit] r197822 - a safepoint now references its function name directly in the object file
Gael Thomas
gael.thomas at lip6.fr
Fri Dec 20 10:04:53 PST 2013
Author: gthomas
Date: Fri Dec 20 12:04:53 2013
New Revision: 197822
URL: http://llvm.org/viewvc/llvm-project?rev=197822&view=rev
Log:
a safepoint now references its function name directly in the object file
Modified:
vmkit/branches/mcjit/include/vmkit/safepoint.h
vmkit/branches/mcjit/lib/vmkit/compiler.cc
vmkit/branches/mcjit/lib/vmkit/safpoint.cc
Modified: vmkit/branches/mcjit/include/vmkit/safepoint.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/safepoint.h?rev=197822&r1=197821&r2=197822&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/vmkit/safepoint.h (original)
+++ vmkit/branches/mcjit/include/vmkit/safepoint.h Fri Dec 20 12:04:53 2013
@@ -12,22 +12,22 @@ namespace vmkit {
class Safepoint { /* directly in the data sections */
uintptr_t _addr;
- void* _code;
+ const char* _functionName;
CompilationUnit* _unit;
uint32_t _sourceIndex;
uint32_t _nbLives;
public:
- void setUnit(CompilationUnit* unit) { _unit = unit; }
+ void setUnit(CompilationUnit* unit) { _unit = unit; }
- uintptr_t addr() { return _addr; }
- void* code() { return _code; }
- uint32_t sourceIndex() { return _sourceIndex; }
- uint32_t nbLives() { return _nbLives; }
- uint32_t liveAt(uint32_t i) { return ((uint32_t*)(this + 1))[i]; }
+ uintptr_t addr() { return _addr; }
+ const char* functionName() { return _functionName; }
+ uint32_t sourceIndex() { return _sourceIndex; }
+ uint32_t nbLives() { return _nbLives; }
+ uint32_t liveAt(uint32_t i) { return ((uint32_t*)(this + 1))[i]; }
- Safepoint* getNext();
- void dump();
+ Safepoint* getNext();
+ void dump();
static Safepoint* get(CompilationUnit* unit, llvm::Module* module);
};
Modified: vmkit/branches/mcjit/lib/vmkit/compiler.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/compiler.cc?rev=197822&r1=197821&r2=197822&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/compiler.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/compiler.cc Fri Dec 20 12:04:53 2013
@@ -144,6 +144,7 @@ void CompilationUnit::compileModule(llvm
while(sf->addr()) {
sf->setUnit(this);
vm()->addSafepoint(sf);
+
vm()->getSafepoint(sf->addr())->dump();
sf = sf->getNext();
}
Modified: vmkit/branches/mcjit/lib/vmkit/safpoint.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/safpoint.cc?rev=197822&r1=197821&r2=197822&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/safpoint.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/safpoint.cc Fri Dec 20 12:04:53 2013
@@ -93,10 +93,31 @@ bool VmkitGCPass::findCustomSafePoints(l
* VmkitGCMetadataPrinter
*/
void VmkitGCMetadataPrinter::finishAssembly(llvm::AsmPrinter &AP) {
- AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
-
unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(0);
+ uint32_t i = 0;
+ AP.OutStreamer.AddComment("--- function names for the frame tables ---");
+ AP.OutStreamer.AddBlankLine();
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getSectionForConstant(llvm::SectionKind::getMergeable1ByteCString()));
+ for (iterator I = begin(), IE = end(); I != IE; ++I, i++) {
+ llvm::GCFunctionInfo* gcInfo = *I;
+ if(gcInfo->getFunction().hasGC()) {
+ llvm::SmallString<256> id("gcFunc");
+ id += i;
+
+ llvm::MCSymbol *sym = AP.OutContext.GetOrCreateSymbol(id);
+ AP.OutStreamer.EmitLabel(sym);
+
+ llvm::StringRef ref = gcInfo->getFunction().getName();
+ uint32_t len = ref.size();
+ for(uint32_t n=0; n<len; n++)
+ AP.EmitInt8(ref.data()[n]);
+ AP.EmitInt8(0);
+ }
+ }
+
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
+
fprintf(stderr, "generating frame tables for: %s\n", getModule().getModuleIdentifier().c_str());
llvm::SmallString<256> symName("_");
symName += getModule().getModuleIdentifier();
@@ -111,12 +132,19 @@ void VmkitGCMetadataPrinter::finishAssem
AP.OutStreamer.AddBlankLine();
AP.OutStreamer.EmitLabel(sym);
- for (iterator I = begin(), IE = end(); I != IE; ++I) {
+ i = 0;
+ for (iterator I = begin(), IE = end(); I != IE; ++I, i++) {
llvm::GCFunctionInfo* gcInfo = *I;
if(gcInfo->getFunction().hasGC()) {
AP.OutStreamer.AddComment("live roots for " + llvm::Twine(gcInfo->getFunction().getName()));
AP.OutStreamer.AddBlankLine();
+
+ llvm::SmallString<256> id("gcFunc");
+ id += i;
+
+ const llvm::MCExpr* funcName = llvm::MCSymbolRefExpr::Create(AP.OutContext.GetOrCreateSymbol(id), AP.OutStreamer.getContext());
+
for(llvm::GCFunctionInfo::iterator safepoint=gcInfo->begin(); safepoint!=gcInfo->end(); safepoint++) {
llvm::DebugLoc* debug = &safepoint->Loc;
uint32_t kind = safepoint->Kind;
@@ -128,7 +156,8 @@ void VmkitGCMetadataPrinter::finishAssem
}
AP.OutStreamer.EmitValue(address, IntPtrSize);
- AP.EmitGlobalConstant(&gcInfo->getFunction());
+ AP.OutStreamer.EmitValue(funcName, IntPtrSize);
+ // AP.EmitGlobalConstant(&gcInfo->getFunction());
AP.EmitInt32(0);
if(IntPtrSize == 8)
AP.EmitInt32(0);
@@ -163,7 +192,7 @@ Safepoint* Safepoint::get(CompilationUni
}
void Safepoint::dump() {
- fprintf(stderr, " [%p] safepoint at 0x%lx for function %p::%d\n", this, addr(), code(), sourceIndex());
+ fprintf(stderr, " [%p] safepoint at 0x%lx for %s::%d\n", this, addr(), functionName(), sourceIndex());
for(uint32_t i=0; i<nbLives(); i++)
fprintf(stderr, " live at %d\n", liveAt(i));
}
More information about the vmkit-commits
mailing list