@@ -56,7 +56,8 @@ class Wamr : public WasmVm {
56
56
Wamr () = default ;
57
57
58
58
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" ; }
60
61
61
62
Cloneable cloneable () override { return Cloneable::CompiledBytecode; }
62
63
std::unique_ptr<WasmVm> clone () override ;
@@ -118,18 +119,32 @@ class Wamr : public WasmVm {
118
119
std::unordered_map<std::string, WasmFuncPtr> module_functions_;
119
120
};
120
121
121
- bool Wamr::load (std::string_view bytecode, std::string_view /* precompiled*/ ,
122
+ bool Wamr::load (std::string_view bytecode, std::string_view precompiled,
122
123
const std::unordered_map<uint32_t , std::string> & /* function_names*/ ) {
123
124
store_ = wasm_store_new (engine ());
124
125
if (store_ == nullptr ) {
125
126
return false ;
126
127
}
127
128
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
+
133
148
module_ = wasm_module_new (store_.get (), &binary);
134
149
if (module_ == nullptr ) {
135
150
return false ;
@@ -224,8 +239,8 @@ static const char *printValKind(wasm_valkind_t kind) {
224
239
return " f32" ;
225
240
case WASM_F64:
226
241
return " f64" ;
227
- case WASM_ANYREF :
228
- return " anyref " ;
242
+ case WASM_EXTERNREF :
243
+ return " externref " ;
229
244
case WASM_FUNCREF:
230
245
return " funcref" ;
231
246
default :
0 commit comments