Skip to content

Optimize sub-graphs that have no suspension point #58

Description

@Simn

Given this:

import haxe.coro.Coroutine;

@:coroutine @:coroutine.debug function f() {
	Coroutine.yield();
	if (Math.random() > 0.5) {
		trace(">");
	} else {
		trace ("<");
	}
	Coroutine.yield();
}

function main() {
	Coroutine.run(f);
}

We get this CFG:

Image

The sub-graph consisting of nodes 1, 2, 3 and 4 can be folded to a single state by using a normal if. I'll have to remember some graph theory in order to detect this accurately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions