<div dir="ltr"><br><br><div class="gmail_quote">On Mon, Mar 30, 2015 at 8:46 PM Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:<br><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><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></blockquote><div><br></div><div>If OrcLazyJIT requires CallbackManagerBuilder pass it by reference.<br><br></div><div>Is CallbackManagerBuilder polymorphic?</div></div></div>