diff --git a/src/alloc.c b/src/alloc.c index b3cfdc2003ceb..dd431d0e04a01 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -805,7 +805,6 @@ void jl_init_box_caches(void) } } -#ifdef JL_GC_MARKSWEEP void jl_mark_box_caches(void) { int64_t i; @@ -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) { diff --git a/src/ast.c b/src/ast.c index 4bee7e9f8a02d..26f0df1d6402e 100644 --- a/src/ast.c +++ b/src/ast.c @@ -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); @@ -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; } diff --git a/src/builtins.c b/src/builtins.c index 5d18d930926df..6fb28367656d7 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -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. diff --git a/src/ccall.cpp b/src/ccall.cpp index f3834c2e955f7..00c36f782cffe 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -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); @@ -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); diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 769404bc86821..f380ab0c10087 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -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); @@ -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); @@ -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, diff --git a/src/codegen.cpp b/src/codegen.cpp index 5af7427cb35ae..c04fa3273a7c6 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -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; @@ -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; @@ -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 gc_frame_pops; @@ -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); @@ -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. @@ -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); @@ -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); @@ -3691,23 +3673,11 @@ 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); @@ -3715,9 +3685,6 @@ emit_gcpop(jl_codectx_t *ctx) 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) @@ -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 = @@ -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); @@ -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 exp_args(0); exp_args.push_back(T_int1); diff --git a/src/dump.c b/src/dump.c index cb778e2ce8d71..be77ebfd8fc35 100644 --- a/src/dump.c +++ b/src/dump.c @@ -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); @@ -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(); } diff --git a/src/gc.c b/src/gc.c index 9cb9a904af706..950e2c2093d9e 100644 --- a/src/gc.c +++ b/src/gc.c @@ -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; @@ -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(); @@ -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); diff --git a/src/init.c b/src/init.c index 4369a0e3b8188..89387c50c9875 100644 --- a/src/init.c +++ b/src/init.c @@ -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) @@ -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(); @@ -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(); diff --git a/src/julia.h b/src/julia.h index d1881951327a8..e6ec13b47d92f 100644 --- a/src/julia.h +++ b/src/julia.h @@ -492,7 +492,6 @@ extern jl_sym_t *arrow_sym; extern jl_sym_t *inert_sym; // gc ------------------------------------------------------------------------- -#ifdef JL_GC_MARKSWEEP typedef struct _jl_gcframe_t { size_t nroots; struct _jl_gcframe_t *prev; @@ -608,44 +607,6 @@ static inline void jl_gc_wb_back(void *ptr) // ptr isa jl_value_t* } } -#else // No Garbage Collection - -#define JL_GC_PUSH(...) ; -#define JL_GC_PUSH1(...) ; -#define JL_GC_PUSH2(...) ; -#define JL_GC_PUSH3(...) ; -#define JL_GC_PUSH4(...) ; -#define JL_GC_PUSH5(...) ; -#define JL_GC_PUSHARGS(rts_var,n) rts_var = ((jl_value_t**)alloca((n)*sizeof(jl_value_t*))); -#define JL_GC_POP() - -#define jl_gc_preserve(v) ((void)(v)) -#define jl_gc_unpreserve() -#define jl_gc_n_preserved_values() (0) - -#define allocb(nb) malloc(nb) -DLLEXPORT jl_value_t *jl_gc_allocobj(size_t sz); -STATIC_INLINE jl_value_t *jl_gc_alloc_1w() { return jl_gc_allocobj(1*sizeof(void*)); } -STATIC_INLINE jl_value_t *jl_gc_alloc_2w() { return jl_gc_allocobj(2*sizeof(void*)); } -STATIC_INLINE jl_value_t *jl_gc_alloc_3w() { return jl_gc_allocobj(3*sizeof(void*)); } - -DLLEXPORT void jl_gc_add_finalizer(jl_value_t *v, jl_function_t *f); - -int64_t jl_gc_diff_total_bytes(void); -#define jl_gc_sync_total_bytes() -#define jl_gc_collect(arg); -#define jl_gc_enable(on) (0) -#define jl_gc_is_enabled() (0) -#define jl_gc_track_malloced_array(a) -#define jl_gc_count_allocd(sz) - -#define jl_gc_wb_binding(bnd, val) -#define jl_gc_wb(parent, ptr) -#define jl_gc_wb_buf(parent, bufptr) -#define jl_gc_wb_back(ptr) - -#endif - DLLEXPORT void *jl_gc_managed_malloc(size_t sz); DLLEXPORT void *jl_gc_managed_realloc(void *d, size_t sz, size_t oldsz, int isaligned, jl_value_t* owner); @@ -1338,9 +1299,7 @@ void jl_install_default_signal_handlers(void); // info describing an exception handler typedef struct _jl_handler_t { jl_jmp_buf eh_ctx; -#ifdef JL_GC_MARKSWEEP jl_gcframe_t *gcstack; -#endif struct _jl_handler_t *prev; } jl_handler_t; @@ -1365,10 +1324,8 @@ typedef struct _jl_task_t { // current exception handler jl_handler_t *eh; -#ifdef JL_GC_MARKSWEEP // saved gc stack top for context switches jl_gcframe_t *gcstack; -#endif // current module, or NULL if this task has not set one jl_module_t *current_module; } jl_task_t; @@ -1388,9 +1345,7 @@ STATIC_INLINE void jl_eh_restore_state(jl_handler_t *eh) { JL_SIGATOMIC_BEGIN(); jl_current_task->eh = eh->prev; -#ifdef JL_GC_MARKSWEEP jl_pgcstack = eh->gcstack; -#endif JL_SIGATOMIC_END(); } @@ -1522,7 +1477,7 @@ DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v); DLLEXPORT size_t jl_static_show_func_sig(JL_STREAM *s, jl_value_t *type); DLLEXPORT void jlbacktrace(void); -#if defined(GC_FINAL_STATS) && defined(JL_GC_MARKSWEEP) +#if defined(GC_FINAL_STATS) void jl_print_gc_stats(JL_STREAM *s); #endif diff --git a/src/options.h b/src/options.h index 43aba33de8103..23540aee47121 100644 --- a/src/options.h +++ b/src/options.h @@ -35,9 +35,6 @@ // GC options ----------------------------------------------------------------- -// only one GC is supported at this time -#define JL_GC_MARKSWEEP - // debugging options // with MEMDEBUG, every object is allocated explicitly with malloc, and diff --git a/src/task.c b/src/task.c index 3ca050988ac84..88a740e407924 100644 --- a/src/task.c +++ b/src/task.c @@ -147,9 +147,7 @@ jl_datatype_t *jl_task_type; DLLEXPORT JL_THREAD jl_task_t * volatile jl_current_task; JL_THREAD jl_task_t *jl_root_task; DLLEXPORT JL_THREAD jl_value_t *jl_exception_in_transit; -#ifdef JL_GC_MARKSWEEP DLLEXPORT JL_THREAD jl_gcframe_t *jl_pgcstack = NULL; -#endif #ifdef COPY_STACKS static JL_THREAD jl_jmp_buf * volatile jl_jmp_target; @@ -302,10 +300,8 @@ static void ctx_switch(jl_task_t *t, jl_jmp_buf *where) #endif // set up global state for new task -#ifdef JL_GC_MARKSWEEP jl_current_task->gcstack = jl_pgcstack; jl_pgcstack = t->gcstack; -#endif // restore task's current module, looking at parent tasks // if it hasn't set one. @@ -843,9 +839,7 @@ DLLEXPORT jl_task_t *jl_new_task(jl_function_t *start, size_t ssize) t->exception = jl_nothing; // there is no active exception handler available on this stack yet t->eh = NULL; -#ifdef JL_GC_MARKSWEEP t->gcstack = NULL; -#endif t->stkbuf = NULL; #ifdef COPY_STACKS @@ -945,9 +939,7 @@ void jl_init_root_task(void *stack, size_t ssize) jl_current_task->donenotify = NULL; jl_current_task->exception = NULL; jl_current_task->eh = NULL; -#ifdef JL_GC_MARKSWEEP jl_current_task->gcstack = NULL; -#endif jl_root_task = jl_current_task;