Skip to content

Commit ce6e341

Browse files
authored
update builtins.jl (#628)
1 parent 1024848 commit ce6e341

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

bin/generate_builtins.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const ALWAYS_PRESENT = Core.Builtin[
1111
applicable, fieldtype, getfield, invoke, isa, isdefined, nfields,
1212
setfield!, throw, tuple, typeassert, typeof
1313
]
14-
# Builtins present in 1.6, not builtins (potentially still normal functions) anymore
14+
# Builtins present from 1.6, not builtins (potentially still normal functions) anymore
1515
const RECENTLY_REMOVED = GlobalRef.(Ref(Core), [
16-
:arrayref, :arrayset, :arrayset, :const_arrayref,
16+
:arrayref, :arrayset, :arrayset, :const_arrayref, :memoryref,
1717
])
1818
const kwinvoke = Core.kwfunc(Core.invoke)
1919

@@ -37,9 +37,9 @@ function nargs(f, table, id)
3737
minarg = 0
3838
maxarg = typemax(Int)
3939
end
40-
# Specialize ~arrayref and arrayset~ memoryref for small numbers of arguments
40+
# Specialize ~arrayref and arrayset~ memoryrefnew for small numbers of arguments
4141
# TODO: how about other memory intrinsics?
42-
if f == Core.memoryref
42+
if (@static isdefined(Core, :memoryrefnew) ? f == Core.memoryrefnew : f == Core.memoryref)
4343
maxarg = 5
4444
end
4545
return minarg, maxarg
@@ -268,7 +268,7 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
268268
# recently removed builtins
269269
for (; mod, name) in RECENTLY_REMOVED
270270
minarg = 1
271-
if name in (:arrayref, :const_arrayref)
271+
if name in (:arrayref, :const_arrayref, :memoryref)
272272
maxarg = 5
273273
elseif name === :arrayset
274274
maxarg = 6

src/builtins.jl

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,6 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
158158
else
159159
return Some{Any}(Core.ifelse(getargs(args, frame)...))
160160
end
161-
elseif @static isdefined(Core, :memoryref) && f === Core.memoryref
162-
if nargs == 1
163-
return Some{Any}(Core.memoryref(@lookup(frame, args[2])))
164-
elseif nargs == 2
165-
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3])))
166-
elseif nargs == 3
167-
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
168-
elseif nargs == 4
169-
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
170-
elseif nargs == 5
171-
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
172-
else
173-
return Some{Any}(Core.memoryref(getargs(args, frame)...))
174-
end
175161
elseif @static isdefined(Core, :memoryref_isassigned) && f === Core.memoryref_isassigned
176162
if nargs == 3
177163
return Some{Any}(Core.memoryref_isassigned(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
@@ -190,6 +176,20 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
190176
else
191177
return Some{Any}(Core.memoryrefmodify!(getargs(args, frame)...))
192178
end
179+
elseif @static isdefined(Core, :memoryrefnew) && f === Core.memoryrefnew
180+
if nargs == 1
181+
return Some{Any}(Core.memoryrefnew(@lookup(frame, args[2])))
182+
elseif nargs == 2
183+
return Some{Any}(Core.memoryrefnew(@lookup(frame, args[2]), @lookup(frame, args[3])))
184+
elseif nargs == 3
185+
return Some{Any}(Core.memoryrefnew(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
186+
elseif nargs == 4
187+
return Some{Any}(Core.memoryrefnew(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
188+
elseif nargs == 5
189+
return Some{Any}(Core.memoryrefnew(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
190+
else
191+
return Some{Any}(Core.memoryrefnew(getargs(args, frame)...))
192+
end
193193
elseif @static isdefined(Core, :memoryrefoffset) && f === Core.memoryrefoffset
194194
if nargs == 1
195195
return Some{Any}(Core.memoryrefoffset(@lookup(frame, args[2])))
@@ -468,6 +468,20 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
468468
else
469469
return Some{Any}(Core.const_arrayref(getargs(args, frame)...))
470470
end
471+
elseif @static (isdefined(Core, :memoryref) && Core.memoryref isa Core.Builtin) && f === Core.memoryref
472+
if nargs == 1
473+
return Some{Any}(Core.memoryref(@lookup(frame, args[2])))
474+
elseif nargs == 2
475+
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3])))
476+
elseif nargs == 3
477+
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
478+
elseif nargs == 4
479+
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
480+
elseif nargs == 5
481+
return Some{Any}(Core.memoryref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
482+
else
483+
return Some{Any}(Core.memoryref(getargs(args, frame)...))
484+
end
471485
elseif f === Core.Intrinsics.llvmcall
472486
return Some{Any}(Core.Intrinsics.llvmcall(getargs(args, frame)...))
473487
end

0 commit comments

Comments
 (0)