LIST * var_get( struct module_t * module, OBJECT * symbol ) { LIST * result = L0; #ifdef OPT_AT_FILES /* Some "fixed" variables... */ if ( object_equal( symbol, constant_TMPDIR ) ) { list_free( saved_var ); result = saved_var = list_new( object_new( path_tmpdir()->value ) ); } else if ( object_equal( symbol, constant_TMPNAME ) ) { list_free( saved_var ); result = saved_var = list_new( path_tmpnam() ); } else if ( object_equal( symbol, constant_TMPFILE ) ) { list_free( saved_var ); result = saved_var = list_new( path_tmpfile() ); } else if ( object_equal( symbol, constant_STDOUT ) ) { list_free( saved_var ); result = saved_var = list_new( object_copy( constant_STDOUT ) ); } else if ( object_equal( symbol, constant_STDERR ) ) { list_free( saved_var ); result = saved_var = list_new( object_copy( constant_STDERR ) ); } else #endif { VARIABLE * v; int n; if ( ( n = module_get_fixed_var( module, symbol ) ) != -1 ) { if ( DEBUG_VARGET ) var_dump( symbol, module->fixed_variables[ n ], "get" ); result = module->fixed_variables[ n ]; } else if ( module->variables && ( v = (VARIABLE *)hash_find( module->variables, symbol ) ) ) { if ( DEBUG_VARGET ) var_dump( v->symbol, v->value, "get" ); result = v->value; } } return result; }
/** Given a list and a value, returns position of that value in the list, or -1 if not found. */ int list_index(LIST* list, OBJECT* value) { int result = 0; for(; list; list = list->next, ++result) { if (object_equal(list->value, value)) return result; } return -1; }
int list_in( LIST * l, OBJECT * value ) { LISTITER iter = list_begin( l ); LISTITER end = list_end( l ); for ( ; iter != end; iter = list_next( iter ) ) if ( object_equal( list_item( iter ), value ) ) return 1; return 0; }
/* Given a list and a value, returns position of that value in the list, or -1 * if not found. */ int list_index( LIST * list, OBJECT * value ) { int result = 0; LISTITER iter = list_begin( list ); LISTITER const end = list_end( list ); for ( ; iter != end; iter = list_next( iter ), ++result ) if ( object_equal( list_item( iter ), value ) ) return result; return -1; }
LIST * list_unique( LIST * sorted_list ) { LIST * result = L0; OBJECT * last_added = 0; LISTITER iter = list_begin( sorted_list ), end = list_end( sorted_list ); for ( ; iter != end; iter = list_next( iter ) ) { if ( !last_added || !object_equal( list_item( iter ), last_added ) ) { result = list_push_back( result, object_copy( list_item( iter ) ) ); last_added = list_item( iter ); } } return result; }
static ITEM * hash_search( struct hash * hp, unsigned int keyval, OBJECT * keydata, ITEM * * previous ) { ITEM * i = *hash_bucket( hp, keyval ); ITEM * p = 0; for ( ; i; i = i->next ) { if ( object_equal( hash_item_key( i ), keydata ) ) { if ( previous ) *previous = p; return i; } p = i; } return 0; }
static LIST * make1list( LIST * l, TARGETS * targets, int flags ) { for ( ; targets; targets = targets->next ) { TARGET * t = targets->target; if ( t->binding == T_BIND_UNBOUND ) make1bind( t ); if ( ( flags & RULE_EXISTING ) && ( flags & RULE_NEWSRCS ) ) { if ( ( t->binding != T_BIND_EXISTS ) && ( t->fate <= T_FATE_STABLE ) ) continue; } else if ( flags & RULE_EXISTING ) { if ( t->binding != T_BIND_EXISTS ) continue; } else if ( flags & RULE_NEWSRCS ) { if ( t->fate <= T_FATE_STABLE ) continue; } /* Prohibit duplicates for RULE_TOGETHER. */ if ( flags & RULE_TOGETHER ) { LISTITER iter = list_begin( l ); LISTITER const end = list_end( l ); for ( ; iter != end; iter = list_next( iter ) ) if ( object_equal( list_item( iter ), t->boundname ) ) break; if ( iter != end ) continue; } /* Build new list. */ l = list_push_back( l, object_copy( t->boundname ) ); } return l; }
static int list_equal( LIST * lhs, LIST * rhs ) { LISTITER lhs_iter, lhs_end, rhs_iter; if ( list_length( lhs ) != list_length( rhs ) ) { return 0; } lhs_iter = list_begin( lhs ); lhs_end = list_end( lhs ); rhs_iter = list_begin( rhs ); for ( ; lhs_iter != lhs_end; ++lhs_iter, ++rhs_iter ) { if ( ! object_equal( list_item( lhs_iter ), list_item( rhs_iter ) ) ) { return 0; } } return 1; }
SETTINGS * addsettings( SETTINGS * head, int flag, OBJECT * symbol, LIST * value ) { SETTINGS * v; /* Look for previous settings. */ for ( v = head; v; v = v->next ) if ( object_equal( v->symbol, symbol ) ) break; /* If not previously set, alloc a new. */ /* If appending, do so. */ /* Else free old and set new. */ if ( !v ) { v = settings_freelist; if ( v ) settings_freelist = v->next; else v = (SETTINGS *)BJAM_MALLOC( sizeof( *v ) ); v->symbol = object_copy( symbol ); v->value = value; v->next = head; v->multiple = 0; head = v; } else if ( flag == VAR_APPEND ) { v->value = list_append( v->value, value ); } else if ( flag != VAR_DEFAULT ) { list_free( v->value ); v->value = value; } else list_free( value ); /* Return (new) head of list. */ return head; }
bool Inliner::inline_primitive(Class* klass, CompiledMethod* cm, executor prim) { const char* inlined_prim = 0; if(prim == Primitives::tuple_at && count_ == 1) { inlined_prim = "tuple_at"; call_tuple_at(ops_, *this); } else if(prim == Primitives::tuple_put && count_ == 2) { inlined_prim = "tuple_put"; call_tuple_put(ops_, *this); } else if(prim == Primitives::fixnum_and && count_ == 1) { inlined_prim = "fixnum_and"; fixnum_and(ops_, *this); } else if(prim == Primitives::fixnum_or && count_ == 1) { inlined_prim = "fixnum_or"; fixnum_or(ops_, *this); } else if(prim == Primitives::fixnum_neg && count_ == 0) { inlined_prim = "fixnum_neg"; fixnum_neg(ops_, *this); } else if(prim == Primitives::fixnum_equal && count_ == 1) { inlined_prim = "fixnum_eq"; fixnum_compare(cEqual, ops_, *this); } else if(prim == Primitives::fixnum_lt && count_ == 1) { inlined_prim = "fixnum_lt"; fixnum_compare(cLessThan, ops_, *this); } else if(prim == Primitives::fixnum_le && count_ == 1) { inlined_prim = "fixnum_le"; fixnum_compare(cLessThanEqual, ops_, *this); } else if(prim == Primitives::fixnum_gt && count_ == 1) { inlined_prim = "fixnum_gt"; fixnum_compare(cGreaterThan, ops_, *this); } else if(prim == Primitives::fixnum_ge && count_ == 1) { inlined_prim = "fixnum_ge"; fixnum_compare(cGreaterThanEqual, ops_, *this); } else if(prim == Primitives::object_equal && count_ == 1) { inlined_prim = "object_equal"; object_equal(klass, ops_, *this); } else if(prim == Primitives::float_add && count_ == 1) { inlined_prim = "float_add"; float_op(cAdd, klass, ops_, *this); } else if(prim == Primitives::float_sub && count_ == 1) { inlined_prim = "float_sub"; float_op(cSub, klass, ops_, *this); } else if(prim == Primitives::float_mul && count_ == 1) { inlined_prim = "float_mul"; float_op(cMultiply, klass, ops_, *this); } else if(prim == Primitives::float_div && count_ == 1) { inlined_prim = "float_div"; float_op(cDivide, klass, ops_, *this); } else if(prim == Primitives::float_mod && count_ == 1) { inlined_prim = "float_mod"; float_op(cMod, klass, ops_, *this); } else if(prim == Primitives::float_equal && count_ == 1) { inlined_prim = "float_equal"; float_compare(cEqual, klass, ops_, *this); } else if(prim == Primitives::float_lt && count_ == 1) { inlined_prim = "float_lt"; float_compare(cLessThan, klass, ops_, *this); } else if(prim == Primitives::float_le && count_ == 1) { inlined_prim = "float_le"; float_compare(cLessThanEqual, klass, ops_, *this); } else if(prim == Primitives::float_gt && count_ == 1) { inlined_prim = "float_gt"; float_compare(cGreaterThan, klass, ops_, *this); } else if(prim == Primitives::float_ge && count_ == 1) { inlined_prim = "float_ge"; float_compare(cGreaterThanEqual, klass, ops_, *this); } else if(prim == Primitives::fixnum_s_eqq && count_ == 1) { inlined_prim = "fixnum_s_eqq"; fixnum_s_eqq(ops_, *this); } else if(prim == Primitives::symbol_s_eqq && count_ == 1) { inlined_prim = "symbol_s_eqq"; symbol_s_eqq(ops_, *this); } else { JITStubResults stub_res; if(Primitives::get_jit_stub(cm->prim_index(), stub_res)) { if(stub_res.arg_count() == count_) { Value* self = recv(); ops_.check_class(self, klass, failure()); std::vector<Value*> call_args; Signature sig(ops_.state(), "Object"); sig << "VM"; call_args.push_back(ops_.vm()); if(stub_res.pass_callframe()) { sig << "CallFrame"; call_args.push_back(ops_.call_frame()); } sig << "Object"; call_args.push_back(self); for(int i = 0; i < stub_res.arg_count(); i++) { sig << "Object"; call_args.push_back(arg(i)); } Function* func = sig.function(stub_res.name()); func->setDoesNotCapture(1, true); if(stub_res.pass_callframe()) { func->setDoesNotCapture(2, true); } Value* res = sig.call(stub_res.name(), call_args, "prim_value", ops_.b()); // Only doing this when stub_res.can_fail() causes an exception // to be thrown when running the ci specs, need to investigate. BasicBlock* cont = ops_.new_block("continue"); Value* as_i = ops_.ptrtoint(res); Value* icmp = ops_.b().CreateICmpEQ(as_i, ConstantInt::get(ops_.state()->IntPtrTy, reinterpret_cast<intptr_t>(Qundef))); use_send_for_failure(); ops_.b().CreateCondBr(icmp, failure(), cont); ops_.set_block(cont); set_result(res); if(ops_.state()->config().jit_inline_debug) { context_.inline_log("inlining") << ops_.state()->symbol_cstr(cm->scope()->module()->name()) << "#" << ops_.state()->symbol_cstr(cm->name()) << " into " << ops_.state()->symbol_cstr(ops_.method_name()) << ". generic primitive: " << stub_res.name() << "\n"; } return true; } } } if(inlined_prim) { if(ops_.state()->config().jit_inline_debug) { context_.inline_log("inlining") << ops_.state()->symbol_cstr(cm->scope()->module()->name()) << "#" << ops_.state()->symbol_cstr(cm->name()) << " into " << ops_.state()->symbol_cstr(ops_.method_name()) << ". primitive " << inlined_prim << "\n"; } return true; } // Add more primitive inlining! if(ops_.state()->config().jit_inline_debug) { context_.inline_log("NOT inlining") << ops_.state()->symbol_cstr(cm->scope()->module()->name()) << "#" << ops_.state()->symbol_cstr(cm->name()) << " into " << ops_.state()->symbol_cstr(ops_.method_name()) << ". primitive: " << ops_.state()->symbol_cstr(cm->primitive()) << "\n"; } return false; }
static pobject equal(pobject env, pobject params) { pobject o1 = eval(env, cons_car(params)); pobject o2 = eval(env, cons_car(cons_cdr(params))); return object_bool(object_equal(o1, o2)); }
static void dependGraphOutput( TARGET * t, int depth ) { TARGETS * c; if ( ( t->flags & T_FLAG_VISITED ) || !t->name || !t->boundname ) return; t->flags |= T_FLAG_VISITED; switch ( t->fate ) { case T_FATE_TOUCHED: case T_FATE_MISSING: case T_FATE_OUTDATED: case T_FATE_UPDATE: out_printf( "->%s%2d Name: %s\n", spaces( depth ), depth, target_name( t ) ); break; default: out_printf( " %s%2d Name: %s\n", spaces( depth ), depth, target_name( t ) ); break; } if ( !object_equal( t->name, t->boundname ) ) out_printf( " %s Loc: %s\n", spaces( depth ), object_str( t->boundname ) ); switch ( t->fate ) { case T_FATE_STABLE: out_printf( " %s : Stable\n", spaces( depth ) ); break; case T_FATE_NEWER: out_printf( " %s : Newer\n", spaces( depth ) ); break; case T_FATE_ISTMP: out_printf( " %s : Up to date temp file\n", spaces( depth ) ); break; case T_FATE_NEEDTMP: out_printf( " %s : Temporary file, to be updated\n", spaces( depth ) ); break; case T_FATE_TOUCHED: out_printf( " %s : Been touched, updating it\n", spaces( depth ) ); break; case T_FATE_MISSING: out_printf( " %s : Missing, creating it\n", spaces( depth ) ); break; case T_FATE_OUTDATED: out_printf( " %s : Outdated, updating it\n", spaces( depth ) ); break; case T_FATE_REBUILD: out_printf( " %s : Rebuild, updating it\n", spaces( depth ) ); break; case T_FATE_UPDATE: out_printf( " %s : Updating it\n", spaces( depth ) ); break; case T_FATE_CANTFIND: out_printf( " %s : Can not find it\n", spaces( depth ) ); break; case T_FATE_CANTMAKE: out_printf( " %s : Can make it\n", spaces( depth ) ); break; } if ( t->flags & ~T_FLAG_VISITED ) { out_printf( " %s : ", spaces( depth ) ); if ( t->flags & T_FLAG_TEMP ) out_printf( "TEMPORARY " ); if ( t->flags & T_FLAG_NOCARE ) out_printf( "NOCARE " ); if ( t->flags & T_FLAG_NOTFILE ) out_printf( "NOTFILE " ); if ( t->flags & T_FLAG_TOUCHED ) out_printf( "TOUCHED " ); if ( t->flags & T_FLAG_LEAVES ) out_printf( "LEAVES " ); if ( t->flags & T_FLAG_NOUPDATE ) out_printf( "NOUPDATE " ); out_printf( "\n" ); } for ( c = t->depends; c; c = c->next ) { out_printf( " %s : Depends on %s (%s)", spaces( depth ), target_name( c->target ), target_fate[ (int)c->target->fate ] ); if ( !timestamp_cmp( &c->target->time, &t->time ) ) out_printf( " (max time)"); out_printf( "\n" ); } for ( c = t->depends; c; c = c->next ) dependGraphOutput( c->target, depth + 1 ); }
void make0 ( TARGET * t, TARGET * p, /* parent */ int depth, /* for display purposes */ COUNTS * counts, /* for reporting */ int anyhow, TARGET * rescanning ) /* forcibly touch all (real) targets */ { TARGETS * c; TARGET * ptime = t; TARGET * located_target = 0; timestamp last; timestamp leaf; timestamp hlast; int fate; char const * flag = ""; SETTINGS * s; #ifdef OPT_GRAPH_DEBUG_EXT int savedFate; int oldTimeStamp; #endif if ( DEBUG_MAKEPROG ) out_printf( "make\t--\t%s%s\n", spaces( depth ), object_str( t->name ) ); /* * Step 1: Initialize. */ if ( DEBUG_MAKEPROG ) out_printf( "make\t--\t%s%s\n", spaces( depth ), object_str( t->name ) ); t->fate = T_FATE_MAKING; t->depth = depth; /* * Step 2: Under the influence of "on target" variables, bind the target and * search for headers. */ /* Step 2a: Set "on target" variables. */ s = copysettings( t->settings ); pushsettings( root_module(), s ); /* Step 2b: Find and timestamp the target file (if it is a file). */ if ( ( t->binding == T_BIND_UNBOUND ) && !( t->flags & T_FLAG_NOTFILE ) ) { OBJECT * another_target; object_free( t->boundname ); t->boundname = search( t->name, &t->time, &another_target, t->flags & T_FLAG_ISFILE ); /* If it was detected that this target refers to an already existing and * bound target, we add a dependency so that every target depending on * us will depend on that other target as well. */ if ( another_target ) located_target = bindtarget( another_target ); t->binding = timestamp_empty( &t->time ) ? T_BIND_MISSING : T_BIND_EXISTS; } /* INTERNAL, NOTFILE header nodes have the time of their parents. */ if ( p && ( t->flags & T_FLAG_INTERNAL ) ) ptime = p; /* If temp file does not exist but parent does, use parent. */ if ( p && ( t->flags & T_FLAG_TEMP ) && ( t->binding == T_BIND_MISSING ) && ( p->binding != T_BIND_MISSING ) ) { t->binding = T_BIND_PARENTS; ptime = p; } #ifdef OPT_SEMAPHORE { LIST * var = var_get( root_module(), constant_JAM_SEMAPHORE ); if ( !list_empty( var ) ) { TARGET * const semaphore = bindtarget( list_front( var ) ); semaphore->progress = T_MAKE_SEMAPHORE; t->semaphore = semaphore; } } #endif /* Step 2c: If its a file, search for headers. */ if ( t->binding == T_BIND_EXISTS ) headers( t ); /* Step 2d: reset "on target" variables. */ popsettings( root_module(), s ); freesettings( s ); /* * Pause for a little progress reporting. */ if ( DEBUG_BIND ) { if ( !object_equal( t->name, t->boundname ) ) out_printf( "bind\t--\t%s%s: %s\n", spaces( depth ), object_str( t->name ), object_str( t->boundname ) ); switch ( t->binding ) { case T_BIND_UNBOUND: case T_BIND_MISSING: case T_BIND_PARENTS: out_printf( "time\t--\t%s%s: %s\n", spaces( depth ), object_str( t->name ), target_bind[ (int)t->binding ] ); break; case T_BIND_EXISTS: out_printf( "time\t--\t%s%s: %s\n", spaces( depth ), object_str( t->name ), timestamp_str( &t->time ) ); break; } } /* * Step 3: Recursively make0() dependencies & headers. */ /* Step 3a: Recursively make0() dependencies. */ for ( c = t->depends; c; c = c->next ) { int const internal = t->flags & T_FLAG_INTERNAL; /* Warn about circular deps, except for includes, which include each * other alot. */ if ( c->target->fate == T_FATE_INIT ) make0( c->target, ptime, depth + 1, counts, anyhow, rescanning ); else if ( c->target->fate == T_FATE_MAKING && !internal ) out_printf( "warning: %s depends on itself\n", object_str( c->target->name ) ); else if ( c->target->fate != T_FATE_MAKING && rescanning ) make0rescan( c->target, rescanning ); if ( rescanning && c->target->includes && c->target->includes->fate != T_FATE_MAKING ) make0rescan( target_scc( c->target->includes ), rescanning ); } if ( located_target ) { if ( located_target->fate == T_FATE_INIT ) make0( located_target, ptime, depth + 1, counts, anyhow, rescanning ); else if ( located_target->fate != T_FATE_MAKING && rescanning ) make0rescan( located_target, rescanning ); } /* Step 3b: Recursively make0() internal includes node. */ if ( t->includes ) make0( t->includes, p, depth + 1, counts, anyhow, rescanning ); /* Step 3c: Add dependencies' includes to our direct dependencies. */ { TARGETS * incs = 0; for ( c = t->depends; c; c = c->next ) if ( c->target->includes ) incs = targetentry( incs, c->target->includes ); t->depends = targetchain( t->depends, incs ); } if ( located_target ) t->depends = targetentry( t->depends, located_target ); /* Step 3d: Detect cycles. */ { int cycle_depth = depth; for ( c = t->depends; c; c = c->next ) { TARGET * scc_root = target_scc( c->target ); if ( scc_root->fate == T_FATE_MAKING && ( !scc_root->includes || scc_root->includes->fate != T_FATE_MAKING ) ) { if ( scc_root->depth < cycle_depth ) { cycle_depth = scc_root->depth; t->scc_root = scc_root; } } } } /* * Step 4: Compute time & fate. */ /* Step 4a: Pick up dependencies' time and fate. */ timestamp_clear( &last ); timestamp_clear( &leaf ); fate = T_FATE_STABLE; for ( c = t->depends; c; c = c->next ) { /* If we are in a different strongly connected component, pull * timestamps from the root. */ if ( c->target->scc_root ) { TARGET * const scc_root = target_scc( c->target ); if ( scc_root != t->scc_root ) { timestamp_max( &c->target->leaf, &c->target->leaf, &scc_root->leaf ); timestamp_max( &c->target->time, &c->target->time, &scc_root->time ); c->target->fate = max( c->target->fate, scc_root->fate ); } } /* If LEAVES has been applied, we only heed the timestamps of the leaf * source nodes. */ timestamp_max( &leaf, &leaf, &c->target->leaf ); if ( t->flags & T_FLAG_LEAVES ) { timestamp_copy( &last, &leaf ); continue; } timestamp_max( &last, &last, &c->target->time ); fate = max( fate, c->target->fate ); #ifdef OPT_GRAPH_DEBUG_EXT if ( DEBUG_FATE ) if ( fate < c->target->fate ) out_printf( "fate change %s from %s to %s by dependency %s\n", object_str( t->name ), target_fate[ (int)fate ], target_fate[ (int)c->target->fate ], object_str( c->target->name ) ); #endif } /* Step 4b: Pick up included headers time. */ /* * If a header is newer than a temp source that includes it, the temp source * will need building. */ if ( t->includes ) timestamp_copy( &hlast, &t->includes->time ); else timestamp_clear( &hlast ); /* Step 4c: handle NOUPDATE oddity. * * If a NOUPDATE file exists, mark it as having eternally old dependencies. * Do not inherit our fate from our dependencies. Decide fate based only on * other flags and our binding (done later). */ if ( t->flags & T_FLAG_NOUPDATE ) { #ifdef OPT_GRAPH_DEBUG_EXT if ( DEBUG_FATE ) if ( fate != T_FATE_STABLE ) out_printf( "fate change %s back to stable, NOUPDATE.\n", object_str( t->name ) ); #endif timestamp_clear( &last ); timestamp_clear( &t->time ); /* Do not inherit our fate from our dependencies. Decide fate based only * upon other flags and our binding (done later). */ fate = T_FATE_STABLE; } /* Step 4d: Determine fate: rebuild target or what? */ /* In English: If can not find or make child, can not make target. If children changed, make target. If target missing, make it. If children newer, make target. If temp's children newer than parent, make temp. If temp's headers newer than parent, make temp. If deliberately touched, make it. If up-to-date temp file present, use it. If target newer than non-notfile parent, mark target newer. Otherwise, stable! Note this block runs from least to most stable: as we make it further down the list, the target's fate gets more stable. */ #ifdef OPT_GRAPH_DEBUG_EXT savedFate = fate; oldTimeStamp = 0; #endif if ( fate >= T_FATE_BROKEN ) { fate = T_FATE_CANTMAKE; } else if ( fate >= T_FATE_SPOIL ) { fate = T_FATE_UPDATE; } else if ( t->binding == T_BIND_MISSING ) { fate = T_FATE_MISSING; } else if ( t->binding == T_BIND_EXISTS && timestamp_cmp( &last, &t->time ) > 0 ) { #ifdef OPT_GRAPH_DEBUG_EXT oldTimeStamp = 1; #endif fate = T_FATE_OUTDATED; } else if ( t->binding == T_BIND_PARENTS && timestamp_cmp( &last, &p->time ) > 0 ) { #ifdef OPT_GRAPH_DEBUG_EXT oldTimeStamp = 1; #endif fate = T_FATE_NEEDTMP; } else if ( t->binding == T_BIND_PARENTS && timestamp_cmp( &hlast, &p->time ) > 0 ) { fate = T_FATE_NEEDTMP; } else if ( t->flags & T_FLAG_TOUCHED ) { fate = T_FATE_TOUCHED; } else if ( anyhow && !( t->flags & T_FLAG_NOUPDATE ) ) { fate = T_FATE_TOUCHED; } else if ( t->binding == T_BIND_EXISTS && ( t->flags & T_FLAG_TEMP ) ) { fate = T_FATE_ISTMP; } else if ( t->binding == T_BIND_EXISTS && p && p->binding != T_BIND_UNBOUND && timestamp_cmp( &t->time, &p->time ) > 0 ) { #ifdef OPT_GRAPH_DEBUG_EXT oldTimeStamp = 1; #endif fate = T_FATE_NEWER; } else { fate = T_FATE_STABLE; } #ifdef OPT_GRAPH_DEBUG_EXT if ( DEBUG_FATE && ( fate != savedFate ) ) { if ( savedFate == T_FATE_STABLE ) out_printf( "fate change %s set to %s%s\n", object_str( t->name ), target_fate[ fate ], oldTimeStamp ? " (by timestamp)" : "" ); else out_printf( "fate change %s from %s to %s%s\n", object_str( t->name ), target_fate[ savedFate ], target_fate[ fate ], oldTimeStamp ? " (by timestamp)" : "" ); } #endif /* Step 4e: Handle missing files. */ /* If it is missing and there are no actions to create it, boom. */ /* If we can not make a target we do not care about it, okay. */ /* We could insist that there are updating actions for all missing */ /* files, but if they have dependencies we just pretend it is a NOTFILE. */ if ( ( fate == T_FATE_MISSING ) && !t->actions && !t->depends ) { if ( t->flags & T_FLAG_NOCARE ) { #ifdef OPT_GRAPH_DEBUG_EXT if ( DEBUG_FATE ) out_printf( "fate change %s to STABLE from %s, " "no actions, no dependencies and do not care\n", object_str( t->name ), target_fate[ fate ] ); #endif fate = T_FATE_STABLE; } else { out_printf( "don't know how to make %s\n", object_str( t->name ) ); fate = T_FATE_CANTFIND; } } /* Step 4f: Propagate dependencies' time & fate. */ /* Set leaf time to be our time only if this is a leaf. */ timestamp_max( &t->time, &t->time, &last ); timestamp_copy( &t->leaf, timestamp_empty( &leaf ) ? &t->time : &leaf ); /* This target's fate may have been updated by virtue of following some * target's rebuilds list, so only allow it to be increased to the fate we * have calculated. Otherwise, grab its new fate. */ if ( fate > t->fate ) t->fate = fate; else fate = t->fate; /* * Step 4g: If this target needs to be built, make0 all targets * that are updated by the same actions used to update this target. * These have already been marked as REBUILDS, and make1 has * special handling for them. We just need to make sure that * they get make0ed. */ if ( ( fate >= T_FATE_BUILD ) && ( fate < T_FATE_BROKEN ) ) { ACTIONS * a; TARGETS * c; for ( a = t->actions; a; a = a->next ) { for ( c = a->action->targets; c; c = c->next ) { if ( c->target->fate == T_FATE_INIT ) { make0( c->target, ptime, depth + 1, counts, anyhow, rescanning ); } } } } /* Step 4h: If this target needs to be built, force rebuild everything in * its rebuilds list. */ if ( ( fate >= T_FATE_BUILD ) && ( fate < T_FATE_BROKEN ) ) force_rebuilds( t ); /* * Step 5: Sort dependencies by their update time. */ if ( globs.newestfirst ) t->depends = make0sort( t->depends ); /* * Step 6: A little harmless tabulating for tracing purposes. */ /* Do not count or report interal includes nodes. */ if ( t->flags & T_FLAG_INTERNAL ) return; if ( counts ) { #ifdef OPT_IMPROVED_PATIENCE_EXT ++counts->targets; #else if ( !( ++counts->targets % 1000 ) && DEBUG_MAKE ) { out_printf( "...patience...\n" ); out_flush(); } #endif if ( fate == T_FATE_ISTMP ) ++counts->temp; else if ( fate == T_FATE_CANTFIND ) ++counts->cantfind; else if ( ( fate == T_FATE_CANTMAKE ) && t->actions ) ++counts->cantmake; else if ( ( fate >= T_FATE_BUILD ) && ( fate < T_FATE_BROKEN ) && t->actions ) ++counts->updating; } if ( !( t->flags & T_FLAG_NOTFILE ) && ( fate >= T_FATE_SPOIL ) ) flag = "+"; else if ( t->binding == T_BIND_EXISTS && p && timestamp_cmp( &t->time, &p->time ) > 0 ) flag = "*"; if ( DEBUG_MAKEPROG ) out_printf( "made%s\t%s\t%s%s\n", flag, target_fate[ (int)t->fate ], spaces( depth ), object_str( t->name ) ); }
LIST * hcache( TARGET * t, int rec, regexp * re[], LIST * hdrscan ) { HCACHEDATA * c; LIST * l = 0; ++queries; if ( ( c = (HCACHEDATA *)hash_find( hcachehash, t->boundname ) ) ) { if ( c->time == t->time ) { LIST *l1 = hdrscan, *l2 = c->hdrscan; LISTITER iter1 = list_begin( l1 ), end1 = list_end( l1 ), iter2 = list_begin( l2 ), end2 = list_end( l2 ); while ( iter1 != end1 && iter2 != end2 ) { if ( !object_equal( list_item( iter1 ), list_item( iter2 ) ) ) { iter1 = end1; } else { iter1 = list_next( iter1 ); iter2 = list_next( iter2 ); } } if ( iter1 != end1 || iter2 != end2 ) { if (DEBUG_HEADER) printf( "HDRSCAN out of date in cache for %s\n", object_str( t->boundname ) ); printf( "HDRSCAN out of date for %s\n", object_str( t->boundname ) ); printf(" real : "); list_print( hdrscan ); printf( "\n cached: " ); list_print( c->hdrscan ); printf( "\n" ); list_free( c->includes ); list_free( c->hdrscan ); c->includes = L0; c->hdrscan = L0; } else { if (DEBUG_HEADER) printf( "using header cache for %s\n", object_str( t->boundname ) ); c->age = 0; ++hits; l = list_copy( c->includes ); return l; } } else { if (DEBUG_HEADER) printf ("header cache out of date for %s\n", object_str( t->boundname ) ); list_free( c->includes ); list_free( c->hdrscan ); c->includes = L0; c->hdrscan = L0; } } else { int found; c = (HCACHEDATA *)hash_insert( hcachehash, t->boundname, &found ); if ( !found ) { c->boundname = object_copy( t->boundname ); c->next = hcachelist; hcachelist = c; } } /* 'c' points at the cache entry. Its out of date. */ l = headers1( L0, t->boundname, rec, re ); c->time = t->time; c->age = 0; c->includes = list_copy( l ); c->hdrscan = list_copy( hdrscan ); return l; }
LIST * var_get( struct module_t * module, OBJECT * symbol ) { LIST * result = L0; #ifdef OPT_AT_FILES /* Some "fixed" variables... */ if ( object_equal( symbol, constant_TMPDIR ) ) { list_free( saved_var ); result = saved_var = list_new( object_new( path_tmpdir()->value ) ); } else if ( object_equal( symbol, constant_TMPNAME ) ) { list_free( saved_var ); result = saved_var = list_new( path_tmpnam() ); } else if ( object_equal( symbol, constant_TMPFILE ) ) { list_free( saved_var ); result = saved_var = list_new( path_tmpfile() ); } else if ( object_equal( symbol, constant_STDOUT ) ) { list_free( saved_var ); result = saved_var = list_new( object_copy( constant_STDOUT ) ); } else if ( object_equal( symbol, constant_STDERR ) ) { list_free( saved_var ); result = saved_var = list_new( object_copy( constant_STDERR ) ); } else #endif { VARIABLE * v; int n; if ( ( n = module_get_fixed_var( module, symbol ) ) != -1 ) { if ( DEBUG_VARGET ) var_dump( symbol, module->fixed_variables[ n ], "get" ); result = module->fixed_variables[ n ]; } else if ( module->variables && ( v = (VARIABLE *)hash_find( module->variables, symbol ) ) ) { if ( DEBUG_VARGET ) var_dump( v->symbol, v->value, "get" ); result = v->value; } #ifdef OS_VMS else if ( ( module->name && object_equal( module->name, constant_ENVIRON ) ) || root_module() == module ) { /* On VMS, when a variable from root or ENVIRON module is not found, * explicitly request it from the process. * By design, process variables (and logicals) are not made available * to C main(), and thus will not get loaded in bulk to root/ENVRON. * So we get around it by getting any such variable on first request. */ const char * val = getenv( object_str( symbol ) ); if ( val ) { struct module_t * environ_module = module; char * environ[ 2 ] = { 0 }; /* NULL-terminated */ string buf[ 1 ]; if ( root_module() == module ) { environ_module = bindmodule( constant_ENVIRON ); } string_copy( buf, object_str( symbol ) ); string_append( buf, "=" ); string_append( buf, val ); environ[ 0 ] = buf->value; /* Load variable to global module, with splitting, for backward * compatibility. Then to .ENVIRON, without splitting. */ var_defines( root_module(), environ, 1 ); var_defines( environ_module, environ, 0 ); string_free( buf ); if ( module->variables && ( v = (VARIABLE *)hash_find( module->variables, symbol ) ) ) { if ( DEBUG_VARGET ) var_dump( v->symbol, v->value, "get" ); result = v->value; } } } #endif } return result; }