Skip to content

Commit

Permalink
Remove cgparams that disallow language features.
Browse files Browse the repository at this point in the history
We realistically rely on LLVM optimization passes anyway.
  • Loading branch information
maleadt committed Sep 5, 2017
1 parent 5c6f423 commit c31fdea
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 54 deletions.
11 changes: 3 additions & 8 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -727,27 +727,22 @@ end
struct CodegenParams
cached::Cint

runtime::Cint
exceptions::Cint
track_allocations::Cint
code_coverage::Cint
static_alloc::Cint
dynamic_alloc::Cint
prefer_specsig::Cint

module_setup::Any
module_activation::Any
raise_exception::Any

CodegenParams(;cached::Bool=true,
runtime::Bool=true, exceptions::Bool=true,
track_allocations::Bool=true, code_coverage::Bool=true,
static_alloc::Bool=true, dynamic_alloc::Bool=true,
prefer_specsig::Bool=false,
static_alloc::Bool=true, prefer_specsig::Bool=false,
module_setup=nothing, module_activation=nothing, raise_exception=nothing) =
new(Cint(cached),
Cint(runtime), Cint(exceptions), Cint(track_allocations), Cint(code_coverage),
Cint(static_alloc), Cint(dynamic_alloc), Cint(prefer_specsig),
Cint(track_allocations), Cint(code_coverage),
Cint(static_alloc), Cint(prefer_specsig),
module_setup, module_activation, raise_exception)
end

Expand Down
6 changes: 0 additions & 6 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1513,12 +1513,6 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
rt = (jl_value_t*)jl_any_type; // convert return type to jl_value_t*
}

// check if we require the runtime
// TODO: could be more fine-grained,
// respecting special functions below that don't require the runtime
if (!llvmcall && (!f_lib || f_lib == JL_DL_LIBNAME))
JL_FEAT_REQUIRE(ctx, runtime);

// some sanity checking and check whether there's a vararg
bool isVa;
size_t nargt;
Expand Down
13 changes: 0 additions & 13 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,8 @@ static Value *mark_callee_rooted(IRBuilder<> &irbuilder, Value *V)

// --- language feature checks ---

// branch on whether a language feature is enabled or not
#define JL_FEAT_TEST(ctx, feature) ((ctx).params->feature)

// require a language feature to be enabled
#define JL_FEAT_REQUIRE(ctx, feature) \
if (!JL_FEAT_TEST(ctx, feature)) \
jl_errorf("%s for %s:%d requires the " #feature " language feature, which is disabled", \
__FUNCTION__, (ctx).file.str().c_str(), *(ctx).line);


// --- hook checks ---

Expand Down Expand Up @@ -908,7 +901,6 @@ static void raise_exception(jl_codectx_t &ctx, Value *exc,
jl_box_voidpointer(wrap(ctx.builder.GetInsertBlock())),
jl_box_voidpointer(wrap(exc)));
} else {
JL_FEAT_REQUIRE(ctx, runtime);
ctx.builder.CreateCall(prepare_call(jlthrow_func), { mark_callee_rooted(exc) });
}
ctx.builder.CreateUnreachable();
Expand Down Expand Up @@ -2117,8 +2109,6 @@ static void emit_cpointercheck(jl_codectx_t &ctx, const jl_cgval_t &x, const std
// allocation for known size object
static Value *emit_allocobj(jl_codectx_t &ctx, size_t static_size, Value *jt)
{
JL_FEAT_REQUIRE(ctx, dynamic_alloc);
JL_FEAT_REQUIRE(ctx, runtime);
Value *ptls_ptr = emit_bitcast(ctx, ctx.ptlsStates, T_pint8);
auto call = ctx.builder.CreateCall(prepare_call(jl_alloc_obj_func),
{ptls_ptr, ConstantInt::get(T_size, static_size),
Expand Down Expand Up @@ -2349,12 +2339,9 @@ static int compare_cgparams(const jl_cgparams_t *a, const jl_cgparams_t *b)
{
return (a->cached == b->cached) &&
// language features
(a->runtime == b->runtime) &&
(a->exceptions == b->exceptions) &&
(a->track_allocations == b->track_allocations) &&
(a->code_coverage == b->code_coverage) &&
(a->static_alloc == b->static_alloc) &&
(a->dynamic_alloc == b->dynamic_alloc) &&
(a->prefer_specsig == b->prefer_specsig) &&
// hooks
(a->module_setup == b->module_setup) &&
Expand Down
21 changes: 0 additions & 21 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2219,7 +2219,6 @@ static Value *emit_f_is(jl_codectx_t &ctx, const jl_cgval_t &arg1, const jl_cgva
decay_derived(varg2));
}

JL_FEAT_REQUIRE(ctx, runtime);
Value *varg1 = mark_callee_rooted(boxed(ctx, arg1));
Value *varg2 = mark_callee_rooted(boxed(ctx, arg2, false)); // potentially unrooted!
return ctx.builder.CreateTrunc(ctx.builder.CreateCall(prepare_call(jlegal_func), {varg1, varg2}), T_int1);
Expand Down Expand Up @@ -2264,7 +2263,6 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
if (jl_subtype(ty.typ, (jl_value_t*)jl_type_type)) {
Value *rt_arg = boxed(ctx, arg);
Value *rt_ty = boxed(ctx, ty);
JL_FEAT_REQUIRE(ctx, runtime);
ctx.builder.CreateCall(prepare_call(jltypeassert_func), {rt_arg, rt_ty});
*ret = arg;
return true;
Expand Down Expand Up @@ -2305,7 +2303,6 @@ static bool emit_builtin_call(jl_codectx_t &ctx, jl_cgval_t *ret, jl_value_t *f,
nva = ctx.builder.CreateTrunc(nva, T_int32);
#endif
Value *theArgs = ctx.builder.CreateGEP(ctx.argArray, ConstantInt::get(T_size, ctx.nReqArgs));
JL_FEAT_REQUIRE(ctx, runtime);
Value *r = ctx.builder.CreateCall(prepare_call(jlapply2va_func), { theF, theArgs, nva });
*ret = mark_julia_type(ctx, r, true, jl_any_type);
return true;
Expand Down Expand Up @@ -2964,7 +2961,6 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, jl_expr_t *ex)
}
}
}
JL_FEAT_REQUIRE(ctx, runtime);
jl_cgval_t result = mark_julia_type(ctx,
emit_jlcall(
ctx,
Expand Down Expand Up @@ -3016,16 +3012,6 @@ static jl_cgval_t emit_call(jl_codectx_t &ctx, jl_expr_t *ex)
}
}

if (!JL_FEAT_TEST(ctx, runtime)) {
char* name = NULL;
if (jl_is_symbol(args[0]))
name = jl_symbol_name((jl_sym_t*)args[0]);
if (jl_is_globalref(args[0]))
name = jl_symbol_name(jl_globalref_name(args[0]));
jl_errorf("generic call to %s requires the runtime language feature",
name ? name : "<unknown>");
}

// emit function and arguments
Value *callval = emit_jlcall(ctx, jlapplygeneric_func, nullptr, argv, nargs);
return mark_julia_type(ctx, callval, true, rt);
Expand Down Expand Up @@ -3068,7 +3054,6 @@ static Value *global_binding_pointer(jl_codectx_t &ctx, jl_module_t *m, jl_sym_t
b = jl_get_binding(m, s);
if (b == NULL) {
// var not found. switch to delayed lookup.
JL_FEAT_REQUIRE(ctx, runtime);
std::stringstream name;
name << "delayedvar" << globalUnique++;
Constant *initnul = V_null;
Expand Down Expand Up @@ -3438,7 +3423,6 @@ static void emit_assignment(jl_codectx_t &ctx, jl_value_t *l, jl_value_t *r)
if (bp == NULL && s != NULL)
bp = global_binding_pointer(ctx, ctx.module, s, &bnd, true);
if (bp != NULL) { // it's a global
JL_FEAT_REQUIRE(ctx, runtime);
assert(bnd);
Value *rval = mark_callee_rooted(boxed(ctx, emit_expr(ctx, r), false)); // no root needed since this is about to be assigned to a global
ctx.builder.CreateCall(prepare_call(jlcheckassign_func),
Expand Down Expand Up @@ -3655,7 +3639,6 @@ static void emit_stmtpos(jl_codectx_t &ctx, jl_value_t *expr)
}
else if (head == leave_sym) {
assert(jl_is_long(args[0]));
JL_FEAT_REQUIRE(ctx, runtime);
ctx.builder.CreateCall(prepare_call(jlleave_func),
ConstantInt::get(T_int32, jl_unbox_long(args[0])));
}
Expand Down Expand Up @@ -3765,7 +3748,6 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr)
else if (head == method_sym) {
jl_value_t *mn = args[0];
assert(jl_expr_nargs(ex) != 1 || jl_is_symbol(mn) || jl_is_slot(mn));
JL_FEAT_REQUIRE(ctx, runtime);

Value *bp = NULL, *name, *bp_owner = V_null;
jl_binding_t *bnd = NULL;
Expand Down Expand Up @@ -3832,7 +3814,6 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr)
sym = jl_globalref_name(sym);
}
if (jl_is_symbol(sym)) {
JL_FEAT_REQUIRE(ctx, runtime);
jl_binding_t *bnd = NULL;
(void)global_binding_pointer(ctx, mod, sym, &bnd, true); assert(bnd);
ctx.builder.CreateCall(prepare_call(jldeclareconst_func),
Expand Down Expand Up @@ -3862,7 +3843,6 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr)
true, jl_any_type);
}
else if (head == copyast_sym) {
JL_FEAT_REQUIRE(ctx, runtime);
jl_value_t *arg = args[0];
if (jl_is_quotenode(arg)) {
jl_value_t *arg1 = jl_fieldref(arg, 0);
Expand Down Expand Up @@ -3900,7 +3880,6 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr)
jl_error("syntax: prefix \"$\" in non-quoted expression");
if (jl_is_toplevel_only_expr(expr) &&
!jl_is_method(ctx.linfo->def.method)) {
JL_FEAT_REQUIRE(ctx, runtime);
// call interpreter to run a toplevel expr from inside a
// compiled toplevel thunk.
Value *args[2] = {
Expand Down
2 changes: 1 addition & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ jl_value_t *jl_memory_exception;
jl_value_t *jl_readonlymemory_exception;
union jl_typemap_t jl_cfunction_list;

jl_cgparams_t jl_default_cgparams = {1, 1, 1, 1, 1, 1, 1, 0, NULL, NULL, NULL};
jl_cgparams_t jl_default_cgparams = {1, 1, 1, 1, 0, NULL, NULL, NULL};

// --- type properties and predicates ---

Expand Down
7 changes: 2 additions & 5 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -1806,12 +1806,9 @@ typedef struct {
typedef struct {
int cached; // can the compiler use/populate the compilation cache?

int runtime; // can we call into the runtime?
int exceptions; // are exceptions supported (requires runtime)?
int track_allocations; // can we track allocations (don't if disallowed)?
int code_coverage; // can we measure coverage (don't if disallowed)?
int track_allocations; // can we track allocations?
int code_coverage; // can we measure coverage?
int static_alloc; // is the compiler allowed to allocate statically?
int dynamic_alloc; // is the compiler allowed to allocate dynamically (requires runtime)?
int prefer_specsig; // are specialized function signatures preferred?


Expand Down

0 comments on commit c31fdea

Please sign in to comment.