Skip to content

Commit 0dbae10

Browse files
committed
Update WAVM binding to match new API
1 parent f21d5e7 commit 0dbae10

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/wavm.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#pragma GCC diagnostic ignored "-Wunused-variable"
4646

4747
using namespace std;
48+
using namespace WAVM;
4849

4950
namespace hera {
5051

@@ -60,7 +61,7 @@ class WavmEthereumInterface : public EthereumInterface {
6061
EthereumInterface(_context, _code, _msg, _result, _meterGas)
6162
{}
6263

63-
void setWasmMemory(Runtime::MemoryInstance* _wasmMemory) {
64+
void setWasmMemory(Runtime::Memory* _wasmMemory) {
6465
m_wasmMemory = _wasmMemory;
6566
}
6667

@@ -70,7 +71,7 @@ class WavmEthereumInterface : public EthereumInterface {
7071
void memorySet(size_t offset, uint8_t value) override { (Runtime::memoryArrayPtr<U8>(m_wasmMemory, offset, 1))[0] = value; }
7172
uint8_t memoryGet(size_t offset) override { return (Runtime::memoryArrayPtr<U8>(m_wasmMemory, offset, 1))[0]; }
7273

73-
Runtime::MemoryInstance* m_wasmMemory;
74+
Runtime::Memory* m_wasmMemory;
7475
};
7576

7677
unique_ptr<WasmEngine> WavmEngine::create()
@@ -181,7 +182,7 @@ namespace wavm_host_module {
181182

182183
bool resolve(const string& moduleName,
183184
const string& exportName,
184-
IR::ObjectType type,
185+
IR::ExternType type,
185186
Runtime::Object*& outObject) override
186187
{
187188
outObject = nullptr;
@@ -202,7 +203,8 @@ ExecutionResult WavmEngine::execute(
202203
) {
203204
ExecutionResult result = internalExecute(context, code, state_code, msg, meterInterfaceGas);
204205
// And clean up mess left by this run.
205-
Runtime::collectGarbage();
206+
// TODO: enable this.
207+
// Runtime::collectCompartmentGarbage(compartment);
206208
return result;
207209
}
208210

@@ -255,7 +257,7 @@ ExecutionResult WavmEngine::internalExecute(
255257
heraAssert(linkResult.success, "Couldn't link contract against host module.");
256258

257259
// compile the module from IR to LLVM bitcode
258-
Runtime::GCPointer<Runtime::Module> module = Runtime::compileModule(moduleIR);
260+
Runtime::ModuleRef module = Runtime::compileModule(moduleIR);
259261

260262
// instantiate contract module
261263
Runtime::GCPointer<Runtime::ModuleInstance> moduleInstance = Runtime::instantiateModule(compartment, module, move(linkResult.resolvedImports), "<ewasmcontract>");
@@ -265,7 +267,7 @@ ExecutionResult WavmEngine::internalExecute(
265267
wavm_host_module::interface.top()->setWasmMemory(asMemory(Runtime::getInstanceExport(moduleInstance, "memory")));
266268

267269
// invoke the main function
268-
Runtime::GCPointer<Runtime::FunctionInstance> mainFunction = asFunctionNullable(Runtime::getInstanceExport(moduleInstance, "main"));
270+
Runtime::GCPointer<Runtime::Function> mainFunction = asFunctionNullable(Runtime::getInstanceExport(moduleInstance, "main"));
269271
ensureCondition(mainFunction, ContractValidationFailure, "\"main\" not found");
270272

271273
// this is how WAVM's try/catch for exceptions

0 commit comments

Comments
 (0)