示例#1
0
        /// <inheritdoc/>
        public ulong AddLazyCompiledModule(BitcodeModule bitcodeModule, LLVMOrcSymbolResolverFn resolver)
        {
            LLVMModuleRef moduleHandle    = bitcodeModule.Detach( );
            var           wrappedResolver = new WrappedNativeCallback <LLVMOrcSymbolResolverFn>(resolver);
            var           err             = LLVMOrcAddLazilyCompiledIR(JitStackHandle, out ulong retHandle, moduleHandle, wrappedResolver, IntPtr.Zero);

            moduleHandle.SetHandleAsInvalid( );
            if (!err.IsInvalid)
            {
                throw new LlvmException(err.ToString( ));
            }

            // keep resolver delegate alive as native code needs to call it after this function exits
            SymbolResolvers.Add(retHandle, wrappedResolver);
            return(retHandle);
        }
示例#2
0
        /// <inheritdoc/>
        public ulong AddEagerlyCompiledModule(BitcodeModule bitcodeModule, LLVMOrcSymbolResolverFn resolver)
        {
            bitcodeModule.ValidateNotNull(nameof(bitcodeModule));
            resolver.ValidateNotNull(nameof(resolver));

            // detach the module before providing to JIT as JIT takes ownership
            LLVMModuleRef moduleHandle    = bitcodeModule.Detach( );
            var           wrappedResolver = new WrappedNativeCallback <LLVMOrcSymbolResolverFn>(resolver);
            var           err             = LLVMOrcAddEagerlyCompiledIR(JitStackHandle, out ulong retHandle, moduleHandle, wrappedResolver, IntPtr.Zero);

            moduleHandle.SetHandleAsInvalid( );
            if (!err.IsInvalid)
            {
                throw new LlvmException(err.ToString( ));
            }

            // keep resolver delegate alive as native code needs to call it after this function exits
            SymbolResolvers.Add(retHandle, wrappedResolver);
            return(retHandle);
        }