Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuples made me sad (so I fixed them) #4042

Merged
merged 28 commits into from
Dec 7, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9f2002c
Pass tuples unboxed if possible
Keno Aug 11, 2013
793562b
All tests pass
Keno Aug 12, 2013
9bfd041
Specialize more functions
Keno Aug 12, 2013
4917312
bugfixes
Keno Aug 13, 2013
2ffa794
Remove unnessecary pto argument from emit_unbox
Keno Aug 13, 2013
c802070
Adjust llvmcall for new tuple infrastructure
Keno Aug 13, 2013
91f8ae7
Some llvmcall bugfixes
Keno Aug 13, 2013
c343b5a
Address compiler warnings
Keno Aug 13, 2013
49217ff
Also remove PM initialization
Keno Aug 13, 2013
9cc2819
Handle nothingness correctly
Keno Aug 13, 2013
aec2612
Fix a performance regression
Keno Aug 14, 2013
6b567e1
tpl -> &tpl and don't use return value from unreachable
Keno Aug 15, 2013
1933ea7
Allow unboxed storing tupl purebits tuples
Keno Aug 15, 2013
c58e1ff
remove invalid check from store_unboxed_p
Keno Aug 16, 2013
17690a0
is_stable_expr for tuples
Keno Aug 16, 2013
10330fa
Fix tuples branch for some changes since it was introduced
Keno Oct 2, 2013
a93b442
Tuples branch bug-fixes
Keno Oct 5, 2013
0e2c3e6
Fix a missing JL_GC_POP
Keno Oct 25, 2013
f8b79c4
Fix ifelse on the tuple branch
Keno Oct 26, 2013
8217d70
Merge some bugfixes from MCJIT branch
Keno Nov 16, 2013
71a5def
Fix build failure after merge
Keno Nov 17, 2013
665ffe5
Cleanup
Keno Nov 19, 2013
e02db98
Separate out llvmcall
Keno Nov 19, 2013
9deb3a1
Simplify emit_tupleset, but disallowing non-constant ones
Keno Nov 20, 2013
ee26d21
Add a missing GC root
Keno Nov 21, 2013
f9999b1
Fix an improperly adjusted gc frame
Keno Nov 23, 2013
a7d99e6
Fix vararg root counting
Keno Nov 27, 2013
d5ad8e6
Fix a rebase conflict
Keno Nov 27, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2066,7 +2066,7 @@ function inlining_pass(e::Expr, sv, ast)
end

function add_variable(ast, name, typ)
vinf = {name,typ,2}
vinf = {name,typ,18}
locllist = ast.args[2][1]::Array{Any,1}
vinflist = ast.args[2][2]::Array{Any,1}
push!(locllist, name)
Expand Down
8 changes: 4 additions & 4 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ done(mt::MethodTable, i::()) = true
uncompressed_ast(l::LambdaStaticData) =
isa(l.ast,Expr) ? l.ast : ccall(:jl_uncompress_ast, Any, (Any,Any), l, l.ast)

function _dump_function(f, t::ANY, native)
str = ccall(:jl_dump_function, Any, (Any,Any,Bool), f, t, native)::ByteString
function _dump_function(f, t::ANY, native, wrapper)
str = ccall(:jl_dump_function, Any, (Any,Any,Bool,Bool), f, t, native, wrapper)::ByteString
if str == ""
error("no method found for the specified argument types")
end
str
end

code_llvm (f::Callable, types::Tuple) = print(_dump_function(f, types, false))
code_native(f::Callable, types::Tuple) = print(_dump_function(f, types, true))
code_llvm (f::Callable, types::Tuple) = print(_dump_function(f, types, false, false))
code_native(f::Callable, types::Tuple) = print(_dump_function(f, types, true, false))

function functionlocs(f::Function, types=(Any...))
locs = Any[]
Expand Down
2 changes: 1 addition & 1 deletion src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ value_t fl_invoke_julia_macro(value_t *args, uint32_t nargs)
int i;
for(i=0; i < nargs; i++) margs[i] = NULL;
for(i=1; i < nargs; i++) margs[i] = scm_to_julia(args[i], 1);
jl_value_t *result=NULL;
jl_value_t *result = NULL;

JL_TRY {
margs[0] = scm_to_julia(args[0], 1);
Expand Down
19 changes: 10 additions & 9 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static Value *julia_to_native(Type *ty, jl_value_t *jt, Value *jv,
{
Type *vt = jv->getType();
if (ty == jl_pvalue_llvmt) {
return boxed(jv);
return boxed(jv,ctx);
}
else if (ty == vt && !addressOf) {
return jv;
Expand All @@ -269,7 +269,7 @@ static Value *julia_to_native(Type *ty, jl_value_t *jt, Value *jv,
}
}
// error. box for error handling.
jv = boxed(jv);
jv = boxed(jv,ctx);
}
else if (jl_is_cpointer_type(jt)) {
assert(ty->isPointerTy());
Expand Down Expand Up @@ -314,6 +314,8 @@ static Value *julia_to_native(Type *ty, jl_value_t *jt, Value *jv,
// //safe thing would be to also check that jl_typeof(aty)->size > sizeof(ty) here and/or at runtime
Value *pjv = builder.CreateBitCast(emit_nthptr_addr(jv, (size_t)1), PointerType::get(ty,0));
return builder.CreateLoad(pjv, false);
} else if (jl_is_tuple(jt)) {
return emit_unbox(ty,jv,jt);
}
// TODO: error for & with non-pointer argument type
assert(jl_is_bitstype(jt));
Expand Down Expand Up @@ -353,7 +355,7 @@ static native_sym_arg_t interpret_symbol_arg(jl_value_t *arg, jl_codectx_t *ctx,
"cglobal: first argument not a pointer or valid constant expression",
ctx);
}
jl_ptr = emit_unbox(T_size, T_psize, arg1);
jl_ptr = emit_unbox(T_size, arg1, ptr_ty);
}

void *fptr=NULL;
Expand Down Expand Up @@ -670,7 +672,7 @@ static Value *emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
addressOf = true;
argi = jl_exprarg(argi,0);
}
Value *ary = boxed(emit_expr(argi, ctx));
Value *ary = boxed(emit_expr(argi, ctx),ctx);
JL_GC_POP();
return mark_julia_type(
builder.CreateBitCast(emit_nthptr_addr(ary, addressOf?1:0),lrt),
Expand Down Expand Up @@ -790,23 +792,22 @@ static Value *emit_ccall(jl_value_t **args, size_t nargs, jl_codectx_t *ctx)
if (largty == jl_pvalue_llvmt || largty->isStructTy()) {
arg = emit_expr(argi, ctx, true);
if (largty == jl_pvalue_llvmt && arg->getType() != jl_pvalue_llvmt) {
arg = boxed(arg);
arg = boxed(arg,ctx);
needroot = true;
}
}
}
else {
arg = emit_unboxed(argi, ctx);
if (jl_is_bitstype(expr_type(argi, ctx))) {
Type *totype = addressOf ? largty->getContainedType(0) : largty;
Type *ptype = addressOf ? largty : PointerType::get(largty,0);
Type *at = arg->getType();
Type *totype = addressOf ? largty->getContainedType(0) : largty;
if (at != jl_pvalue_llvmt && at != totype &&
!(at->isPointerTy() && jargty==(jl_value_t*)jl_voidpointer_type)) {
emit_type_error(arg, jargty, "ccall", ctx);
arg = UndefValue::get(totype);
}
else {
arg = emit_unbox(totype, ptype, arg);
arg = emit_unbox(totype, arg, jargty);
}
}
}
Expand Down
Loading