Skip to content

Commit e5f806d

Browse files
committed
Update WAVM binding to match new API
1 parent a4bacf2 commit e5f806d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/wavm.cpp

Lines changed: 10 additions & 8 deletions
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()
@@ -258,7 +259,7 @@ namespace wavm_host_module {
258259
bool resolve(
259260
const string& moduleName,
260261
const string& exportName,
261-
IR::ObjectType type,
262+
IR::ExternType type,
262263
Runtime::Object*& outObject
263264
) override
264265
{
@@ -293,11 +294,13 @@ ExecutionResult WavmEngine::execute(
293294
try {
294295
ExecutionResult result = internalExecute(context, code, state_code, msg, meterInterfaceGas);
295296
// And clean up mess left by this run.
296-
Runtime::collectGarbage();
297+
// TODO: enable this.
298+
// Runtime::collectCompartmentGarbage(compartment);
297299
return result;
298300
} catch (exception const&) {
299301
// And clean up mess left by this run.
300-
Runtime::collectGarbage();
302+
// TODO: enable this.
303+
// Runtime::collectCompartmentGarbage(compartment);
301304
// We only catch this exception here in order to clean up garbage..
302305
// TODO: hopefully WAVM is fixed so that this isn't needed
303306
throw;
@@ -353,8 +356,7 @@ ExecutionResult WavmEngine::internalExecute(
353356
heraAssert(linkResult.success, "Couldn't link contract against host module.");
354357

355358
// compile the module from IR to LLVM bitcode
356-
Runtime::GCPointer<Runtime::Module> module = Runtime::compileModule(moduleIR);
357-
heraAssert(module, "Couldn't compile IR to bitcode.");
359+
Runtime::ModuleRef module = Runtime::compileModule(moduleIR);
358360

359361
// instantiate contract module
360362
Runtime::GCPointer<Runtime::ModuleInstance> moduleInstance = Runtime::instantiateModule(compartment, module, move(linkResult.resolvedImports), "<ewasmcontract>");
@@ -364,7 +366,7 @@ ExecutionResult WavmEngine::internalExecute(
364366
wavm_host_module::interface.top()->setWasmMemory(asMemory(Runtime::getInstanceExport(moduleInstance, "memory")));
365367

366368
// invoke the main function
367-
Runtime::GCPointer<Runtime::FunctionInstance> mainFunction = asFunctionNullable(Runtime::getInstanceExport(moduleInstance, "main"));
369+
Runtime::GCPointer<Runtime::Function> mainFunction = asFunctionNullable(Runtime::getInstanceExport(moduleInstance, "main"));
368370
ensureCondition(mainFunction, ContractValidationFailure, "\"main\" not found");
369371

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

0 commit comments

Comments
 (0)