summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2021-10-15 05:44:59 +0200
committerBjörn Gustavsson <bjorn@erlang.org>2021-10-15 05:44:59 +0200
commitd5186bded46f05bc2b70075c791e6a6d2cb0f98c (patch)
tree01155cd1faf3ddc74e2139275ce7d19e13d6d5a4
parent2fddc92c1bdadfdf5e49b6b3158fa88bfe118f58 (diff)
downloaderlang-d5186bded46f05bc2b70075c791e6a6d2cb0f98c.tar.gz
wip
-rw-r--r--erts/emulator/beam/atom.names1
-rw-r--r--erts/emulator/beam/emu/bs_instrs.tab56
-rw-r--r--erts/emulator/test/bs_construct_SUITE.erl4
3 files changed, 34 insertions, 27 deletions
diff --git a/erts/emulator/beam/atom.names b/erts/emulator/beam/atom.names
index 49b9fd0e9f..8bb1717337 100644
--- a/erts/emulator/beam/atom.names
+++ b/erts/emulator/beam/atom.names
@@ -454,7 +454,6 @@ atom namelist
atom native
atom native_addresses
atom need_gc
-atom negative_size
atom Neq='=/='
atom Neqeq='/='
atom net_kernel
diff --git a/erts/emulator/beam/emu/bs_instrs.tab b/erts/emulator/beam/emu/bs_instrs.tab
index 7ca7c4e711..93c1df370b 100644
--- a/erts/emulator/beam/emu/bs_instrs.tab
+++ b/erts/emulator/beam/emu/bs_instrs.tab
@@ -871,13 +871,13 @@ BS_LOAD_FIXED_SIZE(Ptr, Dst) {
$Dst = $Ptr[4];
}
-BS_FAIL_INFO(Fail, Reason, ErrorType) {
- erts_prepare_bs_construct_fail_info(c_p, p, $Reason, $ErrorType, am_control);
+BS_FAIL_INFO(Fail, Reason, ErrorType, Value) {
+ erts_prepare_bs_construct_fail_info(c_p, p, $Reason, $ErrorType, $Value);
$FAIL_HEAD_OR_BODY($Fail);
}
BS_FAIL_INFO_SYSTEM_LIMIT(Fail) {
- $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size);
+ $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size, Size);
}
i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
@@ -914,7 +914,7 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
$BS_LOAD_SRC(p, Src);
if (is_not_binary(Src)) {
- $BS_FAIL_INFO($Fail, BADARG, am_type);
+ $BS_FAIL_INFO($Fail, BADARG, am_type, Src);
}
byte_size = binary_size(Src);
high_bits = byte_size >> ((sizeof(Uint) * 8)-3);
@@ -922,7 +922,7 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
if (high_bits == 0) {
num_bits += low_bits;
} else {
- $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size);
+ $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size, make_small(low_bits)); /* FIXME */
}
}
break;
@@ -948,24 +948,24 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
$BS_SAFE_MUL(signed_size, unit, $BS_FAIL_INFO_SYSTEM_LIMIT($Fail), size);
if (size >> (sizeof(Uint) * 8 - 1) != 0) {
/* The signed size does not fit in a word. */
- $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size);
+ $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size, Size);
}
num_bits += size;
} else {
- $BS_FAIL_INFO($Fail, BADARG, am_negative_size);
+ $BS_FAIL_INFO($Fail, BADARG, am_size, Size);
}
} else {
#ifdef ARCH_64
/* The size must fit in a small on 64-bit platforms. */
if (is_big(Size)) {
if (!big_sign(Size)) {
- $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size);
+ $BS_FAIL_INFO($Fail, SYSTEM_LIMIT, am_size, Size);
} else {
- $BS_FAIL_INFO($Fail, BADARG, am_negative_size);
+ $BS_FAIL_INFO($Fail, BADARG, am_size, Size);
}
} else {
/* Not an integer. */
- $BS_FAIL_INFO($Fail, BADARG, am_size);
+ $BS_FAIL_INFO($Fail, BADARG, am_size, Size);
}
#else
Uint size;
@@ -975,10 +975,10 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
/* Not an integer or a negative integer. Determine which. */
if (is_big(Size)) {
/* Negative integer. */
- $BS_FAIL_INFO($Fail, BADARG, am_negative_size);
+ $BS_FAIL_INFO($Fail, BADARG, am_size, Size);
}
/* Not an integer. */
- $BS_FAIL_INFO($Fail, BADARG, am_size);
+ $BS_FAIL_INFO($Fail, BADARG, am_size, Size);
}
/* Huge positive integer. */
$BS_FAIL_INFO_SYSTEM_LIMIT($Fail);
@@ -1050,7 +1050,7 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
*/
if (is_not_small(Src) || Src > make_small(0x10FFFFUL) ||
(make_small(0xD800UL) <= Src && Src <= make_small(0xDFFFUL))) {
- $BS_FAIL_INFO($Fail, BADARG, am_type);
+ $BS_FAIL_INFO($Fail, BADARG, am_type, Src);
}
num_bits += 4 * 8;
break;
@@ -1076,7 +1076,7 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
new_binary = erts_bs_append_checked(c_p, reg, live, num_bits, alloc, unit);
HEAVY_SWAPIN;
if (is_non_value(new_binary)) {
- $BS_FAIL_INFO($Fail, c_p->freason, c_p->fvalue);
+ $BS_FAIL_INFO($Fail, c_p->freason, c_p->fvalue, reg[live]);
}
p_start += BSC_NUM_ARGS;
} else if (p[0] == BSC_PRIVATE_APPEND) {
@@ -1091,7 +1091,7 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
$BS_LOAD_SRC(p, Src);
new_binary = erts_bs_private_append_checked(c_p, Src, num_bits, unit);
if (is_non_value(new_binary)) {
- $BS_FAIL_INFO($Fail, c_p->freason, c_p->fvalue);
+ $BS_FAIL_INFO($Fail, c_p->freason, c_p->fvalue, Src);
}
p_start += BSC_NUM_ARGS;
} else {
@@ -1188,7 +1188,7 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
case BSC_BINARY_ALL:
$BS_LOAD_UNIT(p, unit);
if (!erts_new_bs_put_binary_all(c_p, Src, unit)) {
- $BS_FAIL_INFO($Fail, BADARG, am_type);
+ $BS_FAIL_INFO($Fail, BADARG, am_type, Src);
}
break;
case BSC_BINARY:
@@ -1197,13 +1197,15 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
$BS_LOAD_SIZE(p, Size);
$BS_GET_UNCHECKED_FIELD_SIZE(Size, unit, $BADARG($Fail), _size);
if (!erts_new_bs_put_binary(c_p, Src, _size)) {
- $BS_FAIL_INFO($Fail, BADARG, c_p->fvalue);
+ Eterm reason = is_binary(Src) ? am_short : am_type;
+ $BS_FAIL_INFO($Fail, BADARG, reason, Src);
}
break;
case BSC_BINARY_FIXED_SIZE:
$BS_LOAD_FIXED_SIZE(p, Size);
if (!erts_new_bs_put_binary(c_p, Src, Size)) {
- $BS_FAIL_INFO($Fail, BADARG, c_p->fvalue);
+ Eterm reason = is_binary(Src) ? am_short : am_type;
+ $BS_FAIL_INFO($Fail, BADARG, reason, Src);
}
break;
case BSC_FLOAT:
@@ -1211,15 +1213,17 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
$BS_LOAD_FLAGS(p, flags);
$BS_LOAD_SIZE(p, Size);
$BS_GET_UNCHECKED_FIELD_SIZE(Size, unit, $BADARG($Fail), _size);
- if (is_value(erts_new_bs_put_float(c_p, Src, _size, flags))) {
- $BS_FAIL_INFO($Fail, BADARG, c_p->fvalue);
+ Src = erts_new_bs_put_float(c_p, Src, _size, flags);
+ if (is_value(Src)) {
+ $BS_FAIL_INFO($Fail, BADARG, c_p->fvalue, Src);
}
break;
case BSC_FLOAT_FIXED_SIZE:
$BS_LOAD_FLAGS(p, flags);
$BS_LOAD_FIXED_SIZE(p, Size);
- if (is_value(erts_new_bs_put_float(c_p, Src, Size, flags))) {
- $BS_FAIL_INFO($Fail, BADARG, c_p->fvalue);
+ Src = erts_new_bs_put_float(c_p, Src, Size, flags);
+ if (is_value(Src)) {
+ $BS_FAIL_INFO($Fail, BADARG, c_p->fvalue, Src);
}
break;
case BSC_INTEGER:
@@ -1231,7 +1235,7 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
$BS_LOAD_SIZE(p, Size);
$BS_GET_UNCHECKED_FIELD_SIZE(Size, unit, $BADARG($Fail), _size);
if (!erts_new_bs_put_integer(ERL_BITS_ARGS_3(Src, _size, flags))) {
- $BS_FAIL_INFO($Fail, BADARG, am_type);
+ $BS_FAIL_INFO($Fail, BADARG, am_type, Src);
}
}
break;
@@ -1240,19 +1244,19 @@ i_bs_create_bin(Fail, Alloc, Live, Dst, N) {
$BS_LOAD_FLAGS(p, flags);
$BS_LOAD_FIXED_SIZE(p, Size);
if (!erts_new_bs_put_integer(ERL_BITS_ARGS_3(Src, Size, flags))) {
- $BS_FAIL_INFO($Fail, BADARG, am_type);
+ $BS_FAIL_INFO($Fail, BADARG, am_type, Src);
}
break;
case BSC_UTF8:
if (!erts_bs_put_utf8(ERL_BITS_ARGS_1(Src))) {
- $BS_FAIL_INFO($Fail, BADARG, am_type);
+ $BS_FAIL_INFO($Fail, BADARG, am_type, Src);
}
break;
case BSC_UTF16:
$BS_LOAD_FLAGS(p, flags);
$BS_LOAD_SRC(p, Src);
if (!erts_bs_put_utf16(ERL_BITS_ARGS_2(Src, flags))) {
- $BS_FAIL_INFO($Fail, BADARG, am_type);
+ $BS_FAIL_INFO($Fail, BADARG, am_type, Src);
}
break;
default:
diff --git a/erts/emulator/test/bs_construct_SUITE.erl b/erts/emulator/test/bs_construct_SUITE.erl
index 5cf34a5507..420e10be2d 100644
--- a/erts/emulator/test/bs_construct_SUITE.erl
+++ b/erts/emulator/test/bs_construct_SUITE.erl
@@ -1007,6 +1007,7 @@ error_info(_Config) ->
{badarg, {4,binary,type,Atom}} = ?ERROR_INFO(<<1:32, "xyz", Binary/binary, Atom/binary>>),
{badarg, {1,integer,type,Atom}} = ?ERROR_INFO(<<Atom:32>>),
+ {badarg, {1,integer,type,Atom}} = ?ERROR_INFO(<<Atom:(id(32))>>),
{badarg, {1,integer,type,LongList}} = ?ERROR_INFO(<<LongList:32>>),
{badarg, {1,integer,size,Atom}} = ?ERROR_INFO(<<42:Atom>>),
{badarg, {1,integer,type,Atom}} = ?ERROR_INFO(<<Atom:32>>),
@@ -1017,14 +1018,17 @@ error_info(_Config) ->
{system_limit, {1,integer,size,1 bsl 64}} = ?ERROR_INFO(<<42:(1 bsl 64)>>),
{badarg, {1,binary,type,Atom}} = ?ERROR_INFO(<<Atom:10/binary>>),
+ {badarg, {1,binary,type,Atom}} = ?ERROR_INFO(<<Atom:(id(10))/binary>>),
{badarg, {1,binary,size,Atom}} = ?ERROR_INFO(<<Binary:Atom/binary>>),
{badarg, {1,binary,size,NegSize}} = ?ERROR_INFO(<<Binary:NegSize/binary>>),
{badarg, {1,binary,size,HugeNegSize}} = ?ERROR_INFO(<<Binary:HugeNegSize/binary>>),
{badarg, {1,binary,short,Binary}} = ?ERROR_INFO(<<Binary:10/binary>>),
+ {badarg, {1,binary,short,Binary}} = ?ERROR_INFO(<<Binary:(id(10))/binary>>),
{badarg, {1,binary,type,Atom}} = ?ERROR_INFO(<<Atom/binary>>),
{badarg, {1,binary,unit,<<1:1>>}} = ?ERROR_INFO(<<(id(<<1:1>>))/binary>>),
{badarg, {1,binary,unit,<<0:1111>>}} = ?ERROR_INFO(<<(id(<<0:1111>>))/binary>>),
{system_limit, {1,binary,size,1 bsl 64}} = ?ERROR_INFO(<<Binary:(1 bsl 64)/binary>>),
+ {system_limit, {1,binary,size,1 bsl 64}} = ?ERROR_INFO(<<Binary:(id(1 bsl 64))/binary>>),
{badarg, {1,float,type,Atom}} = ?ERROR_INFO(<<Atom:64/float>>),
{badarg, {1,float,size,Atom}} = ?ERROR_INFO(<<Atom:Atom/float>>),