Skip to content

Commit

Permalink
Merge pull request JuliaLang#11811 from JuliaLang/yyc/remove-jl_gc_ma…
Browse files Browse the repository at this point in the history
…rksweep

Remove JL_GC_MARKSWEEP option
  • Loading branch information
JeffBezanson committed Jun 23, 2015
2 parents 9cd6ad4 + 0cb11a7 commit a1378b4
Show file tree
Hide file tree
Showing 12 changed files with 3 additions and 152 deletions.
2 changes: 0 additions & 2 deletions src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,6 @@ void jl_init_box_caches(void)
}
}

#ifdef JL_GC_MARKSWEEP
void jl_mark_box_caches(void)
{
int64_t i;
Expand All @@ -824,7 +823,6 @@ void jl_mark_box_caches(void)
jl_gc_setmark(boxed_gensym_cache[i]);
}
}
#endif

jl_value_t *jl_box_bool(int8_t x)
{
Expand Down
4 changes: 0 additions & 4 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ static jl_value_t *full_list_of_lists(value_t e, int expronly)

static jl_value_t *scm_to_julia(value_t e, int expronly)
{
#ifdef JL_GC_MARKSWEEP
int en = jl_gc_enable(0);
#endif
jl_value_t *v;
JL_TRY {
v = scm_to_julia_(e, expronly);
Expand All @@ -210,9 +208,7 @@ static jl_value_t *scm_to_julia(value_t e, int expronly)
jl_cellset(ex->args, 0, jl_cstr_to_string("invalid AST"));
v = (jl_value_t*)ex;
}
#ifdef JL_GC_MARKSWEEP
jl_gc_enable(en);
#endif
return v;
}

Expand Down
2 changes: 0 additions & 2 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,7 @@ void jl_enter_handler(jl_handler_t *eh)
{
JL_SIGATOMIC_BEGIN();
eh->prev = jl_current_task->eh;
#ifdef JL_GC_MARKSWEEP
eh->gcstack = jl_pgcstack;
#endif
jl_current_task->eh = eh;
// TODO: this should really go after setjmp(). see comment in
// ctx_switch in task.c.
Expand Down
4 changes: 0 additions & 4 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,12 +715,10 @@ static Value *emit_llvmcall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
}
}

#ifdef JL_GC_MARKSWEEP
// make sure args are rooted
if (t == jl_pvalue_llvmt && (needroot || might_need_root(argi))) {
make_gcroot(arg, ctx);
}
#endif
Value *v = julia_to_native(t, tti, arg, expr_type(argi, ctx), false, false, false, false, false, i, ctx, NULL);
bool issigned = jl_signed_type && jl_subtype(tti, (jl_value_t*)jl_signed_type, 0);
argvals[i] = llvm_type_rewrite(v, t, t, false, false, issigned, ctx);
Expand Down Expand Up @@ -1298,12 +1296,10 @@ static Value *emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
}
}

#ifdef JL_GC_MARKSWEEP
// make sure args are rooted
if (largty == jl_pvalue_llvmt && (needroot || might_need_root(argi))) {
make_gcroot(arg, ctx);
}
#endif

bool nSR=false;
bool issigned = jl_signed_type && jl_subtype(jargty, (jl_value_t*)jl_signed_type, 0);
Expand Down
4 changes: 0 additions & 4 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,6 @@ static Value* emit_allocobj(size_t static_size)
// if ptr is NULL this emits a write barrier _back_
static void emit_write_barrier(jl_codectx_t* ctx, Value *parent, Value *ptr)
{
#ifdef JL_GC_MARKSWEEP
Value* parenttag = builder.CreateBitCast(emit_typeptr_addr(parent), T_psize);
Value* parent_type = builder.CreateLoad(parenttag);
Value* parent_mark_bits = builder.CreateAnd(parent_type, 1);
Expand All @@ -1897,12 +1896,10 @@ static void emit_write_barrier(jl_codectx_t* ctx, Value *parent, Value *ptr)
builder.CreateBr(cont);
ctx->f->getBasicBlockList().push_back(cont);
builder.SetInsertPoint(cont);
#endif
}

static void emit_checked_write_barrier(jl_codectx_t *ctx, Value *parent, Value *ptr)
{
#ifdef JL_GC_MARKSWEEP
BasicBlock *cont;
Value *not_null = builder.CreateICmpNE(ptr, V_null);
BasicBlock *if_not_null = BasicBlock::Create(getGlobalContext(), "wb_not_null", ctx->f);
Expand All @@ -1913,7 +1910,6 @@ static void emit_checked_write_barrier(jl_codectx_t *ctx, Value *parent, Value *
builder.CreateBr(cont);
ctx->f->getBasicBlockList().push_back(cont);
builder.SetInsertPoint(cont);
#endif
}

static Value *emit_setfield(jl_datatype_t *sty, Value *strct, size_t idx0,
Expand Down
37 changes: 0 additions & 37 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ static GlobalVariable *jlemptytuple_var;
#if JL_NEED_FLOATTEMP_VAR
static GlobalVariable *jlfloattemp_var;
#endif
#ifdef JL_GC_MARKSWEEP
static GlobalVariable *jlpgcstack_var;
#endif
static GlobalVariable *jlexc_var;
static GlobalVariable *jldiverr_var;
static GlobalVariable *jlundeferr_var;
Expand Down Expand Up @@ -334,10 +332,8 @@ static Function *box8_func;
static Function *box16_func;
static Function *box32_func;
static Function *box64_func;
#ifdef JL_GC_MARKSWEEP
static Function *wbfunc;
static Function *queuerootfun;
#endif
static Function *expect_func;
static Function *jldlsym_func;
static Function *jlnewbits_func;
Expand Down Expand Up @@ -540,11 +536,9 @@ struct jl_gcinfo_t {
int argDepth;
int maxDepth;
int argSpaceOffs;
#ifdef JL_GC_MARKSWEEP
Instruction *gcframe;
Instruction *argSpaceInits;
StoreInst *storeFrameSize;
#endif
BasicBlock::iterator first_gcframe_inst;
BasicBlock::iterator last_gcframe_inst;
std::vector<Instruction*> gc_frame_pops;
Expand Down Expand Up @@ -2696,10 +2690,8 @@ static Value *emit_call(jl_value_t **args, size_t arglen, jl_codectx_t *ctx, jl_
}
if (theFptr == NULL) {
Value *theFunc = emit_expr(args[0], ctx);
#ifdef JL_GC_MARKSWEEP
if (!headIsGlobal && (jl_is_expr(a0) || jl_is_lambda_info(a0)))
make_gcroot(boxed(theFunc,ctx), ctx);
#endif
// extract pieces of the function object
// TODO: try extractvalue instead
theFptr = emit_nthptr_recast(theFunc, (ssize_t)(offsetof(jl_function_t,fptr)/sizeof(void*)), tbaa_func, jl_pfptr_llvmt);
Expand Down Expand Up @@ -3579,7 +3571,6 @@ static void allocate_gc_frame(size_t n_roots, BasicBlock *b0, jl_codectx_t *ctx)
gc->argDepth = 0;
gc->maxDepth = 0;

#ifdef JL_GC_MARKSWEEP
// allocate gc frame
// gc->gcframe is assumed to be the first instruction creating the gc frame
// in finalize_gc_frame.
Expand All @@ -3595,14 +3586,6 @@ static void allocate_gc_frame(size_t n_roots, BasicBlock *b0, jl_codectx_t *ctx)
builder.CreateBitCast(builder.CreateConstGEP1_32(gc->gcframe, 1), PointerType::get(jl_ppvalue_llvmt,0)));
Instruction *linst = builder.CreateStore(gc->gcframe, prepare_global(jlpgcstack_var), false);
gc->argSpaceInits = &b0->back();
#else
// gc->gcframe is assumed to be the first instruction creating the gc frame
// in finalize_gc_frame
gc->argTemp = builder.CreateAlloca(jl_pvalue_llvmt,
ConstantInt::get(T_int32, n_roots));
gc->first_gcframe_inst = BasicBlock::iterator(gc->argTemp);
Instruction *linst = gc->argTemp;
#endif
// initialize local variable stack roots to null
for(size_t i=0; i < (size_t)gc->argSpaceOffs; i++) {
Value *varSlot = emit_local_slot(i, ctx);
Expand Down Expand Up @@ -3656,7 +3639,6 @@ static void clear_gc_frame(jl_gcinfo_t *gc)
static void finalize_gc_frame(jl_codectx_t *ctx)
{
jl_gcinfo_t *gc = &ctx->gc;
#ifdef JL_GC_MARKSWEEP
if (gc->argSpaceOffs + gc->maxDepth == 0) {
// 0 roots; remove gc frame entirely
clear_gc_frame(gc);
Expand Down Expand Up @@ -3691,33 +3673,18 @@ static void finalize_gc_frame(jl_codectx_t *ctx)
instList.insertAfter(argTempi, after);
}
}
#else
if (gc->maxDepth != 0) {
BasicBlock::iterator bbi(gc->argTemp);
AllocaInst *newgcframe =
new AllocaInst(jl_pvalue_llvmt,
ConstantInt::get(T_int32, (gc->argSpaceOffs +
gc->maxDepth)));
ReplaceInstWithInst(gc->argTemp->getParent()->getInstList(), bbi,
newgcframe);
}
#endif
}

static void
emit_gcpop(jl_codectx_t *ctx)
{
#ifdef JL_GC_MARKSWEEP
// finalize_gc_frame assumes each frame pop takes 4 instructions.
Instruction *gcpop =
(Instruction*)builder.CreateConstGEP1_32(ctx->gc.gcframe, 1);
ctx->gc.gc_frame_pops.push_back(gcpop);
builder.CreateStore(builder.CreateBitCast(builder.CreateLoad(gcpop, false),
jl_ppvalue_llvmt),
prepare_global(jlpgcstack_var));
#else
(void)ctx;
#endif
}

static Function *gen_cfun_wrapper(jl_function_t *ff, jl_value_t *jlrettype, jl_tupletype_t *argt, int64_t isref)
Expand Down Expand Up @@ -5129,13 +5096,11 @@ static void init_julia_llvm_env(Module *m)
"jl_array_t");
jl_parray_llvmt = PointerType::get(jl_array_llvmt,0);

#ifdef JL_GC_MARKSWEEP
jlpgcstack_var =
new GlobalVariable(*m, jl_ppvalue_llvmt,
false, GlobalVariable::ExternalLinkage,
NULL, "jl_pgcstack");
add_named_global(jlpgcstack_var, (void*)&jl_pgcstack);
#endif

global_to_llvm("__stack_chk_guard", (void*)&__stack_chk_guard, m);
Function *jl__stack_chk_fail =
Expand Down Expand Up @@ -5356,7 +5321,6 @@ static void init_julia_llvm_env(Module *m)
jlgetfield_func = builtin_func_map[jl_f_get_field];
jlapplygeneric_func = jlcall_func_to_llvm("jl_apply_generic", (void*)&jl_apply_generic, m);

#ifdef JL_GC_MARKSWEEP
queuerootfun = Function::Create(FunctionType::get(T_void, args_1ptr, false),
Function::ExternalLinkage,
"jl_gc_queue_root", m);
Expand All @@ -5369,7 +5333,6 @@ static void init_julia_llvm_env(Module *m)
Function::ExternalLinkage,
"jl_gc_wb_slow", m);
add_named_global(wbfunc, (void*)&jl_gc_wb_slow);
#endif

std::vector<Type *> exp_args(0);
exp_args.push_back(T_int1);
Expand Down
4 changes: 0 additions & 4 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,9 +1526,7 @@ DLLEXPORT void jl_preload_sysimg_so(const char *fname)

void jl_restore_system_image_from_stream(ios_t *f)
{
#ifdef JL_GC_MARKSWEEP
int en = jl_gc_enable(0);
#endif
DUMP_MODES last_mode = mode;
mode = MODE_SYSTEM_IMAGE;
arraylist_new(&backref_list, 250000);
Expand Down Expand Up @@ -1594,9 +1592,7 @@ void jl_restore_system_image_from_stream(ios_t *f)
//jl_printf(JL_STDERR, "backref_list.len = %d\n", backref_list.len);
arraylist_free(&backref_list);

#ifdef JL_GC_MARKSWEEP
jl_gc_enable(en);
#endif
mode = last_mode;
jl_update_all_fptrs();
}
Expand Down
34 changes: 1 addition & 33 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,6 @@ void jl_finalize(jl_value_t *o)
(void)finalize_object(o);
}

#ifdef JL_GC_MARKSWEEP

typedef struct _buff_t {
union {
uintptr_t header;
Expand Down Expand Up @@ -2680,33 +2678,6 @@ static void big_obj_stats(void)
}
#endif //MEMPROFILE

#else //JL_GC_MARKSWEEP
DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz)
{
size_t allocsz = sz + sizeof_jl_taggedvalue_t;
if (allocsz < sz) // overflow in adding offs, size was "negative"
jl_throw(jl_memory_exception);
allocd_bytes += allocsz;
gc_num.alloc++;
return jl_valueof(malloc(allocsz));
}
int64_t jl_gc_diff_total_bytes(void)
{
return 0;
}
DLLEXPORT jl_weakref_t *jl_gc_new_weakref(jl_value_t *value)
{
jl_weakref_t *wr = (jl_weakref_t*)jl_gc_alloc_1w();
jl_set_typeof(wr, jl_weakref_type);
wr->value = value;
return wr;
}
static inline int maybe_collect(void)
{
return 0;
}
#endif //JL_GC_MARKSWEEP

DLLEXPORT void *jl_gc_counted_malloc(size_t sz)
{
maybe_collect();
Expand Down Expand Up @@ -2762,14 +2733,11 @@ DLLEXPORT void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz, int isal
if (allocsz < sz) // overflow in adding offs, size was "negative"
jl_throw(jl_memory_exception);

#ifdef JL_GC_MARKSWEEP
if (gc_bits(jl_astaggedvalue(owner)) == GC_MARKED) {
perm_scanned_bytes += allocsz - oldsz;
live_bytes += allocsz - oldsz;
}
else
#endif
if (allocsz < oldsz)
else if (allocsz < oldsz)
freed_bytes += (oldsz - allocsz);
else
allocd_bytes += (allocsz - oldsz);
Expand Down
6 changes: 1 addition & 5 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ static struct uv_shutdown_queue_item *next_shutdown_queue_item(struct uv_shutdow

DLLEXPORT void jl_atexit_hook()
{
#if defined(JL_GC_MARKSWEEP) && defined(GC_FINAL_STATS)
#if defined(GC_FINAL_STATS)
jl_print_gc_stats(JL_STDERR);
#endif
if (jl_options.code_coverage)
Expand Down Expand Up @@ -1067,10 +1067,8 @@ void _julia_init(JL_IMAGE_SEARCH rel)
}
#endif

#ifdef JL_GC_MARKSWEEP
jl_gc_init();
jl_gc_enable(0);
#endif
jl_init_frontend();
jl_init_types();
jl_init_tasks();
Expand Down Expand Up @@ -1140,9 +1138,7 @@ void _julia_init(JL_IMAGE_SEARCH rel)
if (jl_options.handle_signals == JL_OPTIONS_HANDLE_SIGNALS_ON)
jl_install_default_signal_handlers();

#ifdef JL_GC_MARKSWEEP
jl_gc_enable(1);
#endif

if (jl_options.image_file)
jl_init_restored_modules();
Expand Down
Loading

0 comments on commit a1378b4

Please sign in to comment.