Skip to content

Commit

Permalink
using stage 1 system image by default
Browse files Browse the repository at this point in the history
rebuilding through stage 0 only when necessary
no longer compiling-in boot.j; just load it (only in stage 0)
removing code no longer needed due to new bootstrapping approach
  • Loading branch information
JeffBezanson committed Jan 20, 2012
1 parent 1352a7d commit 819eb5a
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
/libjulia-release.dylib

/sys.ji
/sys0.ji
/h2j
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ julia-debug julia-release:
@$(MAKE) -sC ui/webserver $@
@ln -f $@-$(DEFAULT_REPL) julia

sys.ji: VERSION j/sysimg.j j/start_image.j src/boot.j src/dump.c j/*.j
sys0.ji: src/boot.j src/dump.c
$(QUIET_JULIA) ./julia -b stage0.j

# if sys.ji exists, use it to rebuild, otherwise use sys0.ji
sys.ji: sys0.ji VERSION j/sysimg.j j/start_image.j j/*.j
ifeq ($(wildcard sys.ji),)
$(QUIET_JULIA) ./julia -J sys0.ji stage1.j
else
$(QUIET_JULIA) ./julia stage1.j
endif

install: release
install -d $(DESTDIR)/usr/share/julia/lib
install -d $(DESTDIR)/usr/share/julia/j
Expand All @@ -39,6 +47,7 @@ h2j: lib/libLLVM*.a lib/libclang*.a src/h2j.cpp
clean:
@rm -f julia
@rm -f *~ *#
@rm -f sys0.ji
@rm -f sys.ji
@$(MAKE) -sC j clean
@$(MAKE) -sC src clean
Expand Down
2 changes: 1 addition & 1 deletion j/stage0.j
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ end
load("sysimg.j")

ccall(:jl_save_system_image, Void, (Ptr{Uint8},Ptr{Uint8}),
cstring("sys.ji"), cstring("j/start_image.j"))
cstring("sys0.ji"), cstring("j/start_image.j"))

end # module
2 changes: 1 addition & 1 deletion j/stage1.j
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ begin
end

ccall(:jl_save_system_image, Void, (Ptr{Uint8},Ptr{Uint8}),
cstring("sys.ji.new"), cstring("j/start_image.j"))
cstring("sys.ji"), cstring("j/start_image.j"))

end # module
6 changes: 1 addition & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ release debug: %: libjulia-%
%.do: %.cpp julia.h
$(QUIET_CC) $(CXX) $(CXXFLAGS) $(DEBUGFLAGS) $(shell $(LLVMROOT)/bin/llvm-config --cppflags) -c $< -o $@

ast.o ast.do: julia_flisp.boot.inc boot.j.inc
ast.o ast.do: julia_flisp.boot.inc

julia_flisp.boot.inc: julia_flisp.boot flisp/libflisp.a
$(QUIET_FLISP) flisp/flisp ./bin2hex.scm < $< > $@
Expand All @@ -45,9 +45,6 @@ julia_flisp.boot: julia-parser.scm julia-syntax.scm \
match.scm utils.scm jlfrontend.scm mk_julia_flisp_boot.scm flisp/libflisp.a
$(QUIET_FLISP) flisp/flisp ./mk_julia_flisp_boot.scm

boot.j.inc: boot.j preparse.scm julia_flisp.boot
$(QUIET_FLISP) flisp/flisp ./preparse.scm $< | flisp/flisp ./bin2hex.scm > $@

codegen.o codegen.do: intrinsics.cpp debuginfo.cpp cgutils.cpp ccall.cpp
builtins.o builtins.do: table.c

Expand Down Expand Up @@ -77,7 +74,6 @@ clean:
rm -f ../libjulia*.$(SHLIB_EXT)
rm -f julia_flisp.boot
rm -f julia_flisp.boot.inc
rm -f boot.j.inc
rm -f *.do
rm -f *.o
rm -f *~ *#
Expand Down
16 changes: 0 additions & 16 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,6 @@ DLLEXPORT void jl_shutdown_frontend(void)
//fl_applyn(0, symbol_value(symbol("show-profiles")));
}

static char boot_j[] = {
#include "boot.j.inc"
};

void jl_load_boot_j(void)
{
value_t bootc = cvalue(iostreamtype, sizeof(ios_t));
ios_t *pi = value2c(ios_t*, bootc);
ios_static_buffer(pi, boot_j, sizeof(boot_j));
value_t sexpr = fl_read_sexpr(bootc);
jl_value_t *ast = scm_to_julia(sexpr);
JL_GC_PUSH(&ast);
jl_load_file_expr("boot.j", ast);
JL_GC_POP();
}

static jl_sym_t *scmsym_to_julia(value_t s)
{
assert(issymbol(s));
Expand Down
76 changes: 3 additions & 73 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void julia_init(char *imageFile)
jl_current_module = jl_base_module;
jl_init_intrinsic_functions();
jl_init_primitives();
jl_load_boot_j();
jl_load("src/boot.j");
jl_get_builtin_hooks();
jl_boot_file_loaded = 1;
jl_init_box_caches();
Expand Down Expand Up @@ -201,81 +201,11 @@ int julia_trampoline(int argc, char *argv[], int (*pmain)(int ac,char *av[]))

jl_function_t *jl_typeinf_func=NULL;

static void clear_tfunc_caches(void)
{
htable_t *t = &jl_system_module->bindings;
size_t i;
for(i=0; i < t->size; i+=2) {
if (t->table[i+1] == HT_NOTFOUND)
continue;
jl_binding_t *b = (jl_binding_t*)t->table[i+1];
if (b->value != NULL && jl_is_func(b->value) && jl_is_gf(b->value)) {
jl_function_t *f = (jl_function_t*)b->value;
jl_methtable_t *mt = jl_gf_mtable(f);
//mt->cache = NULL;
jl_methlist_t *ml = mt->defs;
while (ml != NULL) {
if (ml->func != NULL && ml->func->linfo != NULL)
ml->func->linfo->tfunc = (jl_value_t*)jl_null;
ml = ml->next;
}
}
}
}
/*
static void clear_method_caches(void)
{
htable_t *t = &jl_system_module->bindings;
size_t i;
for(i=0; i < t->size; i+=2) {
if (t->table[i+1] == HT_NOTFOUND)
continue;
jl_binding_t *b = (jl_binding_t*)t->table[i+1];
if (b->value != NULL && jl_is_func(b->value) && jl_is_gf(b->value)) {
jl_function_t *f = (jl_function_t*)b->value;
jl_methtable_t *mt = jl_gf_mtable(f);
mt->cache = NULL;
}
}
}
*/
DLLEXPORT void jl_enable_inference(void)
{
if (jl_typeinf_func != NULL) return;
if (jl_boundp(jl_system_module, jl_symbol("typeinf_ext"))) {
//clear_method_caches();
jl_typeinf_func =
(jl_function_t*)jl_get_global(jl_system_module,
jl_symbol("typeinf_ext"));
// warm up type inference to put the latency up front
jl_value_t *one = jl_box_long(1);
jl_apply((jl_function_t*)jl_get_global(jl_system_module,
jl_symbol("+")),
&one, 1);
/*
cached t-functions and inferred ASTs need to be cleared at
this point, because during bootstrapping we might not be
able to inline optimally. the reason is that we cache an AST
before doing inlining, to prevent infinite recursion.
for example, consider this function:
> (x::Real, y::Real) = (y < x)
after doing inference on this >, we cache its AST "(y < x)".
now we begin inlining. the problem is that the inlining code
itself will trigger compilation of functions that use >, so
"(y < x)" will be inlined into those functions. ultimately
we inline the definition of < into "(y < x)", but by then it's
too late, since "(y < x)" has already been inlined into some
functions.
to fix this, we clear the t-function cache after all
type-inference related code has been compiled. now we can
inline everything fully without compilation of the compiler
itself interfering.
*/
clear_tfunc_caches();
}
jl_typeinf_func = (jl_function_t*)jl_get_global(jl_system_module,
jl_symbol("typeinf_ext"));
}

static jl_value_t *base(char *name)
Expand Down
1 change: 0 additions & 1 deletion src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,6 @@ void jl_init_codegen(void);
void jl_init_intrinsic_functions(void);
void jl_init_tasks(void *stack, size_t ssize);
void jl_init_serializer(void);
void jl_load_boot_j(void);

void jl_save_system_image(char *fname, char *startscriptname);
void jl_restore_system_image(char *fname);
Expand Down
8 changes: 0 additions & 8 deletions src/preparse.scm

This file was deleted.

0 comments on commit 819eb5a

Please sign in to comment.