aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/utils.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2015-01-23 12:36:01 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-12 18:56:41 +0100
commitaefea82d97f984c615990729a0f7d4303741f233 (patch)
tree962845857597b9b3b29135fef2df28f1bb594731 /erts/emulator/beam/utils.c
parenta97632afab52befd2e48f963f1c5e178e3871995 (diff)
downloadotp-aefea82d97f984c615990729a0f7d4303741f233.tar.gz
otp-aefea82d97f984c615990729a0f7d4303741f233.tar.bz2
otp-aefea82d97f984c615990729a0f7d4303741f233.zip
erts: Add RESERVE and FAST_PUSH for ESTACK & WSTACK
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r--erts/emulator/beam/utils.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index cea20a6002..bd90ec2fba 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -190,11 +190,17 @@ erts_set_hole_marker(Eterm* ptr, Uint sz)
* Helper function for the ESTACK macros defined in global.h.
*/
void
-erl_grow_estack(ErtsEStack* s, Eterm* default_estack)
+erl_grow_estack(ErtsEStack* s, Eterm* default_estack, Uint need)
{
Uint old_size = (s->end - s->start);
- Uint new_size = old_size * 2;
+ Uint new_size;
Uint sp_offs = s->sp - s->start;
+
+ if (need < old_size)
+ new_size = 2*old_size;
+ else
+ new_size = ((need / old_size) + 2) * old_size;
+
if (s->start != default_estack) {
s->start = erts_realloc(s->alloc_type, s->start,
new_size*sizeof(Eterm));
@@ -210,11 +216,17 @@ erl_grow_estack(ErtsEStack* s, Eterm* default_estack)
* Helper function for the WSTACK macros defined in global.h.
*/
void
-erl_grow_wstack(ErtsWStack* s, UWord* default_wstack)
+erl_grow_wstack(ErtsWStack* s, UWord* default_wstack, Uint need)
{
Uint old_size = (s->wend - s->wstart);
- Uint new_size = old_size * 2;
+ Uint new_size;
Uint sp_offs = s->wsp - s->wstart;
+
+ if (need < old_size)
+ new_size = 2 * old_size;
+ else
+ new_size = ((need / old_size) + 2) * old_size;
+
if (s->wstart != default_wstack) {
s->wstart = erts_realloc(s->alloc_type, s->wstart,
new_size*sizeof(UWord));