From 36e9ff758887b404d01f2e556d873f565bc2bc55 Mon Sep 17 00:00:00 2001 From: ricroc Date: Fri, 7 Nov 2003 16:31:08 +0000 Subject: [PATCH] My first attempt to synchronize OPTYap with CVS git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@920 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/alloc.c | 6 ++---- C/amasm.c | 5 +++++ C/c_interface.c | 2 +- C/compiler.c | 21 ++++++++++++++++++--- C/computils.c | 9 ++++++--- C/grow.c | 10 +++++----- C/init.c | 45 ++++++++++++++++++++++++++++++++++++++------- C/save.c | 11 ++--------- C/stdpreds.c | 2 +- 9 files changed, 78 insertions(+), 33 deletions(-) diff --git a/C/alloc.c b/C/alloc.c index 04ea548f0..edfde195e 100644 --- a/C/alloc.c +++ b/C/alloc.c @@ -12,7 +12,7 @@ * Last rev: * * mods: * * comments: allocating space * -* version:$Id: alloc.c,v 1.39 2003-10-30 22:52:46 vsc Exp $ * +* version:$Id: alloc.c,v 1.40 2003-11-07 16:31:08 ricroc Exp $ * *************************************************************************/ #ifdef SCCS static char SccsId[] = "%W% %G%"; @@ -1049,10 +1049,8 @@ InitHeap(void *heap_addr) BaseAllocArea = AllocCodeSpace(OPT_CHUNK_SIZE); TopAllocArea = BaseAllocArea; #endif - LOCAL = REMOTE; /* point to the first area */ -#endif - +#endif /* YAPOR || TABLING */ } void diff --git a/C/amasm.c b/C/amasm.c index bef13fc86..5ba755383 100644 --- a/C/amasm.c +++ b/C/amasm.c @@ -2129,6 +2129,11 @@ do_pass(void) a_n(_table_new_answer, (int) cpc->rnd2); break; #endif /* TABLING */ +#ifdef TABLING_INNER_CUTS + case clause_with_cut_op: + a_e(_clause_with_cut); + break; +#endif /* TABLING_INNER_CUTS */ #ifdef SFUNC case get_s_f_op: a_rf(_get_s_f); diff --git a/C/c_interface.c b/C/c_interface.c index 390ede766..b6d094ec4 100644 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -932,7 +932,7 @@ YAP_Init(YAP_init_args *yap_init) from the other workers */ Yap_InitYaamRegs(); -#endif +#endif /* SBA */ /* slaves, waiting for work */ CurrentModule = 1; P = GETWORK_FIRST_TIME; diff --git a/C/compiler.c b/C/compiler.c index e448b7915..7e9f23d4c 100644 --- a/C/compiler.c +++ b/C/compiler.c @@ -49,12 +49,14 @@ STATIC_PROTO( int checktemp, (void)); STATIC_PROTO(void checkreg, (int)); STATIC_PROTO(void c_layout, (void)); STATIC_PROTO(void c_optimize, (PInstr *)); - #ifdef SFUNC STATIC_PROTO(void compile_sf_term, (Term, int)); - #endif +#ifdef TABLING_INNER_CUTS +PInstr *cut_mark; +#endif /* TABLING_INNER_CUTS */ + static PInstr *BodyStart; static Ventry *vtable; @@ -2364,6 +2366,12 @@ c_layout(void) #else switch (ic) { #endif +#ifdef TABLING_INNER_CUTS + case cut_op: + case cutexit_op: + cut_mark->op = clause_with_cut_op; + break; +#endif /* TABLING_INNER_CUTS */ case allocate_op: case deallocate_op: #ifdef TABLING @@ -2476,8 +2484,11 @@ c_layout(void) Contents[rn] = NIL; ++Uses[rn]; break; - case save_b_op: case comit_b_op: +#ifdef TABLING_INNER_CUTS + cut_mark->op = clause_with_cut_op; +#endif /* TABLING_INNER_CUTS */ + case save_b_op: case patch_b_op: case save_appl_op: case save_pair_op: @@ -2819,6 +2830,10 @@ Yap_cclause(Term inp_clause, int NOfArgs, int mod) } /* phase 1 : produce skeleton code and variable information */ c_head(head); +#ifdef TABLING_INNER_CUTS + Yap_emit(nop_op, Zero, Zero); + cut_mark = cpc; +#endif /* TABLING_INNER_CUTS */ Yap_emit(allocate_op, Zero, Zero); c_body(body, mod); /* Insert blobs at the very end */ diff --git a/C/computils.c b/C/computils.c index d7642ae81..080acab90 100644 --- a/C/computils.c +++ b/C/computils.c @@ -619,12 +619,15 @@ static char *opformat[] = "restore_temps_and_skip\t\t%l", "enter_lu", "empty_call\t\t%l,%d", -#ifdef TABLING - "table_new_answer", -#endif /* TABLING */ #ifdef YAPOR "sync", #endif /* YAPOR */ +#ifdef TABLING + "table_new_answer", +#endif /* TABLING */ +#ifdef TABLING_INNER_CUTS + "clause_with_cut", +#endif /* TABLING_INNER_CUTS */ "fetch_args_for_bccall\t%v", "binary_cfunc\t\t%v,%P", "blob\t%O" diff --git a/C/grow.c b/C/grow.c index 87398b665..ac5153cf2 100644 --- a/C/grow.c +++ b/C/grow.c @@ -135,7 +135,7 @@ SetHeapRegs(void) BB = ChoicePtrAdjust(BB); H_FZ = PtoGloAdjust(H_FZ); TR_FZ = PtoTRAdjust(TR_FZ); -#endif +#endif /* TABLING */ TR = PtoTRAdjust(TR); YENV = PtoLocAdjust(YENV); if (IsOldGlobalPtr(S)) @@ -180,7 +180,7 @@ SetStackRegs(void) B_FZ = ChoicePtrAdjust(B_FZ); BB = ChoicePtrAdjust(BB); TR_FZ = PtoTRAdjust(TR_FZ); -#endif +#endif /* TABLING */ YENV = PtoLocAdjust(YENV); if (MyTR) MyTR = PtoTRAdjust(MyTR); @@ -704,7 +704,7 @@ do_growheap(int fix_code, UInt in_size) } #ifdef TABLING fix_tabling_info(); -#endif +#endif /* TABLING */ if (sz >= sizeof(CELL) * 16 * 1024L) { return (TRUE); } @@ -733,7 +733,7 @@ Yap_growglobal(CELL **ptr) return(FALSE); #ifdef TABLING fix_tabling_info(); -#endif +#endif /* TABLING */ return(TRUE); } @@ -779,7 +779,7 @@ growstack(long size) AdjustRegs(MaxTemps); #ifdef TABLING fix_tabling_info(); -#endif +#endif /* TABLING */ YAPLeaveCriticalSection(); CreepFlag = CalculateStackGap(); ASP += 256; diff --git a/C/init.c b/C/init.c index 158c43961..567bddbf0 100644 --- a/C/init.c +++ b/C/init.c @@ -978,8 +978,8 @@ InitCodes(void) modp->PredFlags |= MetaPredFlag; } #ifdef YAPOR - heap_regs->getworkcode.u.ld.p = (CODEADDR)RepPredProp(PredPropByAtom(Yap_LookupAtom("$getwork"), 0)); - heap_regs->getworkcode_seq.u.ld.p = (CODEADDR)RepPredProp(PredPropByAtom(Yap_LookupAtom("$getwork_seq"), 0)); + heap_regs->getworkcode.u.ld.p = RepPredProp(PredPropByAtom(Yap_LookupAtom("$getwork"), 0)); + heap_regs->getworkcode_seq.u.ld.p = RepPredProp(PredPropByAtom(Yap_LookupAtom("$getwork_seq"), 0)); #endif heap_regs->db_erased_marker = (DBRef)Yap_AllocCodeSpace(sizeof(DBStruct)); @@ -1011,7 +1011,7 @@ InitYapOr(int Heap, #ifdef YAPOR worker_id = 0; -#endif +#endif /* YAPOR */ /* starting message */ #ifdef YAPOR @@ -1027,21 +1027,52 @@ InitYapOr(int Heap, #endif /* YAPOR */ #ifdef TABLING #ifdef TABLING_BATCHED_SCHEDULING +#ifdef YAPOR +#ifdef ALLOC_BEFORE_CHECK + INFORMATION_MESSAGE("YapTab: batched scheduling (TLWL-ABC)"); +#endif +#if defined(TABLE_LOCK_AT_WRITE_LEVEL) && ! defined(ALLOC_BEFORE_CHECK) + INFORMATION_MESSAGE("YapTab: batched scheduling (TLWL)"); +#endif +#ifdef TABLE_LOCK_AT_NODE_LEVEL + INFORMATION_MESSAGE("YapTab: batched scheduling (TLNL)"); +#endif +#ifdef TABLE_LOCK_AT_ENTRY_LEVEL + INFORMATION_MESSAGE("YapTab: batched scheduling (TLEL)"); +#endif +#else INFORMATION_MESSAGE("YapTab: batched scheduling"); +#endif /* YAPOR */ #else /* TABLING_LOCAL_SCHEDULING */ +#ifdef YAPOR +#ifdef ALLOC_BEFORE_CHECK + INFORMATION_MESSAGE("YapTab: local scheduling (TLWL-ABC)"); +#endif +#if defined(TABLE_LOCK_AT_WRITE_LEVEL) && ! defined(ALLOC_BEFORE_CHECK) + INFORMATION_MESSAGE("YapTab: local scheduling (TLWL)"); +#endif +#ifdef TABLE_LOCK_AT_NODE_LEVEL + INFORMATION_MESSAGE("YapTab: local scheduling (TLNL)"); +#endif +#ifdef TABLE_LOCK_AT_ENTRY_LEVEL + INFORMATION_MESSAGE("YapTab: local scheduling (TLEL)"); +#endif +#else INFORMATION_MESSAGE("YapTab: local scheduling"); +#endif /* YAPOR */ #endif /* TABLING_SCHEDULING */ #endif /* TABLING */ #ifdef YAPOR map_memory(Heap, Stack, Trail, aux_number_workers); #else Yap_InitMemory (Trail, Heap, Stack); -#endif +#endif /* YAPOR */ /* global initializations */ init_global(aux_number_workers, aux_scheduler_loop, aux_delayed_release_load); init_signals(); } -#endif +#endif /* YAPOR || TABLING */ + void Yap_InitStacks(int Heap, @@ -1088,7 +1119,7 @@ Yap_InitStacks(int Heap, #else if (Heap < MinHeapSpace) Heap = MinHeapSpace; -#endif +#endif /* YAPOR || TABLING */ #if defined(YAPOR) || defined(TABLING) InitYapOr(Heap, @@ -1131,7 +1162,7 @@ Yap_exit (int value) { #if defined(YAPOR) unmap_memory(); -#endif /* YAPOR || TABLING */ +#endif /* YAPOR */ if (! (Yap_PrologMode & BootMode) ) Yap_ShutdownLoadForeign(); exit(value); diff --git a/C/save.c b/C/save.c index 1c61625ed..c442d81cd 100644 --- a/C/save.c +++ b/C/save.c @@ -344,17 +344,10 @@ put_info(int info, int mode) /* say whether we just saved the heap or everything */ putout(mode); /* current state of stacks, to be used by SavedInfo */ -#if defined(YAPOR) || defined(TABLING) - /* space available in heap area */ - putout(Unsigned(Yap_GlobalBase)-Unsigned(Yap_HeapBase)); - /* space available for stacks */ - putout(Unsigned(Yap_LocalBase)-Unsigned(Yap_GlobalBase)+CellSize); -#else /* space available in heap area */ putout(Unsigned(Yap_GlobalBase)-Unsigned(Yap_HeapBase)); /* space available for stacks */ putout(Unsigned(Yap_LocalBase)-Unsigned(Yap_GlobalBase)); -#endif /* YAPOR || TABLING */ /* space available for trail */ putout(Unsigned(Yap_TrailTop)-Unsigned(Yap_TrailBase)); /* Space used in heap area */ @@ -468,7 +461,7 @@ save_heap(void) j = Unsigned(HeapTop) - Unsigned(Yap_HeapBase); /* store 10 more cells because of the memory manager */ mywrite(splfild, (char *) Yap_HeapBase, j); -#endif +#endif /* YAPOR || TABLING */ } static void @@ -804,7 +797,7 @@ CopyCode(void) #else myread(splfild, (char *) Yap_HeapBase, (Unsigned(OldHeapTop) - Unsigned(OldHeapBase))); -#endif +#endif /* YAPOR || TABLING */ } /* Copy the local and global stack and also the trail to their new home */ diff --git a/C/stdpreds.c b/C/stdpreds.c index 28b8005e2..354412210 100644 --- a/C/stdpreds.c +++ b/C/stdpreds.c @@ -2630,7 +2630,7 @@ Yap_InitCPreds(void) Yap_InitGrowPreds(); #if defined(YAPOR) || defined(TABLING) Yap_init_optyap_preds(); -#endif +#endif /* YAPOR || TABLING */ { void (*(*(p))) (void) = E_Modules; while (*p)