@@ -59,7 +59,8 @@ class Wamr : public WasmVm {
59
59
Wamr () = default ;
60
60
61
61
std::string_view getEngineName () override { return " wamr" ; }
62
- std::string_view getPrecompiledSectionName () override { return " " ; }
62
+ // has to use the same name provided to test-tools/append-aot-to-wasm/append_aot_to_wasm.py
63
+ std::string_view getPrecompiledSectionName () override { return " aot" ; }
63
64
64
65
Cloneable cloneable () override { return Cloneable::CompiledBytecode; }
65
66
std::unique_ptr<WasmVm> clone () override ;
@@ -121,18 +122,31 @@ class Wamr : public WasmVm {
121
122
std::unordered_map<std::string, WasmFuncPtr> module_functions_;
122
123
};
123
124
124
- bool Wamr::load (std::string_view bytecode, std::string_view /* precompiled*/ ,
125
+ bool Wamr::load (std::string_view bytecode, std::string_view precompiled,
125
126
const std::unordered_map<uint32_t , std::string> & /* function_names*/ ) {
126
127
store_ = wasm_store_new (engine ());
127
128
if (store_ == nullptr ) {
128
129
return false ;
129
130
}
130
131
131
- wasm_byte_vec_t binary = {.size = bytecode.size (),
132
- .data = (char *)bytecode.data (),
133
- .num_elems = bytecode.size (),
134
- .size_of_elem = sizeof (byte_t ),
135
- .lock = nullptr };
132
+ wasm_byte_vec_t binary = {0 };
133
+ if (precompiled.empty ()) {
134
+ binary.size = bytecode.size ();
135
+ binary.data = (char *)bytecode.data ();
136
+ binary.num_elems = bytecode.size ();
137
+ binary.size_of_elem = sizeof (byte_t );
138
+ binary.lock = nullptr ;
139
+ } else {
140
+ // skip leading paddings
141
+ unsigned padding_count = precompiled[0 ];
142
+ precompiled.remove_prefix (padding_count + 1 );
143
+
144
+ binary.size = precompiled.size ();
145
+ binary.data = (char *)precompiled.data ();
146
+ binary.num_elems = precompiled.size ();
147
+ binary.size_of_elem = sizeof (byte_t );
148
+ binary.lock = nullptr ;
149
+ }
136
150
137
151
module_ = wasm_module_new (store_.get (), &binary);
138
152
if (module_ == nullptr ) {
0 commit comments