diff options
author | Björn Gustavsson <[email protected]> | 2017-10-30 10:38:24 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2017-10-30 10:38:24 +0100 |
commit | 5c05e738eadcd0b6239b287adb536847da65bba1 (patch) | |
tree | 7268af6888f2eb9b53e39a903ebc8241b0595906 /erts | |
parent | 7b2a7fe7cf4011bed318925675d2e96abf8f76ec (diff) | |
parent | 696f47b64c8ad5da71cbffd8fecf0f3bae1e7466 (diff) | |
download | otp-5c05e738eadcd0b6239b287adb536847da65bba1.tar.gz otp-5c05e738eadcd0b6239b287adb536847da65bba1.tar.bz2 otp-5c05e738eadcd0b6239b287adb536847da65bba1.zip |
Merge pull request #1610 from bjorng/bjorn/erts/is_builtin/ERL-500/OTP-14713
Correct erlang:is_builtin/3 for apply/2 and yield/0
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/beam/beam_emu.c | 17 | ||||
-rw-r--r-- | erts/emulator/test/bif_SUITE.erl | 18 |
2 files changed, 22 insertions, 13 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index aa94fbf536..60d0008d8f 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -3199,13 +3199,16 @@ erts_is_builtin(Eterm Mod, Eterm Name, int arity) Export e; Export* ep; - if (Mod == am_erlang && Name == am_apply && arity == 3) { - /* - * Special case. apply/3 is built-in (implemented in C), - * but implemented in a different way than all other - * BIFs. - */ - return 1; + if (Mod == am_erlang) { + /* + * Special case for built-in functions that are implemented + * as instructions as opposed to SNIFs. + */ + if (Name == am_apply && (arity == 2 || arity == 3)) { + return 1; + } else if (Name == am_yield && arity == 0) { + return 1; + } } e.info.mfa.module = Mod; diff --git a/erts/emulator/test/bif_SUITE.erl b/erts/emulator/test/bif_SUITE.erl index 146c37b118..e1b42e5d85 100644 --- a/erts/emulator/test/bif_SUITE.erl +++ b/erts/emulator/test/bif_SUITE.erl @@ -781,14 +781,20 @@ is_builtin(_Config) -> {F,A} <- M:module_info(exports)], Exp = ordsets:from_list(Exp0), - %% erlang:apply/3 is considered to be built-in, but is not - %% implemented as other BIFs. + %% Built-ins implemented as special instructions. + Instructions = [{erlang,apply,2},{erlang,apply,3},{erlang,yield,0}], - Builtins0 = [{erlang,apply,3}|erlang:system_info(snifs)], + Builtins0 = Instructions ++ erlang:system_info(snifs), Builtins = ordsets:from_list(Builtins0), - NotBuiltin = ordsets:subtract(Exp, Builtins), - _ = [true = erlang:is_builtin(M, F, A) || {M,F,A} <- Builtins], - _ = [false = erlang:is_builtin(M, F, A) || {M,F,A} <- NotBuiltin], + + Fakes = [{M,F,42} || {M,F,_} <- Instructions], + All = ordsets:from_list(Fakes ++ Exp), + NotBuiltin = ordsets:subtract(All, Builtins), + + _ = [{true,_} = {erlang:is_builtin(M, F, A),MFA} || + {M,F,A}=MFA <- Builtins], + _ = [{false,_} = {erlang:is_builtin(M, F, A),MFA} || + {M,F,A}=MFA <- NotBuiltin], ok. |