// heuristic for whether a top-level input should be evaluated with // the compiler or the interpreter. static int eval_with_compiler_p(jl_expr_t *expr, int compileloops) { assert(jl_is_expr(expr)); if (expr->head==body_sym) { jl_array_t *body = expr->args; size_t i; for(i=0; i < body->length; i++) { jl_value_t *stmt = jl_cellref(body,i); if (jl_is_expr(stmt)) { // TODO: only backward branches if (compileloops && (((jl_expr_t*)stmt)->head == goto_sym || ((jl_expr_t*)stmt)->head == goto_ifnot_sym)) { return 1; } // to compile code that uses exceptions /* if (((jl_expr_t*)stmt)->head == enter_sym) { return 1; } */ } } } if (has_intrinsics(expr)) return 1; return 0; }
static int has_intrinsics(jl_expr_t *e) { if (e->head == call_sym && jl_is_symbol(jl_exprarg(e,0)) && is_intrinsic((jl_sym_t*)jl_exprarg(e,0))) return 1; int i; for(i=0; i < e->args->length; i++) { jl_value_t *a = jl_exprarg(e,i); if (jl_is_expr(a) && has_intrinsics((jl_expr_t*)a)) return 1; } return 0; }
static int has_intrinsics(jl_expr_t *e) { jl_value_t *e0 = jl_exprarg(e,0); if (e->head == call_sym && ((jl_is_symbol(e0) && is_intrinsic((jl_sym_t*)e0)) || (jl_is_topnode(e0) && is_intrinsic((jl_sym_t*)jl_fieldref(e0,0))))) return 1; int i; for(i=0; i < e->args->length; i++) { jl_value_t *a = jl_exprarg(e,i); if (jl_is_expr(a) && has_intrinsics((jl_expr_t*)a)) return 1; } return 0; }
// heuristic for whether a top-level input should be evaluated with // the compiler or the interpreter. int jl_eval_with_compiler_p(jl_expr_t *expr, int compileloops) { assert(jl_is_expr(expr)); if (expr->head==body_sym && compileloops) { jl_array_t *body = expr->args; size_t i, maxlabl=0; // compile if there are backwards branches for(i=0; i < body->length; i++) { jl_value_t *stmt = jl_cellref(body,i); if (jl_is_labelnode(stmt)) { int l = jl_labelnode_label(stmt); if (l > maxlabl) maxlabl = l; } } size_t sz = (maxlabl+1+7)/8; char *labls = alloca(sz); memset(labls,0,sz); for(i=0; i < body->length; i++) { jl_value_t *stmt = jl_cellref(body,i); if (jl_is_labelnode(stmt)) { int l = jl_labelnode_label(stmt); labls[l/8] |= (1<<(l&7)); } else if (compileloops && jl_is_gotonode(stmt)) { int l = jl_gotonode_label(stmt); if (labls[l/8]&(1<<(l&7))) { return 1; } } else if (jl_is_expr(stmt)) { if (compileloops && ((jl_expr_t*)stmt)->head==goto_ifnot_sym) { int l = jl_unbox_long(jl_exprarg(stmt,1)); if (labls[l/8]&(1<<(l&7))) { return 1; } } // to compile code that uses exceptions /* if (((jl_expr_t*)stmt)->head == enter_sym) { return 1; } */ } } } if (has_intrinsics(expr)) return 1; return 0; }
static int has_intrinsics(jl_expr_t *e) { if (e->args->length == 0) return 0; if (e->head == static_typeof_sym) return 1; jl_value_t *e0 = jl_exprarg(e,0); if (e->head == call_sym && ((jl_is_symbol(e0) && is_intrinsic(jl_current_module,(jl_sym_t*)e0)) || (jl_is_topnode(e0) && is_intrinsic(jl_base_relative_to(jl_current_module),(jl_sym_t*)jl_fieldref(e0,0))))) return 1; int i; for(i=0; i < e->args->length; i++) { jl_value_t *a = jl_exprarg(e,i); if (jl_is_expr(a) && has_intrinsics((jl_expr_t*)a)) return 1; } return 0; }