Skip to content

Commit

Permalink
Add NOOP expr operator
Browse files Browse the repository at this point in the history
During the tiling process we sometimes add tiles for the labels in
conditional expressions, that have no operator associated. However,
the operator in memory would then be 0, which is a valid operator type.

That didn't matter until I changed the order of LOAD and COPY, since COPY
is special-cased in the register allocator to make a reference - the
register allocator would then create a cycle in the union-find data
structure and loop forever. Oops.

One (valid) way to deal with it is to have pseudotiles initialized to an
invalid value like -1. But I think I tried that once and it ran into
problems (maybe due to invalid operator info).  So instead, I'm
declaring the 'zero' operator to be illegal, and also, I'm starting
nodes from 1, so that no valid reference is ever zero.
  • Loading branch information
bdw committed Jan 31, 2018
1 parent 783a4f0 commit 9a2d346
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/jit/expr.c
Expand Up @@ -685,6 +685,9 @@ MVMJitExprTree * MVM_jit_expr_tree_build(MVMThreadContext *tc, MVMJitGraph *jg,
MVM_VECTOR_INIT(tree->info, 256);
MVM_VECTOR_INIT(tree->roots, 16);

/* ensure that all references are nonzero */
MVM_VECTOR_PUSH(tree->nodes, MVM_JIT_NOOP);

tree->graph = jg;
tree->num_labels = 0;
/* Hold indices to the node that last computed a value belonging
Expand Down Expand Up @@ -937,7 +940,7 @@ MVMJitExprTree * MVM_jit_expr_tree_build(MVMThreadContext *tc, MVMJitGraph *jg,
}

done:
if (tree->nodes_num > 0) {
if (tree->roots_num > 0) {
active_values_flush(tc, tree, values, sg->num_locals);
MVM_jit_expr_tree_analyze(tc, tree);
MVM_jit_log(tc, "Build tree out of: [");
Expand Down
2 changes: 2 additions & 0 deletions src/jit/expr_ops.h
Expand Up @@ -13,6 +13,8 @@
src/jit/expr.h, so keep it in order!
*/
#define MVM_JIT_EXPR_OPS(_) \
/* invalid operator */ \
_(NOOP, 0, 0, VOID, NO_CAST), \
/* memory access */ \
_(LOAD, 1, 1, REG, NO_CAST), \
_(STORE, 2, 1, VOID, NO_CAST), \
Expand Down

0 comments on commit 9a2d346

Please sign in to comment.