Error Compiler::embedConstPool(const Label& label, const ConstPool& pool) noexcept { if (label.getId() == kInvalidValue) return kErrorInvalidState; align(kAlignData, static_cast<uint32_t>(pool.getAlignment())); bind(label); HLData* embedNode = newDataNode(nullptr, static_cast<uint32_t>(pool.getSize())); if (embedNode == nullptr) return kErrorNoHeapMemory; pool.fill(embedNode->getData()); addNode(embedNode); return kErrorOk; }
Error CodeBuilder::embedConstPool(const Label& label, const ConstPool& pool) { if (_lastError) return _lastError; if (!isLabelValid(label)) return setLastError(DebugUtils::errored(kErrorInvalidLabel)); ASMJIT_PROPAGATE(align(kAlignData, static_cast<uint32_t>(pool.getAlignment()))); ASMJIT_PROPAGATE(bind(label)); CBData* node = newDataNode(nullptr, static_cast<uint32_t>(pool.getSize())); if (ASMJIT_UNLIKELY(!node)) return setLastError(DebugUtils::errored(kErrorNoHeapMemory)); pool.fill(node->getData()); addNode(node); return kErrorOk; }
Error X86Compiler::_newConst(BaseMem* mem, uint32_t scope, const void* data, size_t size) { Error error = kErrorOk; size_t offset; Label* dstLabel; ConstPool* dstPool; if (scope == kConstScopeLocal) { dstLabel = &_localConstPoolLabel; dstPool = &_localConstPool; } else if (scope == kConstScopeGlobal) { dstLabel = &_globalConstPoolLabel; dstPool = &_globalConstPool; } else { error = kErrorInvalidArgument; goto _OnError; } error = dstPool->add(data, size, offset); if (error != kErrorOk) goto _OnError; if (dstLabel->getId() == kInvalidValue) { *dstLabel = newLabel(); if (!dstLabel->isInitialized()) { error = kErrorNoHeapMemory; goto _OnError; } } *static_cast<X86Mem*>(mem) = x86::ptr(*dstLabel, static_cast<int32_t>(offset), static_cast<uint32_t>(size)); return kErrorOk; _OnError: return error; }