Summary: This diff tries to support a specific form of linked list iteration in Java. ``` while (p != null) { p = p.getNext(); } ``` This example was a constant cost before because the cost checker could not detect that it is an iteration on a linked list. The heuristic this diff implemented is: (1) `p = p.getNext()`: It tries to find this specific form of assignment. Then, it increments `p.linked_list_index` by 1. Note that `linked_list_index` is a virtual field for keeping an index in the linked list. Its initial value is always 0. (2) At `p != null`, it tries to prune the value of `p.linked_list_index`: the upper-bound of `p.linked_list_index` is pruned by `<= p.linked_list_length`. Here again, `p.linked_list_length` is also a virtual field to denote the length of the linked list. Reviewed By: ezgicicek Differential Revision: D22234892 fbshipit-source-id: 2fee176bbmaster
parent
3a338e6960
commit
b48534c640
Loading…
Reference in new issue