| 105 | // ============================================================================ |
| 106 | |
| 107 | Error CodeHolder::init(const CodeInfo& info) noexcept { |
| 108 | // Cannot reinitialize if it's locked or there is one or more CodeEmitter |
| 109 | // attached. |
| 110 | if (isInitialized()) |
| 111 | return DebugUtils::errored(kErrorAlreadyInitialized); |
| 112 | |
| 113 | // If we are just initializing there should be no emitters attached). |
| 114 | ASMJIT_ASSERT(_emitters == nullptr); |
| 115 | |
| 116 | // Create the default section and insert it to the `_sections` array. |
| 117 | Error err = _sections.willGrow(&_baseHeap); |
| 118 | if (err == kErrorOk) { |
| 119 | SectionEntry* se = _baseZone.allocZeroedT<SectionEntry>(); |
| 120 | if (ASMJIT_LIKELY(se)) { |
| 121 | se->_flags = SectionEntry::kFlagExec | SectionEntry::kFlagConst; |
| 122 | se->_setDefaultName('.', 't', 'e', 'x', 't'); |
| 123 | _sections.appendUnsafe(se); |
| 124 | } |
| 125 | else { |
| 126 | err = DebugUtils::errored(kErrorNoHeapMemory); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | if (ASMJIT_UNLIKELY(err)) { |
| 131 | _baseZone.reset(false); |
| 132 | return err; |
| 133 | } |
| 134 | else { |
| 135 | _codeInfo = info; |
| 136 | return kErrorOk; |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | void CodeHolder::reset(bool releaseMemory) noexcept { |
| 141 | CodeHolder_resetInternal(this, releaseMemory); |
nothing calls this directly
no test coverage detected