From 4e46143499be0e40ae29eff550cbeec4ebde3d85 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 12 Jun 2015 18:27:48 -0300 Subject: [PATCH] some optimizations in godot memory handling --- core/os/memory.cpp | 7 ------- core/os/memory.h | 17 ++++++++++++----- platform/x11/detect.py | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/os/memory.cpp b/core/os/memory.cpp index 617e40e92a4..1d9ac4e3028 100644 --- a/core/os/memory.cpp +++ b/core/os/memory.cpp @@ -112,13 +112,6 @@ size_t Memory::get_dynamic_mem_usage() { return MemoryPoolDynamic::get_singleton()->get_total_usage(); } -void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_description) { - - void *failptr=0; - ERR_FAIL_COND_V( check < p_size , failptr); /** bug, or strange compiler, most likely */ - - return p_pointer; -} diff --git a/core/os/memory.h b/core/os/memory.h index 4497fcc200d..0a35c93fdba 100644 --- a/core/os/memory.h +++ b/core/os/memory.h @@ -236,11 +236,11 @@ void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_de #endif -_FORCE_INLINE_ void postinitialize_handler(void *) {} +_ALWAYS_INLINE_ void postinitialize_handler(void *) {} template -_FORCE_INLINE_ T *_post_initialize(T *p_obj) { +_ALWAYS_INLINE_ T *_post_initialize(T *p_obj) { postinitialize_handler(p_obj); return p_obj; @@ -249,19 +249,26 @@ _FORCE_INLINE_ T *_post_initialize(T *p_obj) { #ifdef DEBUG_MEMORY_ENABLED #define memnew(m_class) _post_initialize(new(__FILE__":"__STR(__LINE__)", memnew type: "__STR(m_class)) m_class) -#define memnew_placement(m_placement,m_class) _post_initialize(new(m_placement,sizeof(m_class),__FILE__":"__STR(__LINE__)", type: "__STR(m_class)) m_class) #else #define memnew(m_class) _post_initialize(new("") m_class) -#define memnew_placement(m_placement,m_class) _post_initialize(new(m_placement,sizeof(m_class),"") m_class) #endif +_ALWAYS_INLINE_ void * operator new(size_t p_size,void *p_pointer,size_t check, const char *p_description) { +// void *failptr=0; +// ERR_FAIL_COND_V( check < p_size , failptr); /** bug, or strange compiler, most likely */ + + return p_pointer; +} + + #define memnew_allocator(m_class,m_allocator) _post_initialize(new(m_allocator::alloc) m_class) +#define memnew_placement(m_placement,m_class) _post_initialize(new(m_placement,sizeof(m_class),"") m_class) -_FORCE_INLINE_ bool predelete_handler(void *) { return true; } +_ALWAYS_INLINE_ bool predelete_handler(void *) { return true; } template void memdelete(T *p_class) { diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 85714c46bb3..ff85e286db3 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -111,9 +111,9 @@ def configure(env): if (env["target"]=="release"): if (env["debug_release"]=="yes"): - env.Append(CCFLAGS=['-g2','-fomit-frame-pointer']) + env.Append(CCFLAGS=['-g2']) else: - env.Append(CCFLAGS=['-O2','-ffast-math','-fomit-frame-pointer']) + env.Append(CCFLAGS=['-O3','-ffast-math']) elif (env["target"]=="release_debug"):