Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
* upstream/master: (89 commits)
  fix JuliaLang#5225
  update pcre
  fix off-by-1 in isqrt. closes JuliaLang#4884
  Add more keywords to ctags regex, plus README
  annotate the types of arguments for derived trigonometric & hyperbolic functions
  fix doc for && and || and update helpdb
  only show ccall literal address warning in imaging mode. closes JuliaLang#5215
  minor update of hypot to ensure consistency of output types
  Fix JuliaLang#5217
  silence compiler warning
  hopefully more robust way of getting github URL (don't assume module name is Pkg name)
  add text/html writemime for MethodList and Method (fix JuliaLang#4952)
  update NEWS
  doc: `import M: single,name` syntax, close JuliaLang#5214
  clean up native finalizers code
  specialized abs2 for bool
  remove use of callback API in REPL
  Some error message cleanup to fix segfault when transposing sparse vector with illegal values.
  test/git*.jl: don't use `echo` to read-and-write from processes.
  test/git*.jl: don't use `echo` to read-and-write from processes.
  ...
  • Loading branch information
Michael Fox committed Dec 23, 2013
2 parents 69d1040 + def4b95 commit e25f4ad
Show file tree
Hide file tree
Showing 77 changed files with 2,148 additions and 955 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -68,7 +68,7 @@ $(BUILD)/etc/julia/juliarc.jl: etc/juliarc.jl | $(BUILD)/etc/julia
$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys%ji: $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys%bc

$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys%o: $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys%bc
$(call spawn,$(LLVM_LLC)) -filetype=obj -relocation-model=pic -o $@ $<
$(call spawn,$(LLVM_LLC)) -filetype=obj -relocation-model=pic -mattr=-bmi2,-avx2 -o $@ $<

$(BUILD)/$(JL_PRIVATE_LIBDIR)/sys%$(SHLIB_EXT): $(BUILD)/$(JL_PRIVATE_LIBDIR)/sys%o
$(CXX) -shared -fPIC -L$(BUILD)/$(JL_PRIVATE_LIBDIR) -L$(BUILD)/$(JL_LIBDIR) -o $@ $< \
Expand Down
13 changes: 12 additions & 1 deletion NEWS.md
Expand Up @@ -6,6 +6,11 @@ New language features

* Greatly enhanced performance for passing and returning tuples ([#4042]).

* Tuples (of integers, symbols, or bools) can now be used as type
parameters ([#5164]).

* `import module: name1, name2, ...` ([#5214]).

New library functions
---------------------

Expand Down Expand Up @@ -44,21 +49,27 @@ Library improvements

* `rand` now supports arbitrary `Ranges` arguments ([#5059]).

* `mod2pi` function ([#4799], [#4862]).

Deprecated or removed
---------------------

* `dense` is deprecated in favor of `full` ([#4759])

* The `Stat` type is renamed `StatStruct` ([#4670])

* `set_rounding`, `get_rounding` and `with_rounding` now take an additional
argument specifying the floating point type to which they apply. The old
behaviour and `[get/set/with]_bigfloat_rounding` functions are deprecated ([#5007])

[#4775]: https://github.com/JuliaLang/julia/issues/4775
[#4870]: https://github.com/JuliaLang/julia/issues/4870
[#4766]: https://github.com/JuliaLang/julia/issues/4766
[#4782]: https://github.com/JuliaLang/julia/issues/4782
[#4759]: https://github.com/JuliaLang/julia/issues/4759
[#4819]: https://github.com/JuliaLang/julia/issues/4819
[#4670]: https://github.com/JuliaLang/julia/issues/4670

[#5007]: https://github.com/JuliaLang/julia/issues/5007


Julia v0.2.0 Release Notes
Expand Down
10 changes: 5 additions & 5 deletions base/array.jl
Expand Up @@ -121,15 +121,15 @@ function reinterpret{T,S,N}(::Type{T}, a::Array{S}, dims::NTuple{N,Int})
end
nel = div(length(a)*sizeof(S),sizeof(T))
if prod(dims) != nel
error("new dimensions $(dims) must be consistent with array size $(nel)")
throw(DimensionMismatch("new dimensions $(dims) must be consistent with array size $(nel)"))
end
ccall(:jl_reshape_array, Array{T,N}, (Any, Any, Any), Array{T,N}, a, dims)
end
reinterpret(t::Type,x) = reinterpret(t,[x])[1]

function reshape{T,N}(a::Array{T}, dims::NTuple{N,Int})
if prod(dims) != length(a)
error("new dimensions $(dims) must be consistent with array size $(length(a))")
throw(DimensionMismatch("new dimensions $(dims) must be consistent with array size $(length(a))"))
end
ccall(:jl_reshape_array, Array{T,N}, (Any, Any, Any), Array{T,N}, a, dims)
end
Expand Down Expand Up @@ -598,12 +598,12 @@ function setindex!(A::Array, x, I::Union(Real,AbstractArray)...)
nel *= length(idx)
end
if length(X) != nel
error("argument dimensions must match")
throw(DimensionMismatch(""))
end
if ndims(X) > 1
for i = 1:length(I)
if size(X,i) != length(I[i])
error("argument dimensions must match")
throw(DimensionMismatch(""))
end
end
end
Expand Down Expand Up @@ -996,7 +996,7 @@ end
## promotion to complex ##

function complex{S<:Real,T<:Real}(A::Array{S}, B::Array{T})
if size(A) != size(B); error("argument dimensions must match"); end
if size(A) != size(B); throw(DimensionMismatch("")); end
F = similar(A, typeof(complex(zero(S),zero(T))))
for i=1:length(A)
@inbounds F[i] = complex(A[i], B[i])
Expand Down
6 changes: 5 additions & 1 deletion base/base.jl
Expand Up @@ -70,6 +70,10 @@ end

type EOFError <: Exception end

type DimensionMismatch <: Exception
name::ASCIIString
end

type WeakRef
value
WeakRef() = WeakRef(nothing)
Expand All @@ -94,7 +98,7 @@ isequal(w::WeakRef, v::WeakRef) = isequal(w.value, v.value)
isequal(w::WeakRef, v) = isequal(w.value, v)
isequal(w, v::WeakRef) = isequal(w, v.value)

function finalizer(o::ANY, f::Function)
function finalizer(o::ANY, f::Union(Function,Ptr))
if isimmutable(o)
error("objects of type ", typeof(o), " cannot be finalized")
end
Expand Down
130 changes: 88 additions & 42 deletions base/bitarray.jl
Expand Up @@ -2125,25 +2125,58 @@ ctranspose(B::BitArray) = transpose(B)

## Permute array dims ##

function permute_one_dim(ivars, stridenames)
len = length(ivars)
counts = { symbol(string("count",i)) for i=1:len}
toReturn = cell(len+1,2)
for i = 1:length(toReturn)
toReturn[i] = nothing
end

tmp = counts[end]
toReturn[len+1] = quote
ind = 1
$tmp = $(stridenames[len])
end

#inner most loop
toReturn[1] = quote
P[ind] = B[+($(counts...))+offset]
ind+=1
$(counts[1]) += $(stridenames[1])
end
for i = 1:len-1
tmp = counts[i]
val = i
toReturn[(i+1)] = quote
$tmp = $(stridenames[val])
end
tmp2 = counts[i+1]
val = i+1
toReturn[(i+1)+(len+1)] = quote
$tmp2 += $(stridenames[val])
end
end
toReturn
end

let permutedims_cache = nothing, stridenames::Array{Any,1} = {}
global permutedims
function permutedims(B::Union(BitArray,StridedArray), perm)
global permutedims!
function permutedims!(P::BitArray,B::BitArray, perm)
dimsB = size(B)
ndimsB = length(dimsB)
ndimsB == length(perm) || error("invalid dimensions")
dimsP = ntuple(ndimsB, i->dimsB[perm[i]])::typeof(dimsB)
P = similar(B, dimsP)
(ndimsB == length(perm) && isperm(perm)) || error("no valid permutation of dimensions")
dimsP = size(P)
ndimsP = length(dimsP)
(dimsP==dimsB[perm]) || error("destination tensor of incorrect size")

ranges = ntuple(ndimsB, i->(1:dimsP[i]))
while length(stridenames) < ndimsB
push!(stridenames, gensym())
end

#calculates all the strides
if isa(B,BitArray)
strides = [ prod(dimsB[1:(perm[dim]-1)])::Int for dim = 1:length(perm) ]
else
strides = [ stride(B, perm[dim]) for dim = 1:length(perm) ]
end
strides = [ prod(dimsB[1:(perm[dim]-1)])::Int for dim = 1:length(perm) ]

#Creates offset, because indexing starts at 1
offset = 0
Expand All @@ -2157,53 +2190,66 @@ function permutedims(B::Union(BitArray,StridedArray), perm)
B = B.parent
end

function permute_one_dim(ivars)
len = length(ivars)
counts = { symbol(string("count",i)) for i=1:len}
toReturn = cell(len+1,2)
for i = 1:length(toReturn)
toReturn[i] = nothing
end
if is(permutedims_cache,nothing)
permutedims_cache = Dict()
end

tmp = counts[end]
toReturn[len+1] = quote
ind = 1
$tmp = $(stridenames[len])
end
gen_cartesian_map(permutedims_cache, iv->permute_one_dim(iv,stridenames), ranges,
tuple(:B, :P, :perm, :offset, stridenames[1:ndimsB]...),
B, P, perm, offset, strides...)

#inner most loop
toReturn[1] = quote
P[ind] = B[+($(counts...))+offset]
ind+=1
$(counts[1]) += $(stridenames[1])
end
for i = 1:len-1
tmp = counts[i]
val = i
toReturn[(i+1)] = quote
$tmp = $(stridenames[val])
end
tmp2 = counts[i+1]
val = i+1
toReturn[(i+1)+(len+1)] = quote
$tmp2 += $(stridenames[val])
end
end
toReturn
return P
end
function permutedims!(P::Array,B::StridedArray, perm)
dimsB = size(B)
ndimsB = length(dimsB)
(ndimsB == length(perm) && isperm(perm)) || error("no valid permutation of dimensions")
dimsP = size(P)
ndimsP = length(dimsP)
(dimsP==dimsB[perm]) || error("destination tensor of incorrect size")

ranges = ntuple(ndimsB, i->(1:dimsP[i]))
while length(stridenames) < ndimsB
push!(stridenames, gensym())
end

#calculates all the strides
strides = [ stride(B, perm[dim]) for dim = 1:length(perm) ]

#Creates offset, because indexing starts at 1
offset = 0
for i in strides
offset+=i
end
offset = 1-offset

if isa(B,SubArray)
offset += (B.first_index-1)
B = B.parent
end

if is(permutedims_cache,nothing)
permutedims_cache = Dict()
end

gen_cartesian_map(permutedims_cache, permute_one_dim, ranges,
gen_cartesian_map(permutedims_cache, iv->permute_one_dim(iv,stridenames), ranges,
tuple(:B, :P, :perm, :offset, stridenames[1:ndimsB]...),
B, P, perm, offset, strides...)

return P
end
end # let

function permutedims(B::Union(BitArray,StridedArray), perm)
dimsB = size(B)
ndimsB = length(dimsB)
(ndimsB == length(perm) && isperm(perm)) || error("no valid permutation of dimensions")
dimsP = ntuple(ndimsB, i->dimsB[perm[i]])::typeof(dimsB)
P = similar(B, dimsP)
permutedims!(P,B,perm)
end


## Concatenation ##

function hcat(B::BitVector...)
Expand Down
1 change: 1 addition & 0 deletions base/bool.jl
Expand Up @@ -26,6 +26,7 @@ typemax(::Type{Bool}) = true
signbit(x::Bool) = 0
sign(x::Bool) = x
abs(x::Bool) = x
abs2(x::Bool) = x

<(x::Bool, y::Bool) = y&!x
<=(x::Bool, y::Bool) = y|!x
Expand Down
45 changes: 14 additions & 31 deletions base/client.jl
Expand Up @@ -37,13 +37,6 @@ exit(n) = ccall(:jl_exit, Void, (Int32,), n)
exit() = exit(0)
quit() = exit()

function repl_callback(ast::ANY, show_value)
global _repl_enough_stdin = true
stop_reading(STDIN)
STDIN.readcb = false
put(repl_channel, (ast, show_value))
end

function repl_cmd(cmd)
shell = shell_split(get(ENV,"JULIA_SHELL",get(ENV,"SHELL","/bin/sh")))
# Note that we can't support the fish shell due to its lack of subshells
Expand Down Expand Up @@ -144,28 +137,9 @@ function eval_user_input(ast::ANY, show_value)
isa(STDIN,TTY) && println()
end

function read_buffer(stream::AsyncStream, nread)
global _repl_enough_stdin::Bool
while !_repl_enough_stdin && nb_available(stream.buffer) > 0
nread = int(search(stream.buffer,'\n')) # never more than one line or readline explodes :O
nread2 = int(search(stream.buffer,'\r'))
if nread == 0
if nread2 == 0
nread = nb_available(stream.buffer)
else
nread = nread2
end
else
if nread2 != 0 && nread2 < nread
nread = nread2
end
end
ptr = pointer(stream.buffer.data,stream.buffer.ptr)
skip(stream.buffer,nread)
#println(STDERR,stream.buffer.data[stream.buffer.ptr-nread:stream.buffer.ptr-1])
ccall(:jl_read_buffer,Void,(Ptr{Void},Cssize_t),ptr,nread)
end
return false
function repl_callback(ast::ANY, show_value)
global _repl_enough_stdin = true
put(repl_channel, (ast, show_value))
end

function run_repl()
Expand All @@ -175,7 +149,17 @@ function run_repl()

# install Ctrl-C interrupt handler (InterruptException)
ccall(:jl_install_sigint_handler, Void, ())
STDIN.closecb = (x...)->put(repl_channel,(nothing,-1))
buf = Uint8[0]
@async begin
while !eof(STDIN)
read(STDIN, buf)
ccall(:jl_read_buffer,Void,(Ptr{Void},Cssize_t),buf,1)
if _repl_enough_stdin
yield()
end
end
put(repl_channel,(nothing,-1))
end

while true
if have_color
Expand All @@ -185,7 +169,6 @@ function run_repl()
end
ccall(:repl_callback_enable, Void, (Ptr{Uint8},), prompt_string)
global _repl_enough_stdin = false
start_reading(STDIN, read_buffer)
(ast, show_value) = take(repl_channel)
if show_value == -1
# exit flag
Expand Down

0 comments on commit e25f4ad

Please sign in to comment.