diff options
author | Rickard Green <[email protected]> | 2017-02-06 20:17:28 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2017-02-06 20:17:28 +0100 |
commit | 12eb5089147513d1bc0797617bb6e95bc6e0c332 (patch) | |
tree | 2e9297dc7cb7b2839c9774307044d138bce46fa2 /lib/stdlib/src | |
parent | 888c889714569a142525505c914f577135a46ec9 (diff) | |
parent | 8a72a253e2eda59e510d953f0b6eb21b50e06d0e (diff) | |
download | otp-12eb5089147513d1bc0797617bb6e95bc6e0c332.tar.gz otp-12eb5089147513d1bc0797617bb6e95bc6e0c332.tar.bz2 otp-12eb5089147513d1bc0797617bb6e95bc6e0c332.zip |
Merge branch 'rickard/magic-references'
OTP-14205
* rickard/magic-references:
Add binary overhead for magic ref/binaries
Adjust the only usage of exposed magic binaries
Use magic refs for maps merge trap context
Use magic refs binary_to_term/term_to_binary trap context
Use magic refs for distributed send trap context
Use magic refs for unicode static NIFs traps
Use magic refs for binary compile patterns
Use magic refs for list_to_binary/binary_to_list traps
Use magic refs for compiled match specs
Use magic refs for re:run() static NIFs trap
Use magic refs for code loading state
Use magic refs in trapping processes()/ports() BIFs
Use magic refs for NIF resources
Implement magic references
Implement erts_refc_inc_unless()
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/binary.erl | 2 | ||||
-rw-r--r-- | lib/stdlib/src/dets.erl | 7 | ||||
-rw-r--r-- | lib/stdlib/src/ets.erl | 18 |
3 files changed, 12 insertions, 15 deletions
diff --git a/lib/stdlib/src/binary.erl b/lib/stdlib/src/binary.erl index ccc827ca2d..45666fbcb4 100644 --- a/lib/stdlib/src/binary.erl +++ b/lib/stdlib/src/binary.erl @@ -24,7 +24,7 @@ -export_type([cp/0]). --opaque cp() :: {'am' | 'bm', binary()}. +-opaque cp() :: {'am' | 'bm', reference()}. -type part() :: {Start :: non_neg_integer(), Length :: integer()}. %%% BIFs. diff --git a/lib/stdlib/src/dets.erl b/lib/stdlib/src/dets.erl index 5bc9475fc8..e81383775b 100644 --- a/lib/stdlib/src/dets.erl +++ b/lib/stdlib/src/dets.erl @@ -1063,11 +1063,8 @@ foldl_bins([Bin | Bins], MP, Terms) -> compile_match_spec(select, ?PATTERN_TO_OBJECT_MATCH_SPEC('_') = Spec) -> {Spec, true}; compile_match_spec(select, Spec) -> - case catch ets:match_spec_compile(Spec) of - X when is_binary(X) -> - {Spec, {match_spec, X}}; - _ -> - badarg + try {Spec, {match_spec, ets:match_spec_compile(Spec)}} + catch error:_ -> badarg end; compile_match_spec(object, Pat) -> compile_match_spec(select, ?PATTERN_TO_OBJECT_MATCH_SPEC(Pat)); diff --git a/lib/stdlib/src/ets.erl b/lib/stdlib/src/ets.erl index 20de06fd0b..d6fd1e3ea1 100644 --- a/lib/stdlib/src/ets.erl +++ b/lib/stdlib/src/ets.erl @@ -51,8 +51,8 @@ -type tab() :: atom() | tid(). -type type() :: set | ordered_set | bag | duplicate_bag. -type continuation() :: '$end_of_table' - | {tab(),integer(),integer(),binary(),list(),integer()} - | {tab(),_,_,integer(),binary(),list(),integer(),integer()}. + | {tab(),integer(),integer(),comp_match_spec(),list(),integer()} + | {tab(),_,_,integer(),comp_match_spec(),list(),integer(),integer()}. -opaque tid() :: integer(). @@ -488,7 +488,7 @@ update_element(_, _, _) -> %%% End of BIFs --opaque comp_match_spec() :: binary(). %% this one is REALLY opaque +-opaque comp_match_spec() :: reference(). -spec match_spec_run(List, CompiledMatchSpec) -> list() when List :: [tuple()], @@ -505,28 +505,28 @@ match_spec_run(List, CompiledMS) -> repair_continuation('$end_of_table', _) -> '$end_of_table'; %% ordered_set -repair_continuation(Untouched = {Table,Lastkey,EndCondition,N2,Bin,L2,N3,N4}, MS) +repair_continuation(Untouched = {Table,Lastkey,EndCondition,N2,MSRef,L2,N3,N4}, MS) when %% (is_atom(Table) or is_integer(Table)), is_integer(N2), - byte_size(Bin) =:= 0, + %% is_reference(MSRef), is_list(L2), is_integer(N3), is_integer(N4) -> - case ets:is_compiled_ms(Bin) of + case ets:is_compiled_ms(MSRef) of true -> Untouched; false -> {Table,Lastkey,EndCondition,N2,ets:match_spec_compile(MS),L2,N3,N4} end; %% set/bag/duplicate_bag -repair_continuation(Untouched = {Table,N1,N2,Bin,L,N3}, MS) +repair_continuation(Untouched = {Table,N1,N2,MSRef,L,N3}, MS) when %% (is_atom(Table) or is_integer(Table)), is_integer(N1), is_integer(N2), - byte_size(Bin) =:= 0, + %% is_reference(MSRef), is_list(L), is_integer(N3) -> - case ets:is_compiled_ms(Bin) of + case ets:is_compiled_ms(MSRef) of true -> Untouched; false -> |