• R/O
  • SSH
  • HTTPS

natexec: コミット


コミットメタ情報

リビジョン73 (tree)
日時2020-01-15 17:59:36
作者quiret

ログメッセージ

- added the ability to call overrided operator new without using/compiling-with FEP, made the null-pointer exception only arise if compiled with FEP to help guide developers

変更サマリ

差分

--- NativeExecutive/src/CExecutiveManager.memory.cpp (revision 72)
+++ NativeExecutive/src/CExecutiveManager.memory.cpp (revision 73)
@@ -287,10 +287,9 @@
287287 }
288288 }
289289
290-#if !defined(_MSC_VER) || !defined(_DEBUG)
291-
292290 // Need to make sure that malloc is initialized no-matter-what.
293291 // Because the event management is its own isolated subsystem we can depend on it.
292+// We also want the ability to initialize memory management without calling the special entry point on both Windows and Linux.
294293
295294 static volatile bool _malloc_has_initialized_overrides = false;
296295
@@ -302,8 +301,10 @@
302301
303302 initializeGlobalMemoryOverrides();
304303 }
305-}
304+}
306305
306+#if !defined(_MSC_VER) || !defined(_DEBUG)
307+
307308 // Since the C++ programming language does use memory allocation in standard features such as
308309 // exception throwing, we have to provide thread-safe memory allocation systems.
309310 void* malloc( size_t memSize )
@@ -570,6 +571,10 @@
570571 printf( "call to global operator new detected.\n" );
571572 #endif //NATEXEC_LOG_GLOBAL_ALLOC
572573
574+#ifndef NATEXEC_FIRST_ENTRY_POINT
575+ _prepare_overrides();
576+#endif //NATEXEC_FIRST_ENTRY_POINT
577+
573578 NativeExecutive::CUnfairMutexContext ctxMemLock( _global_memlock.GetMutex() );
574579
575580 return _global_mem_alloc.get().Allocate( memSize );
@@ -581,6 +586,10 @@
581586 printf( "call to global operator new (nothrow) detected.\n" );
582587 #endif //NATEXEC_LOG_GLOBAL_ALLOC
583588
589+#ifndef NATEXEC_FIRST_ENTRY_POINT
590+ _prepare_overrides();
591+#endif //NATEXEC_FIRST_ENTRY_POINT
592+
584593 NativeExecutive::CUnfairMutexContext ctxMemLock( _global_memlock.GetMutex() );
585594
586595 return _global_mem_alloc.get().Allocate( memSize );
@@ -592,6 +601,10 @@
592601 printf( "call to global operator new (with align) detected.\n" );
593602 #endif //NATEXEC_LOG_GLOBAL_ALLOC
594603
604+#ifndef NATEXEC_FIRST_ENTRY_POINT
605+ _prepare_overrides();
606+#endif //NATEXEC_FIRST_ENTRY_POINT
607+
595608 NativeExecutive::CUnfairMutexContext ctxMemLock( _global_memlock.GetMutex() );
596609
597610 return _global_mem_alloc.get().Allocate( memSize, (size_t)alignment );
@@ -603,6 +616,13 @@
603616 printf( "call to global operator new (nothrow, with align) detected.\n" );
604617 #endif //NNATEXEC_LOG_GLOBAL_ALLOC
605618
619+#ifndef NATEXEC_FIRST_ENTRY_POINT
620+ // If we have a first-entry-point already then we are supposed to call it before any other C++ runtime calls.
621+ // Thus we can have this preprocessor check to remind people of the correct application runtime order.
622+
623+ _prepare_overrides();
624+#endif //NATEXEC_FIRST_ENTRY_POINT
625+
606626 NativeExecutive::CUnfairMutexContext ctxMemLock( _global_memlock.GetMutex() );
607627
608628 return _global_mem_alloc.get().Allocate( memSize, (size_t)alignment );
@@ -716,6 +736,10 @@
716736 void* NatExecGlobalStaticAlloc::Allocate( void *refPtr, size_t memSize, size_t alignment )
717737 {
718738 #ifdef NATEXEC_GLOBALMEM_OVERRIDE
739+ // I guess that we cannot really control the execution of this function thus we always
740+ // call to prepare overrides.
741+ _prepare_overrides();
742+
719743 NativeExecutive::CUnfairMutexContext ctxMemLock( _global_memlock.GetMutex() );
720744
721745 return _global_mem_alloc.get().Allocate( memSize, alignment );
旧リポジトリブラウザで表示