Merge branch 'master' of ../yap-6.2

This commit is contained in:
Vítor Santos Costa 2010-12-07 15:08:25 +00:00
commit 30b0160b0d
8 changed files with 56 additions and 12 deletions

View File

@ -13818,7 +13818,7 @@ Yap_absmi(int inp)
ENDP(pt1); ENDP(pt1);
ENDD(d1); ENDD(d1);
} else if (mod != CurrentModule) { } else if (mod != CurrentModule) {
goto execute2_metacall; goto execute2_metacall;
} }
} }
if (PRED_GOAL_EXPANSION_ALL) { if (PRED_GOAL_EXPANSION_ALL) {

View File

@ -2647,6 +2647,9 @@ YAP_Init(YAP_init_args *yap_init)
else else
Yap_AttsSize = 2048*sizeof(CELL); Yap_AttsSize = 2048*sizeof(CELL);
if (restore_result == DO_ONLY_CODE) { if (restore_result == DO_ONLY_CODE) {
/* first, initialise the saved state */
Term t_goal = MkAtomTerm(AtomStartupSavedState);
YAP_RunGoalOnce(t_goal);
return YAP_BOOT_FROM_SAVED_CODE; return YAP_BOOT_FROM_SAVED_CODE;
} else { } else {
return YAP_BOOT_FROM_SAVED_STACKS; return YAP_BOOT_FROM_SAVED_STACKS;

View File

@ -484,6 +484,24 @@ InitDebug(void)
Yap_PutValue(At, MkIntTerm(15)); Yap_PutValue(At, MkIntTerm(15));
} }
static UInt
update_flags_from_prolog(UInt flags, PredEntry *pe)
{
if (pe->PredFlags & MetaPredFlag)
flags |= MetaPredFlag;
if (pe->PredFlags & SourcePredFlag)
flags |= SourcePredFlag;
if (pe->PredFlags & SequentialPredFlag)
flags |= SequentialPredFlag;
if (pe->PredFlags & MyddasPredFlag)
flags |= MyddasPredFlag;
if (pe->PredFlags & UDIPredFlag)
flags |= UDIPredFlag;
if (pe->PredFlags & ModuleTransparentPredFlag)
flags |= ModuleTransparentPredFlag;
return flags;
}
void void
Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags) Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
{ {
@ -521,8 +539,9 @@ Yap_InitCPred(char *Name, unsigned long int Arity, CPredicate code, UInt flags)
} }
if (pe->PredFlags & CPredFlag) { if (pe->PredFlags & CPredFlag) {
/* already exists */ /* already exists */
flags = update_flags_from_prolog(flags, pe);
cl = ClauseCodeToStaticClause(pe->CodeOfPred); cl = ClauseCodeToStaticClause(pe->CodeOfPred);
if ((flags | StandardPredFlag | CPredFlag) != pe->PredFlags) { if ((flags | StandardPredFlag | CPredFlag ) != pe->PredFlags) {
Yap_ClauseSpace -= cl->ClSize; Yap_ClauseSpace -= cl->ClSize;
Yap_FreeCodeSpace((ADDR)cl); Yap_FreeCodeSpace((ADDR)cl);
cl = NULL; cl = NULL;
@ -618,6 +637,7 @@ Yap_InitCmpPred(char *Name, unsigned long int Arity, CmpPredicate cmp_code, UInt
} }
} }
if (pe->PredFlags & CPredFlag) { if (pe->PredFlags & CPredFlag) {
flags = update_flags_from_prolog(flags, pe);
p_code = pe->CodeOfPred; p_code = pe->CodeOfPred;
/* already exists */ /* already exists */
} else { } else {
@ -691,7 +711,12 @@ Yap_InitAsmPred(char *Name, unsigned long int Arity, int code, CPredicate def,
return; return;
} }
} }
pe->PredFlags = flags | AsmPredFlag | StandardPredFlag | (code); flags |= AsmPredFlag | StandardPredFlag | (code);
if (pe->PredFlags & AsmPredFlag) {
flags = update_flags_from_prolog(flags, pe);
/* already exists */
}
pe->PredFlags = flags;
pe->cs.f_code = def; pe->cs.f_code = def;
pe->ModuleOfPred = CurrentModule; pe->ModuleOfPred = CurrentModule;
if (def != NULL) { if (def != NULL) {
@ -859,6 +884,7 @@ Yap_InitCPredBack(char *Name, unsigned long int Arity,
} }
if (pe->cs.p_code.FirstClause != NIL) if (pe->cs.p_code.FirstClause != NIL)
{ {
flags = update_flags_from_prolog(flags, pe);
#ifdef CUT_C #ifdef CUT_C
CleanBack(pe, Start, Cont, Cut); CleanBack(pe, Start, Cont, Cut);
#else #else

View File

@ -266,6 +266,7 @@
AtomSpy = Yap_FullLookupAtom("$spy"); AtomSpy = Yap_FullLookupAtom("$spy");
AtomStack = Yap_LookupAtom("stack"); AtomStack = Yap_LookupAtom("stack");
AtomStackFree = Yap_LookupAtom("stackfree"); AtomStackFree = Yap_LookupAtom("stackfree");
AtomStartupSavedState = Yap_FullLookupAtom("$startup_saved_state");
AtomStaticClause = Yap_FullLookupAtom("$static_clause"); AtomStaticClause = Yap_FullLookupAtom("$static_clause");
AtomStaticProcedure = Yap_LookupAtom("static_procedure"); AtomStaticProcedure = Yap_LookupAtom("static_procedure");
AtomStream = Yap_FullLookupAtom("$stream"); AtomStream = Yap_FullLookupAtom("$stream");

View File

@ -266,6 +266,7 @@
AtomSpy = AtomAdjust(AtomSpy); AtomSpy = AtomAdjust(AtomSpy);
AtomStack = AtomAdjust(AtomStack); AtomStack = AtomAdjust(AtomStack);
AtomStackFree = AtomAdjust(AtomStackFree); AtomStackFree = AtomAdjust(AtomStackFree);
AtomStartupSavedState = AtomAdjust(AtomStartupSavedState);
AtomStaticClause = AtomAdjust(AtomStaticClause); AtomStaticClause = AtomAdjust(AtomStaticClause);
AtomStaticProcedure = AtomAdjust(AtomStaticProcedure); AtomStaticProcedure = AtomAdjust(AtomStaticProcedure);
AtomStream = AtomAdjust(AtomStream); AtomStream = AtomAdjust(AtomStream);

View File

@ -530,6 +530,8 @@
#define AtomStack Yap_heap_regs->AtomStack_ #define AtomStack Yap_heap_regs->AtomStack_
Atom AtomStackFree_; Atom AtomStackFree_;
#define AtomStackFree Yap_heap_regs->AtomStackFree_ #define AtomStackFree Yap_heap_regs->AtomStackFree_
Atom AtomStartupSavedState_;
#define AtomStartupSavedState Yap_heap_regs->AtomStartupSavedState_
Atom AtomStaticClause_; Atom AtomStaticClause_;
#define AtomStaticClause Yap_heap_regs->AtomStaticClause_ #define AtomStaticClause Yap_heap_regs->AtomStaticClause_
Atom AtomStaticProcedure_; Atom AtomStaticProcedure_;

View File

@ -271,6 +271,7 @@ A SourceSink N "source_sink"
A Spy F "$spy" A Spy F "$spy"
A Stack N "stack" A Stack N "stack"
A StackFree N "stackfree" A StackFree N "stackfree"
A StartupSavedState F "$startup_saved_state"
A StaticClause F "$static_clause" A StaticClause F "$static_clause"
A StaticProcedure N "static_procedure" A StaticProcedure N "static_procedure"
A Stream F "$stream" A Stream F "$stream"

View File

@ -88,6 +88,8 @@ true :- true.
) )
), ),
'$db_clean_queues'(0), '$db_clean_queues'(0),
% this must be executed from C-code.
% '$startup_saved_state',
'$startup_reconsult', '$startup_reconsult',
'$startup_goals', '$startup_goals',
'$set_input'(user_input),'$set_output'(user), '$set_input'(user_input),'$set_output'(user),
@ -196,24 +198,38 @@ true :- true.
'$sync_mmapped_arrays', '$sync_mmapped_arrays',
set_value('$live','$false'). set_value('$live','$false').
'$startup_goals' :- %
% first, recover what we need from the saved state...
%
'$startup_saved_state' :-
get_value('$extend_file_search_path',P), P \= [], get_value('$extend_file_search_path',P), P \= [],
set_value('$extend_file_search_path',[]), set_value('$extend_file_search_path',[]),
'$extend_file_search_path'(P), '$extend_file_search_path'(P),
fail. fail.
% use if we come from a save_program and we have SWI's shlib % use if we come from a save_program and we have SWI's shlib
'$startup_goals' :- '$startup_saved_state' :-
recorded('$reload_foreign_libraries',G,R), recorded('$reload_foreign_libraries',G,R),
erase(R), erase(R),
shlib:reload_foreign_libraries, shlib:reload_foreign_libraries,
fail. fail.
% use if we come from a save_program and we have a goal to execute % use if we come from a save_program and we have a goal to execute
'$startup_goals' :- '$startup_saved_state' :-
recorded('$restore_goal',G,R), recorded('$restore_goal',G,R),
erase(R), erase(R),
prompt(_,' | '), prompt(_,' | '),
'$system_catch'('$do_yes_no'((G->true),user),user,Error,user:'$Error'(Error)), '$system_catch'('$do_yes_no'((G->true),user),user,Error,user:'$Error'(Error)),
fail. fail.
'$startup_saved_state'.
% then recover program.
'$startup_reconsult' :-
get_value('$consult_on_boot',X), X \= [], !,
set_value('$consult_on_boot',[]),
'$do_startup_reconsult'(X).
'$startup_reconsult'.
% then we can execute the programs.
'$startup_goals' :- '$startup_goals' :-
recorded('$startup_goal',G,_), recorded('$startup_goal',G,_),
'$current_module'(Module), '$current_module'(Module),
@ -252,12 +268,6 @@ true :- true.
fail. fail.
'$startup_goals'. '$startup_goals'.
'$startup_reconsult' :-
get_value('$consult_on_boot',X), X \= [], !,
set_value('$consult_on_boot',[]),
'$do_startup_reconsult'(X).
'$startup_reconsult'.
% %
% MYDDAS: Import all the tables from one database % MYDDAS: Import all the tables from one database
% %