From f13399e708d69a3c8c6cbe4e341666785eb2e484 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Fri, 13 Sep 2024 15:03:08 +1000 Subject: [PATCH] WIP --- src/bif_maps.c | 2 +- src/bif_threads.c | 2 +- src/module.c | 2 +- src/parser.c | 10 +++++----- src/query.c | 20 ++++++++++---------- src/query.h | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/bif_maps.c b/src/bif_maps.c index 3ae653879..7b1b54ac2 100644 --- a/src/bif_maps.c +++ b/src/bif_maps.c @@ -392,7 +392,7 @@ static bool bif_engine_create_4(query *q) str->first_time = str->is_engine = true; str->curr_yield = NULL; - str->engine = query_create(q->st.m, true); + str->engine = query_create(q->st.m); str->engine->curr_engine = n; str->engine->is_engine = true; str->engine->trace = q->trace; diff --git a/src/bif_threads.c b/src/bif_threads.c index bf164bf9b..95b0f967c 100644 --- a/src/bif_threads.c +++ b/src/bif_threads.c @@ -744,7 +744,7 @@ static bool bif_thread_create_3(query *q) cell *goal = deep_clone_to_tmp(q, p1, p1_ctx); check_heap_error(goal); t->nbr_vars = rebase_term(q, goal, 0); - t->q = query_create(q->st.m, false); + t->q = query_create(q->st.m); check_heap_error(t->q); t->q->thread_ptr = t; t->q->my_chan = n; diff --git a/src/module.c b/src/module.c index 6c894e794..dee9f7770 100644 --- a/src/module.c +++ b/src/module.c @@ -937,7 +937,7 @@ bool do_use_module_2(module *curr_m, cell *c) pr2->alias = pr; } else if (is_structure(lhs) && is_structure(rhs)) { // assertz(goal_expansion(rhs, module:lhs)) - query *q = query_create(curr_m, false); + query *q = query_create(curr_m); check_error(q); q->varnames = true; char *dst1 = print_canonical_to_strbuf(q, rhs, 0, 0); diff --git a/src/parser.c b/src/parser.c index fe6e31325..381651a70 100644 --- a/src/parser.c +++ b/src/parser.c @@ -497,7 +497,7 @@ static bool goal_run(parser *p, cell *goal) if (goal->val_off == g_cut_s) return false; - query *q = query_create(p->m, false); + query *q = query_create(p->m); execute(q, goal, MAX_ARITY); if (q->retry != QUERY_OK) { @@ -1767,7 +1767,7 @@ void reset(parser *p) static bool dcg_expansion(parser *p) { - query *q = query_create(p->m, false); + query *q = query_create(p->m); check_error(q); q->trace = false; @@ -1849,7 +1849,7 @@ static bool term_expansion(parser *p) if (h->val_off == g_colon_s) return false; - query *q = query_create(m, true); + query *q = query_create(m); check_error(q); q->trace = false; cell *c = p->cl->cells; @@ -1926,7 +1926,7 @@ static cell *goal_expansion(parser *p, cell *goal) return goal; } - query *q = query_create(p->m, true); + query *q = query_create(p->m); check_error(q); q->trace = false; q->varnames = true; @@ -4034,7 +4034,7 @@ bool run(parser *p, const char *pSrc, bool dump, query **subq, unsigned int yiel return true; } - query *q = query_create(p->m, false); + query *q = query_create(p->m); if (!q) { p->srcptr = NULL; diff --git a/src/query.c b/src/query.c index 050814f68..34426a764 100644 --- a/src/query.c +++ b/src/query.c @@ -29,10 +29,10 @@ static void msleep(int ms) static const unsigned INITIAL_NBR_QUEUE_CELLS = 1000; static const unsigned INITIAL_NBR_HEAP_CELLS = 1000; -static const unsigned INITIAL_NBR_FRAMES = 1000; -static const unsigned INITIAL_NBR_SLOTS = 4000; -static const unsigned INITIAL_NBR_TRAILS = 4000; -static const unsigned INITIAL_NBR_CHOICES = 1000; +static const unsigned INITIAL_NBR_SLOTS = 1000; +static const unsigned INITIAL_NBR_TRAILS = 1000; +static const unsigned INITIAL_NBR_CHOICES = 100; +static const unsigned INITIAL_NBR_FRAMES = 100; static const unsigned INITIAL_NBR_CELLS = 100; int g_tpl_interrupt = 0; @@ -1931,7 +1931,7 @@ void query_destroy(query *q) free(q); } -query *query_create(module *m, bool is_sub_query) +query *query_create(module *m) { static pl_atomic uint64_t g_query_id = 0; query *q = calloc(1, sizeof(query)); @@ -1955,10 +1955,10 @@ query *query_create(module *m, bool is_sub_query) // Allocate these now... - q->frames_size = is_sub_query ? 100 : INITIAL_NBR_FRAMES; - q->choices_size = is_sub_query ? 100 : INITIAL_NBR_CHOICES; - q->slots_size = is_sub_query ? 1000 : INITIAL_NBR_SLOTS; - q->trails_size = is_sub_query ? 1000 : INITIAL_NBR_TRAILS; + q->frames_size = INITIAL_NBR_FRAMES; + q->choices_size = INITIAL_NBR_CHOICES; + q->slots_size = INITIAL_NBR_SLOTS; + q->trails_size = INITIAL_NBR_TRAILS; ensure(q->frames = calloc(q->frames_size, sizeof(frame)), NULL); ensure(q->choices = calloc(q->choices_size, sizeof(choice)), NULL); @@ -1979,7 +1979,7 @@ query *query_create(module *m, bool is_sub_query) query *query_create_subquery(query *q, cell *curr_instr) { - query *task = query_create(q->st.m, true); + query *task = query_create(q->st.m); if (!task) return NULL; task->parent = q; task->st.fp = 1; diff --git a/src/query.h b/src/query.h index 311bebdfa..4d53d75a6 100644 --- a/src/query.h +++ b/src/query.h @@ -10,7 +10,7 @@ typedef struct { const char *functor; } csv; -query *query_create(module *m, bool sub_query); +query *query_create(module *m); query *query_create_subquery(query *q, cell *curr_instr); query *query_create_task(query *q, cell *curr_instr); void query_destroy(query *q);