44#include " interpreter.h"
55
66#include < inttypes.h>
7+ #include < new> // for std::bad_alloc
78
89static const StackType g_stackTypeFromInterpType[] =
910{
@@ -37,12 +38,7 @@ static const char *g_stackTypeString[] = { "I4", "I8", "R4", "R8", "O ", "VT", "
3738/* ****************************************************************************/
3839void DECLSPEC_NORETURN Interp_NOMEM ()
3940{
40- // Ensure we don't return and that the compiler knows we won't
41- #ifdef _MSC_VER
42- __debugbreak ();
43- #else
44- __builtin_trap ();
45- #endif
41+ throw std::bad_alloc ();
4642}
4743
4844// GCInfoEncoder needs an IAllocator implementation. This is a simple one that forwards to the Compiler.
@@ -859,8 +855,8 @@ void InterpCompiler::EmitCode()
859855void InterpCompiler::BuildGCInfo (InterpMethod *pInterpMethod)
860856{
861857#ifdef FEATURE_INTERPRETER
862- InterpIAllocator* pAllocator = new InterpIAllocator (this );
863- InterpreterGcInfoEncoder* gcInfoEncoder = new InterpreterGcInfoEncoder (m_compHnd, m_methodInfo, pAllocator, Interp_NOMEM);
858+ InterpIAllocator* pAllocator = new ( this ) InterpIAllocator (this );
859+ InterpreterGcInfoEncoder* gcInfoEncoder = new ( this ) InterpreterGcInfoEncoder (m_compHnd, m_methodInfo, pAllocator, Interp_NOMEM);
864860 assert (gcInfoEncoder);
865861
866862 gcInfoEncoder->SetCodeLength (m_methodCodeSize);
@@ -876,11 +872,6 @@ void InterpCompiler::BuildGCInfo(InterpMethod *pInterpMethod)
876872 // GC Encoder automatically puts the GC info in the right spot using ICorJitInfo::allocGCInfo(size_t)
877873 // let's save the values anyway for debugging purposes
878874 gcInfoEncoder->Emit ();
879-
880- // Interpreter-FIXME: Why doesn't the JIT code do this? Is it because the placement new it uses automatically frees them
881- // at the end of JIT compilation?
882- delete gcInfoEncoder;
883- delete pAllocator;
884875#endif
885876}
886877
0 commit comments