summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErlang/OTP <otp@erlang.org>2023-02-16 15:15:16 +0100
committerErlang/OTP <otp@erlang.org>2023-02-16 15:15:16 +0100
commit7b6b95e2176ffea379bd60fef434775c6b32d7e6 (patch)
treebfeecf40afa1a8c06671c33aafa3edcec1be5068
parent088aff7aa542d96fef880f1fe6946ff97ecd447a (diff)
parentd862919cfd653af8a23c481ac4ce32d941ed5746 (diff)
downloaderlang-7b6b95e2176ffea379bd60fef434775c6b32d7e6.tar.gz
Merge branch 'john/jit/fix-type-hint-bug/OTP-18415' into maint-25
* john/jit/fix-type-hint-bug/OTP-18415: jit: Fix type hint error in emit_is_ge/lt
-rw-r--r--erts/emulator/beam/jit/arm/instr_common.cpp12
-rw-r--r--erts/emulator/beam/jit/x86/instr_common.cpp12
-rw-r--r--erts/emulator/test/op_SUITE.erl17
3 files changed, 31 insertions, 10 deletions
diff --git a/erts/emulator/beam/jit/arm/instr_common.cpp b/erts/emulator/beam/jit/arm/instr_common.cpp
index ea67b2c18e..0a6e099e72 100644
--- a/erts/emulator/beam/jit/arm/instr_common.cpp
+++ b/erts/emulator/beam/jit/arm/instr_common.cpp
@@ -1362,8 +1362,10 @@ void BeamModuleAssembler::emit_is_lt(const ArgLabel &Fail,
comment("skipped test for small operands since they are always small");
a.cmp(ARG1, ARG2);
a.b_ge(resolve_beam_label(Fail, disp1MB));
- } else if (always_one_of(LHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED) &&
- always_one_of(RHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED)) {
+ } else if (always_one_of(LHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED) &&
+ always_one_of(RHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED)) {
Label branch_compare = a.newLabel();
a.cmp(ARG1, ARG2);
@@ -1419,8 +1421,10 @@ void BeamModuleAssembler::emit_is_ge(const ArgLabel &Fail,
comment("skipped test for small operands since they are always small");
a.cmp(ARG1, ARG2);
a.b_lt(resolve_beam_label(Fail, disp1MB));
- } else if (always_one_of(LHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED) &&
- always_one_of(RHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED)) {
+ } else if (always_one_of(LHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED) &&
+ always_one_of(RHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED)) {
Label branch_compare = a.newLabel();
a.cmp(ARG1, ARG2);
diff --git a/erts/emulator/beam/jit/x86/instr_common.cpp b/erts/emulator/beam/jit/x86/instr_common.cpp
index 9157ed6e9c..13e883ce70 100644
--- a/erts/emulator/beam/jit/x86/instr_common.cpp
+++ b/erts/emulator/beam/jit/x86/instr_common.cpp
@@ -1586,8 +1586,10 @@ void BeamModuleAssembler::emit_is_lt(const ArgLabel &Fail,
if (both_small) {
comment("skipped test for small operands since they are always small");
- } else if (always_one_of(LHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED) &&
- always_one_of(RHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED)) {
+ } else if (always_one_of(LHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED) &&
+ always_one_of(RHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED)) {
/* The only possible kind of immediate is a small and all other
* values are boxed, so we can test for smalls by testing boxed. */
comment("simplified small test since all other types are boxed");
@@ -1641,8 +1643,10 @@ void BeamModuleAssembler::emit_is_ge(const ArgLabel &Fail,
if (both_small) {
comment("skipped test for small operands since they are always small");
- } else if (always_one_of(LHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED) &&
- always_one_of(RHS, BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_BOXED)) {
+ } else if (always_one_of(LHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED) &&
+ always_one_of(RHS,
+ BEAM_TYPE_INTEGER | BEAM_TYPE_MASK_ALWAYS_BOXED)) {
/* The only possible kind of immediate is a small and all other
* values are boxed, so we can test for smalls by testing boxed. */
comment("simplified small test since all other types are boxed");
diff --git a/erts/emulator/test/op_SUITE.erl b/erts/emulator/test/op_SUITE.erl
index 1f1f34d35f..21d41b89a3 100644
--- a/erts/emulator/test/op_SUITE.erl
+++ b/erts/emulator/test/op_SUITE.erl
@@ -25,7 +25,7 @@
-export([all/0, suite/0,
bsl_bsr/1,logical/1,t_not/1,relop_simple/1,relop/1,
complex_relop/1,unsafe_fusing/1,
- range_tests/1]).
+ range_tests/1,typed_relop/1]).
-import(lists, [foldl/3,flatmap/2]).
@@ -35,7 +35,7 @@ suite() ->
all() ->
[bsl_bsr, logical, t_not, relop_simple, relop,
- complex_relop, unsafe_fusing, range_tests].
+ complex_relop, unsafe_fusing, range_tests, typed_relop].
%% Test the bsl and bsr operators.
bsl_bsr(Config) when is_list(Config) ->
@@ -683,6 +683,19 @@ range_big_2(X) when (-1 bsl 59) - 1 =< X, X =< 1 bsl 59 ->
range_big_2(_) ->
outside.
+%% Tests operators where type hints are significant.
+typed_relop(Config) when is_list(Config) ->
+ _ = [compare_integer_pid(1 bsl N) || N <- lists:seq(1, 64)],
+ ok.
+
+compare_integer_pid(N) when is_integer(N) ->
+ Immed = self(),
+ true = is_pid(Immed),
+ if
+ N >= Immed -> ct:fail("integer compared greater than pid");
+ N < Immed -> ok
+ end.
+
%%%
%%% Utilities.
%%%