aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/beam_emu.c
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-03-03 17:16:51 +0100
committerBjörn-Egil Dahlberg <[email protected]>2015-03-12 19:15:31 +0100
commit3697ee925251edfe7a7ac2ed483039f414830012 (patch)
tree9148ec5edd135b936955f3da2150ad9df53a6282 /erts/emulator/beam/beam_emu.c
parentde95f407aba2c8b7bf2a5827842722581aacfd6a (diff)
downloadotp-3697ee925251edfe7a7ac2ed483039f414830012.tar.gz
otp-3697ee925251edfe7a7ac2ed483039f414830012.tar.bz2
otp-3697ee925251edfe7a7ac2ed483039f414830012.zip
erts: Fix instruction new_map
Diffstat (limited to 'erts/emulator/beam/beam_emu.c')
-rw-r--r--erts/emulator/beam/beam_emu.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c
index c753e57ddc..8288eb9798 100644
--- a/erts/emulator/beam/beam_emu.c
+++ b/erts/emulator/beam/beam_emu.c
@@ -6557,6 +6557,27 @@ new_map(Process* p, Eterm* reg, BeamInstr* I)
BeamInstr *ptr;
map_t *mp;
+ ptr = &Arg(4);
+
+ if (n > MAP_SMALL_MAP_LIMIT) {
+ if (HeapWordsLeft(p) < n) {
+ erts_garbage_collect(p, n, reg, Arg(2));
+ }
+
+ mhp = p->htop;
+ thp = p->htop;
+ E = p->stop;
+
+ for (i = 0; i < n/2; i++) {
+ GET_TERM(*ptr++, *mhp++);
+ GET_TERM(*ptr++, *mhp++);
+ }
+
+ p->htop = mhp;
+
+ return erts_hashmap_from_array(p, thp, n/2);
+ }
+
if (HeapWordsLeft(p) < need) {
erts_garbage_collect(p, need, reg, Arg(2));
}
@@ -6564,7 +6585,6 @@ new_map(Process* p, Eterm* reg, BeamInstr* I)
thp = p->htop;
mhp = thp + 1 + n/2;
E = p->stop;
- ptr = &Arg(4);
keys = make_tuple(thp);
*thp++ = make_arityval(n/2);