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

[P4Testgen] Refactor the P4Testgen extern implementation. #4728

Merged
merged 2 commits into from
Jul 17, 2024

Conversation

fruffy
Copy link
Collaborator

@fruffy fruffy commented Jun 16, 2024

This PR cleans up some of the implementation of Extern functions in P4Testen. This is a breaking change. Part of this PR was prompted by #4706 which uncovered a nasty bug.

Currently, externs are defined as a static list of functions inside the expression stepper. This is necessary to access helper functions and members of the expression stepper. However one subtle consequence is that when the list of externs is instantiated the first time, the calling expression stepper object is bound to this last. Now for any future object this object will be invoked instead of a potentially different expression stepper.

The way to fix this is to make the stepper itself part of the parameters of the defined extern functions. This is a bit tricky to implement because of access protection rules hence we had to rewrite the structure of the extern function lists. They are now templates that are instantiated for each stepper class.

There are also more quality of life improvements. I folded the arguments for externs into an ExternInfo class and move the extern list out of the evalExternMethodCall which gives back some indentation space.

@fruffy fruffy added the p4tools Topics related to the P4Tools back end label Jun 16, 2024
@fruffy fruffy changed the title Refactor the P4Testgen extern implementation. [P4Testgen] Refactor the P4Testgen extern implementation. Jun 17, 2024
@fruffy fruffy force-pushed the fruffy/testgen_extern_refactoring branch 3 times, most recently from dcc6c21 to 059c349 Compare June 17, 2024 20:07
@fruffy fruffy requested a review from vlstill June 17, 2024 21:20
@fruffy fruffy marked this pull request as ready for review June 19, 2024 16:00
@fruffy fruffy force-pushed the fruffy/testgen_extern_refactoring branch from 059c349 to 012681e Compare July 8, 2024 14:39
Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy force-pushed the fruffy/testgen_extern_refactoring branch from 3cc5e45 to ac537e6 Compare July 8, 2024 15:54
Signed-off-by: fruffy <fruffy@nyu.edu>
@fruffy fruffy requested a review from vlstill July 16, 2024 14:18
@fruffy fruffy added this pull request to the merge queue Jul 17, 2024
Merged via the queue into main with commit fcaa90d Jul 17, 2024
17 checks passed
@fruffy fruffy deleted the fruffy/testgen_extern_refactoring branch July 17, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p4tools Topics related to the P4Tools back end
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants