本文整理汇总了C++中ModuleGenerator::initHeapUsage方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleGenerator::initHeapUsage方法的具体用法?C++ ModuleGenerator::initHeapUsage怎么用?C++ ModuleGenerator::initHeapUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleGenerator
的用法示例。
在下文中一共展示了ModuleGenerator::initHeapUsage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fail
static bool
DecodeMemory(JSContext* cx, Decoder& d, ModuleGenerator& mg, MutableHandle<ArrayBufferObject*> heap)
{
uint32_t sectionStart;
if (!d.startSection(MemoryId, §ionStart))
return Fail(cx, d, "failed to start section");
if (sectionStart == Decoder::NotStarted)
return true;
uint32_t initialSizePages;
if (!d.readVarU32(&initialSizePages))
return Fail(cx, d, "expected initial memory size");
CheckedInt<int32_t> initialSize = initialSizePages;
initialSize *= PageSize;
if (!initialSize.isValid())
return Fail(cx, d, "initial memory size too big");
uint32_t maxSizePages;
if (!d.readVarU32(&maxSizePages))
return Fail(cx, d, "expected initial memory size");
CheckedInt<int32_t> maxSize = maxSizePages;
maxSize *= PageSize;
if (!maxSize.isValid())
return Fail(cx, d, "initial memory size too big");
uint8_t exported;
if (!d.readFixedU8(&exported))
return Fail(cx, d, "expected exported byte");
if (exported) {
UniqueChars fieldName = DuplicateString("memory");
if (!fieldName || !mg.addMemoryExport(Move(fieldName)))
return false;
}
if (!d.finishSection(sectionStart))
return Fail(cx, d, "memory section byte size mismatch");
bool signalsForOOB = CompileArgs(cx).useSignalHandlersForOOB;
heap.set(ArrayBufferObject::createForWasm(cx, initialSize.value(), signalsForOOB));
if (!heap)
return false;
mg.initHeapUsage(HeapUsage::Unshared);
return true;
}
示例2: Fail
static bool
DecodeMemorySection(JSContext* cx, Decoder& d, ModuleGenerator& mg,
MutableHandle<ArrayBufferObject*> heap)
{
if (!d.readCStringIf(MemoryLabel))
return true;
uint32_t sectionStart;
if (!d.startSection(§ionStart))
return Fail(cx, d, "expected memory section byte size");
if (!d.readCStringIf(InitialLabel))
return Fail(cx, d, "expected memory section initial field");
uint32_t initialHeapSize;
if (!d.readVarU32(&initialHeapSize))
return Fail(cx, d, "expected initial memory size");
if (initialHeapSize < PageSize || initialHeapSize % PageSize != 0)
return Fail(cx, d, "initial memory size not a multiple of 0x10000");
if (initialHeapSize > INT32_MAX)
return Fail(cx, d, "initial memory size too big");
if (!d.readCStringIf(EndLabel))
return Fail(cx, d, "expected end field of memory section");
if (!d.finishSection(sectionStart))
return Fail(cx, d, "memory section byte size mismatch");
bool signalsForOOB = CompileArgs(cx).useSignalHandlersForOOB;
heap.set(ArrayBufferObject::createForWasm(cx, initialHeapSize, signalsForOOB));
if (!heap)
return false;
mg.initHeapUsage(HeapUsage::Unshared);
return true;
}