2008-04-26
2008-04-26 19:04:26 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
8853883a2a1548529993e6d2b394c510151c150d
(98 lines)
(+56/-42)
[
Show
| Annotate
]
Branch: 7.9
Moved compilation_depth to struct compilation.
Yet another step on the way to making the compiler thread safe.
Got rid of some now unused cleanup code in dynamic_load.c.
Rev: src/builtin_functions.c:1.656
Rev: src/dynamic_load.c:1.91
Rev: src/encode.c:1.264
Rev: src/language.yacc:1.416
Rev: src/pike_compiler.h:1.9
Rev: src/program.c:1.679
Rev: src/program.h:1.240
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: program.c,v 1.678 2008/04/26 16:08:13 grubba Exp $
+ || $Id: program.c,v 1.679 2008/04/26 19:04:26 grubba Exp $
*/
#include "global.h"
1227:
struct program *gc_internal_program = 0;
static struct program *gc_mark_program_pos = 0;
- int compilation_depth=-1;
+
static struct mapping *resolve_cache=0;
#ifdef PIKE_DEBUG
1562:
{
struct program_state *p=Pike_compiler;
int n;
- for(n=0;n<=compilation_depth;n++,p=p->previous)
+ for(n=0;n<=c->compilation_depth;n++,p=p->previous)
{
int i;
if(see_inherit)
1765:
/* Fixme: allow level=0 to return the current level */
struct program *parent_compilation(int level)
{
+ struct compilation *c = THIS_COMPILATION;
int n;
struct program_state *p=Pike_compiler->previous;
for(n=0;n<level;n++)
{
- if(n>=compilation_depth) return 0;
+ if(n>=c->compilation_depth) return 0;
p=p->previous;
if(!p) return 0;
}
2007: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
fprintf(stderr, "%.*soverloaded reference %d (id_flags:0x%04x)\n",
- compilation_depth, " ", cur_id, ref->id_flags);
+ c->compilation_depth, "", cur_id, ref->id_flags);
#endif
if (!new_is_variable && IDENTIFIER_IS_VARIABLE(i->identifier_flags)) {
2371:
*/
low_init_threads_disable();
- compilation_depth++;
+ c->compilation_depth++;
if (!Pike_compiler->compiler_frame) {
new_node_s_context();
2386:
tmp.u.program=p;
id=add_constant(name, &tmp, flags & ~ID_EXTERN);
#if 0
- fprintf(stderr,"Compiling class %s, depth=%d\n",name->str,compilation_depth);
+ fprintf(stderr,"Compiling class %s, depth=%d\n",
+ name->str, c->compilation_depth);
}else{
fprintf(stderr,"Compiling file %s, depth=%d\n",
c->lex.current_file ? c->lex.current_file->str : "-",
- compilation_depth);
+ c->compilation_depth);
#endif
}
}else{
2408:
}
}
if (pass == 1) {
- if(compilation_depth >= 1)
+ if(c->compilation_depth >= 1)
add_ref(p->parent = Pike_compiler->new_program);
}
p->flags &=~ PROGRAM_VIRGIN;
2418:
"pass=%d: threads_disabled:%d, compilation_depth:%d\n",
(long)th_self(), p, name ? name->str : "-",
Pike_compiler->compiler_pass,
- threads_disabled, compilation_depth));
+ threads_disabled, c->compilation_depth));
init_type_stack();
2490: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
if (name) {
fprintf (stderr, "%.*sstarting program %d (pass=%d): ",
- compilation_depth, " ", Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
+ c->compilation_depth, "",
+ Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
push_string (name);
print_svalue (stderr, --Pike_sp);
putc ('\n', stderr);
}
else
fprintf (stderr, "%.*sstarting program %d (pass=%d)\n",
- compilation_depth, " ", Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
+ c->compilation_depth, "",
+ Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
#endif
- if (compilation_depth >= 1) {
+ if (c->compilation_depth >= 1) {
if(TEST_COMPAT(7,2) || (c->lex.pragmas & ID_SAVE_PARENT))
{
p->flags |= PROGRAM_USES_PARENT;
2637:
CDFPRINTF((stderr,
"th(%ld) start_new_program(%d, %s): "
"threads_disabled:%d, compilation_depth:%d\n",
- (long)th_self(), line, file, threads_disabled, compilation_depth));
+ (long)th_self(), line, file,
+ threads_disabled, c->compilation_depth));
low_start_new_program(0,1,0,0,0);
store_linenumber(line,c->lex.current_file);
3397:
*/
struct program *end_first_pass(int finish)
{
+ struct compilation *c = THIS_COMPILATION;
int e;
struct program *prog;
struct pike_string *s;
3495: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
fprintf (stderr, "%.*sfinishing program %d (pass=%d)\n",
- compilation_depth, " ", Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
+ c->compilation_depth, "",
+ Pike_compiler->new_program->id, Pike_compiler->compiler_pass);
#endif
toss_compilation_resources();
3504: Inside #if 0
CDFPRINTF((stderr,
"th(%ld) end_first_pass(): "
"compilation_depth:%d, Pike_compiler->compiler_pass:%d\n",
- (long)th_self(), compilation_depth, Pike_compiler->compiler_pass));
+ (long)th_self(),
+ c->compilation_depth, Pike_compiler->compiler_pass));
#endif
if(!Pike_compiler->compiler_frame && (Pike_compiler->compiler_pass==2 || !prog) && resolve_cache)
3528:
"th(%ld) %p end_first_pass(%d): "
"threads_disabled:%d, compilation_depth:%d\n",
(long)th_self(), prog, finish,
- threads_disabled, compilation_depth));
+ threads_disabled, c->compilation_depth));
- compilation_depth--;
+ c->compilation_depth--;
exit_threads_disable(NULL);
3915:
struct pike_string *function_name)
{
int n,e,id;
+ struct compilation *c = THIS_COMPILATION;
struct program_state *state=Pike_compiler->previous;
struct program *p;
3968:
}
- for(n=0;n<compilation_depth;n++,state=state->previous)
+ for(n=0;n<c->compilation_depth;n++,state=state->previous)
{
struct program *p=state->new_program;
4202: Inside #if 0
* previous compilations, but I'm too lazy to figure out
* exactly how deep down we need to go...
*/
- for(e=0;e<compilation_depth;e++,state=state->previous)
+ for(e=0;e<c->compilation_depth;e++,state=state->previous)
state->new_program->flags |= PROGRAM_USES_PARENT;
#endif
}
4751:
struct pike_type *t;
#ifdef PROGRAM_BUILD_DEBUG
+ struct compilation *c = THIS_COMPILATION;
fprintf (stderr, "%.*sdefining variable (pass=%d): %s %s\n",
- compilation_depth, " ", Pike_compiler->compiler_pass, type, name);
+ c->compilation_depth, "",
+ Pike_compiler->compiler_pass, type, name);
#endif
n=make_shared_string(name);
4780: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
{
+ struct compilation *c = THIS_COMPILATION;
struct pike_string *d = describe_type (t);
fprintf (stderr, "%.*sdefining variable (pass=%d): %s ",
- compilation_depth, " ", Pike_compiler->compiler_pass, d->str);
+ c->compilation_depth, "", Pike_compiler->compiler_pass, d->str);
free_string (d);
push_string (n);
print_svalue (stderr, --Pike_sp);
4810: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
{
+ struct compilation *c = THIS_COMPILATION;
struct pike_string *d = describe_type (type);
fprintf (stderr, "%.*sdefining variable (pass=%d): %s ",
- compilation_depth, " ", Pike_compiler->compiler_pass, d->str);
+ c->compilation_depth, "", Pike_compiler->compiler_pass, d->str);
free_string (d);
push_string (name);
print_svalue (stderr, --Pike_sp);
4961:
struct svalue zero;
#ifdef PROGRAM_BUILD_DEBUG
+ struct compilation *cc = THIS_COMPILATION;
{
if (c) {
struct pike_type *t = get_type_of_svalue(c);
struct pike_string *d = describe_type (t);
fprintf (stderr, "%.*sdefining constant (pass=%d): %s ",
- compilation_depth, " ",
+ cc->compilation_depth, "",
Pike_compiler->compiler_pass, d->str);
free_type(t);
free_string (d);
4977: Inside #if defined(PROGRAM_BUILD_DEBUG)
}
else {
fprintf (stderr, "%.*sdeclaring constant (pass=%d): ",
- compilation_depth, " ",
+ cc->compilation_depth, "",
Pike_compiler->compiler_pass);
push_string (name);
print_svalue (stderr, --Pike_sp);
5096: Inside #if defined(PROGRAM_BUILD_DEBUG)
}
#ifdef PROGRAM_BUILD_DEBUG
fprintf (stderr, "%.*sstored constant #%d at %d\n",
- compilation_depth, " ",
+ cc->compilation_depth, "",
n, id->func.offset);
#endif
return n;
5366: Inside #if defined(PROGRAM_BUILD_DEBUG)
{
struct pike_string *d = describe_type (type);
fprintf (stderr, "%.*sdefining function (pass=%d): %s ",
- compilation_depth, " ", Pike_compiler->compiler_pass, d->str);
+ c->compilation_depth, "", Pike_compiler->compiler_pass, d->str);
free_string (d);
push_string (name);
print_svalue (stderr, --Pike_sp);
5512: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
fprintf(stderr, "%.*sexisted as identifier #%d\n",
- compilation_depth, " ", i);
+ c->compilation_depth, "", i);
#endif
funp=ID_FROM_INT(Pike_compiler->new_program, i);
5569: Inside #if defined(PROGRAM_BUILD_DEBUG)
}else{
#ifdef PROGRAM_BUILD_DEBUG
fprintf(stderr, "%.*sidentifier was inherited\n",
- compilation_depth, " ");
+ c->compilation_depth, "");
#endif
if((ref.id_flags & ID_FINAL)
5586: Inside #if defined(PROGRAM_BUILD_DEBUG)
{
#ifdef PROGRAM_BUILD_DEBUG
fprintf(stderr, "%.*sidentifier is local\n",
- compilation_depth, " ");
+ c->compilation_depth, "");
#endif
goto make_a_new_def;
5595: Inside #if defined(PROGRAM_BUILD_DEBUG)
/* Otherwise we alter the existing definition */
#ifdef PROGRAM_BUILD_DEBUG
fprintf(stderr, "%.*saltering the existing definition\n",
- compilation_depth, " ");
+ c->compilation_depth, "");
#endif
copy_shared_string(fun.name, name);
5700: Inside #if defined(PROGRAM_BUILD_DEBUG)
#ifdef PROGRAM_BUILD_DEBUG
fprintf(stderr, "%.*sadded new definition #%d\n",
- compilation_depth, " ", i);
+ c->compilation_depth, "", i);
#endif
if (getter_setter_offset >= 0) {
7389:
static void run_init(struct compilation *c)
{
debug_malloc_touch(c);
- c->save_depth=compilation_depth;
- compilation_depth=-1;
+
if (c->compat_handler) free_object(c->compat_handler);
c->compat_handler=0;
7458:
#endif
#ifdef PIKE_DEBUG
- if (compilation_depth != -1) {
+ if (c->compilation_depth != -1) {
fprintf(stderr, "compile(): compilation_depth is %d\n",
- compilation_depth);
+ c->compilation_depth);
}
#endif /* PIKE_DEBUG */
- compilation_depth=c->save_depth;
+
if (resolve_cache)
free_mapping(resolve_cache);
7508: Inside #if 0
#if 0
CDFPRINTF((stderr, "th(%ld) compile() starting compilation_depth=%d\n",
- (long)th_self(),compilation_depth));
+ (long)th_self(),c->compilation_depth));
#endif
if(c->placeholder && c->placeholder->prog != null_program) {
7529:
"th(%ld) %p run_pass1() start: "
"threads_disabled:%d, compilation_depth:%d\n",
(long)th_self(), Pike_compiler->new_program,
- threads_disabled, compilation_depth));
+ threads_disabled, c->compilation_depth));
run_init2(c);
7618:
"th(%ld) %p run_pass2() start: "
"threads_disabled:%d, compilation_depth:%d\n",
(long)th_self(), Pike_compiler->new_program,
- threads_disabled, compilation_depth));
+ threads_disabled, c->compilation_depth));
verify_supporters();
7649:
exit_threads_disable(NULL);
CDFPRINTF((stderr,
- "th(%ld) %p run_cleanup(): threads_disabled:%d, compilation_depth:%d\n",
- (long)th_self(), c->target, threads_disabled, compilation_depth));
+ "th(%ld) %p run_cleanup(): "
+ "threads_disabled:%d, compilation_depth:%d\n",
+ (long)th_self(), c->target,
+ threads_disabled, c->compilation_depth));
if (!c->p)
{
/* fprintf(stderr, "Destructing placeholder.\n"); */
7791:
c->minor = -1;
c->lex.current_line = 1;
c->lex.current_file = make_shared_string("-");
+ c->compilation_depth = -1;
break;
case PROG_EVENT_EXIT:
CDFPRINTF((stderr, "th(%ld) compilation: EXIT(%p).\n",