<div dir="ltr">Sorry, that should have read "<span style="font-size:13px">CompileCallbackManager factory functor which <i>OrcLazyJIT</i> can run during construction".</span><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">- Lang.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 30, 2015 at 12:53 PM, Lang Hames <span dir="ltr"><<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Pawel,<div><br></div><div>Yes - CallbackManagerBuilder is polymorphic*, but it also requires references to the stack that it is a part of, so it cannot be constructed outside an OrcLazyJIT instance. That's why createCallbackManagerBuilder is the way it is: It can't return a CompileCallbackManager value, so instead it returns a CompileCallbackManager factory functor which the compiler can run during construction. It indicates failure by returning a null factory functor, which the user can detect before the try to construct the JIT.</div><div><br></div><div>* The overhead of the polymorphism disappears if you can template your CompileOnDemand layer on a target specific subclass of CompileCallbackManager, but lli is cross-target, so we can't do that here.</div><div><br></div><div>Cheers,</div><div>Lang.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 30, 2015 at 12:43 PM, Paweł Bylica <span dir="ltr"><<a href="mailto:chfast@gmail.com" target="_blank">chfast@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span>On Mon, Mar 30, 2015 at 8:46 PM Lang Hames <<a href="mailto:lhames@gmail.com" target="_blank">lhames@gmail.com</a>> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dave,<div><br></div><div></div></div><span><div dir="ltr"><div>> More or less - it's an implementation detail, but I'd consider pulling out the logic of the JIT instance's ctor into the factory function so that it doesn't have to have a !ok state, it just returns from the factory directly on the failure cases, then if it doesn't fail initializing the structures - it passes them to the JIT instance's ctor which can't fail at this point because all the failures have been dealt with.<br><br></div></div><div dir="ltr"><div><div class="gmail_extra">There's a problem with that, at least the way things are written at the moment: The CompileOnDemand layer needs a reference to a CompileCallbackManager (so that it can inject JIT callbacks), and the CompileCallbackManager needs a reference to a lower JIT layer so that it can output callback code. These are all class members, so they have to be initialised in the constructor. The potential failure point is the CompileCallbackManager: There may not be one for the target.</div><div class="gmail_extra"><br></div><div class="gmail_extra">In r233579 I've solved this by separating the selection of callback managers (which can fail if there isn't one for the target) from the construction of the callback manager (which should always work, assuming you get that far). Now runOrcLazyJIT looks like:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><font face="monospace, monospace">auto CallbackManagerBuilder = createCallbackManagerBuilder(Target);</font></div><div class="gmail_extra"><font face="monospace, monospace">if (!CallbackManagerBuilder)</font></div><div class="gmail_extra"><font face="monospace, monospace">  return 1; // No callback manager for target.</font></div><div class="gmail_extra"><font face="monospace, monospace">OrcLazyJIT J(..., CallbackManagerBuilder); // <- Construction is now guaranteed.</font></div><div class="gmail_extra"><font face="monospace, monospace">... // Do stuff with the JIT</font></div><div class="gmail_extra"><br></div><div class="gmail_extra">What do you think?</div><div class="gmail_extra"><br></div><div class="gmail_extra">- Lang</div></div></div></span></blockquote><div><br></div><div>If OrcLazyJIT requires CallbackManagerBuilder pass it by reference.<br><br></div><div>Is CallbackManagerBuilder polymorphic?</div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>