|
|
|
|
|
|
#include "global.h" |
#include "program.h" |
#include "object.h" |
#include "buffer.h" |
#include "pike_types.h" |
#include "stralloc.h" |
#include "las.h" |
#include "lex.h" |
#include "pike_macros.h" |
#include "fsort.h" |
#include "pike_error.h" |
#include "docode.h" |
#include "interpret.h" |
#include "main.h" |
#include "pike_memory.h" |
#include "gc.h" |
#include "threads.h" |
#include "constants.h" |
#include "operators.h" |
#include "builtin_functions.h" |
#include "mapping.h" |
#include "cyclic.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 "bitvector.h" |
#include "sprintf.h" |
|
#include <errno.h> |
#include <fcntl.h> |
|
#define sp Pike_sp |
|
|
#ifdef PIKE_THREADS |
static COND_T Pike_compiler_cond; |
static THREAD_T Pike_compiler_thread; |
static int lock_depth = 0; |
|
PMOD_EXPORT void lock_pike_compiler(void) |
{ |
if (lock_depth && (Pike_compiler_thread != th_self())) { |
SWAP_OUT_CURRENT_THREAD(); |
while (lock_depth && (Pike_compiler_thread != th_self())) { |
co_wait_interpreter(&Pike_compiler_cond); |
} |
SWAP_IN_CURRENT_THREAD(); |
} |
lock_depth++; |
Pike_compiler_thread = th_self(); |
} |
|
PMOD_EXPORT void unlock_pike_compiler(void) |
{ |
#ifdef PIKE_DEBUG |
if (lock_depth < 1) { |
Pike_fatal("Pike compiler running unlocked!\n"); |
} |
#endif |
lock_depth--; |
co_broadcast(&Pike_compiler_cond); |
} |
#else |
PMOD_EXPORT void lock_pike_compiler(void) |
{ |
} |
PMOD_EXPORT void unlock_pike_compiler(void) |
{ |
} |
#endif |
|
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); |
|
|
static struct mapping *reverse_symbol_table = NULL; |
|
static struct block_allocator program_allocator = BA_INIT_PAGES(sizeof(struct program), 4); |
|
ATTRIBUTE((malloc)) |
struct program * alloc_program(void) { |
return ba_alloc(&program_allocator); |
} |
|
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); |
} |
*_size = size; |
} |
|
void free_all_program_blocks(void) { |
ba_destroy(&program_allocator); |
} |
|
|
|
|
#ifdef COMPILER_DEBUG |
#define CDFPRINTF(...) fprintf(stderr, __VA_ARGS__) |
#ifndef PIKE_THREADS |
|
static const int lock_depth = 1; |
#endif |
#else /* !COMPILER_DEBUG */ |
#define CDFPRINTF(...) |
#endif /* COMPILER_DEBUG */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define FIND_FUNCTION_HASHSIZE 16384 |
|
|