Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow binary bifs in match_spec and trace pattern guards #5027

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

stolen
Copy link
Contributor

@stolen stolen commented Jul 5, 2021

This commit adds byte_size/2, binary_part/2 and binary_part/3 to
a valid guard lists, extending functionality of ets select and tracing.

These calls are now valid:

> dbg:fun2ms(fun([B, _]) when byte_size(B) == 4 -> return_trace() end).
> ets:fun2ms(fun({B}) when byte_size(B) == 4 -> ok end).

> dbg:fun2ms(fun([B, _]) when binary_part(B, {2, 2}) == <<"ll">> -> return_trace() end).
> ets:fun2ms(fun({B}) when binary_part(B, {2, 2}) == <<"ll">> -> ok end).

> dbg:fun2ms(fun([B, _]) when binary_part(B, 2, 2) == <<"ll">> -> return_trace() end).
> ets:fun2ms(fun({B}) when binary_part(B, 2, 2) == <<"ll">> -> ok end).

Also erts_internal:trace_pattern and ets:select work with these match specs.

Fixes #5026

@CLAassistant
Copy link

CLAassistant commented Jul 5, 2021

CLA assistant check
All committers have signed the CLA.

@stolen stolen force-pushed the erts/binary-bifs-in-trace-guards branch from f061d93 to 0855c82 Compare July 5, 2021 16:36
This commit adds byte_size/2, binary_part/2 and binary_part/3 to
a valid guard lists, extending functionality of ets select and tracing.
@stolen stolen force-pushed the erts/binary-bifs-in-trace-guards branch from 0855c82 to 954fd53 Compare July 6, 2021 12:56
@garazdawi garazdawi added the team:VM Assigned to OTP team VM label Jul 12, 2021
@rickard-green rickard-green assigned bjorng and sverker and unassigned bjorng Aug 9, 2021
@sverker sverker added enhancement testing currently being tested, tag is used by OTP internal CI labels Aug 10, 2021
@sverker
Copy link
Contributor

sverker commented Aug 10, 2021

Looks ok. Put into test.

@sverker sverker merged commit b600fe6 into erlang:master Aug 12, 2021
@sverker
Copy link
Contributor

sverker commented Aug 12, 2021

Merged to master.
@stolen Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

binary bifs do not work in ets:select and erlang:trace_pattern
5 participants