Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

follow up #596 #600

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions bin/generate_builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,12 @@ function maybe_evaluate_builtin(frame, call_expr, expand::Bool)
elseif name === :arraysize
maxarg = 2
end
fcall = generate_fcall_nargs(name, minarg, maxarg)
_scopedname = "$mod.$name"
fcall = generate_fcall_nargs(_scopedname, minarg, maxarg)
rname = repr(name)
print(io,
"""
elseif @static isdefined($mod, $rname) && f === $name
elseif @static (isdefined($mod, $rname) && $_scopedname isa Core.Builtin) && f === $_scopedname
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out that we never hit this path on the recent versions since we exclude the generic cases above (

if !(isa(f, Core.Builtin) || isa(f, Core.IntrinsicFunction))
).

This change is necessary to make this script functional on the previous versions.

$fcall
""")
end
Expand Down
60 changes: 30 additions & 30 deletions src/builtins.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,65 +330,65 @@
call_expr.args[3] = @lookup(frame, args[3])
return Some{Any}(Core.eval(moduleof(frame), call_expr))
end
elseif @static isdefined(Core, :arrayref) && f === :arrayref
elseif @static (isdefined(Core, :arrayref) && Core.arrayref isa Core.Builtin) && f === Core.arrayref
if nargs == 1
return Some{Any}(arrayref(@lookup(frame, args[2])))
return Some{Any}(Core.arrayref(@lookup(frame, args[2])))

Check warning on line 335 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L335

Added line #L335 was not covered by tests
elseif nargs == 2
return Some{Any}(arrayref(@lookup(frame, args[2]), @lookup(frame, args[3])))
return Some{Any}(Core.arrayref(@lookup(frame, args[2]), @lookup(frame, args[3])))

Check warning on line 337 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L337

Added line #L337 was not covered by tests
elseif nargs == 3
return Some{Any}(arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
return Some{Any}(Core.arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
elseif nargs == 4
return Some{Any}(arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
return Some{Any}(Core.arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))

Check warning on line 341 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L341

Added line #L341 was not covered by tests
elseif nargs == 5
return Some{Any}(arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
return Some{Any}(Core.arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))

Check warning on line 343 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L343

Added line #L343 was not covered by tests
else
return Some{Any}(arrayref(getargs(args, frame)...))
return Some{Any}(Core.arrayref(getargs(args, frame)...))

Check warning on line 345 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L345

Added line #L345 was not covered by tests
end
elseif @static isdefined(Core, :arrayset) && f === :arrayset
elseif @static (isdefined(Core, :arrayset) && Core.arrayset isa Core.Builtin) && f === Core.arrayset
if nargs == 1
return Some{Any}(arrayset(@lookup(frame, args[2])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2])))

Check warning on line 349 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L349

Added line #L349 was not covered by tests
elseif nargs == 2
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3])))

Check warning on line 351 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L351

Added line #L351 was not covered by tests
elseif nargs == 3
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))

Check warning on line 353 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L353

Added line #L353 was not covered by tests
elseif nargs == 4
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
elseif nargs == 5
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
elseif nargs == 6
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6]), @lookup(frame, args[7])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6]), @lookup(frame, args[7])))

Check warning on line 359 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L359

Added line #L359 was not covered by tests
else
return Some{Any}(arrayset(getargs(args, frame)...))
return Some{Any}(Core.arrayset(getargs(args, frame)...))

Check warning on line 361 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L361

Added line #L361 was not covered by tests
end
elseif @static isdefined(Core, :arrayset) && f === :arrayset
elseif @static (isdefined(Core, :arrayset) && Core.arrayset isa Core.Builtin) && f === Core.arrayset
if nargs == 1
return Some{Any}(arrayset(@lookup(frame, args[2])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2])))

Check warning on line 365 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L365

Added line #L365 was not covered by tests
elseif nargs == 2
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3])))

Check warning on line 367 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L367

Added line #L367 was not covered by tests
elseif nargs == 3
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))

Check warning on line 369 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L369

Added line #L369 was not covered by tests
elseif nargs == 4
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))

Check warning on line 371 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L371

Added line #L371 was not covered by tests
elseif nargs == 5
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))

Check warning on line 373 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L373

Added line #L373 was not covered by tests
elseif nargs == 6
return Some{Any}(arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6]), @lookup(frame, args[7])))
return Some{Any}(Core.arrayset(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6]), @lookup(frame, args[7])))

Check warning on line 375 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L375

Added line #L375 was not covered by tests
else
return Some{Any}(arrayset(getargs(args, frame)...))
return Some{Any}(Core.arrayset(getargs(args, frame)...))

Check warning on line 377 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L377

Added line #L377 was not covered by tests
end
elseif @static isdefined(Core, :const_arrayref) && f === :const_arrayref
elseif @static (isdefined(Core, :const_arrayref) && Core.const_arrayref isa Core.Builtin) && f === Core.const_arrayref
if nargs == 1
return Some{Any}(const_arrayref(@lookup(frame, args[2])))
return Some{Any}(Core.const_arrayref(@lookup(frame, args[2])))

Check warning on line 381 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L381

Added line #L381 was not covered by tests
elseif nargs == 2
return Some{Any}(const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3])))
return Some{Any}(Core.const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3])))

Check warning on line 383 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L383

Added line #L383 was not covered by tests
elseif nargs == 3
return Some{Any}(const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))
return Some{Any}(Core.const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4])))

Check warning on line 385 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L385

Added line #L385 was not covered by tests
elseif nargs == 4
return Some{Any}(const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))
return Some{Any}(Core.const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5])))

Check warning on line 387 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L387

Added line #L387 was not covered by tests
elseif nargs == 5
return Some{Any}(const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))
return Some{Any}(Core.const_arrayref(@lookup(frame, args[2]), @lookup(frame, args[3]), @lookup(frame, args[4]), @lookup(frame, args[5]), @lookup(frame, args[6])))

Check warning on line 389 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L389

Added line #L389 was not covered by tests
else
return Some{Any}(const_arrayref(getargs(args, frame)...))
return Some{Any}(Core.const_arrayref(getargs(args, frame)...))

Check warning on line 391 in src/builtins.jl

View check run for this annotation

Codecov / codecov/patch

src/builtins.jl#L391

Added line #L391 was not covered by tests
end
elseif f === Core.Intrinsics.llvmcall
return Some{Any}(Core.Intrinsics.llvmcall(getargs(args, frame)...))
Expand Down
4 changes: 4 additions & 0 deletions test/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -993,3 +993,7 @@ end
@test (@interpret string("", "pcre_h.jl")) == string("", "pcre_h.jl")
@test (@interpret Base.strcat("", "build_h.jl")) == Base.strcat("", "build_h.jl")
end

# test for using generic functions that were previously builtin
func_arrayref(a, i) = Core.arrayref(true, a, i)
@test 2 == @interpret func_arrayref([1,2,3], 2)
Loading