| 141 | } |
| 142 | |
| 143 | Error BaseAssembler::embedDataArray(TypeId typeId, const void* data, size_t itemCount, size_t repeatCount) { |
| 144 | uint32_t deabstractDelta = TypeUtils::deabstractDeltaOfSize(registerSize()); |
| 145 | TypeId finalTypeId = TypeUtils::deabstract(typeId, deabstractDelta); |
| 146 | |
| 147 | if (ASMJIT_UNLIKELY(!TypeUtils::isValid(finalTypeId))) |
| 148 | return reportError(DebugUtils::errored(kErrorInvalidArgument)); |
| 149 | |
| 150 | if (itemCount == 0 || repeatCount == 0) |
| 151 | return kErrorOk; |
| 152 | |
| 153 | uint32_t typeSize = TypeUtils::sizeOf(finalTypeId); |
| 154 | Support::FastUInt8 of = 0; |
| 155 | |
| 156 | size_t dataSize = Support::mulOverflow(itemCount, size_t(typeSize), &of); |
| 157 | size_t totalSize = Support::mulOverflow(dataSize, repeatCount, &of); |
| 158 | |
| 159 | if (ASMJIT_UNLIKELY(of)) |
| 160 | return reportError(DebugUtils::errored(kErrorOutOfMemory)); |
| 161 | |
| 162 | CodeWriter writer(this); |
| 163 | ASMJIT_PROPAGATE(writer.ensureSpace(this, totalSize)); |
| 164 | |
| 165 | for (size_t i = 0; i < repeatCount; i++) |
| 166 | writer.emitData(data, dataSize); |
| 167 | |
| 168 | writer.done(this); |
| 169 | |
| 170 | #ifndef ASMJIT_NO_LOGGING |
| 171 | if (_logger) { |
| 172 | StringTmp<512> sb; |
| 173 | Formatter::formatData(sb, _logger->flags(), arch(), typeId, data, itemCount, repeatCount); |
| 174 | sb.append('\n'); |
| 175 | _logger->log(sb); |
| 176 | } |
| 177 | #endif |
| 178 | |
| 179 | return kErrorOk; |
| 180 | } |
| 181 | |
| 182 | #ifndef ASMJIT_NO_LOGGING |
| 183 | static const TypeId dataTypeIdBySize[9] = { |
nothing calls this directly
no test coverage detected