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

Protect against orphan nodes #29

Open
danluu opened this issue Apr 29, 2016 · 0 comments
Open

Protect against orphan nodes #29

danluu opened this issue Apr 29, 2016 · 0 comments

Comments

@danluu
Copy link
Contributor

danluu commented Apr 29, 2016

inc/NativeJIT/Nodes/Node.h

        // Increments the number of node's parents that will evaluate the node
        // through the Node<T>::CodeGen() method. The node will be evaluated
        // only once, but the result will also be stored in cache with a
        // matching number of references. The cache will be released once all
        // parents evaluate the node.
        // IMPORTANT: Currently, there's an assumption that if a node is created,
        // it must be placed inside the tree. TODO: Remove this assumption and
        // allow for optimizing away unused nodes.
        void IncrementParentCount();

Fix: maintain count of nodes created and count of nodes in tree. Assert fail if they don't match.

Note that not fixing this will only cause more code to get generated than is necessary. In our first pass, if we have an orphan root with children, code will get generated that can't be reached through any reasonable means.

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

No branches or pull requests

1 participant