-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Even when we don't want to fully legalize code for JS, we should still legalize things that only JS cares about. In particular, dynCall_* methods are used from JS to call into the wasm table, and if they exist they are only for JS, so we should only legalize them. The use case motivating this is that in dynamic linking you may want to disable legalization, so that wasm=>wasm module calls are fast even with i64s, but you do still need dynCalls to be legalized even in that case, otherwise an invoke with an i64 parameter would fail.
- Loading branch information
Showing
9 changed files
with
175 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2018 WebAssembly Community Group participants | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef wasm_abi_abi_h | ||
#define wasm_abi_abi_h | ||
|
||
#include "wasm.h" | ||
|
||
namespace wasm { | ||
|
||
namespace ABI { | ||
|
||
enum LegalizationLevel { | ||
Full = 0, | ||
Minimal = 1 | ||
}; | ||
|
||
inline std::string getLegalizationPass(LegalizationLevel level) { | ||
if (level == Full) { | ||
return "legalize-js-interface"; | ||
} else { | ||
return "legalize-js-interface-minimally"; | ||
} | ||
} | ||
|
||
} // namespace ABI | ||
|
||
} // namespace wasm | ||
|
||
#endif // wasm_abi_abi_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(module | ||
(type $FUNCSIG$j (func (result i64))) | ||
(type $FUNCSIG$vi (func (param i32))) | ||
(import "env" "imported" (func $imported (result i64))) | ||
(import "env" "setTempRet0" (func $setTempRet0 (param i32))) | ||
(export "func" (func $func)) | ||
(export "dynCall_foo" (func $legalstub$dyn)) | ||
(func $func (; 2 ;) (type $FUNCSIG$j) (result i64) | ||
(drop | ||
(call $imported) | ||
) | ||
(unreachable) | ||
) | ||
(func $dyn (; 3 ;) (type $FUNCSIG$j) (result i64) | ||
(drop | ||
(call $imported) | ||
) | ||
(unreachable) | ||
) | ||
(func $legalstub$dyn (; 4 ;) (result i32) | ||
(local $0 i64) | ||
(set_local $0 | ||
(call $dyn) | ||
) | ||
(call $setTempRet0 | ||
(i32.wrap/i64 | ||
(i64.shr_u | ||
(get_local $0) | ||
(i64.const 32) | ||
) | ||
) | ||
) | ||
(i32.wrap/i64 | ||
(get_local $0) | ||
) | ||
) | ||
) | ||
(module | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
(module | ||
(import "env" "imported" (func $imported (result i64))) | ||
(export "func" (func $func)) | ||
(export "dynCall_foo" (func $dyn)) | ||
(func $func (result i64) | ||
(drop (call $imported)) | ||
(unreachable) | ||
) | ||
(func $dyn (result i64) | ||
(drop (call $imported)) | ||
(unreachable) | ||
) | ||
) | ||
(module) | ||
|