diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-17 13:42:26 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-17 13:42:26 -0700 |
commit | 92cbfdb2fb58986724bb796489b8138d217ca5f1 (patch) | |
tree | e539c33bfff5d3d677a1731e4185887edb0fba63 /src/wasm-traversal.h | |
parent | 90d4fa0164ab0fad4ca7b60489c43eebd41ed9e3 (diff) | |
parent | 5d76c53d350cc4565c8c4f4298c8fd346ca8fcb5 (diff) | |
download | binaryen-92cbfdb2fb58986724bb796489b8138d217ca5f1.tar.gz binaryen-92cbfdb2fb58986724bb796489b8138d217ca5f1.tar.bz2 binaryen-92cbfdb2fb58986724bb796489b8138d217ca5f1.zip |
Merge pull request #515 from WebAssembly/learn-coloring
Smarter local coalescing
Diffstat (limited to 'src/wasm-traversal.h')
-rw-r--r-- | src/wasm-traversal.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h index afa20ecb5..d7fc83f59 100644 --- a/src/wasm-traversal.h +++ b/src/wasm-traversal.h @@ -154,6 +154,14 @@ struct Walker : public VisitorType { // function either (which could be very inefficient). bool isFunctionParallel() { return false; } + // This method is used to create instances per function for a function-parallel + // pass. You may need to override this if you subclass a Walker, as otherwise + // this will create the parent class. + // Note that this returns nullptr, and we check if the result is nullptr and + // do new SubType later. This is important since non-function parallel + // passes may not be constructable via new SubType. + virtual SubType* create() { return nullptr; } + // Useful methods for visitor implementions // Replace the current node. You can call this in your visit*() methods. @@ -191,13 +199,14 @@ struct Walker : public VisitorType { self->visitExport(curr.get()); } - auto processFunction = [](Module* module, SubType* instance, Function* func) { + auto processFunction = [this](Module* module, SubType* instance, Function* func) { std::unique_ptr<SubType> allocated; if (!instance) { - instance = new SubType; - allocated = std::unique_ptr<SubType>(instance); + instance = create(); + if (!instance) instance = new SubType; assert(module); instance->setModule(module); + allocated = std::unique_ptr<SubType>(instance); } instance->setFunction(func); instance->walk(func->body); |