@@ -56,7 +56,8 @@ class Wamr : public WasmVm {
5656 Wamr () = default ;
5757
5858 std::string_view getEngineName () override { return " wamr" ; }
59- std::string_view getPrecompiledSectionName () override { return " " ; }
59+ // must use the exact name given by test-tools/append-aot-to-wasm/append_aot_to_wasm.py
60+ std::string_view getPrecompiledSectionName () override { return " wamr-aot" ; }
6061
6162 Cloneable cloneable () override { return Cloneable::CompiledBytecode; }
6263 std::unique_ptr<WasmVm> clone () override ;
@@ -118,18 +119,32 @@ class Wamr : public WasmVm {
118119 std::unordered_map<std::string, WasmFuncPtr> module_functions_;
119120};
120121
121- bool Wamr::load (std::string_view bytecode, std::string_view /* precompiled*/ ,
122+ bool Wamr::load (std::string_view bytecode, std::string_view precompiled,
122123 const std::unordered_map<uint32_t , std::string> & /* function_names*/ ) {
123124 store_ = wasm_store_new (engine ());
124125 if (store_ == nullptr ) {
125126 return false ;
126127 }
127128
128- wasm_byte_vec_t binary = {.size = bytecode.size (),
129- .data = (char *)bytecode.data (),
130- .num_elems = bytecode.size (),
131- .size_of_elem = sizeof (byte_t ),
132- .lock = nullptr };
129+ wasm_byte_vec_t binary = {0 };
130+ if (precompiled.empty ()) {
131+ binary.size = bytecode.size ();
132+ binary.data = const_cast <char *>(bytecode.data ());
133+ binary.num_elems = bytecode.size ();
134+ binary.size_of_elem = sizeof (byte_t );
135+ binary.lock = nullptr ;
136+ } else {
137+ // skip leading paddings
138+ auto padding_count = static_cast <uint8_t >(precompiled[0 ]);
139+ precompiled.remove_prefix (padding_count + 1 );
140+
141+ binary.size = precompiled.size ();
142+ binary.data = const_cast <char *>(precompiled.data ());
143+ binary.num_elems = precompiled.size ();
144+ binary.size_of_elem = sizeof (byte_t );
145+ binary.lock = nullptr ;
146+ }
147+
133148 module_ = wasm_module_new (store_.get (), &binary);
134149 if (module_ == nullptr ) {
135150 return false ;
@@ -224,8 +239,8 @@ static const char *printValKind(wasm_valkind_t kind) {
224239 return " f32" ;
225240 case WASM_F64:
226241 return " f64" ;
227- case WASM_ANYREF :
228- return " anyref " ;
242+ case WASM_EXTERNREF :
243+ return " externref " ;
229244 case WASM_FUNCREF:
230245 return " funcref" ;
231246 default :
0 commit comments