summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-10 17:38:28 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-10 17:38:28 +0200
commit9918c1206e291b0bbd324463b3d1fa347a7222de (patch)
treebdf6c8ae05f3d9ec5c4720414bae3ccb1ce78e8c /quickjs.c
parent7adeb5c56e18858ab92337c59b393f0704538e22 (diff)
downloadquickjs-9918c1206e291b0bbd324463b3d1fa347a7222de.tar.gz
quickjs-9918c1206e291b0bbd324463b3d1fa347a7222de.zip
workaround for #282
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/quickjs.c b/quickjs.c
index fd464c9..028744c 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -31821,10 +31821,11 @@ static BOOL code_has_label(CodeContext *s, int pos, int label)
/* return the target label, following the OP_goto jumps
the first opcode at destination is stored in *pop
*/
-static int find_jump_target(JSFunctionDef *s, int label, int *pop, int *pline)
+static int find_jump_target(JSFunctionDef *s, int label0, int *pop, int *pline)
{
- int i, pos, op;
+ int i, pos, op, label;
+ label = label0;
update_label(s, label, -1);
for (i = 0; i < 10; i++) {
assert(label >= 0 && label < s->label_count);
@@ -31855,6 +31856,19 @@ static int find_jump_target(JSFunctionDef *s, int label, int *pop, int *pline)
}
}
/* cycle detected, could issue a warning */
+ /* XXX: the combination of find_jump_target() and skip_dead_code()
+ seems incorrect with cyclic labels. See for exemple:
+
+ for (;;) {
+ l:break l;
+ l:break l;
+ l:break l;
+ l:break l;
+ }
+
+ Avoiding changing the target is just a workaround and might not
+ suffice to completely fix the problem. */
+ label = label0;
done:
*pop = op;
update_label(s, label, +1);