aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2018-03-13 17:31:45 +0100
committerSverker Eriksson <[email protected]>2018-03-13 17:31:45 +0100
commit65498fa75ae3d468e8cc54c8e82debe2733312e7 (patch)
tree2d98e6e0c07731e9a8916972825cad08fff9cdf2 /lib/kernel
parentacaef0dcba397ee1fb6713b7d59976dd8484fe8b (diff)
parent847c465d9fae3630c011d928743f262288072057 (diff)
downloadotp-65498fa75ae3d468e8cc54c8e82debe2733312e7.tar.gz
otp-65498fa75ae3d468e8cc54c8e82debe2733312e7.tar.bz2
otp-65498fa75ae3d468e8cc54c8e82debe2733312e7.zip
Merge branch 'sverker/dict-put-immed-opt/OTP-14976'
* sverker/dict-put-immed-opt: erts: Optimize erlang:put/2 for hash collision lists erts: Optimize erlang:put/2 for immed values erts: Refactor erlang:put/2
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/test/pdict_SUITE.erl32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/kernel/test/pdict_SUITE.erl b/lib/kernel/test/pdict_SUITE.erl
index d105952df9..a891451c82 100644
--- a/lib/kernel/test/pdict_SUITE.erl
+++ b/lib/kernel/test/pdict_SUITE.erl
@@ -33,6 +33,7 @@
init_per_group/2,end_per_group/2,
mixed/1,
literals/1,
+ destructive/1,
simple/1, complicated/1, heavy/1, simple_all_keys/1, info/1]).
-export([init_per_testcase/2, end_per_testcase/2]).
-export([other_process/2]).
@@ -52,6 +53,7 @@ suite() ->
all() ->
[simple, complicated, heavy, simple_all_keys, info,
literals,
+ destructive,
mixed].
groups() ->
@@ -367,6 +369,36 @@ match_keys(All) ->
ok.
+%% Test destructive put optimization of immed values
+%% does not affect get/0 or process_info.
+destructive(_Config) ->
+ Keys = lists:seq(1,100),
+ [put(Key, 17) || Key <- Keys],
+ Get1 = get(),
+ {dictionary,PI1} = process_info(self(), dictionary),
+
+ [begin
+ {Key, 17} = lists:keyfind(Key, 1, Get1),
+ {Key, 17} = lists:keyfind(Key, 1, PI1)
+ end
+ || Key <- Keys],
+
+ [17 = put(Key, 42) || Key <- Keys], % Mutate
+
+ Get2 = get(),
+ {dictionary,PI2} = process_info(self(), dictionary),
+
+ [begin
+ {Key, 17} = lists:keyfind(Key, 1, Get1),
+ {Key, 17} = lists:keyfind(Key, 1, PI1),
+ {Key, 42} = lists:keyfind(Key, 1, Get2),
+ {Key, 42} = lists:keyfind(Key, 1, PI2)
+
+ end
+ || Key <- Keys],
+
+ ok.
+
%% Do random mixed put/erase to test grow/shrink
%% Written for a temporary bug in gc during shrink
mixed(_Config) ->