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

Implement lists:reverse/1,2 as nif #806

Merged
merged 1 commit into from
Nov 7, 2023

Conversation

pguyot
Copy link
Collaborator

@pguyot pguyot commented Sep 12, 2023

This nif does not need to be updated after #795 is merged.

Also rewrite several lists module functions to not use this nif, either because
it was not necessary (lists:seq/2,3) or because a non-tail recursive loop
is more efficient memory-wise.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

@pguyot pguyot force-pushed the w34/implement-lists-reverse-as-nif branch from 1d02c86 to 11afecd Compare October 28, 2023 20:25
@pguyot pguyot marked this pull request as ready for review October 28, 2023 21:12
Copy link
Collaborator

@fadushin fadushin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just worried about losing tail recursion optimization in some of the list.erl refactor.

libs/estdlib/src/lists.erl Show resolved Hide resolved
libs/estdlib/src/lists.erl Show resolved Hide resolved
libs/estdlib/src/lists.erl Show resolved Hide resolved
src/libAtomVM/nifs.c Show resolved Hide resolved
@pguyot
Copy link
Collaborator Author

pguyot commented Oct 29, 2023

I think I checked all cases looking at disassembly and the non-tail recursion versions were more or as efficient memory wise.

src/libAtomVM/nifs.c Outdated Show resolved Hide resolved
src/libAtomVM/nifs.c Outdated Show resolved Hide resolved
src/libAtomVM/nifs.c Show resolved Hide resolved
Also rewrite several lists module functions to not use this nif, either because
it was not necessary (lists:seq/2,3) or because a non-tail recursive loop
is more efficient memory-wise.

Signed-off-by: Paul Guyot <pguyot@kallisys.net>
@pguyot pguyot force-pushed the w34/implement-lists-reverse-as-nif branch from 11afecd to 5817b40 Compare October 31, 2023 21:51
@bettio bettio merged commit e2d7027 into atomvm:master Nov 7, 2023
81 of 84 checks passed
@pguyot pguyot deleted the w34/implement-lists-reverse-as-nif branch November 8, 2023 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants