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