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

Partial legalization (#1824) review followup #1832

Merged
merged 2 commits into from
Dec 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/abi/js.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace wasm {

namespace ABI {

enum LegalizationLevel {
enum class LegalizationLevel {
Full = 0,
Minimal = 1
};

inline std::string getLegalizationPass(LegalizationLevel level) {
if (level == Full) {
if (level == LegalizationLevel::Full) {
return "legalize-js-interface";
} else {
return "legalize-js-interface-minimally";
Expand Down
3 changes: 2 additions & 1 deletion src/asm2wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,8 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
// so that the output of the first pass is valid
passRunner.add<FinalizeCalls>(this);
passRunner.add(ABI::getLegalizationPass(
legalizeJavaScriptFFI ? ABI::Full : ABI::Minimal
legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full
: ABI::LegalizationLevel::Minimal
));
if (runOptimizationPasses) {
// autodrop can add some garbage
Expand Down
4 changes: 2 additions & 2 deletions src/passes/LegalizeJSInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct LegalizeJSInterface : public Pass {
if (ex->kind == ExternalKind::Function) {
// if it's an import, ignore it
auto* func = module->getFunction(ex->value);
if (isIllegal(func) && isRelevant(ex.get(), func)) {
if (isIllegal(func) && shouldBeLegalized(ex.get(), func)) {
auto legalName = makeLegalStub(func, module);
ex->value = legalName;
}
Expand Down Expand Up @@ -131,7 +131,7 @@ struct LegalizeJSInterface : public Pass {
return false;
}

bool isRelevant(Export* ex, Function* func) {
bool shouldBeLegalized(Export* ex, Function* func) {
if (full) return true;
// We are doing minimal legalization - just what JS needs.
return ex->name.startsWith("dynCall_");
Expand Down
3 changes: 2 additions & 1 deletion src/tools/wasm-emscripten-finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ int main(int argc, const char *argv[]) {
passRunner.setDebug(options.debug);
passRunner.setDebugInfo(debugInfo);
passRunner.add(ABI::getLegalizationPass(
legalizeJavaScriptFFI ? ABI::Full : ABI::Minimal
legalizeJavaScriptFFI ? ABI::LegalizationLevel::Full
: ABI::LegalizationLevel::Minimal
));
passRunner.run();

Expand Down