Skip to content

Commit

Permalink
Make expr tree environment-controllable
Browse files Browse the repository at this point in the history
MVM_JIT_EXPR_ENABLE needs to be set to nonempty value for the expr
tree compiler to run.
  • Loading branch information
bdw committed Aug 25, 2015
1 parent 2fbd57a commit 04d892a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/instance.h
Expand Up @@ -187,6 +187,7 @@ struct MVMInstance {

/* Flag for if jit is enabled */
MVMint32 jit_enabled;
MVMint32 jit_expr_enabled;

/* File for JIT logging */
FILE *jit_log_fh;
Expand Down
7 changes: 6 additions & 1 deletion src/jit/graph.c
Expand Up @@ -2430,14 +2430,19 @@ static MVMint32 jgb_consume_bb(MVMThreadContext *tc, JitGraphBuilder *jgb,
jgb->cur_ins = bb->first_ins;
/* First try to create an expression tree */
tree = MVM_jit_expr_tree_build(tc, jgb->graph, bb);
if (tree != NULL) {
if (tc->instance->jit_expr_enabled && tree != NULL) {
MVMJitNode *node = MVM_spesh_alloc(tc, jgb->graph->sg, sizeof(MVMJitNode));
node->type = MVM_JIT_NODE_EXPR_TREE;
node->u.tree = tree;
jg_append_node(jgb->graph, node);
/* Log the tree */
MVM_jit_log_expr_tree(tc, tree);
} else {
if (tree != NULL) {
/* log the tree for fun and giggles */
MVM_jit_log_expr_tree(tc, tree);
MVM_jit_expr_tree_destroy(tc, tree);
}
/* Otherwise, try to consume the basic block per instruction */
while (jgb->cur_ins) {
jgb_before_ins(tc, jgb, jgb->cur_bb, jgb->cur_ins);
Expand Down
6 changes: 5 additions & 1 deletion src/moar.c
Expand Up @@ -15,7 +15,7 @@ static void setup_std_handles(MVMThreadContext *tc);
MVMInstance * MVM_vm_create_instance(void) {
MVMInstance *instance;
char *spesh_log, *spesh_nodelay, *spesh_disable, *spesh_inline_disable, *spesh_osr_disable;
char *jit_log, *jit_disable, *jit_bytecode_dir;
char *jit_log, *jit_expr_enable, *jit_disable, *jit_bytecode_dir;
char *dynvar_log;
int init_stat;

Expand Down Expand Up @@ -154,6 +154,10 @@ MVMInstance * MVM_vm_create_instance(void) {
jit_disable = getenv("MVM_JIT_DISABLE");
if (!jit_disable || strlen(jit_disable) == 0)
instance->jit_enabled = 1;
jit_expr_enable = getenv("MVM_JIT_EXPR_ENABLE");
if (jit_expr_enable && strlen(jit_expr_enable) > 0)
instance->jit_expr_enabled = 1;

jit_log = getenv("MVM_JIT_LOG");
if (jit_log && strlen(jit_log))
instance->jit_log_fh = fopen(jit_log, "w");
Expand Down

0 comments on commit 04d892a

Please sign in to comment.