aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-03-13 19:38:52 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2025-03-13 19:38:52 +0200
commit8848ad8a546627e1e935c46950c7a9df759b320e (patch)
tree37edc965e348f2fd5433533ad963f7bd41be8a05
parent1283d90da7c16bf0e44118e0e9130f2274e2a0f8 (diff)
downloadposthaste-8848ad8a546627e1e935c46950c7a9df759b320e.tar.gz
posthaste-8848ad8a546627e1e935c46950c7a9df759b320e.zip
increase priority for loops
m---------deps/ejit0
-rw-r--r--examples/global-loop.ph (renamed from examples/ok-loop-huge.ph)0
-rw-r--r--examples/local-loop.ph12
-rw-r--r--src/lower.c3
4 files changed, 15 insertions, 0 deletions
diff --git a/deps/ejit b/deps/ejit
-Subproject ba9145b0b7af2a82c62f8dfa28807958af5d0c8
+Subproject 57f6b41047e95374701ee276248f0f861516845
diff --git a/examples/ok-loop-huge.ph b/examples/global-loop.ph
index 2381537..2381537 100644
--- a/examples/ok-loop-huge.ph
+++ b/examples/global-loop.ph
diff --git a/examples/local-loop.ph b/examples/local-loop.ph
new file mode 100644
index 0000000..2b7d870
--- /dev/null
+++ b/examples/local-loop.ph
@@ -0,0 +1,12 @@
+procedure SUM{num[int]} return int
+var sum = 0
+var idx = 0
+is
+ do
+ sum = sum + idx,
+ idx = idx + 1
+ until idx = num,
+ return sum
+end procedure
+
+print SUM(1000000001)
diff --git a/src/lower.c b/src/lower.c
index 7f74a50..f08d5a0 100644
--- a/src/lower.c
+++ b/src/lower.c
@@ -907,12 +907,15 @@ static struct ejit_reloc branch_if(struct fn *f, struct ast *cond, bool branch)
static void lower_until(struct fn *f, struct ast *n)
{
struct ejit_label l = ejit_label(f->f);
+ ejit_inc_prio(f->f, 100); /* completely arbitrary */
lower_list(f, until_body(n));
struct ast *cond = until_cond(n);
struct ejit_reloc branch = branch_if(f, cond, false);
ejit_patch(f->f, branch, l);
+ ejit_dec_prio(f->f, 100);
+
n->l = null_loc();
}