summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/emu/bs_instrs.tab
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/beam/emu/bs_instrs.tab')
-rw-r--r--erts/emulator/beam/emu/bs_instrs.tab56
1 files changed, 26 insertions, 30 deletions
diff --git a/erts/emulator/beam/emu/bs_instrs.tab b/erts/emulator/beam/emu/bs_instrs.tab
index 305b2d6312..a5e6bb46de 100644
--- a/erts/emulator/beam/emu/bs_instrs.tab
+++ b/erts/emulator/beam/emu/bs_instrs.tab
@@ -426,13 +426,14 @@ bs_init.verify(Fail) {
}
bs_init.execute(Live, Dst) {
+ erts_bin_offset = 0;
+ erts_writable_bin = 0;
+
if (BsOp1 <= ERL_ONHEAP_BIN_LIMIT) {
ErlHeapBin* hb;
Uint bin_need;
bin_need = heap_bin_size(BsOp1);
- erts_bin_offset = 0;
- erts_writable_bin = 0;
$GC_TEST(0, bin_need+BsOp2+ERL_SUB_BIN_SIZE, $Live);
hb = (ErlHeapBin *) HTOP;
HTOP += bin_need;
@@ -444,10 +445,7 @@ bs_init.execute(Live, Dst) {
Binary* bptr;
ProcBin* pb;
- erts_bin_offset = 0;
- erts_writable_bin = 0;
- $TEST_BIN_VHEAP(BsOp1 / sizeof(Eterm),
- BsOp2 + PROC_BIN_SIZE + ERL_SUB_BIN_SIZE, $Live);
+ $TEST_BIN_VHEAP(BsOp1 / sizeof(Eterm), BsOp2 + PROC_BIN_SIZE, $Live);
/*
* Allocate the binary struct itself.
@@ -539,7 +537,9 @@ bs_init_bits.execute(Live, Dst) {
} else {
alloc += PROC_BIN_SIZE;
}
- $test_heap(alloc, $Live);
+
+ erts_bin_offset = 0;
+ erts_writable_bin = 0;
/* num_bits = Number of bits to build
* num_bytes = Number of bytes to allocate in the binary
@@ -549,38 +549,18 @@ bs_init_bits.execute(Live, Dst) {
if (num_bytes <= ERL_ONHEAP_BIN_LIMIT) {
ErlHeapBin* hb;
- erts_bin_offset = 0;
- erts_writable_bin = 0;
+ $test_heap(alloc, $Live);
hb = (ErlHeapBin *) HTOP;
HTOP += heap_bin_size(num_bytes);
hb->thing_word = header_heap_bin(num_bytes);
hb->size = num_bytes;
erts_current_bin = (byte *) hb->data;
new_binary = make_binary(hb);
-
- do_bits_sub_bin:
- if (num_bits & 7) {
- ErlSubBin* sb;
-
- sb = (ErlSubBin *) HTOP;
- HTOP += ERL_SUB_BIN_SIZE;
- sb->thing_word = HEADER_SUB_BIN;
- sb->size = num_bytes - 1;
- sb->bitsize = num_bits & 7;
- sb->offs = 0;
- sb->bitoffs = 0;
- sb->is_writable = 0;
- sb->orig = new_binary;
- new_binary = make_binary(sb);
- }
- HEAP_SPACE_VERIFIED(0);
- $Dst = new_binary;
} else {
Binary* bptr;
ProcBin* pb;
- erts_bin_offset = 0;
- erts_writable_bin = 0;
+ $TEST_BIN_VHEAP(num_bytes / sizeof(Eterm), alloc, $Live);
/*
* Allocate the binary struct itself.
@@ -602,8 +582,24 @@ bs_init_bits.execute(Live, Dst) {
pb->flags = 0;
OH_OVERHEAD(&(MSO(c_p)), pb->size / sizeof(Eterm));
new_binary = make_binary(pb);
- goto do_bits_sub_bin;
}
+
+ if (num_bits & 7) {
+ ErlSubBin* sb;
+
+ sb = (ErlSubBin *) HTOP;
+ HTOP += ERL_SUB_BIN_SIZE;
+ sb->thing_word = HEADER_SUB_BIN;
+ sb->size = num_bytes - 1;
+ sb->bitsize = num_bits & 7;
+ sb->offs = 0;
+ sb->bitoffs = 0;
+ sb->is_writable = 0;
+ sb->orig = new_binary;
+ new_binary = make_binary(sb);
+ }
+ HEAP_SPACE_VERIFIED(0);
+ $Dst = new_binary;
}
bs_add(Fail, Src1, Src2, Unit, Dst) {