Shrinking alloy memory interface so that alloy-sandbox doesn't need xe.
This commit is contained in:
@@ -61,4 +61,43 @@ uint64_t Memory::SearchAligned(uint64_t start, uint64_t end,
|
||||
return 0;
|
||||
}
|
||||
|
||||
SimpleMemory::SimpleMemory(size_t capacity) : memory_(capacity) {
|
||||
membase_ = reinterpret_cast<uint8_t*>(memory_.data());
|
||||
reserve_address_ = capacity - 8;
|
||||
}
|
||||
|
||||
SimpleMemory::~SimpleMemory() = default;
|
||||
|
||||
uint8_t SimpleMemory::LoadI8(uint64_t address) {
|
||||
return poly::load<uint8_t>(membase_ + address);
|
||||
}
|
||||
|
||||
uint16_t SimpleMemory::LoadI16(uint64_t address) {
|
||||
return poly::load<uint16_t>(membase_ + address);
|
||||
}
|
||||
|
||||
uint32_t SimpleMemory::LoadI32(uint64_t address) {
|
||||
return poly::load<uint32_t>(membase_ + address);
|
||||
}
|
||||
|
||||
uint64_t SimpleMemory::LoadI64(uint64_t address) {
|
||||
return poly::load<uint64_t>(membase_ + address);
|
||||
}
|
||||
|
||||
void SimpleMemory::StoreI8(uint64_t address, uint8_t value) {
|
||||
poly::store<uint8_t>(membase_ + address, value);
|
||||
}
|
||||
|
||||
void SimpleMemory::StoreI16(uint64_t address, uint16_t value) {
|
||||
poly::store<uint16_t>(membase_ + address, value);
|
||||
}
|
||||
|
||||
void SimpleMemory::StoreI32(uint64_t address, uint32_t value) {
|
||||
poly::store<uint32_t>(membase_ + address, value);
|
||||
}
|
||||
|
||||
void SimpleMemory::StoreI64(uint64_t address, uint64_t value) {
|
||||
poly::store<uint64_t>(membase_ + address, value);
|
||||
}
|
||||
|
||||
} // namespace alloy
|
||||
|
||||
Reference in New Issue
Block a user