aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/bs_instrs.tab
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-03-06 06:23:24 +0100
committerBjörn Gustavsson <[email protected]>2019-03-07 10:39:56 +0100
commit2de437ef15d1cddf70a0553437b678f9bca5f35c (patch)
tree3af6502d2f3e646195db54df7d22f0c87f74bee8 /erts/emulator/beam/bs_instrs.tab
parent7128f182ac4051b45bb0f526d8983f5ada1e12f0 (diff)
downloadotp-2de437ef15d1cddf70a0553437b678f9bca5f35c.tar.gz
otp-2de437ef15d1cddf70a0553437b678f9bca5f35c.tar.bz2
otp-2de437ef15d1cddf70a0553437b678f9bca5f35c.zip
Slightly optimize binary construction
Use S operands instead of s operands for a slight speed increase and reduction in code size of process_main(). Use micro instructions for frequently executed instructions. While at it, use safe multiplication in gen_get_integer() in beam_load.c.
Diffstat (limited to 'erts/emulator/beam/bs_instrs.tab')
-rw-r--r--erts/emulator/beam/bs_instrs.tab72
1 files changed, 55 insertions, 17 deletions
diff --git a/erts/emulator/beam/bs_instrs.tab b/erts/emulator/beam/bs_instrs.tab
index 493ec10222..652460a66d 100644
--- a/erts/emulator/beam/bs_instrs.tab
+++ b/erts/emulator/beam/bs_instrs.tab
@@ -292,15 +292,25 @@ i_bs_skip_bits_imm2(Fail, Ms, Bits) {
}
i_new_bs_put_binary(Fail, Sz, Flags, Src) {
+ Eterm sz = $Sz;
Sint _size;
- $BS_GET_UNCHECKED_FIELD_SIZE($Sz, (($Flags) >> 3), $BADARG($Fail), _size);
+ $BS_GET_UNCHECKED_FIELD_SIZE(sz, (($Flags) >> 3), $BADARG($Fail), _size);
if (!erts_new_bs_put_binary(ERL_BITS_ARGS_2(($Src), _size))) {
$BADARG($Fail);
}
}
+i_new_bs_put_binary_all := i_new_bs_put_binary_all.fetch.execute;
-i_new_bs_put_binary_all(Fail, Src, Unit) {
- if (!erts_new_bs_put_binary_all(ERL_BITS_ARGS_2(($Src), ($Unit)))) {
+i_new_bs_put_binary_all.head() {
+ Eterm src;
+}
+
+i_new_bs_put_binary_all.fetch(Src) {
+ src = $Src;
+}
+
+i_new_bs_put_binary_all.execute(Fail, Unit) {
+ if (!erts_new_bs_put_binary_all(ERL_BITS_ARGS_2(src, ($Unit)))) {
$BADARG($Fail);
}
}
@@ -312,9 +322,11 @@ i_new_bs_put_binary_imm(Fail, Sz, Src) {
}
i_new_bs_put_float(Fail, Sz, Flags, Src) {
+ Eterm sz = $Sz;
+ Eterm flags = $Flags;
Sint _size;
- $BS_GET_UNCHECKED_FIELD_SIZE($Sz, (($Flags) >> 3), $BADARG($Fail), _size);
- if (!erts_new_bs_put_float(c_p, ($Src), _size, ($Flags))) {
+ $BS_GET_UNCHECKED_FIELD_SIZE(sz, (flags >> 3), $BADARG($Fail), _size);
+ if (!erts_new_bs_put_float(c_p, ($Src), _size, flags)) {
$BADARG($Fail);
}
}
@@ -326,15 +338,27 @@ i_new_bs_put_float_imm(Fail, Sz, Flags, Src) {
}
i_new_bs_put_integer(Fail, Sz, Flags, Src) {
- Sint _size;
- $BS_GET_UNCHECKED_FIELD_SIZE($Sz, (($Flags) >> 3), $BADARG($Fail), _size);
- if (!erts_new_bs_put_integer(ERL_BITS_ARGS_3(($Src), _size, ($Flags)))) {
- $BADARG($Fail);
- }
+ Eterm sz = $Sz;
+ Eterm flags = $Flags;
+ Sint _size;
+ $BS_GET_UNCHECKED_FIELD_SIZE(sz, (flags >> 3), $BADARG($Fail), _size);
+ if (!erts_new_bs_put_integer(ERL_BITS_ARGS_3(($Src), _size, flags))) {
+ $BADARG($Fail);
+ }
}
-i_new_bs_put_integer_imm(Fail, Sz, Flags, Src) {
- if (!erts_new_bs_put_integer(ERL_BITS_ARGS_3(($Src), ($Sz), ($Flags)))) {
+i_new_bs_put_integer_imm := i_new_bs_put_integer_imm.fetch.execute;
+
+i_new_bs_put_integer_imm.head() {
+ Eterm src;
+}
+
+i_new_bs_put_integer_imm.fetch(Src) {
+ src = $Src;
+}
+
+i_new_bs_put_integer_imm.execute(Fail, Sz, Flags) {
+ if (!erts_new_bs_put_integer(ERL_BITS_ARGS_3(src, ($Sz), ($Flags)))) {
$BADARG($Fail);
}
}
@@ -1381,12 +1405,19 @@ i_bs_get_position(Ctx, Dst) {
# match at a position beyond 16MB.
#
-bs_set_position(Ctx, Pos) {
+bs_set_position := bs_set_position.fetch.execute;
+
+bs_set_position.head() {
Eterm context, position;
- ErlBinMatchState *ms;
+}
+bs_set_position.fetch(Ctx, Pos) {
context = $Ctx;
position = $Pos;
+}
+
+bs_set_position.execute() {
+ ErlBinMatchState *ms;
ASSERT(header_is_bin_matchstate(*boxed_val(context)));
ms = (ErlBinMatchState*)boxed_val(context);
@@ -1399,12 +1430,19 @@ bs_set_position(Ctx, Pos) {
}
}
-bs_get_position(Ctx, Dst, Live) {
- ErlBinMatchState *ms;
+bs_get_position := bs_get_position.fetch.execute;
+
+bs_get_position.head() {
Eterm context;
- Uint position;
+}
+bs_get_position.fetch(Ctx) {
context = $Ctx;
+}
+
+bs_get_position.execute(Dst, Live) {
+ ErlBinMatchState *ms;
+ Uint position;
ASSERT(header_is_bin_matchstate(*boxed_val(context)));
ms = (ErlBinMatchState*)boxed_val(context);