@@ -5217,6 +5217,21 @@ function occurs_outside_getfield(e::ANY, sym::ANY,
5217
5217
if head === :(= )
5218
5218
return occurs_outside_getfield (e. args[2 ], sym, sv,
5219
5219
field_count, field_names)
5220
+ elseif head === :foreigncall
5221
+ args = e. args
5222
+ nccallargs = args[5 ]:: Int
5223
+ # Only arguments escape, GC root arguments do not escape.
5224
+ for i in 1 : length (args)
5225
+ a = args[i]
5226
+ if i > 5 + nccallargs && symequal (a, sym)
5227
+ # No need to verify indices, uninitialized members can be
5228
+ # ignored in root slot.
5229
+ continue
5230
+ end
5231
+ if occurs_outside_getfield (a, sym, sv, field_count, field_names)
5232
+ return true
5233
+ end
5234
+ end
5220
5235
else
5221
5236
if (head === :block && isa (sym, Slot) &&
5222
5237
sv. src. slotflags[slot_id (sym)] & Slot_UsedUndef == 0 )
@@ -5800,8 +5815,11 @@ end
5800
5815
function replace_getfield! (e:: Expr , tupname, vals, field_names, sv:: InferenceState )
5801
5816
for i = 1 : length (e. args)
5802
5817
a = e. args[i]
5803
- if isa (a,Expr) && is_known_call (a, getfield, sv. src, sv. mod) &&
5804
- symequal (a. args[2 ],tupname)
5818
+ if ! isa (a, Expr)
5819
+ continue
5820
+ end
5821
+ a = a:: Expr
5822
+ if is_known_call (a, getfield, sv. src, sv. mod) && symequal (a. args[2 ], tupname)
5805
5823
idx = if isa (a. args[3 ], Int)
5806
5824
a. args[3 ]
5807
5825
else
@@ -5830,8 +5848,22 @@ function replace_getfield!(e::Expr, tupname, vals, field_names, sv::InferenceSta
5830
5848
end
5831
5849
end
5832
5850
e. args[i] = val
5833
- elseif isa (a, Expr)
5834
- replace_getfield! (a:: Expr , tupname, vals, field_names, sv)
5851
+ else
5852
+ if a. head === :foreigncall
5853
+ args = a. args
5854
+ nccallargs = args[5 ]:: Int
5855
+ le = length (args)
5856
+ next_i = 6 + nccallargs
5857
+ while next_i <= le
5858
+ i = next_i
5859
+ next_i += 1
5860
+
5861
+ symequal (args[i], tupname) || continue
5862
+ splice! (args, i, vals)
5863
+ next_i += length (vals) - 1
5864
+ end
5865
+ end
5866
+ replace_getfield! (a, tupname, vals, field_names, sv)
5835
5867
end
5836
5868
end
5837
5869
end
0 commit comments