Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

constant-fold construction of tuple types

a small improvement to effect_free, which helps inlining

definitions used by ccall need to be available earlier
  • Loading branch information...
commit c53772da9053da9d7d329032de4bafc282db21f6 1 parent 505ceb0
@JeffBezanson JeffBezanson authored
Showing with 17 additions and 14 deletions.
  1. +12 −0 base/base.jl
  2. +0 −10 base/c.jl
  3. +0 −2  base/expr.jl
  4. +5 −2 base/inference.jl
View
12 base/base.jl
@@ -11,6 +11,16 @@ typealias Callable Union(Function,DataType)
convert(T, x) = convert_default(T, x, convert)
convert(T::Tuple, x::Tuple) = convert_tuple(T, x, convert)
+ptr_arg_convert{T}(::Type{Ptr{T}}, x) = convert(T, x)
+ptr_arg_convert(::Type{Ptr{Void}}, x) = x
+
+# conversion used by ccall
+cconvert(T, x) = convert(T, x)
+# use the code in ccall.cpp to safely allocate temporary pointer arrays
+cconvert{T}(::Type{Ptr{Ptr{T}}}, a::Array) = a
+# TODO: for some reason this causes a strange type inference problem
+#cconvert(::Type{Ptr{Uint8}}, s::String) = bytestring(s)
+
abstract IO
type ErrorException <: Exception
@@ -129,6 +139,8 @@ function precompile(f, args::Tuple)
end
end
+esc(e::ANY) = Expr(:escape, e)
+
macro boundscheck(yesno,blk)
quote
$(Expr(:boundscheck,yesno))
View
10 base/c.jl
@@ -2,16 +2,6 @@
import Core.Intrinsics.cglobal
-ptr_arg_convert{T}(::Type{Ptr{T}}, x) = convert(T, x)
-ptr_arg_convert(::Type{Ptr{Void}}, x) = x
-
-# conversion used by ccall
-cconvert(T, x) = convert(T, x)
-# use the code in ccall.cpp to safely allocate temporary pointer arrays
-cconvert{T}(::Type{Ptr{Ptr{T}}}, a::Array) = a
-# TODO: for some reason this causes a strange type inference problem
-#cconvert(::Type{Ptr{Uint8}}, s::String) = bytestring(s)
-
# constants to match JL_RTLD_* in src/julia.h
const RTLD_LOCAL = 0x00000000
const RTLD_GLOBAL = 0x00000001
View
2  base/expr.jl
@@ -24,8 +24,6 @@ macro gensym(names...)
return blk
end
-esc(e::ANY) = Expr(:escape, e)
-
## expressions ##
splicedexpr(hd::Symbol, args::Array{Any,1}) = (e=Expr(hd); e.args=args; e)
View
7 base/inference.jl
@@ -1682,12 +1682,12 @@ function without_linenums(a::Array{Any,1})
l
end
-_pure_builtins = {getfield, tuple, tupleref, tuplelen, fieldtype}
+_pure_builtins = {getfield, tuple, tupleref, tuplelen, fieldtype, apply_type}
# detect some important side-effect-free calls
function effect_free(e::ANY, sv)
if isa(e,Symbol) || isa(e,SymbolNode) || isa(e,Number) || isa(e,String) ||
- isa(e,TopNode) || isa(e,QuoteNode)
+ isa(e,TopNode) || isa(e,QuoteNode) || isa(e,Type)
return true
end
if isa(e,Expr)
@@ -1763,6 +1763,9 @@ function inlineable(f, e::Expr, sv, enclosing_ast)
end
end
end
+ if is(f,tuple) && isa(e.typ,Tuple) && all(isType,e.typ) && isleaftype(e.typ) && effect_free(e,sv)
+ return (map(t->t.parameters[1], e.typ), ())
+ end
if isa(f,IntrinsicFunction)
return NF
end
Please sign in to comment.
Something went wrong with that request. Please try again.