Skip to content

Commit

Permalink
store tuple and vector types to the stack eagerly
Browse files Browse the repository at this point in the history
fix #11187 (pass struct and tuple objects by stack pointer)
fix #11450 (ccall emission was frobbing the stack)
likely may fix #11026 and may fix #11003 (ref #10525) invalid stack-read on 32-bit

this additionally changes the julia specSig calling convention to pass
non-primitive types by pointer instead of by-value

this additionally fixes a bug in gen_cfunction that could be exposed by
turning off specSig

this additionally moves the alloca calls in ccall (and other places) to
the entry BasicBlock in the function, ensuring that llvm detects them as
static allocations and moves them into the function prologue

this additionally fixes some undefined behavior from changing
a variable's size through a alloca-cast instead of zext/sext/trunc

this additionally prepares for turning back on allocating tuples as vectors,
since the gc now guarantees 16-byte alignment

future work this makes possible:
 - create a function to replace the jlallocobj_func+init_bits_value call pair (to reduce codegen pressure)
 - allow moving pointers sometimes rather than always copying immutable data
 - teach the GC how it can re-use an existing pointer as a box
  • Loading branch information
vtjnash committed Jun 12, 2015
1 parent 2336ff8 commit 4647931
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 223 deletions.
5 changes: 3 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3051,6 +3051,7 @@ end
function remove_redundant_temp_vars(ast, sa)
varinfo = ast.args[2][1]
gensym_types = ast.args[2][3]
body = ast.args[3]
for (v,init) in sa
if ((isa(init,Symbol) || isa(init,SymbolNode)) &&
any(vi->symequal(vi[1],init), varinfo) &&
Expand All @@ -3059,7 +3060,7 @@ function remove_redundant_temp_vars(ast, sa)
# this transformation is not valid for vars used before def.
# we need to preserve the point of assignment to know where to
# throw errors (issue #4645).
if !occurs_undef(v, ast.args[3], varinfo)
if !occurs_undef(v, body, varinfo)

# the transformation is not ideal if the assignment
# is present for the auto-unbox functionality
Expand All @@ -3068,7 +3069,7 @@ function remove_redundant_temp_vars(ast, sa)
# everywhere later in the function
if (isa(init,SymbolNode) ? (init.typ <: (isa(v,GenSym)?gensym_types[(v::GenSym).id+1]:local_typeof(v, varinfo))) : true)
delete_var!(ast, v)
sym_replace(ast.args[3], [v], [], [init], [])
sym_replace(body, Any[v], Void[], Any[init], Void[])
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static int NOINLINE compare_fields(jl_value_t *a, jl_value_t *b,
return 1;
}

int jl_egal(jl_value_t *a, jl_value_t *b)
int jl_egal(jl_value_t *a, jl_value_t *b) // warning: a,b may NOT have been gc-rooted by the caller
{
if (a == b)
return 1;
Expand Down
Loading

0 comments on commit 4647931

Please sign in to comment.