Skip to content

Commit 0d7a607

Browse files
vtjnashfcard
authored andcommitted
store tuple and vector types to the stack eagerly
fix JuliaLang#11187 (pass struct and tuple objects by stack pointer) fix JuliaLang#11450 (ccall emission was frobbing the stack) likely may fix JuliaLang#11026 and may fix JuliaLang#11003 (ref JuliaLang#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
1 parent f4d75a0 commit 0d7a607

File tree

7 files changed

+397
-222
lines changed

7 files changed

+397
-222
lines changed

base/inference.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,6 +3051,7 @@ end
30513051
function remove_redundant_temp_vars(ast, sa)
30523052
varinfo = ast.args[2][1]
30533053
gensym_types = ast.args[2][3]
3054+
body = ast.args[3]
30543055
for (v,init) in sa
30553056
if ((isa(init,Symbol) || isa(init,SymbolNode)) &&
30563057
any(vi->symequal(vi[1],init), varinfo) &&
@@ -3059,7 +3060,7 @@ function remove_redundant_temp_vars(ast, sa)
30593060
# this transformation is not valid for vars used before def.
30603061
# we need to preserve the point of assignment to know where to
30613062
# throw errors (issue #4645).
3062-
if !occurs_undef(v, ast.args[3], varinfo)
3063+
if !occurs_undef(v, body, varinfo)
30633064

30643065
# the transformation is not ideal if the assignment
30653066
# is present for the auto-unbox functionality
@@ -3068,7 +3069,7 @@ function remove_redundant_temp_vars(ast, sa)
30683069
# everywhere later in the function
30693070
if (isa(init,SymbolNode) ? (init.typ <: (isa(v,GenSym)?gensym_types[(v::GenSym).id+1]:local_typeof(v, varinfo))) : true)
30703071
delete_var!(ast, v)
3071-
sym_replace(ast.args[3], [v], [], [init], [])
3072+
sym_replace(body, Any[v], Void[], Any[init], Void[])
30723073
end
30733074
end
30743075
end

src/builtins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static int NOINLINE compare_fields(jl_value_t *a, jl_value_t *b,
273273
return 1;
274274
}
275275

276-
int jl_egal(jl_value_t *a, jl_value_t *b)
276+
int jl_egal(jl_value_t *a, jl_value_t *b) // warning: a,b may NOT have been gc-rooted by the caller
277277
{
278278
if (a == b)
279279
return 1;

0 commit comments

Comments
 (0)