{
mc = firstContext;
jitHost = new JitHost(*this);
- pnjitStartup(jitHost);
+ if (!callJitStartup(jitHost))
+ {
+ LogError("jitStartup failed");
+ return -1;
+ }
}
pJitInstance = pngetJit();
{
mc = firstContext;
jitHost = new JitHost(*this);
- pnjitStartup(jitHost);
+ if (!callJitStartup(jitHost))
+ {
+ LogError("jitStartup failed");
+ return false;
+ }
}
pJitInstance = pngetJit();
HeapFree(ourHeap, 0, array);
}
+// Helper for calling pnjitStartup. Needed to allow SEH here.
+bool JitInstance::callJitStartup(ICorJitHost* jithost)
+{
+ // Calling into the collection, which could fail, especially
+ // for altjits. So protect the call.
+
+ struct Param : FilterSuperPMIExceptionsParam_CaptureException
+ {
+ JitInstance* pThis;
+ ICorJitHost* jithost;
+ bool result;
+ } param;
+ param.pThis = this;
+ param.jithost = jithost;
+ param.result = false;
+
+ PAL_TRY(Param*, pParam, ¶m)
+ {
+ pParam->pThis->pnjitStartup(pParam->jithost);
+ pParam->result = true;
+ }
+ PAL_EXCEPT_FILTER(FilterSuperPMIExceptions_CaptureExceptionAndStop)
+ {
+ SpmiException e(¶m.exceptionPointers);
+
+ LogError("failed to call jitStartup.");
+ e.ShowAndDeleteMessage();
+ }
+ PAL_ENDTRY
+
+ return param.result;
+}
+
// Reset JitConfig, that stores Enviroment variables.
bool JitInstance::resetConfig(MethodContext* firstContext)
{
- if (pnjitStartup != nullptr)
+ if (pnjitStartup == nullptr)
+ {
+ return false;
+ }
+
+ mc = firstContext;
+ ICorJitHost* newHost = new JitHost(*this);
+
+ if (!callJitStartup(newHost))
{
- mc = firstContext;
- ICorJitHost* newHost = new JitHost(*this);
- pnjitStartup(newHost);
- delete static_cast<JitHost*>(jitHost);
- jitHost = newHost;
- return true;
+ return false;
}
- return false;
-}
+
+ delete static_cast<JitHost*>(jitHost);
+ jitHost = newHost;
+ return true;
+}
\ No newline at end of file
HRESULT StartUp(char* PathToJit, bool copyJit, bool breakOnDebugBreakorAV, MethodContext* firstContext);
bool reLoad(MethodContext* firstContext);
+ bool callJitStartup(ICorJitHost* newHost);
+
bool resetConfig(MethodContext* firstContext);
Result CompileMethod(MethodContext* MethodToCompile, int mcIndex, bool collectThroughput);