diff --git a/base/LineEdit.jl b/base/LineEdit.jl index c190bc9ad6d9c..30f7aca305204 100644 --- a/base/LineEdit.jl +++ b/base/LineEdit.jl @@ -856,8 +856,6 @@ function postprocess!(dict::Dict) # needs to be done first for every branch if haskey(dict, '\0') add_specialisations(dict, dict, 1) - else - dict['\0'] = (args...)->error("Unrecognized input") end for (k,v) in dict k == '\0' && continue @@ -1573,7 +1571,17 @@ function prompt!(term, prompt, s = init_state(term, prompt)) activate(prompt, s, term) while true map = keymap(s, prompt) - state = match_input(map, s)(s, keymap_data(s, prompt)) + fcn = match_input(map, s) + # errors in keymaps shouldn't cause the REPL to fail, so wrap in a + # try/catch block + local state + try + state = fcn(s, keymap_data(s, prompt)) + catch e + warn("Caught an exception in the keymap:") + warn(e) + state = :done + end if state == :abort stop_reading(term) return buffer(s), false, false diff --git a/base/markdown/Common/Common.jl b/base/markdown/Common/Common.jl index 23e849e12607b..a1f04dffd7cc3 100644 --- a/base/markdown/Common/Common.jl +++ b/base/markdown/Common/Common.jl @@ -1,7 +1,8 @@ include("block.jl") include("inline.jl") -@flavor common [list, indentcode, blockquote, hashheader, paragraph, +@flavor common [list, indentcode, blockquote, hashheader, horizontalrule, + paragraph, - linebreak, escapes, en_dash, inline_code, asterisk_bold, - asterisk_italic, image, link] + linebreak, escapes, en_dash, inline_code, + asterisk_bold, asterisk_italic, image, link] diff --git a/base/markdown/Common/block.jl b/base/markdown/Common/block.jl index db2b2c76a47bd..fbdbed46f330d 100644 --- a/base/markdown/Common/block.jl +++ b/base/markdown/Common/block.jl @@ -119,25 +119,35 @@ type List items::Vector{Any} ordered::Bool - List(x::AbstractVector) = new(x) + List(x::AbstractVector, b::Bool) = new(x, b) + List(x::AbstractVector) = new(x, false) + List(b::Bool) = new(Any[], b) end List(xs...) = List(vcat(xs...)) -const bullets = ["* ", "• ", "+ ", "- "] +const bullets = "*•+-" +const num_or_bullets = r"^(\*|•|\+|-|\d+(\.|\))) " # Todo: ordered lists, inline formatting function list(stream::IO, block::MD, config::Config) withstream(stream) do skipwhitespace(stream) - startswith(stream, bullets) || return false - the_list = List() + b = startswith(stream, num_or_bullets) + (b == nothing || b == "") && return false + ordered = !(b[1] in bullets) + if ordered + b = b[end - 1] == '.' ? r"^\d+\. " : r"^\d+\) " + # TODO start value + end + the_list = List(ordered) + buffer = IOBuffer() fresh_line = false while !eof(stream) if fresh_line skipwhitespace(stream) - if startswith(stream, bullets) + if startswith(stream, b) != "" push!(the_list.items, parseinline(takebuf_string(buffer), config)) buffer = IOBuffer() else @@ -164,3 +174,30 @@ function list(stream::IO, block::MD, config::Config) return true end end + +# –––––––––––––– +# HorizontalRule +# –––––––––––––– + +type HorizontalRule +end + +function horizontalrule(stream::IO, block::MD, config::Config) + withstream(stream) do + n, rule = 0, ' ' + while !eof(stream) + char = read(stream, Char) + char == '\n' && break + isspace(char) && continue + if n==0 || char==rule + rule = char + n += 1 + else + return false + end + end + is_hr = (n ≥ 3 && rule in "*-") + is_hr && push!(block, HorizontalRule()) + return is_hr + end +end diff --git a/base/markdown/Julia/Julia.jl b/base/markdown/Julia/Julia.jl index ef94a63cdd375..ac95d97418295 100644 --- a/base/markdown/Julia/Julia.jl +++ b/base/markdown/Julia/Julia.jl @@ -8,7 +8,7 @@ We start by borrowing GitHub's `fencedcode` extension – more to follow. include("interp.jl") @flavor julia [blocktex, blockinterp, hashheader, list, indentcode, fencedcode, - blockquote, github_table, paragraph, + blockquote, github_table, horizontalrule, paragraph, - linebreak, escapes, latex, interp, en_dash, inline_code, asterisk_bold, - asterisk_italic, image, link] + linebreak, escapes, latex, interp, en_dash, inline_code, + asterisk_bold, asterisk_italic, image, link] diff --git a/base/markdown/render/html.jl b/base/markdown/render/html.jl index 6fcc69f554675..770d4cbd86bc0 100644 --- a/base/markdown/render/html.jl +++ b/base/markdown/render/html.jl @@ -49,21 +49,25 @@ end function html(io::IO, md::BlockQuote) withtag(io, :blockquote) do - html(io, block.content) + html(io, md.content) end end function html(io::IO, md::List) - withtag(io, :ul) do + withtag(io, md.ordered ? :ol : :ul) do for item in md.items withtag(io, :li) do htmlinline(io, item) - println(io) end + println(io) end end end +function html(io::IO, md::HorizontalRule) + tag(io, :hr) +end + html(io::IO, x) = tohtml(io, x) # Inline elements diff --git a/base/markdown/render/latex.jl b/base/markdown/render/latex.jl index 4fb5010ce98b1..4b9ed097d5083 100644 --- a/base/markdown/render/latex.jl +++ b/base/markdown/render/latex.jl @@ -66,6 +66,10 @@ function writemime(io::IO, ::MIME"text/latex", md::List) end end +function writemime(io::IO, ::MIME"text/latex", md::HorizontalRule) + println(io, "\\rule{\\textwidth}{1pt}") +end + # Inline elements function writemime(io::IO, ::MIME"text/latex", md::Plain) diff --git a/base/markdown/render/plain.jl b/base/markdown/render/plain.jl index ce5a22650bbb5..ab60ae678547b 100644 --- a/base/markdown/render/plain.jl +++ b/base/markdown/render/plain.jl @@ -29,13 +29,17 @@ function plain(io::IO, p::Paragraph) end function plain(io::IO, list::List) - for item in list.items - print(io, " * ") + for (i, item) in enumerate(list.items) + print(io, list.ordered ? "$i. " : " * ") plaininline(io, item) println(io) end end +function plain(io::IO, md::HorizontalRule) + println(io, "–" ^ 3) +end + plain(io::IO, x) = tohtml(io, x) # Inline elements diff --git a/base/markdown/render/terminal/render.jl b/base/markdown/render/terminal/render.jl index 18e1f0180f40c..e9232be62e3e3 100644 --- a/base/markdown/render/terminal/render.jl +++ b/base/markdown/render/terminal/render.jl @@ -30,8 +30,8 @@ function term(io::IO, md::BlockQuote, columns) end function term(io::IO, md::List, columns) - for point in md.items - print(io, " "^2margin, "• ") + for (i, point) in enumerate(md.items) + print(io, " "^2margin, md.ordered ? "$i. " : "• ") print_wrapped(io, width = columns-(4margin+2), pre = " "^(2margin+2), i = 2margin+2) do io terminline(io, point) end @@ -86,6 +86,10 @@ function term(io::IO, br::LineBreak, columns) println(io) end +function term(io::IO, br::HorizontalRule, columns) + println(io, " " ^ margin, "-" ^ (columns - 2margin)) +end + term(io::IO, x, _) = writemime(io, MIME"text/plain"(), x) # Inline Content diff --git a/base/show.jl b/base/show.jl index a9fddd8847579..c2083320549f9 100644 --- a/base/show.jl +++ b/base/show.jl @@ -44,7 +44,7 @@ function show(io::IO, x::ANY) else nb = t.size print(io, "0x") - p = pointer_from_objref(x) + sizeof(Ptr{Void}) + p = data_pointer_from_objref(x) for i=nb-1:-1:0 print(io, hex(unsafe_load(convert(Ptr{UInt8}, p+i)), 2)) end diff --git a/base/sparse/cholmod.jl b/base/sparse/cholmod.jl index be61b25ef172e..26e7fc9483317 100644 --- a/base/sparse/cholmod.jl +++ b/base/sparse/cholmod.jl @@ -21,13 +21,26 @@ using Base.SparseMatrix: AbstractSparseMatrix, SparseMatrixCSC, increment, indty include("cholmod_h.jl") +### These offsets are defined in SuiteSparse_wrapper.c +const common_size = ccall((:jl_cholmod_common_size,:libsuitesparse_wrapper),Int,()) + +const cholmod_com_offsets = Array(Csize_t, 19) +ccall((:jl_cholmod_common_offsets, :libsuitesparse_wrapper), + Void, (Ptr{Csize_t},), cholmod_com_offsets) + +const common_supernodal = (1:4) + cholmod_com_offsets[4] +const common_final_ll = (1:4) + cholmod_com_offsets[7] +const common_print = (1:4) + cholmod_com_offsets[13] +const common_itype = (1:4) + cholmod_com_offsets[18] +const common_dtype = (1:4) + cholmod_com_offsets[19] + ## macro to generate the name of the C function according to the integer type macro cholmod_name(nm,typ) string("cholmod_", eval(typ) == SuiteSparse_long ? "l_" : "", nm) end for Ti in IndexTypes @eval begin function common(::Type{$Ti}) - a = fill(0xff, cholmod_com_sz) + a = fill(0xff, common_size) @isok ccall((@cholmod_name "start" $Ti , :libcholmod), Cint, (Ptr{UInt8},), a) set_print_level(a, 0) # no printing from CHOLMOD by default @@ -36,15 +49,66 @@ for Ti in IndexTypes end end -### These offsets are defined in SuiteSparse_wrapper.c -const cholmod_com_offsets = Array(Csize_t, 19) -ccall((:jl_cholmod_common_offsets, :libsuitesparse_wrapper), - Void, (Ptr{Csize_t},), cholmod_com_offsets) -const common_supernodal = (1:4) + cholmod_com_offsets[4] -const common_final_ll = (1:4) + cholmod_com_offsets[7] -const common_print = (1:4) + cholmod_com_offsets[13] -const common_itype = (1:4) + cholmod_com_offsets[18] -const common_dtype = (1:4) + cholmod_com_offsets[19] +const version_array = Array(Cint, 3) +if dlsym(dlopen("libcholmod"), :cholmod_version) != C_NULL + ccall((:cholmod_version, :libcholmod), Cint, (Ptr{Cint},), version_array) +else + ccall((:jl_cholmod_version, :libsuitesparse_wrapper), Cint, (Ptr{Cint},), version_array) +end +const version = VersionNumber(version_array...) + +function __init__() + if dlsym(dlopen("libcholmod"), :cholmod_version) == C_NULL + warn(""" + + CHOLMOD version incompatibility + + Julia was compiled with CHOLMOD version $version, but is currently linked with a + version older than 2.1.0. This might cause Julia to terminate when working with + sparse matrices for operations involving factorization of a matrix, e.g. solving + systems of equations with \\. + + It is recommended that you either upgrade the package that provides CHOLMOD or + download the OS X or generic Linux binary from www.julialang.org, which is + shipped with the correct versions of all dependencies. + """) + else + tmp = Array(Cint, 3) + ccall((:cholmod_version, :libcholmod), Cint, (Ptr{Cint},), version_array) + ccall((:jl_cholmod_version, :libsuitesparse_wrapper), Cint, (Ptr{Cint},), tmp) + if tmp != version_array + warn(""" + + CHOLMOD version incompatibility + + Julia was compiled with CHOLMOD version $version, but is currently linked + with version $(VersionNumber(tmp...)). This might cause Julia to terminate when working + with sparse matrices for operations involving factorization of a matrix, + e.g. solving systems of equations with \\. + + It is recommended that you either upgrade the package that provides CHOLMOD + or download the OS X or generic Linux binary from www.julialang.org, which + is shipped with the correct versions of all dependencies. + """) + end + end + + intsize = Int(ccall((:jl_cholmod_sizeof_long,:libsuitesparse_wrapper),Csize_t,())) + if intsize != 4length(IndexTypes) + warn(""" + + CHOLMOD integer size incompatibility + + Julia was compiled with a version of CHOLMOD that supported $(32length(IndexTypes)) bit integers, + but is currently linked with version that supports $(8intsize) integers. This might + cause Julia to terminate when working with sparse matrices for operations + involving factorization of a matrix, e.g. solving systems of equations with \\. + + This problem can be fixed by downloading the OS X or generic Linux binary from + www.julialang.org, which are shipped with the correct versions of all dependencies. + """) + end +end function set_print_level(cm::Array{UInt8}, lev::Integer) cm[common_print] = reinterpret(UInt8, [Int32(lev)]) diff --git a/base/sparse/cholmod_h.jl b/base/sparse/cholmod_h.jl index 327f92625b9f4..334e71c481c18 100644 --- a/base/sparse/cholmod_h.jl +++ b/base/sparse/cholmod_h.jl @@ -75,12 +75,3 @@ end macro isok(A) :($A == TRUE || throw(CHOLMODException(""))) end - -const version_array = Array(Cint, 3) -if dlsym(dlopen("libcholmod"), :cholmod_version) != C_NULL - ccall((:cholmod_version, :libcholmod), Cint, (Ptr{Cint},), version_array) -else - ccall((:jl_cholmod_version, :libsuitesparse_wrapper), Cint, (Ptr{Cint},), version_array) -end -const version = VersionNumber(version_array...) -const cholmod_com_sz = ccall((:jl_cholmod_common_size,:libsuitesparse_wrapper),Int,()) diff --git a/base/sysinfo.jl b/base/sysinfo.jl index e1b327d9f3d6f..d5991df95345b 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -119,7 +119,7 @@ function cpu_info() cpus[i] = CPUinfo(unsafe_load(UVcpus[1],i)) end ccall(:uv_free_cpu_info, Void, (Ptr{UV_cpu_info_t}, Int32), UVcpus[1], count[1]) - cpus + return cpus end function uptime() @@ -165,16 +165,13 @@ const shlib_ext = dlext end # This callback function called by dl_iterate_phdr() on Linux - function dl_phdr_info_callback( di_ptr::Ptr{dl_phdr_info}, size::Csize_t, dynamic_libraries_ptr::Ptr{Array{AbstractString,1}} ) - di = unsafe_load(di_ptr) - + function dl_phdr_info_callback(di::dl_phdr_info, size::Csize_t, dynamic_libraries::Array{AbstractString,1}) # Skip over objects without a path (as they represent this own object) name = bytestring(di.name) if !isempty(name) - dynamic_libraries = unsafe_pointer_to_objref( dynamic_libraries_ptr ) - push!(dynamic_libraries, name ) + push!(dynamic_libraries, name) end - convert(Cint, 0)::Cint + return convert(Cint, 0)::Cint end end #@linux_only @@ -183,8 +180,8 @@ function dllist() @linux_only begin const callback = cfunction(dl_phdr_info_callback, Cint, - (Ptr{dl_phdr_info}, Csize_t, Ptr{Array{AbstractString,1}} )) - ccall(:dl_iterate_phdr, Cint, (Ptr{Void}, Ptr{Void}), callback, pointer_from_objref(dynamic_libraries)) + (Ref{dl_phdr_info}, Csize_t, Ref{Array{AbstractString,1}} )) + ccall(:dl_iterate_phdr, Cint, (Ptr{Void}, Any), callback, dynamic_libraries) end @osx_only begin @@ -201,7 +198,7 @@ function dllist() ccall(:jl_dllist, Cint, (Any,), dynamic_libraries) end - dynamic_libraries + return dynamic_libraries end function dlpath( handle::Ptr{Void} ) @@ -211,7 +208,7 @@ function dlpath( handle::Ptr{Void} ) return s end -function dlpath{T<:Union(AbstractString, Symbol)}(libname::T) +function dlpath(libname::Union(AbstractString,Symbol)) handle = dlopen(libname) path = dlpath(handle) dlclose(handle) @@ -222,7 +219,7 @@ function get_process_title() buf = zeros(Uint8, 512) err = ccall(:uv_get_process_title, Cint, (Ptr{Uint8}, Cint), buf, 512) uv_error("get_process_title", err) - bytestring(pointer(buf)) + return bytestring(pointer(buf)) end function set_process_title(title::AbstractString) err = ccall(:uv_set_process_title, Cint, (Ptr{UInt8},), bytestring(title)) diff --git a/src/gc.c b/src/gc.c index fceeb797a5b95..18242f1b7a570 100644 --- a/src/gc.c +++ b/src/gc.c @@ -31,8 +31,6 @@ void jl_(void *jl_value); extern "C" { #endif -#pragma pack(push, 1) - typedef struct { union { uintptr_t header; @@ -153,8 +151,6 @@ typedef struct _bigval_t { #define BVOFFS (offsetof(bigval_t, _data)/sizeof(void*)) #define bigval_header(data) ((bigval_t*)((char*)(data) - BVOFFS*sizeof(void*))) -#pragma pack(pop) - // GC knobs and self-measurement variables static int64_t last_gc_total_bytes = 0; @@ -170,7 +166,7 @@ static size_t collect_interval; static int64_t allocd_bytes; #define N_POOLS 42 -static __attribute__((aligned (64))) pool_t norm_pools[N_POOLS]; +static pool_t norm_pools[N_POOLS]; #define pools norm_pools static bigval_t *big_objects = NULL; @@ -337,11 +333,12 @@ static inline void objprofile_count(void* ty, int old, int sz) #endif } -static inline void gc_setmark_other(void *o, int mark_mode) -{ - _gc_setmark(o, mark_mode); - verify_val(o); -} +//static inline void gc_setmark_other(jl_value_t *v, int mark_mode) // unused function +//{ +// jl_typetag_t *o = jl_typetagof(v); +// _gc_setmark(o, mark_mode); +// verify_val(o); +//} #define inc_sat(v,s) v = (v) >= s ? s : (v)+1 @@ -747,8 +744,7 @@ static void run_finalizers(void) while (to_finalize.len > 0) { f = arraylist_pop(&to_finalize); o = arraylist_pop(&to_finalize); - int ok = 1;run_finalizer((jl_value_t*)o, (jl_value_t*)f); - assert(ok); (void)ok; + run_finalizer((jl_value_t*)o, (jl_value_t*)f); } JL_GC_POP(); } @@ -968,7 +964,7 @@ static inline gcval_t *reset_page(pool_t *p, gcpage_t *pg, gcval_t *fl) return beg; } -static __attribute__((noinline)) void add_page(pool_t *p) +static __attribute__((noinline)) void add_page(pool_t *p) { char *data = (char*)malloc_page(); if (data == NULL) @@ -981,7 +977,7 @@ static __attribute__((noinline)) void add_page(pool_t *p) p->newpages = fl; } -static inline void *__pool_alloc(pool_t* p, int osize, int end_offset) +static inline void *__pool_alloc(pool_t* p, int osize, int end_offset) { gcval_t *v, *end; if (__unlikely((allocd_bytes += osize) >= 0)) { @@ -1000,6 +996,7 @@ static inline void *__pool_alloc(pool_t* p, int osize, int end_offset) // we only update pg's fields when the freelist changes page // since pg's metadata is likely not in cache gcpage_t* pg = page_metadata(v); + assert(pg->osize == p->osize); pg->nfree = 0; pg->allocd = 1; if (next) @@ -1019,6 +1016,7 @@ static inline void *__pool_alloc(pool_t* p, int osize, int end_offset) } else { // like in the freelist case, only update the page metadata when it is full gcpage_t* pg = page_metadata(v); + assert(pg->osize == p->osize); pg->nfree = 0; pg->allocd = 1; p->newpages = v->next; @@ -1259,7 +1257,7 @@ static gcval_t** sweep_page(pool_t* p, gcpage_t* pg, gcval_t **pfl, int sweep_ma return pfl; } -extern void jl_unmark_symbols(void); +//extern void jl_unmark_symbols(void); static void gc_sweep_once(int sweep_mask) { @@ -1281,8 +1279,8 @@ static void gc_sweep_once(int sweep_mask) jl_printf(JL_STDOUT, "GC sweep big %.2f (freed %d/%d with %d rst)\n", (clock_now() - t0)*1000, big_freed, big_total, big_reset); t0 = clock_now(); #endif - if (sweep_mask == GC_MARKED) - jl_unmark_symbols(); + //if (sweep_mask == GC_MARKED) + // jl_unmark_symbols(); #ifdef GC_TIME jl_printf(JL_STDOUT, "GC sweep symbols %.2f\n", (clock_now() - t0)*1000); #endif @@ -1340,7 +1338,7 @@ int max_msp = 0; static arraylist_t tasks; static arraylist_t rem_bindings; -static arraylist_t _remset[2]; +static arraylist_t _remset[2]; // contains jl_value_t* static arraylist_t *remset = &_remset[0]; static arraylist_t *last_remset = &_remset[1]; void reset_remset(void) @@ -1615,7 +1613,7 @@ static int push_root(jl_value_t *v, int d, int bits) refyoung = GC_MARKED_NOESC; } else if(vt == (jl_value_t*)jl_symbol_type) { - gc_setmark_other(v, GC_MARKED); // symbols have their own allocator + //gc_setmark_other(v, GC_MARKED); // symbols have their own allocator and are never freed } else if( #ifdef GC_VERIFY diff --git a/src/intrinsics.cpp b/src/intrinsics.cpp index 7813b5d4f9cc4..9f2e9850e12aa 100644 --- a/src/intrinsics.cpp +++ b/src/intrinsics.cpp @@ -125,6 +125,11 @@ static Value *uint_cnvt(Type *to, Value *x) return builder.CreateZExt(x, to); } +#ifdef LLVM33 + #define LLVM_FP(a,b) APFloat(a,b) +#else + #define LLVM_FP(a,b) APFloat(b,true) +#endif static Constant *julia_const_to_llvm(jl_value_t *e) { jl_value_t *jt = jl_typeof(e); @@ -135,37 +140,65 @@ static Constant *julia_const_to_llvm(jl_value_t *e) if (e == jl_true) return ConstantInt::get(T_int1, 1); - else if (e == jl_false) + if (e == jl_false) return ConstantInt::get(T_int1, 0); + if (jl_is_cpointer_type(jt)) + return ConstantExpr::getIntToPtr(ConstantInt::get(T_size, jl_unbox_long(e)), julia_type_to_llvm((jl_value_t*)bt)); if (jl_is_bitstype(jt)) { int nb = jl_datatype_size(bt); - //APInt copies the data (but only as much as needed, so it doesn't matter if ArrayRef extends too far) - APInt val = APInt(8*nb,ArrayRef((uint64_t*)jl_data_ptr(e),(nb+7)/8)); - if (jl_is_float(e)) { -#ifdef LLVM33 - #define LLVM_FP(a,b) APFloat(a,b) -#else - #define LLVM_FP(a,b) APFloat(b,true) -#endif + //TODO: non-power-of-2 size datatypes may not be interpreted correctly on big-endian systems + switch (nb) { + case 1: { + uint8_t data8 = *(uint8_t*)jl_data_ptr(e); + return ConstantInt::get(T_int8, data8); + } + case 2: { + uint16_t data16 = *(uint16_t*)jl_data_ptr(e); #ifndef DISABLE_FLOAT16 - if (nb == 2) - return ConstantFP::get(jl_LLVMContext,LLVM_FP(APFloat::IEEEhalf,val)); + if (jl_is_float(e)) { + return ConstantFP::get(jl_LLVMContext,LLVM_FP(APFloat::IEEEhalf,APInt(16,data16))); + } +#endif + return ConstantInt::get(T_int16, data16); + } + case 4: { + uint32_t data32 = *(uint32_t*)jl_data_ptr(e); + if (jl_is_float(e)) { + return ConstantFP::get(jl_LLVMContext,LLVM_FP(APFloat::IEEEsingle,APInt(32,data32))); + } + return ConstantInt::get(T_int32, data32); + } + case 8: { + uint64_t data64 = *(uint64_t*)jl_data_ptr(e); + if (jl_is_float(e)) { + return ConstantFP::get(jl_LLVMContext,LLVM_FP(APFloat::IEEEdouble,APInt(64,data64))); + } + return ConstantInt::get(T_int64, data64); + } + default: + size_t nw = (nb+sizeof(uint64_t)-1)/sizeof(uint64_t); + uint64_t *data = (uint64_t*)jl_data_ptr(e); + APInt val; +#if !defined(_P64) + // malloc may not be 16-byte aligned on P32, + // but we must ensure that llvm's uint64_t reads don't fall + // off the end of a page + // where 16-byte alignment requirement == (8-byte typetag) % (uint64_t ArrayRef access) + if (nb % 16 != 0) { + uint64_t *data_a64 = (uint64_t*)alloca(sizeof(uint64_t)*nw); + memcpy(data_a64, data, nb); + val = APInt(8*nb, ArrayRef(data_a64, nw)); + } else #endif - if (nb == 4) - return ConstantFP::get(jl_LLVMContext,LLVM_FP(APFloat::IEEEsingle,val)); - else if (nb == 8) - return ConstantFP::get(jl_LLVMContext,LLVM_FP(APFloat::IEEEdouble,val)); - else if (nb == 16) + val = APInt(8*nb, ArrayRef(data, nw)); + if (nb == 16 && jl_is_float(e)) { return ConstantFP::get(jl_LLVMContext,LLVM_FP(APFloat::IEEEquad,val)); - // If we have a floating point type that's not hardware supported, just treat it like an integer for LLVM purposes - } - Constant *asInt = ConstantInt::get(IntegerType::get(jl_LLVMContext,8*nb),val); - if (jl_is_cpointer_type(jt)) { - return ConstantExpr::getIntToPtr(asInt, julia_type_to_llvm((jl_value_t*)bt)); + // If we have a floating point type that's not hardware supported, just treat it like an integer for LLVM purposes + } + return ConstantInt::get(IntegerType::get(jl_LLVMContext,8*nb),val); } - return asInt; } else if (jl_isbits(jt)) { size_t nf = jl_tuple_len(bt->names), i; diff --git a/test/backtrace.jl b/test/backtrace.jl index ea5eabfbc0469..8fc058eacda92 100644 --- a/test/backtrace.jl +++ b/test/backtrace.jl @@ -10,3 +10,14 @@ for l in bt end @test have_backtrace + +# these could fail on an embedded installation +# but for now, we don't handle that case +dlls = Sys.dllist() +@test !isempty(dlls) +@test length(dlls) > 3 # at a bare minimum, probably have some version of libstdc, libgcc, libjulia, ... +@test Base.samefile(Sys.dlpath(dlls[1]), dlls[1]) +@test Base.samefile(Sys.dlpath(dlls[end]), dlls[end]) +@test length(filter(dlls) do dl + return ismatch(Regex("^libjulia(?:.*)\.$(Sys.dlext)(?:\..+)?\$"), basename(dl)) + end) == 1 # look for something libjulia-like (but only one) diff --git a/test/core.jl b/test/core.jl index be6dcb6fbfee6..5f1f4c05c0776 100644 --- a/test/core.jl +++ b/test/core.jl @@ -2235,3 +2235,17 @@ arithtype9232{T<:Real}(::Type{T},::Type{T}) = arithtype9232(T) result_type9232{T1<:Number,T2<:Number}(::Type{T1}, ::Type{T2}) = arithtype9232(T1, T2) # this gave a "type too large", but not reliably @test length(code_typed(result_type9232, (Type{TypeVar(:_, Union(Float32,Float64))}, Type{TypeVar(:T2, Number)}))) == 1 + +# test functionality of non-power-of-2 bitstype constants +bitstype 24 Int24 +Int24(x::Int) = Intrinsics.box(Int24,Intrinsics.trunc_int(Int24,Intrinsics.unbox(Int,x))) +Int(x::Int24) = Intrinsics.box(Int,Intrinsics.zext_int(Int,Intrinsics.unbox(Int24,x))) +let x,y,f + x = Int24(Int(0x12345678)) # create something (via truncation) + @test Int(0x345678) === Int(x) + function f() Int24(Int(0x02468ace)) end + y = f() # invoke llvm constant folding + @test Int(0x468ace) === Int(y) + @test x !== y + @test string(y) == "Int24(0x468ace)" +end diff --git a/test/markdown.jl b/test/markdown.jl index 3ef9096a7c448..1a5c66b0d1bd0 100644 --- a/test/markdown.jl +++ b/test/markdown.jl @@ -22,6 +22,15 @@ foo ``` """ == MD(Code("julia", "foo")) +@test md""" +* one +* two + +1. pirate +2. ninja +3. zombie""" == Markdown.MD([Markdown.List(["one", "two"]), + Markdown.List(["pirate", "ninja", "zombie"], true)]) + @test md"Foo [bar]" == MD(Paragraph("Foo [bar]")) @test md"Foo [bar](baz)" != MD(Paragraph("Foo [bar](baz)")) @test md"Foo \[bar](baz)" == MD(Paragraph("Foo [bar](baz)")) @@ -33,12 +42,22 @@ foo @test md"#title" |> plain == "# title\n" @test md"## section" |> plain == "## section\n" @test md"## section `foo`" |> plain == "## section `foo`\n" +@test md"""Hello + +--- +World""" |> plain == "Hello\n\n–––\n\nWorld\n" # HTML output @test md"foo *bar* baz" |> html == "

foo bar baz

\n" +@test md"1. Hello" |> html == "
  1. Hello
  2. \n
\n" +@test md"* World" |> html == "
  • World
  • \n
\n" @test md"# title *blah*" |> html == "

title blah

\n" @test md"## title *blah*" |> html == "

title blah

\n" +@test md"""Hello + +--- +World""" |> html == "

Hello

\n
\n

World

\n" # Interpolation / Custom types