[jit] Emit the seq point for filter clauses after the op_get_exc instruction.
[mono.git] / mono / mini / mini-llvm-cpp.cpp
index 4b8320f075907adb3f3e5671ff01def29b65ddf9..f894a7721648c58e1f40e1f0556a192aec0923c6 100644 (file)
@@ -69,6 +69,7 @@ public:
        /* Callbacks installed by mono */
        AllocCodeMemoryCb *alloc_cb;
        DlSymCb *dlsym_cb;
+       ExceptionTableCb *exception_cb;
 
        MonoJITMemoryManager ();
        ~MonoJITMemoryManager ();
@@ -232,6 +233,7 @@ MonoJITMemoryManager::endExceptionTable(const Function *F, unsigned char *TableS
                                        unsigned char *TableEnd, 
                                        unsigned char* FrameRegister)
 {
+       exception_cb (FrameRegister);
 }
 
 #else
@@ -253,20 +255,6 @@ public:
        virtual void NotifyFunctionEmitted(const Function &F,
                                                                           void *Code, size_t Size,
                                                                           const EmittedFunctionDetails &Details) {
-               /*
-                * X86TargetMachine::setCodeModelForJIT() sets the code model to Large on amd64,
-                * which means the JIT will generate calls of the form
-                * mov reg, <imm>
-                * call *reg
-                * Our trampoline code can't patch this. Passing CodeModel::Small to createJIT
-                * doesn't seem to work, we need Default. A discussion is here:
-                * http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-December/027999.html
-                * There seems to no way to get the TargeMachine used by an EE either, so we
-                * install a profiler hook and reset the code model here.
-                * This should be inside an ifdef, but we can't include our config.h either,
-                * since its definitions conflict with LLVM's config.h.
-                * The LLVM mono branch contains a workaround.
-                */
                emitted_cb (wrap (&F), Code, (char*)Code + Size);
        }
 };
@@ -436,6 +424,14 @@ mono_llvm_build_fence (LLVMBuilderRef builder, BarrierKind kind)
        return wrap (ins);
 }
 
+void
+mono_llvm_set_must_tail (LLVMValueRef call_ins)
+{
+       CallInst *ins = (CallInst*)unwrap (call_ins);
+
+       ins->setTailCallKind (CallInst::TailCallKind::TCK_MustTail);
+}
+
 void
 mono_llvm_replace_uses_of (LLVMValueRef var, LLVMValueRef v)
 {
@@ -443,6 +439,18 @@ mono_llvm_replace_uses_of (LLVMValueRef var, LLVMValueRef v)
        unwrap (var)->replaceAllUsesWith (V);
 }
 
+LLVMValueRef
+mono_llvm_create_constant_data_array (const uint8_t *data, int len)
+{
+       return wrap(ConstantDataArray::get (*unwrap(LLVMGetGlobalContext ()), makeArrayRef(data, len)));
+}
+
+void
+mono_llvm_set_is_constant (LLVMValueRef global_var)
+{
+       unwrap<GlobalVariable>(global_var)->setConstant (true);
+}
+
 static cl::list<const PassInfo*, bool, PassNameParser>
 PassList(cl::desc("Optimizations available:"));
 
@@ -623,6 +631,7 @@ mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, Func
   MonoJITMemoryManager *mono_mm = new MonoJITMemoryManager ();
   mono_mm->alloc_cb = alloc_cb;
   mono_mm->dlsym_cb = dlsym_cb;
+  mono_mm->exception_cb = exception_cb;
   mono_ee->mm = mono_mm;
 
   /*
@@ -639,16 +648,11 @@ mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, Func
   // EngineBuilder no longer has a copy assignment operator (?)
   std::unique_ptr<Module> Owner(unwrap(MP));
   EngineBuilder b (std::move(Owner));
-#ifdef TARGET_AMD64
-  ExecutionEngine *EE = b.setJITMemoryManager (mono_mm).setTargetOptions (opts).setAllocateGVsWithCode (true).setMCPU (cpu_name).setCodeModel (CodeModel::Large).create ();
-#else
   ExecutionEngine *EE = b.setJITMemoryManager (mono_mm).setTargetOptions (opts).setAllocateGVsWithCode (true).setMCPU (cpu_name).create ();
-#endif
 
   g_assert (EE);
   mono_ee->EE = EE;
 
-  EE->InstallExceptionTableRegister (exception_cb);
   MonoJITEventListener *listener = new MonoJITEventListener (emitted_cb);
   EE->RegisterJITEventListener (listener);
   mono_ee->listener = listener;