From eea057675de7914af12c6168db0f3bebea35be5b Mon Sep 17 00:00:00 2001 From: Eugene Rozenfeld Date: Sun, 16 Dec 2018 12:07:42 -0800 Subject: Improve removal of dead calls to allocator helpers. This change improves detection of allocators with side effects. Allocators can cause side effects if the allocated object may have a finalizer. This change adds a pHasSideEffects parameter to getNewHelper JitEE interface method. It's used by the jit to check for allocator side effects instead of guessing from helper ids. Fixes #21530. --- src/jit/utils.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'src/jit/utils.cpp') diff --git a/src/jit/utils.cpp b/src/jit/utils.cpp index 8bc85961fd..ae7dd60ad4 100644 --- a/src/jit/utils.cpp +++ b/src/jit/utils.cpp @@ -1170,7 +1170,6 @@ void HelperCallProperties::init() bool isAllocator = false; // true if the result is usually a newly created heap item, or may throw OutOfMemory bool mutatesHeap = false; // true if any previous heap objects [are|can be] modified bool mayRunCctor = false; // true if the helper call may cause a static constructor to be run. - bool mayFinalize = false; // true if the helper call allocates an object that may need to run a finalizer switch (helper) { @@ -1228,19 +1227,13 @@ void HelperCallProperties::init() case CORINFO_HELP_NEWSFAST: case CORINFO_HELP_NEWSFAST_ALIGN8: case CORINFO_HELP_NEWSFAST_ALIGN8_VC: - - isAllocator = true; - nonNullReturn = true; - noThrow = true; // only can throw OutOfMemory - break; - case CORINFO_HELP_NEW_CROSSCONTEXT: case CORINFO_HELP_NEWFAST: case CORINFO_HELP_NEWSFAST_FINALIZE: case CORINFO_HELP_NEWSFAST_ALIGN8_FINALIZE: case CORINFO_HELP_READYTORUN_NEW: + case CORINFO_HELP_BOX: - mayFinalize = true; // These may run a finalizer isAllocator = true; nonNullReturn = true; noThrow = true; // only can throw OutOfMemory @@ -1250,20 +1243,12 @@ void HelperCallProperties::init() // and can throw exceptions other than OOM. case CORINFO_HELP_NEWARR_1_VC: case CORINFO_HELP_NEWARR_1_ALIGN8: - - isAllocator = true; - nonNullReturn = true; - break; - - // These allocation helpers do some checks on the size (and lower bound) inputs, - // and can throw exceptions other than OOM. case CORINFO_HELP_NEW_MDARR: case CORINFO_HELP_NEWARR_1_DIRECT: case CORINFO_HELP_NEWARR_1_OBJ: case CORINFO_HELP_NEWARR_1_R2R_DIRECT: case CORINFO_HELP_READYTORUN_NEWARR_1: - mayFinalize = true; // These may run a finalizer isAllocator = true; nonNullReturn = true; break; @@ -1277,12 +1262,6 @@ void HelperCallProperties::init() noThrow = true; // only can throw OutOfMemory break; - case CORINFO_HELP_BOX: - nonNullReturn = true; - isAllocator = true; - noThrow = true; // only can throw OutOfMemory - break; - case CORINFO_HELP_BOX_NULLABLE: // Box Nullable is not a 'pure' function // It has a Byref argument that it reads the contents of. @@ -1481,7 +1460,6 @@ void HelperCallProperties::init() m_isAllocator[helper] = isAllocator; m_mutatesHeap[helper] = mutatesHeap; m_mayRunCctor[helper] = mayRunCctor; - m_mayFinalize[helper] = mayFinalize; } } -- cgit v1.2.3