diff --git a/dtool/Config.pp b/dtool/Config.pp index aa7f57fda5..934ac553a2 100644 --- a/dtool/Config.pp +++ b/dtool/Config.pp @@ -332,15 +332,6 @@ // your source directory on your PYTHONPATH. #define INSTALL_PYTHON_SOURCE 1 -// Do you want to enable the "in_interpreter" global variable? This -// will enable some callbacks, particularly the MemoryUsage object, to -// know whether they were called from Python code (or other high-level -// show code) and react accordingly, generally for debugging -// purporses. It adds a bit of runtime overhead, and isn't usually -// useful unless we're building a debug tree anyway. The default is -// to enable it only for optimize levels 1 and 2. -#defer TRACK_IN_INTERPRETER $[<= $[OPTIMIZE], 2] - // Do you want to compile in support for tracking memory usage? This // enables you to define the variable "track-memory-usage" at runtime // to help track memory leaks, and also report total memory usage on diff --git a/dtool/LocalSetup.pp b/dtool/LocalSetup.pp index d1a575158a..163d0e75ca 100644 --- a/dtool/LocalSetup.pp +++ b/dtool/LocalSetup.pp @@ -337,9 +337,6 @@ $[cdefine DO_DCAST] visualization tools. */ $[cdefine DO_COLLISION_RECORDING] -/* Define if we want to track callbacks from within the show code. */ -$[cdefine TRACK_IN_INTERPRETER] - /* Define if we want to enable track-memory-usage. */ $[cdefine DO_MEMORY_USAGE] diff --git a/dtool/pptempl/Global.pp b/dtool/pptempl/Global.pp index fefba6a977..a689a091d3 100644 --- a/dtool/pptempl/Global.pp +++ b/dtool/pptempl/Global.pp @@ -766,13 +766,11 @@ Warning: Variable $[upcase $[tree]]_INSTALL is not set! $[INTERROGATE_OPTIONS] \ $[if $[INTERROGATE_PYTHON_INTERFACE],$[if $[PYTHON_NATIVE],-python-native,-python]] \ $[if $[INTERROGATE_C_INTERFACE],-c] \ - $[if $[TRACK_IN_INTERPRETER],-track-interpreter] \ $[if $[<= $[OPTIMIZE], 1],-spam] #defer interrogate_module_options \ $[if $[INTERROGATE_PYTHON_INTERFACE],$[if $[PYTHON_NATIVE],-python-native,-python]] \ - $[if $[INTERROGATE_C_INTERFACE],-c] \ - $[if $[TRACK_IN_INTERPRETER],-track-interpreter] + $[if $[INTERROGATE_C_INTERFACE],-c] // The language stuff is used by model builds only. diff --git a/dtool/src/interrogatedb/interrogate_request.cxx b/dtool/src/interrogatedb/interrogate_request.cxx index 8fc4b4ac40..28d2dd76f6 100644 --- a/dtool/src/interrogatedb/interrogate_request.cxx +++ b/dtool/src/interrogatedb/interrogate_request.cxx @@ -17,10 +17,6 @@ #include // for strdup -#ifdef TRACK_IN_INTERPRETER -int in_interpreter = false; -#endif - void interrogate_request_database(const char *database_filename) { InterrogateModuleDef *def = new InterrogateModuleDef; diff --git a/dtool/src/interrogatedb/interrogate_request.h b/dtool/src/interrogatedb/interrogate_request.h index 1325498795..063b04f2ec 100644 --- a/dtool/src/interrogatedb/interrogate_request.h +++ b/dtool/src/interrogatedb/interrogate_request.h @@ -76,22 +76,6 @@ typedef struct { */ EXPCL_DTOOLCONFIG void interrogate_request_module(InterrogateModuleDef *def); -#ifdef TRACK_IN_INTERPRETER -/* - * If we're tracking whether we're currently running in Python code - * (mainly for the purpose of debug logging from memory allocation - * callbacks), this variable will record that state. It will be set - * true whenever we return to Python code, and false whenever we are - * entering local C or C++ code. The flag will be toggled off and - * on within each generated Python wrapper function. - * - * This will mis-categorize some code that runs at static - * initialization time, but it will correctly identify the vast - * majority of code. - */ -EXPCL_DTOOLCONFIG extern int in_interpreter; -#endif // TRACK_IN_INTERPRETER - #ifdef __cplusplus } #endif diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index 0075c522fc..100a382882 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -187,7 +187,7 @@ underflow() { // indicates that no retry is necessary //_is_closed = !BIO_should_retry(*_source); //_is_closed = !BIO_should_read(*_source); - _is_closed = BIO_eof(*_source); + _is_closed = (BIO_eof(*_source) != 0); if (_is_closed) { downloader_cat.info() << "Lost connection to " diff --git a/panda/src/express/memoryUsage.I b/panda/src/express/memoryUsage.I index 24bddb34e1..03939f09d1 100644 --- a/panda/src/express/memoryUsage.I +++ b/panda/src/express/memoryUsage.I @@ -176,23 +176,6 @@ get_panda_mmap_size() { return AtomicAdjust::get(get_global_ptr()->_total_mmap_size); } -//////////////////////////////////////////////////////////////////// -// Function: MemoryUsage::get_interpreter_size -// Access: Public, Static -// Description: Returns the total number of bytes of allocated memory -// while the high-level languange code is running. This -// number is only meaningful if both Panda and the -// high-level language are single-threaded, and running -// in the same thread. -// -// This number is only available if Panda is able to -// hook into the actual heap callback. -//////////////////////////////////////////////////////////////////// -INLINE size_t MemoryUsage:: -get_interpreter_size() { - return get_global_ptr()->_interpreter_size; -} - //////////////////////////////////////////////////////////////////// // Function: MemoryUsage::get_external_size // Access: Public, Static @@ -202,6 +185,10 @@ get_interpreter_size() { // objects (like ConfigVariables) that cannot use Panda // memory tracking because they are so very low-level. // +// This also includes all of the memory that might have +// been allocated by a high-level interpreter, like +// Python. +// // This number is only available if Panda is able to // hook into the actual heap callback. //////////////////////////////////////////////////////////////////// @@ -214,13 +201,12 @@ get_external_size() { #if defined(USE_MEMORY_DLMALLOC) || defined(USE_MEMORY_PTMALLOC2) // With alternative malloc, none of the Panda allocated memory - // shows up in total_size, so anything there is either interpreter - // or external. - return mu->_total_size - mu->_interpreter_size; + // shows up in total_size, so anything there is external. + return mu->_total_size; #else // Without alternative malloc, the Panda allocated memory is also // included in total_size, so we have to subtract it out. - return mu->_total_size - mu->_total_heap_single_size - mu->_total_heap_array_size - mu->_interpreter_size; + return mu->_total_size - mu->_total_heap_single_size - mu->_total_heap_array_size; #endif } else { return 0; diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index ff3f0d29eb..b84869b59a 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -348,13 +348,6 @@ win32_malloc_hook(int alloc_type, void *ptr, } mu->_total_size += increment; - -#ifdef TRACK_IN_INTERPRETER - if (in_interpreter) { - mu->_interpreter_size += increment; - } -#endif - return true; } #endif // WIN32_VC && _DEBUG @@ -423,7 +416,6 @@ MemoryUsage(const MemoryHook ©) : MemoryHook(copy) { _count = 0; _current_cpp_size = 0; _total_cpp_size = 0; - _interpreter_size = 0; _total_size = 0; } @@ -448,7 +440,6 @@ overflow_heap_size() { << "\n heap array: " << get_panda_heap_array_size() << "\n heap overhead: " << get_panda_heap_overhead() << "\n mmap: " << get_panda_mmap_size() - << "\n interpreter: " << get_interpreter_size() << "\n external: " << get_external_size() << "\n total: " << get_total_size() << "\n"; diff --git a/panda/src/express/memoryUsage.h b/panda/src/express/memoryUsage.h index 9a1ade427e..214e2f1c24 100644 --- a/panda/src/express/memoryUsage.h +++ b/panda/src/express/memoryUsage.h @@ -68,7 +68,6 @@ PUBLISHED: INLINE static size_t get_panda_heap_array_size(); INLINE static size_t get_panda_heap_overhead(); INLINE static size_t get_panda_mmap_size(); - INLINE static size_t get_interpreter_size(); INLINE static size_t get_external_size(); INLINE static size_t get_total_size(); @@ -148,7 +147,6 @@ private: int _count; size_t _current_cpp_size; size_t _total_cpp_size; - size_t _interpreter_size; size_t _total_size; class TypeHistogram { diff --git a/panda/src/express/stringDecoder.cxx b/panda/src/express/stringDecoder.cxx index b2b530562b..41e4b043ea 100644 --- a/panda/src/express/stringDecoder.cxx +++ b/panda/src/express/stringDecoder.cxx @@ -110,6 +110,7 @@ get_next_character() { express_cat.warning() << "Non utf-8 byte in string: 0x" << hex << result << dec << ", string is '" << _input << "'\n"; + nassertr(false, -1); } // End of string reached. diff --git a/panda/src/express/virtualFileSystem.I b/panda/src/express/virtualFileSystem.I index 7a9841cbfd..c5a8766785 100644 --- a/panda/src/express/virtualFileSystem.I +++ b/panda/src/express/virtualFileSystem.I @@ -107,33 +107,6 @@ read_file(const Filename &filename, bool auto_unwrap) const { return result; } -//////////////////////////////////////////////////////////////////// -// Function: VirtualFileSystem::open_read_file -// Access: Published -// Description: Convenience function; returns a newly allocated -// istream if the file exists and can be read, or NULL -// otherwise. Does not return an invalid istream. -// -// If auto_unwrap is true, an explicitly-named .pz file -// is automatically decompressed and the decompressed -// contents are returned. This is different than -// vfs-implicit-pz, which will automatically decompress -// a file if the extension .pz is *not* given. -//////////////////////////////////////////////////////////////////// -INLINE istream *VirtualFileSystem:: -open_read_file(const Filename &filename, bool auto_unwrap) const { - PT(VirtualFile) file = get_file(filename); - if (file == (VirtualFile *)NULL) { - return NULL; - } - istream *str = file->open_read_file(auto_unwrap); - if (str != (istream *)NULL && str->fail()) { - delete str; - str = (istream *)NULL; - } - return str; -} - //////////////////////////////////////////////////////////////////// // Function: VirtualFileSystem::read_file // Access: Public diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index 903136add0..4289bc510a 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -587,6 +587,33 @@ get_global_ptr() { return _global_ptr; } +//////////////////////////////////////////////////////////////////// +// Function: VirtualFileSystem::open_read_file +// Access: Published +// Description: Convenience function; returns a newly allocated +// istream if the file exists and can be read, or NULL +// otherwise. Does not return an invalid istream. +// +// If auto_unwrap is true, an explicitly-named .pz file +// is automatically decompressed and the decompressed +// contents are returned. This is different than +// vfs-implicit-pz, which will automatically decompress +// a file if the extension .pz is *not* given. +//////////////////////////////////////////////////////////////////// +istream *VirtualFileSystem:: +open_read_file(const Filename &filename, bool auto_unwrap) const { + PT(VirtualFile) file = get_file(filename); + if (file == (VirtualFile *)NULL) { + return NULL; + } + istream *str = file->open_read_file(auto_unwrap); + if (str != (istream *)NULL && str->fail()) { + close_read_file(str); + str = (istream *)NULL; + } + return str; +} + //////////////////////////////////////////////////////////////////// // Function: VirtualFileSystem::close_read_file // Access: Published @@ -603,7 +630,7 @@ close_read_file(istream *stream) const { // the stream pointer does not call the appropriate global delete // function; instead apparently calling the system delete // function. So we call the delete function by hand instead. -#if !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) +#if !defined(WIN32_VC) && !defined(USE_MEMORY_NOWRAPPERS) && defined(REDEFINE_GLOBAL_OPERATOR_NEW) stream->~istream(); (*global_operator_delete)(stream); #else diff --git a/panda/src/express/virtualFileSystem.h b/panda/src/express/virtualFileSystem.h index 2d4c00d968..0ecbf3dbfd 100644 --- a/panda/src/express/virtualFileSystem.h +++ b/panda/src/express/virtualFileSystem.h @@ -80,7 +80,7 @@ PUBLISHED: static VirtualFileSystem *get_global_ptr(); BLOCKING INLINE string read_file(const Filename &filename, bool auto_unwrap) const; - BLOCKING INLINE istream *open_read_file(const Filename &filename, bool auto_unwrap) const; + BLOCKING istream *open_read_file(const Filename &filename, bool auto_unwrap) const; BLOCKING void close_read_file(istream *stream) const; public: diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index 9a3e6b678f..d6d149193c 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -35,7 +35,6 @@ PStatCollector PStatClient::_heap_single_size_pcollector("System memory:Heap:Sin PStatCollector PStatClient::_heap_single_other_size_pcollector("System memory:Heap:Single:Other"); PStatCollector PStatClient::_heap_array_size_pcollector("System memory:Heap:Array"); PStatCollector PStatClient::_heap_array_other_size_pcollector("System memory:Heap:Array:Other"); -PStatCollector PStatClient::_heap_interpreter_size_pcollector("System memory:Heap:Interpreter"); PStatCollector PStatClient::_heap_external_size_pcollector("System memory:Heap:External"); PStatCollector PStatClient::_mmap_size_pcollector("System memory:MMap"); @@ -223,7 +222,6 @@ main_tick() { _heap_overhead_size_pcollector.set_level(MemoryUsage::get_panda_heap_overhead()); _heap_single_size_pcollector.set_level(MemoryUsage::get_panda_heap_single_size()); _heap_array_size_pcollector.set_level(MemoryUsage::get_panda_heap_array_size()); - _heap_interpreter_size_pcollector.set_level(MemoryUsage::get_interpreter_size()); _heap_external_size_pcollector.set_level(MemoryUsage::get_external_size()); diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 939d2b2aef..bc0b6e5c14 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -229,7 +229,6 @@ private: static PStatCollector _heap_single_other_size_pcollector; static PStatCollector _heap_array_size_pcollector; static PStatCollector _heap_array_other_size_pcollector; - static PStatCollector _heap_interpreter_size_pcollector; static PStatCollector _heap_external_size_pcollector; static PStatCollector _mmap_size_pcollector; diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 91a0151c06..43194ecb9e 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -202,7 +202,6 @@ static LevelCollectorProperties level_properties[] = { { 1, "System memory:Heap:Single", { 0.8, 0.3, 0.3 } }, { 1, "System memory:Heap:Array", { 0.1, 0.3, 1.0 } }, { 1, "System memory:Heap:Overhead", { 0.9, 0.7, 0.8 } }, - { 1, "System memory:Heap:Interpreter", { 0.6, 1.0, 0.9 } }, { 1, "System memory:Heap:External", { 0.2, 0.2, 0.5 } }, { 1, "System memory:MMap", { 0.9, 0.4, 0.7 } }, { 1, "Vertex Data", { 1.0, 0.4, 0.0 }, "MB", 64, 1048576 },