1289: Enable `DynamicFunc` for closures with captured environment. r=syrusakbary a=losfair

Previously we disabled `DynamicFunc` for any non-zero-sized closures to leave space for future changes. However this feature is critical for applications that needs to bring context with host functions, like integrations with dynamic lauguages. So it might be good to enable it.

A question left is: should we put this behind a feature flag or enable it by default?

@Hywan @syrusakbary 

Co-authored-by: losfair <zhy20000919@hotmail.com>
This commit is contained in:
bors[bot] 2020-03-12 04:25:34 +00:00 committed by GitHub
commit 7b97b8abb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -59,3 +59,5 @@ generate-debug-information = ["wasm-debug"]
# don't export symbols related to the GDB JIT interafce, LLVM or some other native # don't export symbols related to the GDB JIT interafce, LLVM or some other native
# code will be providing them # code will be providing them
generate-debug-information-no-export-symbols = [] generate-debug-information-no-export-symbols = []
# enable DynamicFunc's for closures with captured environment.
dynamicfunc-fat-closures = []

View File

@ -349,9 +349,8 @@ impl<'a> DynamicFunc<'a> {
} }
} }
// Disable "fat" closures for possible future changes. if cfg!(not(feature = "dynamicfunc-fat-closures")) && mem::size_of::<F>() != 0 {
if mem::size_of::<F>() != 0 { unimplemented!("DynamicFunc with captured environment is disabled");
unimplemented!("DynamicFunc with captured environment is not yet supported");
} }
let mut builder = TrampolineBufferBuilder::new(); let mut builder = TrampolineBufferBuilder::new();