| 456 | } |
| 457 | |
| 458 | Error CodeCompiler::_newConst(Mem& out, uint32_t scope, const void* data, size_t size) { |
| 459 | CBConstPool** pPool; |
| 460 | if (scope == kConstScopeLocal) |
| 461 | pPool = &_localConstPool; |
| 462 | else if (scope == kConstScopeGlobal) |
| 463 | pPool = &_globalConstPool; |
| 464 | else |
| 465 | return setLastError(DebugUtils::errored(kErrorInvalidArgument)); |
| 466 | |
| 467 | if (!*pPool && !(*pPool = newConstPool())) |
| 468 | return setLastError(DebugUtils::errored(kErrorNoHeapMemory)); |
| 469 | |
| 470 | CBConstPool* pool = *pPool; |
| 471 | size_t off; |
| 472 | |
| 473 | Error err = pool->add(data, size, off); |
| 474 | if (ASMJIT_UNLIKELY(err)) return setLastError(err); |
| 475 | |
| 476 | out = Mem(Init, |
| 477 | Label::kLabelTag, // Base type. |
| 478 | pool->getId(), // Base id. |
| 479 | 0, // Index type. |
| 480 | kInvalidValue, // Index id. |
| 481 | static_cast<int32_t>(off), // Offset. |
| 482 | static_cast<uint32_t>(size), // Size. |
| 483 | 0); // Flags. |
| 484 | return kErrorOk; |
| 485 | } |
| 486 | |
| 487 | Error CodeCompiler::alloc(Reg& reg) { |
| 488 | if (!reg.isVirtReg()) return kErrorOk; |