Loading config/external/wasm2c_sandbox_compiler/moz.yaml +3 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ origin: description: wasm2c fork used for rlbox sandboxing url: https://github.com/WebAssembly/wabt release: 805bebffde3c41fe4f1255deccc7bcb5b7e05dfa (2023-04-26T15:06:45Z). revision: 805bebffde3c41fe4f1255deccc7bcb5b7e05dfa release: 5abbeaab97eb802acccf866d9c8cc021c1f7e570 (2023-05-02T18:27:21Z). revision: 5abbeaab97eb802acccf866d9c8cc021c1f7e570 license: Apache-2.0 license-file: LICENSE Loading Loading @@ -44,3 +44,4 @@ vendoring: - src/tools/wast* - src/tools/wat* - src/tools/wasm2w* - wasm2c/wasm-rt-exceptions* third_party/wasm2c/include/wabt/c-writer.h +3 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <functional> #include "wabt/common.h" #include "wabt/feature.h" #include "wabt/ir.h" namespace wabt { Loading @@ -28,6 +29,8 @@ class Stream; struct WriteCOptions { std::string_view module_name; /* Set of wasm features enabled for wasm2c */ Features* features; /* * name_to_output_file_index takes const iterators to begin and end of a list * of all functions in the module, number of imported functions, and number of Loading third_party/wasm2c/src/c-writer.cc +22 −9 Original line number Diff line number Diff line Loading @@ -297,6 +297,7 @@ class CWriter { static void SerializeFuncType(const FuncType&, std::string&); std::string GetGlobalName(ModuleFieldType, const std::string&) const; std::string GetLocalName(const std::string&, bool is_label) const; void Indent(int size = INDENT_SIZE); void Dedent(int size = INDENT_SIZE); Loading Loading @@ -367,6 +368,7 @@ class CWriter { const std::string&); void WriteCallIndirectFuncDeclaration(const FuncDeclaration&, const std::string&); void WriteFeatureMacros(); void WriteModuleInstance(); void WriteGlobals(); void WriteGlobal(const Global&, const std::string&); Loading Loading @@ -910,6 +912,13 @@ std::string CWriter::DefineLocalScopeName(std::string_view name, kLocalSymbolPrefix + MangleName(StripLeadingDollar(name))); } std::string CWriter::GetLocalName(const std::string& name, bool is_label) const { std::string mangled = name + (is_label ? kLabelSuffix : kParamSuffix); assert(local_sym_map_.count(mangled) == 1); return local_sym_map_.at(mangled); } std::string CWriter::DefineParamName(std::string_view name) { return DefineLocalScopeName(name, false); } Loading Loading @@ -1021,21 +1030,15 @@ void CWriter::Write(std::string_view s) { } void CWriter::Write(const ParamName& name) { std::string mangled = name.name + kParamSuffix; assert(local_sym_map_.count(mangled) == 1); Write(local_sym_map_[mangled]); Write(GetLocalName(name.name, false)); } void CWriter::Write(const LabelName& name) { std::string mangled = name.name + kLabelSuffix; assert(local_sym_map_.count(mangled) == 1); Write(local_sym_map_[mangled]); Write(GetLocalName(name.name, true)); } void CWriter::Write(const GlobalName& name) { std::string mangled = name.name + MangleField(name.type); assert(global_sym_map_.count(mangled) == 1); Write(global_sym_map_.at(mangled)); Write(GetGlobalName(name.type, name.name)); } void CWriter::Write(const ExternalPtr& name) { Loading Loading @@ -1787,6 +1790,15 @@ void CWriter::WriteCallIndirectFuncDeclaration(const FuncDeclaration& decl, Write(")"); } void CWriter::WriteFeatureMacros() { if (options_.features->exceptions_enabled()) { Write("#define WASM_RT_ENABLE_EXCEPTION_HANDLING", Newline(), Newline()); } if (options_.features->simd_enabled()) { Write("#define WASM_RT_ENABLE_SIMD", Newline(), Newline()); } } void CWriter::WriteModuleInstance() { BeginInstance(); WriteGlobals(); Loading Loading @@ -5120,6 +5132,7 @@ void CWriter::WriteCHeader() { Write("#ifndef ", guard, Newline()); Write("#define ", guard, Newline()); Write(Newline()); WriteFeatureMacros(); Write(s_header_top); Write(Newline()); WriteModuleInstance(); Loading third_party/wasm2c/src/prebuilt/wasm2c_header_top.cc +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,13 @@ R"w2c_template( #include "wasm-rt.h" )w2c_template" R"w2c_template( #if defined(WASM_RT_ENABLE_EXCEPTION_HANDLING) )w2c_template" R"w2c_template(#include "wasm-rt-exceptions.h" )w2c_template" R"w2c_template(#endif )w2c_template" R"w2c_template( #if defined(WASM_RT_ENABLE_SIMD) )w2c_template" R"w2c_template(#include "simde/wasm/simd128.h" Loading third_party/wasm2c/src/tools/wasm2c.cc +3 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ examples: static const std::string supported_features[] = { "multi-memory", "multi-value", "sign-extension", "saturating-float-to-int", "exceptions", "memory64", "extended-const"}; "exceptions", "memory64", "extended-const", "simd"}; static bool IsFeatureSupported(const std::string& feature) { return std::find(std::begin(supported_features), std::end(supported_features), Loading Loading @@ -100,12 +100,13 @@ static void ParseOptions(int argc, char** argv) { ConvertBackslashToSlash(&s_infile); }); parser.Parse(argc, argv); s_write_c_options.features = &s_features; bool any_non_supported_feature = false; #define WABT_FEATURE(variable, flag, default_, help) \ any_non_supported_feature |= \ (s_features.variable##_enabled() != default_) && \ !IsFeatureSupported(flag); s_features.variable##_enabled() && !IsFeatureSupported(flag); #include "wabt/feature.def" #undef WABT_FEATURE Loading Loading
config/external/wasm2c_sandbox_compiler/moz.yaml +3 −2 Original line number Diff line number Diff line Loading @@ -9,8 +9,8 @@ origin: description: wasm2c fork used for rlbox sandboxing url: https://github.com/WebAssembly/wabt release: 805bebffde3c41fe4f1255deccc7bcb5b7e05dfa (2023-04-26T15:06:45Z). revision: 805bebffde3c41fe4f1255deccc7bcb5b7e05dfa release: 5abbeaab97eb802acccf866d9c8cc021c1f7e570 (2023-05-02T18:27:21Z). revision: 5abbeaab97eb802acccf866d9c8cc021c1f7e570 license: Apache-2.0 license-file: LICENSE Loading Loading @@ -44,3 +44,4 @@ vendoring: - src/tools/wast* - src/tools/wat* - src/tools/wasm2w* - wasm2c/wasm-rt-exceptions*
third_party/wasm2c/include/wabt/c-writer.h +3 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <functional> #include "wabt/common.h" #include "wabt/feature.h" #include "wabt/ir.h" namespace wabt { Loading @@ -28,6 +29,8 @@ class Stream; struct WriteCOptions { std::string_view module_name; /* Set of wasm features enabled for wasm2c */ Features* features; /* * name_to_output_file_index takes const iterators to begin and end of a list * of all functions in the module, number of imported functions, and number of Loading
third_party/wasm2c/src/c-writer.cc +22 −9 Original line number Diff line number Diff line Loading @@ -297,6 +297,7 @@ class CWriter { static void SerializeFuncType(const FuncType&, std::string&); std::string GetGlobalName(ModuleFieldType, const std::string&) const; std::string GetLocalName(const std::string&, bool is_label) const; void Indent(int size = INDENT_SIZE); void Dedent(int size = INDENT_SIZE); Loading Loading @@ -367,6 +368,7 @@ class CWriter { const std::string&); void WriteCallIndirectFuncDeclaration(const FuncDeclaration&, const std::string&); void WriteFeatureMacros(); void WriteModuleInstance(); void WriteGlobals(); void WriteGlobal(const Global&, const std::string&); Loading Loading @@ -910,6 +912,13 @@ std::string CWriter::DefineLocalScopeName(std::string_view name, kLocalSymbolPrefix + MangleName(StripLeadingDollar(name))); } std::string CWriter::GetLocalName(const std::string& name, bool is_label) const { std::string mangled = name + (is_label ? kLabelSuffix : kParamSuffix); assert(local_sym_map_.count(mangled) == 1); return local_sym_map_.at(mangled); } std::string CWriter::DefineParamName(std::string_view name) { return DefineLocalScopeName(name, false); } Loading Loading @@ -1021,21 +1030,15 @@ void CWriter::Write(std::string_view s) { } void CWriter::Write(const ParamName& name) { std::string mangled = name.name + kParamSuffix; assert(local_sym_map_.count(mangled) == 1); Write(local_sym_map_[mangled]); Write(GetLocalName(name.name, false)); } void CWriter::Write(const LabelName& name) { std::string mangled = name.name + kLabelSuffix; assert(local_sym_map_.count(mangled) == 1); Write(local_sym_map_[mangled]); Write(GetLocalName(name.name, true)); } void CWriter::Write(const GlobalName& name) { std::string mangled = name.name + MangleField(name.type); assert(global_sym_map_.count(mangled) == 1); Write(global_sym_map_.at(mangled)); Write(GetGlobalName(name.type, name.name)); } void CWriter::Write(const ExternalPtr& name) { Loading Loading @@ -1787,6 +1790,15 @@ void CWriter::WriteCallIndirectFuncDeclaration(const FuncDeclaration& decl, Write(")"); } void CWriter::WriteFeatureMacros() { if (options_.features->exceptions_enabled()) { Write("#define WASM_RT_ENABLE_EXCEPTION_HANDLING", Newline(), Newline()); } if (options_.features->simd_enabled()) { Write("#define WASM_RT_ENABLE_SIMD", Newline(), Newline()); } } void CWriter::WriteModuleInstance() { BeginInstance(); WriteGlobals(); Loading Loading @@ -5120,6 +5132,7 @@ void CWriter::WriteCHeader() { Write("#ifndef ", guard, Newline()); Write("#define ", guard, Newline()); Write(Newline()); WriteFeatureMacros(); Write(s_header_top); Write(Newline()); WriteModuleInstance(); Loading
third_party/wasm2c/src/prebuilt/wasm2c_header_top.cc +7 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,13 @@ R"w2c_template( #include "wasm-rt.h" )w2c_template" R"w2c_template( #if defined(WASM_RT_ENABLE_EXCEPTION_HANDLING) )w2c_template" R"w2c_template(#include "wasm-rt-exceptions.h" )w2c_template" R"w2c_template(#endif )w2c_template" R"w2c_template( #if defined(WASM_RT_ENABLE_SIMD) )w2c_template" R"w2c_template(#include "simde/wasm/simd128.h" Loading
third_party/wasm2c/src/tools/wasm2c.cc +3 −2 Original line number Diff line number Diff line Loading @@ -60,7 +60,7 @@ examples: static const std::string supported_features[] = { "multi-memory", "multi-value", "sign-extension", "saturating-float-to-int", "exceptions", "memory64", "extended-const"}; "exceptions", "memory64", "extended-const", "simd"}; static bool IsFeatureSupported(const std::string& feature) { return std::find(std::begin(supported_features), std::end(supported_features), Loading Loading @@ -100,12 +100,13 @@ static void ParseOptions(int argc, char** argv) { ConvertBackslashToSlash(&s_infile); }); parser.Parse(argc, argv); s_write_c_options.features = &s_features; bool any_non_supported_feature = false; #define WABT_FEATURE(variable, flag, default_, help) \ any_non_supported_feature |= \ (s_features.variable##_enabled() != default_) && \ !IsFeatureSupported(flag); s_features.variable##_enabled() && !IsFeatureSupported(flag); #include "wabt/feature.def" #undef WABT_FEATURE Loading