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

handle nested symbols in dynamic slicer #61

Closed
smacke opened this issue Apr 17, 2021 · 2 comments · Fixed by #69
Closed

handle nested symbols in dynamic slicer #61

smacke opened this issue Apr 17, 2021 · 2 comments · Fixed by #69
Assignees

Comments

@smacke
Copy link
Member

smacke commented Apr 17, 2021

If a cell references lst[1], we need to include both the slice the defines lst[1], as well as the slice that defines the symbol lst. This is hard because lst could have multiple aliases and we need to pick the right one, and the code is not currently structured in a way that makes it easy to do so.

@smacke
Copy link
Member Author

smacke commented Apr 17, 2021

Actually, I think this could be done in attrsub_tracer without too much difficulty. Whenever the obj_name parameter is non-null, then we can lookup the corresponding symbol in the tracer's current active scope and mark it as a dynamic usage. This is true regardless of whether the final object in the chain ends up being loaded, stored, or deleted. When obj_name is null, typically the actual obj is being returned from somewhere else and we don't need to worry about marking its corresponding symbol as dynamically used since that will happen at that same somewhere else.

We do, however, need to mark methods as used, and this might require some extra work since we can't just use obj_name for these.

@smacke
Copy link
Member Author

smacke commented Apr 17, 2021

cc @shreyashankar

Untested code for attrsub_tracer that might get us most of the way there:

if sym_for_obj is None and obj_name is not None:
    sym_for_obj = self.active_scope.lookup_data_symbol_by_name_this_indentation(obj_name)
if sym_for_obj is not None and sym_for_obj.defined_cell_num < nbs().cell_counter():
    sym_for_obj.version_by_used_timestamp[nbs().cell_counter()] = sym_for_obj.defined_cell_num

Can insert this snippet right below this line in attrsub_tracer.

This is untested though and there may be more to do there. For example, If we have

obj.foo()['bar']

I don't know whether it will correctly identify the usage of obj.foo (whose usage is not captured by the code snippet above; obj_name will be None since the object being subscripted is the thing that gets retuned from obj.foo(), not obj.foo).

Also it's worth testing on various aliasing scenarios.

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 a pull request may close this issue.

2 participants