-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add partially evaluated methods ===(x), !==(x), and isa(T) #36759
Conversation
#else | ||
#define DECLARE_BUILTIN(name) \ | ||
JL_CALLABLE(jl_f_##name); \ | ||
extern jl_value_t *jl_builtin_##name | ||
extern jl_value_t *jl_builtin_##name JL_GLOBALLY_ROOTED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a long shot for working around analyzegc https://build.julialang.org/#/builders/65/builds/1574/steps/4/logs/stdio
But I wonder if there is a reason why this is not used? Maybe I'm doing something stupid here?
If this is not the right way to do it, maybe I need to do something like this?
diff --git a/src/builtins.c b/src/builtins.c
index 440b69629e..c2576d553d 100644
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -369,6 +369,7 @@ JL_CALLABLE(jl_f_is)
jl_function_t *fix2 = jl_get_function(jl_base_module, "Fix2");
if (fix2 == NULL)
jl_undefined_var_error(jl_symbol("Fix2"));
+ JL_GC_PROMISE_ROOTED(jl_builtin_is);
return jl_call2(fix2, jl_builtin_is, args[0]);
}
if (args[0] == args[1])
@@ -440,6 +441,7 @@ JL_CALLABLE(jl_f_isa)
jl_function_t *fix2 = jl_get_function(jl_base_module, "Fix2");
if (fix2 == NULL)
jl_undefined_var_error(jl_symbol("Fix2"));
+ JL_GC_PROMISE_ROOTED(jl_builtin_isa);
return jl_call2(fix2, jl_builtin_isa, args[0]);
}
JL_TYPECHK(isa, type, args[1]);
===(x) | ||
|
||
Create a function that compares its argument to `x` using [`===`](@ref), i.e. | ||
a function equivalent to `y -> y == x`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be y -> y === x
This is tricky. I suspect the only good way to do this is to make
|
julia> setfield!(typeof(+).name.mt, fieldcount(Core.MethodTable), 0x01)
# this "seals" a method, and can trick it into thinking that `+` is now a subtype of `Core.Builtin`
julia> Base.:(+)(a) = 1
ERROR: cannot add methods to a builtin function |
Something holding this back? |
It's stuck because I haven't had time to work on what Jeff suggested. I'll close it for now so that others can pick it up without thinking about racing with me. |
This PR adds
===(x)
,!==(x)
, andisa(T)
that creates aFix2
likeisequal
etc. For===(x)
andisa(T)
, it looks like I needed to add tfuncs.fix #36163
fix #32018