4.2内存模式 (Memory Mode)

The EVM uses a linear memory (i.e. starting at zero and growing), without a defined limit. Allocating memory costs a quadratic amount of gasarrow-up-right, which severely limits the amount of memory usable in a single context (i.e. contract call).

EVM使用线性内存(即从零开始增长),没有一个定义的限制。分配内存需要花费二次方的gas量arrow-up-right,这严重限制了单个环境(即合约调用)中可用的内存量。

In addition, the EVM has a separate memory space per context. Contexts may communicate with each other by copying data to call data and returning data buffers.

此外,EVM的每个环境都有一个独立的内存空间。环境可以通过将数据复制到调用数据和返回数据缓冲区来相互通信。

The FuelVM uses a single share memory block per transaction. Memory is allocated statically with a known upper bound, allowing for straightforward implementation of heap types such as vectorsarrow-up-right. Memory in the FuelVM is globally readable across contexts, but locally writable. Each context may only write to portions of the stack and the heap which it has ownershiparrow-up-right over.

FuelVM在每笔交易中使用一个单一的共享 内存块 内存是静态分配的,有一个已知的上限,允许直接实现堆的类型,如向量arrow-up-right。FuelVM中的内存在整个环境中是只读的,但在本地是可修改的的。每个环境只能修改部分堆栈和其所有权arrow-up-right对应的堆。

Last updated