aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_bits.h
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2017-02-27 15:27:05 +0100
committerBjörn-Egil Dahlberg <[email protected]>2017-02-28 15:55:25 +0100
commit4bbbf4ff9b3fe4be24bf8d57780c84d5b3ca0f77 (patch)
tree2c2ceb87baf72f5fcdf0bb5e9b267aabaabf0aed /erts/emulator/beam/erl_bits.h
parent3202e753383d495bce8008721e94428788d4f400 (diff)
downloadotp-4bbbf4ff9b3fe4be24bf8d57780c84d5b3ca0f77.tar.gz
otp-4bbbf4ff9b3fe4be24bf8d57780c84d5b3ca0f77.tar.bz2
otp-4bbbf4ff9b3fe4be24bf8d57780c84d5b3ca0f77.zip
erts: Convert small sub-binaries to heap-binaries
In many cases sub-binaries costs more memory than converting them to heap-binaries. Sub-binaries also has a hidden cost of pinning larger binaries in memory. By converting binaries this cost is reduced. Byte aligned sub-binaries upto 24 bytes (64-bit) or 12 bytes (32-bit) are converted.
Diffstat (limited to 'erts/emulator/beam/erl_bits.h')
-rw-r--r--erts/emulator/beam/erl_bits.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_bits.h b/erts/emulator/beam/erl_bits.h
index 4bd5b24157..1b4546722f 100644
--- a/erts/emulator/beam/erl_bits.h
+++ b/erts/emulator/beam/erl_bits.h
@@ -22,6 +22,23 @@
#define __ERL_BITS_H__
/*
+ * This structure represents a SUB_BINARY.
+ *
+ * Note: The last field (orig) is not counted in arityval in the header.
+ * This simplifies garbage collection.
+ */
+
+typedef struct erl_sub_bin {
+ Eterm thing_word; /* Subtag SUB_BINARY_SUBTAG. */
+ Uint size; /* Binary size in bytes. */
+ Uint offs; /* Offset into original binary. */
+ byte bitsize;
+ byte bitoffs;
+ byte is_writable; /* The underlying binary is writable */
+ Eterm orig; /* Original binary (REFC or HEAP binary). */
+} ErlSubBin;
+
+/*
* This structure represents a binary to be matched.
*/