aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/hipe/hipe_bif0.c
diff options
context:
space:
mode:
authorMarcus Arendt <[email protected]>2015-01-30 10:15:04 +0100
committerMarcus Arendt <[email protected]>2015-01-30 10:15:04 +0100
commit3051ca1fa0d27adee5abbccce10351a07ab7daa1 (patch)
tree42967108495d63a9056cf948c31e623de1c0e76d /erts/emulator/hipe/hipe_bif0.c
parente4a8ab7530d340249c09ca7f27b0120f55b8354a (diff)
parent3d41006a0e17d57fef4324c2a49c778f7a4a3390 (diff)
downloadotp-3051ca1fa0d27adee5abbccce10351a07ab7daa1.tar.gz
otp-3051ca1fa0d27adee5abbccce10351a07ab7daa1.tar.bz2
otp-3051ca1fa0d27adee5abbccce10351a07ab7daa1.zip
Merge branch 'mikpe/hipe-code-alloc-fixes'
* mikpe/hipe-code-alloc-fixes: hipe: improve error handling at code allocation failure hipe: remove two obsolete BIFs hipe: remove HIPE_ALLOC_CODE macro
Diffstat (limited to 'erts/emulator/hipe/hipe_bif0.c')
-rw-r--r--erts/emulator/hipe/hipe_bif0.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/erts/emulator/hipe/hipe_bif0.c b/erts/emulator/hipe/hipe_bif0.c
index 9eb0b88ced..9e5830f345 100644
--- a/erts/emulator/hipe/hipe_bif0.c
+++ b/erts/emulator/hipe/hipe_bif0.c
@@ -397,15 +397,17 @@ BIF_RETTYPE hipe_bifs_enter_code_2(BIF_ALIST_2)
ASSERT(bitoffs == 0);
ASSERT(bitsize == 0);
trampolines = NIL;
-#ifdef HIPE_ALLOC_CODE
- address = HIPE_ALLOC_CODE(nrbytes, BIF_ARG_2, &trampolines, BIF_P);
- if (!address)
- BIF_ERROR(BIF_P, BADARG);
-#else
- if (is_not_nil(BIF_ARG_2))
- BIF_ERROR(BIF_P, BADARG);
- address = erts_alloc(ERTS_ALC_T_HIPE, nrbytes);
-#endif
+ address = hipe_alloc_code(nrbytes, BIF_ARG_2, &trampolines, BIF_P);
+ if (!address) {
+ Uint nrcallees;
+
+ if (is_tuple(BIF_ARG_2))
+ nrcallees = arityval(tuple_val(BIF_ARG_2)[0]);
+ else
+ nrcallees = 0;
+ erl_exit(1, "%s: failed to allocate %lu bytes and %lu trampolines\r\n",
+ __func__, (unsigned long)nrbytes, (unsigned long)nrcallees);
+ }
memcpy(address, bytes, nrbytes);
hipe_flush_icache_range(address, nrbytes);
hp = HAlloc(BIF_P, 3);
@@ -1280,6 +1282,8 @@ static void *hipe_make_stub(Eterm m, Eterm f, unsigned int arity, int is_remote)
export_entry = erts_export_get_or_make_stub(m, f, arity);
StubAddress = hipe_make_native_stub(export_entry, arity);
+ if (!StubAddress)
+ erl_exit(1, "hipe_make_stub: code allocation failed\r\n");
return StubAddress;
}