comparison gcc/memory-block.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
comparison
equal deleted inserted replaced
131:84e7813d76e9 145:1830386684a0
1 /* Shared pool of memory blocks for pool allocators. 1 /* Shared pool of memory blocks for pool allocators.
2 Copyright (C) 2015-2018 Free Software Foundation, Inc. 2 Copyright (C) 2015-2020 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify 6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
26 class memory_block_pool 26 class memory_block_pool
27 { 27 {
28 public: 28 public:
29 /* Blocks have fixed size. This is necessary for sharing. */ 29 /* Blocks have fixed size. This is necessary for sharing. */
30 static const size_t block_size = 64 * 1024; 30 static const size_t block_size = 64 * 1024;
31 /* Number of blocks we keep in the freelists. */
32 static const size_t freelist_size = 1024 * 1024 / block_size;
31 33
32 memory_block_pool (); 34 memory_block_pool ();
33 35
34 static inline void *allocate () ATTRIBUTE_MALLOC; 36 static inline void *allocate () ATTRIBUTE_MALLOC;
35 static inline void release (void *); 37 static inline void release (void *);
36 void clear_free_list (); 38 static void trim (int nblocks = freelist_size);
39 void reduce_free_list (int);
37 40
38 private: 41 private:
39 /* memory_block_pool singleton instance, defined in memory-block.cc. */ 42 /* memory_block_pool singleton instance, defined in memory-block.cc. */
40 static memory_block_pool instance; 43 static memory_block_pool instance;
41 44