[vmkit-commits] [vmkit] r197811 - A lot of changes:
Gael Thomas
gael.thomas at lip6.fr
Fri Dec 20 05:43:30 PST 2013
Author: gthomas
Date: Fri Dec 20 07:43:29 2013
New Revision: 197811
URL: http://llvm.org/viewvc/llvm-project?rev=197811&view=rev
Log:
A lot of changes:
* add a configure option to link vmkit with a different llvm library. Usefull to use an optimized version of llvm for compilation and a debug version of llvm at runtime
* find safepoint intrinsics. Not very interesting as I don't use them for the moment.
* save mmx registers in the trampoline (was a bug).
* generate stack map directly in the section data with MCJIT through GCMetadatPrinter::finishAssembly.
* generate safepoint with MCJIT. Safepoint are just printed for the moment.
Modified:
vmkit/branches/mcjit/autoconf/configure.ac
vmkit/branches/mcjit/configure
vmkit/branches/mcjit/include/j3/j3codegen.h
vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc
vmkit/branches/mcjit/lib/j3/vm/j3method.cc
vmkit/branches/mcjit/lib/j3/vm/j3object.cc
vmkit/branches/mcjit/lib/j3/vm/j3options.cc
vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc
vmkit/branches/mcjit/lib/vmkit/vmkit.cc
Modified: vmkit/branches/mcjit/autoconf/configure.ac
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/autoconf/configure.ac?rev=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/autoconf/configure.ac (original)
+++ vmkit/branches/mcjit/autoconf/configure.ac Fri Dec 20 07:43:29 2013
@@ -160,17 +160,28 @@ if test ! -x "$LLVM_CONFIG"; then
AC_MSG_ERROR([Cannot find $LLVM_CONFIG (or not executable)])
fi
+AC_ARG_WITH(llvm-runtime-config-path,
+ [AS_HELP_STRING(--with-llvm-runtime-config-path=path,
+ [llvm-runtime-config path (use llvm-config-path)])],
+ [[LLVM_RUNTIME_CONFIG=$with_llvm_runtime_config_path]],
+ [[LLVM_RUNTIME_CONFIG="$LLVM_CONFIG"]]
+)
+
+if test ! -x "$LLVM_RUNTIME_CONFIG"; then
+ AC_MSG_ERROR([Cannot find $LLVM_RUNTIME_CONFIG (or not executable)])
+fi
+
LLVM_PATH="`$LLVM_CONFIG --bindir`"
-llvm_cfg=`$LLVM_CONFIG --cxxflags | sed -e 's/-O3//'`
+llvm_cfg=`$LLVM_RUNTIME_CONFIG --cxxflags | sed -e 's/-O3//'`
if ! test -z "`echo $llvm_cfg | grep -- -fno-exceptions`"; then
AC_MSG_ERROR([You have to compile LLVM with exception enabled, please compile it with 'make REQUIRES_EH=1'])
fi
-AC_SUBST(LLVM_CXXFLAGS, [$llvm_cfg" "-I`$LLVM_CONFIG --src-root`/include])
-AC_SUBST(LLVM_LIBS, [`$LLVM_CONFIG --libs`])
-AC_SUBST(LLVM_LDFLAGS, [`$LLVM_CONFIG --ldflags`])
+AC_SUBST(LLVM_CXXFLAGS, [$llvm_cfg" "-I`$LLVM_RUNTIME_CONFIG --src-root`/include])
+AC_SUBST(LLVM_LIBS, [`$LLVM_RUNTIME_CONFIG --libs | tr '\n' ' '`])
+AC_SUBST(LLVM_LDFLAGS, [`$LLVM_RUNTIME_CONFIG --ldflags`])
dnl **************************************************************************
dnl clang
Modified: vmkit/branches/mcjit/configure
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/configure?rev=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/configure (original)
+++ vmkit/branches/mcjit/configure Fri Dec 20 07:43:29 2013
@@ -677,6 +677,7 @@ enable_optimized
enable_debug
enable_assert
with_llvm_config_path
+with_llvm_runtime_config_path
with_clang_path
with_jdkhome
'
@@ -1313,6 +1314,8 @@ Optional Packages:
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-llvm-config-path=path
llvm-config path (use default path)
+ --with-llvm-runtime-config-path=path
+ llvm-runtime-config path (use llvm-config-path)
--with-clang-path=path clang path (use llvm-config --bindir and then
default path)
--with-jdkhome Build J3 with OpenJDK JRE install (default is
@@ -2113,19 +2116,33 @@ if test ! -x "$LLVM_CONFIG"; then
as_fn_error $? "Cannot find $LLVM_CONFIG (or not executable)" "$LINENO" 5
fi
+
+# Check whether --with-llvm-runtime-config-path was given.
+if test "${with_llvm_runtime_config_path+set}" = set; then :
+ withval=$with_llvm_runtime_config_path; LLVM_RUNTIME_CONFIG=$with_llvm_runtime_config_path
+else
+ LLVM_RUNTIME_CONFIG="$LLVM_CONFIG"
+
+fi
+
+
+if test ! -x "$LLVM_RUNTIME_CONFIG"; then
+ as_fn_error $? "Cannot find $LLVM_RUNTIME_CONFIG (or not executable)" "$LINENO" 5
+fi
+
LLVM_PATH="`$LLVM_CONFIG --bindir`"
-llvm_cfg=`$LLVM_CONFIG --cxxflags | sed -e 's/-O3//'`
+llvm_cfg=`$LLVM_RUNTIME_CONFIG --cxxflags | sed -e 's/-O3//'`
if ! test -z "`echo $llvm_cfg | grep -- -fno-exceptions`"; then
as_fn_error $? "You have to compile LLVM with exception enabled, please compile it with 'make REQUIRES_EH=1'" "$LINENO" 5
fi
-LLVM_CXXFLAGS=$llvm_cfg" "-I`$LLVM_CONFIG --src-root`/include
+LLVM_CXXFLAGS=$llvm_cfg" "-I`$LLVM_RUNTIME_CONFIG --src-root`/include
-LLVM_LIBS=`$LLVM_CONFIG --libs`
+LLVM_LIBS=`$LLVM_RUNTIME_CONFIG --libs | tr '\n' ' '`
-LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
+LLVM_LDFLAGS=`$LLVM_RUNTIME_CONFIG --ldflags`
Modified: vmkit/branches/mcjit/include/j3/j3codegen.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegen.h?rev=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3codegen.h (original)
+++ vmkit/branches/mcjit/include/j3/j3codegen.h Fri Dec 20 07:43:29 2013
@@ -193,6 +193,9 @@ namespace j3 {
llvm::Function* funcCXAEndCatch; /* __cxa_end_catch */
llvm::Function* funcGXXPersonality; /* __gxx_personality_v0 */
llvm::Function* gcRoot;
+ llvm::Function* stackMap;
+ llvm::Function* patchPoint64;
+ llvm::Function* patchPointVoid;
llvm::Function* ziTry;
llvm::GlobalValue* gvTypeInfo; /* typename void* */
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=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Fri Dec 20 07:43:29 2013
@@ -52,6 +52,11 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
topPendingBranchs = 0;
isWide = 0;
+ bb = newBB("entry");
+ llvm::IRBuilder<> _builder(bb);
+
+ builder = &_builder;
+
funcJ3MethodIndex = vm->introspectFunction(module(), "j3::J3Method::index()");
funcJ3TypeVT = vm->introspectFunction(module(), "j3::J3Type::vt()");
funcJ3TypeInitialise = vm->introspectFunction(module(), "j3::J3Type::initialise()");
@@ -88,18 +93,26 @@ J3CodeGen::J3CodeGen(vmkit::BumpAllocato
gcRoot = vm->getGCRoot(module());
- //llvm::Intrinsic::getDeclaration(module(), llvm::Intrinsic::experimental_patchpoint_i64);
-
+#if 0
+ //stackMap = llvm::Intrinsic::getDeclaration(module(), llvm::Intrinsic::experimental_stackmap);
+ //patchPointVoid = llvm::Intrinsic::getDeclaration(module(), llvm::Intrinsic::experimental_patchpoint_i64);
+ {
+ llvm::Type* ins[] = {
+ builder->getInt64Ty(),
+ builder->getInt32Ty(),
+ builder->getInt8PtrTy(),
+ builder->getInt32Ty()
+ };
+ patchPointVoid = (llvm::Function*)
+ module()->getOrInsertFunction(llvm::Intrinsic::getName(llvm::Intrinsic::experimental_patchpoint_void),
+ llvm::FunctionType::get(builder->getVoidTy(), ins, 1));
+ }
+#endif
ziTry =
(llvm::Function*)module()->getOrInsertFunction("vmkit.try",
llvm::FunctionType::get(llvm::Type::getVoidTy(llvmFunction->getContext()), 0));
- bb = newBB("entry");
- llvm::IRBuilder<> _builder(bb);
-
- builder = &_builder;
-
if(J3Cst::isNative(method->access()))
generateNative();
else
@@ -655,10 +668,28 @@ void J3CodeGen::translate() {
if(vm->options()->genDebugExecute) {
char buf[256];
snprintf(buf, 256, "%ls::%ls", method->cl()->name()->cStr(), method->name()->cStr());
+#if 0
+
+ fprintf(stderr, "bitcast: ");
+ builder->CreateBitCast(funcEchoDebugEnter, builder->getInt8PtrTy())->dump();
+ fprintf(stderr, "\n");
+
+ llvm::Value* args[] = {
+ builder->getInt64(42), /* patch point id */
+ builder->getInt32(0), /* pad */
+ builder->CreateBitCast(funcEchoDebugEnter, builder->getInt8PtrTy()), /* function funcEchoDebugEnter */
+ builder->getInt32(3), /* number of args */
+ builder->getInt32(0), /* arg[0] */
+ buildString("bip %s\n"), /* arg[1] */
+ buildString(buf) /* arg[2] */
+ };
+ builder->CreateCall(patchPointVoid, args)->dump();
+#else
builder->CreateCall3(funcEchoDebugEnter,
builder->getInt32(0),
buildString("%s\n"),
buildString(buf));
+#endif
}
while(codeReader->remaining()) {
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=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Fri Dec 20 07:43:29 2013
@@ -42,6 +42,14 @@ uint32_t J3Method::index() {
return _index;
}
+struct safepoint_t {
+ void* addr;
+ void* metaData;
+ uint32_t sourceIndex;
+ uint32_t nbLives;
+ uint32_t lives[2];
+}; /* aligned on a 8-byte boundary on a 64 bit machine, on a 4-byte boundary otherwise */
+
uint8_t* J3Method::fnPtr() {
if(!_fnPtr) {
//fprintf(stderr, "materializing: %ls::%ls%ls\n", cl()->name()->cStr(), name()->cStr(), sign()->cStr());
@@ -62,6 +70,29 @@ uint8_t* J3Method::fnPtr() {
llvm::ExecutionEngine* ee = cl()->loader()->ee();
cl()->loader()->addModule(module);
_fnPtr = (uint8_t*)ee->getFunctionAddress(_llvmFunction->getName().data());
+
+#if 1
+ fprintf(stderr, "%s is generated at %p\n", llvmFunctionName(), _fnPtr);
+ llvm::SmallString<256> symName;
+ symName += module->getModuleIdentifier();
+ symName += "__frametable";
+ struct safepoint_t* sf = (safepoint_t*)ee->getGlobalValueAddress(symName.c_str());
+
+ if(!sf)
+ cl()->loader()->vm()->internalError(L"unable to find safepoints");
+
+ while(sf->addr) {
+ fprintf(stderr, " [%p] safepoint at %p for function %p::%d\n", sf, sf->addr, sf->metaData, sf->sourceIndex);
+ for(uint32_t i=0; i<sf->nbLives; i++)
+ fprintf(stderr, " live at %d\n", sf->lives[i]);
+
+ uintptr_t next = (uintptr_t)sf + sizeof(struct safepoint_t) - 2*sizeof(uint32_t) + sf->nbLives*sizeof(uint32_t);
+ //fprintf(stderr, "next at 0x%lx %ld %ld %ld\n", next,
+ //sizeof(struct safepoint_t), sf->nbLives*sizeof(uint32_t), 2*sizeof(uint32_t));
+ sf = (struct safepoint_t*)(((next - 1) & -sizeof(uintptr_t)) + sizeof(uintptr_t));
+ //fprintf(stderr, "=> %p\n", sf);
+ }
+#endif
}
return _fnPtr;
@@ -108,7 +139,7 @@ J3Method* J3Method::newMethod(vmkit::Bum
J3Class* cl,
const vmkit::Name* name,
const vmkit::Name* sign) {
- size_t trampolineSize = 48;
+ size_t trampolineSize = 148;
void* tra = (void*)J3ObjectHandle::trampoline;
J3Method* res = new(allocator, trampolineSize) J3Method(access, cl, name, sign);
@@ -121,19 +152,35 @@ J3Method* J3Method::newMethod(vmkit::Bum
0x51, // 3: push %rcx
0x41, 0x50, // 4: push %r8
0x41, 0x51, // 6: push %r9
- 0x48, 0x83, 0xc4, 0x08, // 8: sub %esp, 8
- 0x48, 0xbe, dd(res, 0), dd(res, 8), dd(res, 16), dd(res, 24), dd(res, 32), dd(res, 40), dd(res, 48), dd(res, 56), // 12: mov -> %rsi
- 0x48, 0xb8, dd(tra, 0), dd(tra, 8), dd(tra, 16), dd(tra, 24), dd(tra, 32), dd(tra, 40), dd(tra, 48), dd(tra, 56), // 22: mov -> %rax
- 0xff, 0xd0, // 32: call %rax
- 0x48, 0x83, 0xec, 0x08, // 34: add %esp, 8
- 0x41, 0x59, // 38: pop %r9
- 0x41, 0x58, // 40: pop %r8
- 0x59, // 42: pop %rcx
- 0x5a, // 43: pop %rdx
- 0x5e, // 44: pop %rsi
- 0x5f, // 45: pop %rdi
- 0xff, 0xe0 // 46: jmp %rax
- // total: 48
+ 0x48, 0x81, 0xec, 0x88, 0x00, 0x00, 0x00, // 8: sub $128+8, %esp
+ 0xf3, 0x0f, 0x11, 0x04, 0x24, // 15: movss %xmm0, (%rsp)
+ 0xf3, 0x0f, 0x11, 0x4c, 0x24, 0x10, // 20: movss %xmm1, 16(%rsp)
+ 0xf3, 0x0f, 0x11, 0x54, 0x24, 0x20, // 26: movss %xmm2, 32(%rsp)
+ 0xf3, 0x0f, 0x11, 0x5c, 0x24, 0x30, // 32: movss %xmm3, 48(%rsp)
+ 0xf3, 0x0f, 0x11, 0x64, 0x24, 0x40, // 38: movss %xmm4, 64(%rsp)
+ 0xf3, 0x0f, 0x11, 0x6c, 0x24, 0x50, // 44: movss %xmm5, 80(%rsp)
+ 0xf3, 0x0f, 0x11, 0x74, 0x24, 0x60, // 50: movss %xmm6, 96(%rsp)
+ 0xf3, 0x0f, 0x11, 0x7c, 0x24, 0x70, // 56: movss %xmm7, 112(%rsp)
+ 0x48, 0xbe, dd(res, 0), dd(res, 8), dd(res, 16), dd(res, 24), dd(res, 32), dd(res, 40), dd(res, 48), dd(res, 56), // 62: mov -> %rsi
+ 0x48, 0xb8, dd(tra, 0), dd(tra, 8), dd(tra, 16), dd(tra, 24), dd(tra, 32), dd(tra, 40), dd(tra, 48), dd(tra, 56), // 72: mov -> %rax
+ 0xff, 0xd0, // 82: call %rax
+ 0xf3, 0x0f, 0x10, 0x04, 0x24, // 84: movss (%rsp), %xmm0
+ 0xf3, 0x0f, 0x10, 0x4c, 0x24, 0x10, // 89: movss 16(%rsp), %xmm1
+ 0xf3, 0x0f, 0x10, 0x54, 0x24, 0x20, // 95: movss 32(%rsp), %xmm2
+ 0xf3, 0x0f, 0x10, 0x5c, 0x24, 0x30, // 101: movss 48(%rsp), %xmm3
+ 0xf3, 0x0f, 0x10, 0x64, 0x24, 0x40, // 107: movss 64(%rsp), %xmm4
+ 0xf3, 0x0f, 0x10, 0x6c, 0x24, 0x50, // 113: movss 80(%rsp), %xmm5
+ 0xf3, 0x0f, 0x10, 0x74, 0x24, 0x60, // 119: movss 96(%rsp), %xmm6
+ 0xf3, 0x0f, 0x10, 0x7c, 0x24, 0x70, // 125: movss 112(%rsp), %xmm7
+ 0x48, 0x81, 0xc4, 0x88, 0x00, 0x00, 0x00, // 131: add $128+8, %esp
+ 0x41, 0x59, // 138: pop %r9
+ 0x41, 0x58, // 140: pop %r8
+ 0x59, // 142: pop %rcx
+ 0x5a, // 143: pop %rdx
+ 0x5e, // 144: pop %rsi
+ 0x5f, // 145: pop %rdi
+ 0xff, 0xe0 // 146: jmp %rax
+ // total: 148
};
#undef dd
@@ -312,19 +359,21 @@ J3MethodType* J3Method::methodType(J3Cla
}
void J3Method::buildLLVMNames(J3Class* from) {
+ const char* prefix = "stub_";
+ uint32_t plen = 5;
J3Mangler mangler(from);
mangler.mangle(mangler.j3Id)->mangle(this)->mangleType(this);
- uint32_t length = mangler.length() + 5;
+ uint32_t length = mangler.length() + plen;
_llvmAllNames = (char*)cl()->loader()->allocator()->allocate(length + 1);
- memcpy(_llvmAllNames, "stub_", 5);
- memcpy(_llvmAllNames+5, mangler.cStr(), mangler.length());
+ memcpy(_llvmAllNames, prefix, plen);
+ memcpy(_llvmAllNames+plen, mangler.cStr(), mangler.length());
_llvmAllNames[length] = 0;
- cl()->loader()->addSymbol(_llvmAllNames, &_selfCode);
+ cl()->loader()->addSymbol(_llvmAllNames+0, &_selfCode);
cl()->loader()->addSymbol(_llvmAllNames+4, this);
- cl()->loader()->addSymbol(_llvmAllNames+5, &_selfCode);
+ cl()->loader()->addSymbol(_llvmAllNames+plen, &_selfCode);
}
char* J3Method::llvmFunctionName(J3Class* from) {
@@ -342,7 +391,7 @@ char* J3Method::llvmDescriptorName(J3Cla
char* J3Method::llvmStubName(J3Class* from) {
if(!_llvmAllNames)
buildLLVMNames(from ? from : cl());
- return _llvmAllNames;
+ return _llvmAllNames + 0;
}
llvm::GlobalValue* J3Method::llvmDescriptor(llvm::Module* module) {
Modified: vmkit/branches/mcjit/lib/j3/vm/j3object.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3object.cc?rev=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3object.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3object.cc Fri Dec 20 07:43:29 2013
@@ -1,4 +1,5 @@
#include <stdint.h>
+#include <setjmp.h>
#include "llvm/IR/DataLayout.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
Modified: vmkit/branches/mcjit/lib/j3/vm/j3options.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3options.cc?rev=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3options.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3options.cc Fri Dec 20 07:43:29 2013
@@ -13,13 +13,14 @@ J3Options::J3Options() {
debugEnterIndent = 1;
- genDebugExecute = 1;
debugExecute = 0;
debugLoad = 0;
debugResolve = 0;
debugIniting = 0;
debugTranslate = 0;
debugLinking = 0;
+
+ genDebugExecute = debugExecute ? 1 : 0;
}
#define nyi(cmd) ({ fprintf(stderr, "option '%s' not yet implemented\n", cmd); })
Modified: vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc?rev=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc Fri Dec 20 07:43:29 2013
@@ -1,14 +1,28 @@
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/DataLayout.h"
+
#include "llvm/CodeGen/GCs.h"
#include "llvm/CodeGen/GCStrategy.h"
+#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/GCMetadataPrinter.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/MC/MCSection.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Target/Mangler.h"
+#include "llvm/Target/TargetLoweringObjectFile.h"
using namespace llvm;
@@ -25,6 +39,7 @@ namespace vmkit {
VmkitGCPass::VmkitGCPass() {
CustomSafePoints = true;
+ UsesMetadata = true;
InitRoots = 1;
}
@@ -55,4 +70,66 @@ namespace vmkit {
return false;
}
+
+ class VmkitGCMetadataPrinter : public GCMetadataPrinter {
+ public:
+ void beginAssembly(AsmPrinter &AP);
+ void finishAssembly(AsmPrinter &AP);
+ };
+
+ static GCMetadataPrinterRegistry::Add<VmkitGCMetadataPrinter>
+ Y("vmkit", "VMKit garbage-collector");
+
+ void VmkitGCMetadataPrinter::beginAssembly(AsmPrinter &AP) {}
+
+ void VmkitGCMetadataPrinter::finishAssembly(AsmPrinter &AP) {
+ AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
+
+ unsigned IntPtrSize = AP.TM.getDataLayout()->getPointerSize(0);
+
+ SmallString<256> symName("_");
+ symName += getModule().getModuleIdentifier();
+ symName += "__frametable";
+
+ MCSymbol *sym = AP.OutContext.GetOrCreateSymbol(symName);
+ AP.OutStreamer.EmitSymbolAttribute(sym, MCSA_Global);
+
+ AP.EmitAlignment(IntPtrSize == 4 ? 2 : 3);
+
+ AP.OutStreamer.AddComment("--- module frame tables ---");
+ AP.OutStreamer.AddBlankLine();
+ AP.OutStreamer.EmitLabel(sym);
+
+ for (iterator I = begin(), IE = end(); I != IE; ++I) {
+ GCFunctionInfo* gcInfo = *I;
+
+ if(gcInfo->getFunction().hasGC()) {
+ AP.OutStreamer.AddComment("live roots for " + Twine(gcInfo->getFunction().getName()));
+ AP.OutStreamer.AddBlankLine();
+ for(llvm::GCFunctionInfo::iterator safepoint=gcInfo->begin(); safepoint!=gcInfo->end(); safepoint++) {
+ DebugLoc* debug = &safepoint->Loc;
+ uint32_t kind = safepoint->Kind;
+
+ const MCExpr* address = MCSymbolRefExpr::Create(safepoint->Label, AP.OutStreamer.getContext());
+ if (debug->getCol() == 1) {
+ const MCExpr* one = MCConstantExpr::Create(1, AP.OutStreamer.getContext());
+ address = MCBinaryExpr::CreateAdd(address, one, AP.OutStreamer.getContext());
+ }
+
+ AP.OutStreamer.EmitValue(address, IntPtrSize);
+ AP.EmitGlobalConstant(&gcInfo->getFunction());
+ AP.EmitInt32(debug->getLine());
+ AP.EmitInt32(gcInfo->live_size(safepoint));
+
+ //fprintf(stderr, "emitting %lu lives\n", gcInfo->live_size(safepoint));
+ for(GCFunctionInfo::live_iterator live=gcInfo->live_begin(safepoint); live!=gcInfo->live_end(safepoint); live++) {
+ AP.EmitInt32(live->StackOffset);
+ }
+ AP.EmitAlignment(IntPtrSize == 4 ? 2 : 3);
+ }
+ }
+ }
+
+ AP.OutStreamer.EmitValue(MCConstantExpr::Create(0, AP.OutStreamer.getContext()), IntPtrSize);
+ }
}
Modified: vmkit/branches/mcjit/lib/vmkit/vmkit.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/vmkit.cc?rev=197811&r1=197810&r2=197811&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/vmkit/vmkit.cc (original)
+++ vmkit/branches/mcjit/lib/vmkit/vmkit.cc Fri Dec 20 07:43:29 2013
@@ -117,7 +117,7 @@ llvm::Function* VMKit::getGCRoot(llvm::M
}
void VMKit::NotifyObjectEmitted(const llvm::ObjectImage &obj) {
- fprintf(stderr, "**** object jit event listener!\n");
+ //fprintf(stderr, "**** object jit event listener!\n");
}
void VMKit::NotifyFunctionEmitted(const llvm::Function &F,
@@ -126,7 +126,7 @@ void VMKit::NotifyFunctionEmitted(const
const llvm::JITEventListener::EmittedFunctionDetails &Details) {
fprintf(stderr, "**** jit event listener!\n");
-
+#if 0
const llvm::MachineFunction* mf = Details.MF;
const std::vector<llvm::LandingPadInfo>& landingPads = mf->getMMI().getLandingPads();
const llvm::MachineCodeEmitter* mce = Details.MCE;
@@ -166,6 +166,7 @@ void VMKit::NotifyFunctionEmitted(const
safepointMap[addr] = sf;
}
}
+#endif
}
void VMKit::log(const wchar_t* msg, ...) {
More information about the vmkit-commits
mailing list