Skip to content

Commit 727d2f7

Browse files
committed
store tuple and vector types to the stack eagerly
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
1 parent 818e2f3 commit 727d2f7

File tree

7 files changed

+398
-223
lines changed

7 files changed

+398
-223
lines changed

base/inference.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,6 +3048,7 @@ end
30483048
function remove_redundant_temp_vars(ast, sa)
30493049
varinfo = ast.args[2][1]
30503050
gensym_types = ast.args[2][3]
3051+
body = ast.args[3]
30513052
for (v,init) in sa
30523053
if ((isa(init,Symbol) || isa(init,SymbolNode)) &&
30533054
any(vi->symequal(vi[1],init), varinfo) &&
@@ -3056,7 +3057,7 @@ function remove_redundant_temp_vars(ast, sa)
30563057
# this transformation is not valid for vars used before def.
30573058
# we need to preserve the point of assignment to know where to
30583059
# throw errors (issue #4645).
3059-
if !occurs_undef(v, ast.args[3], varinfo)
3060+
if !occurs_undef(v, body, varinfo)
30603061

30613062
# the transformation is not ideal if the assignment
30623063
# is present for the auto-unbox functionality
@@ -3065,7 +3066,7 @@ function remove_redundant_temp_vars(ast, sa)
30653066
# everywhere later in the function
30663067
if (isa(init,SymbolNode) ? (init.typ <: (isa(v,GenSym)?gensym_types[(v::GenSym).id+1]:local_typeof(v, varinfo))) : true)
30673068
delete_var!(ast, v)
3068-
sym_replace(ast.args[3], [v], [], [init], [])
3069+
sym_replace(body, Any[v], Void[], Any[init], Void[])
30693070
end
30703071
end
30713072
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)