pike.git/src/program.c:25:
#include "constants.h"
#include "operators.h"
#include "builtin_functions.h"
#include "stuff.h"
#include "mapping.h"
#include "cyclic.h"
#include "pike_security.h"
#include "pike_types.h"
#include "opcodes.h"
#include "version.h"
+ #include "block_allocator.h"
#include "block_alloc.h"
#include "pikecode.h"
#include "pike_compiler.h"
#include "module_support.h"
#include <errno.h>
#include <fcntl.h>
#define sp Pike_sp
#undef ATTRIBUTE
#define ATTRIBUTE(X)
static void low_enter_compiler(struct object *ce, int inherit);
static void exit_program_struct(struct program *);
static size_t add_xstorage(size_t size,
size_t alignment,
ptrdiff_t modulo_orig);
- #undef EXIT_BLOCK
- #define EXIT_BLOCK(P) exit_program_struct( (P) )
+ static struct block_allocator program_allocator = BA_INIT_PAGES(sizeof(struct program), 4);
- #undef COUNT_OTHER
- #define COUNT_OTHER() do{ \
- struct program *p; \
- for(p=first_program;p;p=p->next) \
- { \
- size+=p->total_size - sizeof (struct program); \
- } \
- }while(0)
+ ATTRIBUTE((malloc))
+ struct program * alloc_program() {
+ return ba_alloc(&program_allocator);
+ }
- BLOCK_ALLOC_FILL_PAGES(program, 4)
+ void really_free_program(struct program * p) {
+ exit_program_struct(p);
+ ba_free(&program_allocator, p);
+ }
-
+ void count_memory_in_programs(size_t *num, size_t *_size) {
+ size_t size;
+ struct program *p;
+ ba_count_all(&program_allocator, num, &size);
+ for(p=first_program;p;p=p->next) {
+ size+=p->total_size - sizeof (struct program);
+ }
+ }
-
+ void free_all_program_blocks() {
+ ba_destroy(&program_allocator);
+ }
+
/* #define COMPILER_DEBUG */
/* #define PROGRAM_BUILD_DEBUG */
#ifdef COMPILER_DEBUG
#define CDFPRINTF(X) fprintf X
#else /* !COMPILER_DEBUG */
#define CDFPRINTF(X)
#endif /* COMPILER_DEBUG */
/*
pike.git/src/program.c:7963: Inside #if defined(PIKE_DEBUG)
#ifdef PIKE_DEBUG
struct supporter_marker
{
struct supporter_marker *next;
void *data;
int level, verified;
};
- #undef EXIT_BLOCK
- #define EXIT_BLOCK(P)
- #undef COUNT_OTHER
- #define COUNT_OTHER()
-
+
#undef INIT_BLOCK
#define INIT_BLOCK(X) do { (X)->level = (X)->verified = 0; }while(0)
PTR_HASH_ALLOC(supporter_marker, 128);
static int supnum;
#define SNUM(X) (get_supporter_marker((X))->level)
static void mark_supporters(struct Supporter *s)
{
pike.git/src/program.c:10600:
MAKE_CONST_STRING (s, "__placeholder_object");
ref_push_string (s);
}
void init_program(void)
{
size_t i;
struct svalue key;
struct svalue val;
struct svalue id;
- init_program_blocks();
+
MAKE_CONST_STRING(this_function_string,"this_function");
MAKE_CONST_STRING(this_program_string,"this_program");
MAKE_CONST_STRING(this_string,"this");
MAKE_CONST_STRING(UNDEFINED_string,"UNDEFINED");
MAKE_CONST_STRING(parser_system_string, "parser");
MAKE_CONST_STRING(type_check_system_string, "type_check");
lfun_ids = allocate_mapping(NUM_LFUNS);