| ... | ... |
@@ -236,7 +236,7 @@ |
| 236 | 236 |
|
| 237 | 237 |
//! Cross-platform solution to get offset of `_Field_` in `_Struct_`. |
| 238 | 238 |
#define ASMJIT_OFFSET_OF(_Struct_, _Field_) \ |
| 239 |
- (reinterpret_cast<size_t>(reinterpret_cast<const uint8_t*>(&reinterpret_cast<const _Struct_*>(0x1)->_Field_)) - 1) |
|
| 239 |
+ (reinterpret_cast<intptr_t>(reinterpret_cast<const uint8_t*>(&reinterpret_cast<const _Struct_*>(0x1)->_Field_)) - 1) |
|
| 240 | 240 |
|
| 241 | 241 |
// ============================================================================ |
| 242 | 242 |
// [asmjit::build - ASMJIT_ARRAY_SIZE] |
| ... | ... |
@@ -316,21 +316,21 @@ Error X86Assembler::embedLabel(const Label& op) {
|
| 316 | 316 |
uint8_t* cursor = getCursor(); |
| 317 | 317 |
|
| 318 | 318 |
LabelData* label = getLabelData(op.getId()); |
| 319 |
- RelocData reloc; |
|
| 319 |
+ RelocData rd; |
|
| 320 | 320 |
|
| 321 | 321 |
#ifndef ASMJIT_DISABLE_LOGGER |
| 322 | 322 |
if (_logger) |
| 323 | 323 |
_logger->logFormat(kLoggerStyleData, regSize == 4 ? ".dd L%u\n" : ".dq L%u\n", op.getId()); |
| 324 | 324 |
#endif // !ASMJIT_DISABLE_LOGGER |
| 325 | 325 |
|
| 326 |
- reloc.type = kRelocRelToAbs; |
|
| 327 |
- reloc.size = regSize; |
|
| 328 |
- reloc.from = static_cast<Ptr>(getOffset()); |
|
| 329 |
- reloc.data = 0; |
|
| 326 |
+ rd.type = kRelocRelToAbs; |
|
| 327 |
+ rd.size = regSize; |
|
| 328 |
+ rd.from = static_cast<Ptr>(getOffset()); |
|
| 329 |
+ rd.data = 0; |
|
| 330 | 330 |
|
| 331 | 331 |
if (label->offset != -1) {
|
| 332 | 332 |
// Bound label. |
| 333 |
- reloc.data = static_cast<Ptr>(static_cast<SignedPtr>(label->offset)); |
|
| 333 |
+ rd.data = static_cast<Ptr>(static_cast<SignedPtr>(label->offset)); |
|
| 334 | 334 |
} |
| 335 | 335 |
else {
|
| 336 | 336 |
// Non-bound label. Need to chain. |
| ... | ... |
@@ -344,7 +344,7 @@ Error X86Assembler::embedLabel(const Label& op) {
|
| 344 | 344 |
label->links = link; |
| 345 | 345 |
} |
| 346 | 346 |
|
| 347 |
- if (_relocList.append(reloc) != kErrorOk) |
|
| 347 |
+ if (_relocList.append(rd) != kErrorOk) |
|
| 348 | 348 |
return setError(kErrorNoHeapMemory); |
| 349 | 349 |
|
| 350 | 350 |
// Emit dummy intptr_t (4 or 8 bytes; depends on the address size). |
| ... | ... |
@@ -495,22 +495,22 @@ size_t X86Assembler::_relocCode(void* _dst, Ptr baseAddress) const {
|
| 495 | 495 |
|
| 496 | 496 |
// Relocate all recorded locations. |
| 497 | 497 |
size_t relocCount = _relocList.getLength(); |
| 498 |
- const RelocData* relocData = _relocList.getData(); |
|
| 498 |
+ const RelocData* rdList = _relocList.getData(); |
|
| 499 | 499 |
|
| 500 | 500 |
for (size_t i = 0; i < relocCount; i++) {
|
| 501 |
- const RelocData& r = relocData[i]; |
|
| 501 |
+ const RelocData& rd = rdList[i]; |
|
| 502 | 502 |
|
| 503 | 503 |
// Make sure that the `RelocData` is correct. |
| 504 |
- Ptr ptr = r.data; |
|
| 504 |
+ Ptr ptr = rd.data; |
|
| 505 | 505 |
|
| 506 |
- size_t offset = static_cast<size_t>(r.from); |
|
| 507 |
- ASMJIT_ASSERT(offset + r.size <= static_cast<Ptr>(maxCodeSize)); |
|
| 506 |
+ size_t offset = static_cast<size_t>(rd.from); |
|
| 507 |
+ ASMJIT_ASSERT(offset + rd.size <= static_cast<Ptr>(maxCodeSize)); |
|
| 508 | 508 |
|
| 509 | 509 |
// Whether to use trampoline, can be only used if relocation type is |
| 510 | 510 |
// kRelocAbsToRel on 64-bit. |
| 511 | 511 |
bool useTrampoline = false; |
| 512 | 512 |
|
| 513 |
- switch (r.type) {
|
|
| 513 |
+ switch (rd.type) {
|
|
| 514 | 514 |
case kRelocAbsToAbs: |
| 515 | 515 |
break; |
| 516 | 516 |
|
| ... | ... |
@@ -519,13 +519,13 @@ size_t X86Assembler::_relocCode(void* _dst, Ptr baseAddress) const {
|
| 519 | 519 |
break; |
| 520 | 520 |
|
| 521 | 521 |
case kRelocAbsToRel: |
| 522 |
- ptr -= baseAddress + r.from + 4; |
|
| 522 |
+ ptr -= baseAddress + rd.from + 4; |
|
| 523 | 523 |
break; |
| 524 | 524 |
|
| 525 | 525 |
case kRelocTrampoline: |
| 526 |
- ptr -= baseAddress + r.from + 4; |
|
| 526 |
+ ptr -= baseAddress + rd.from + 4; |
|
| 527 | 527 |
if (!IntUtil::isInt32(static_cast<SignedPtr>(ptr))) {
|
| 528 |
- ptr = reinterpret_cast<Ptr>(tramp) - (baseAddress + r.from + 4); |
|
| 528 |
+ ptr = reinterpret_cast<Ptr>(tramp) - (baseAddress + rd.from + 4); |
|
| 529 | 529 |
useTrampoline = true; |
| 530 | 530 |
} |
| 531 | 531 |
break; |
| ... | ... |
@@ -534,7 +534,7 @@ size_t X86Assembler::_relocCode(void* _dst, Ptr baseAddress) const {
|
| 534 | 534 |
ASMJIT_ASSERT(!"Reached"); |
| 535 | 535 |
} |
| 536 | 536 |
|
| 537 |
- switch (r.size) {
|
|
| 537 |
+ switch (rd.size) {
|
|
| 538 | 538 |
case 8: |
| 539 | 539 |
*reinterpret_cast<int64_t*>(dst + offset) = static_cast<int64_t>(ptr); |
| 540 | 540 |
break; |
| ... | ... |
@@ -566,14 +566,14 @@ size_t X86Assembler::_relocCode(void* _dst, Ptr baseAddress) const {
|
| 566 | 566 |
dst[offset - 1] = byte1; |
| 567 | 567 |
|
| 568 | 568 |
// Absolute address. |
| 569 |
- reinterpret_cast<uint64_t*>(tramp)[0] = static_cast<uint64_t>(r.data); |
|
| 569 |
+ reinterpret_cast<uint64_t*>(tramp)[0] = static_cast<uint64_t>(rd.data); |
|
| 570 | 570 |
|
| 571 | 571 |
// Advance trampoline pointer. |
| 572 | 572 |
tramp += 8; |
| 573 | 573 |
|
| 574 | 574 |
#ifndef ASMJIT_DISABLE_LOGGER |
| 575 | 575 |
if (logger) |
| 576 |
- logger->logFormat(kLoggerStyleComment, "; Trampoline %llX\n", r.data); |
|
| 576 |
+ logger->logFormat(kLoggerStyleComment, "; Trampoline %llX\n", rd.data); |
|
| 577 | 577 |
#endif // !ASMJIT_DISABLE_LOGGER |
| 578 | 578 |
} |
| 579 | 579 |
} |
| ... | ... |
@@ -3655,18 +3655,20 @@ _EmitSib: |
| 3655 | 3655 |
label = self->getLabelData(rmMem->_vmem.base); |
| 3656 | 3656 |
relocId = self->_relocList.getLength(); |
| 3657 | 3657 |
|
| 3658 |
- RelocData reloc; |
|
| 3659 |
- reloc.type = kRelocRelToAbs; |
|
| 3660 |
- reloc.size = 4; |
|
| 3661 |
- reloc.from = static_cast<Ptr>(static_cast<uintptr_t>(cursor - self->_buffer)); |
|
| 3662 |
- reloc.data = static_cast<SignedPtr>(dispOffset); |
|
| 3658 |
+ {
|
|
| 3659 |
+ RelocData rd; |
|
| 3660 |
+ rd.type = kRelocRelToAbs; |
|
| 3661 |
+ rd.size = 4; |
|
| 3662 |
+ rd.from = static_cast<Ptr>(static_cast<uintptr_t>(cursor - self->_buffer)); |
|
| 3663 |
+ rd.data = static_cast<SignedPtr>(dispOffset); |
|
| 3663 | 3664 |
|
| 3664 |
- if (self->_relocList.append(reloc) != kErrorOk) |
|
| 3665 |
- return self->setError(kErrorNoHeapMemory); |
|
| 3665 |
+ if (self->_relocList.append(rd) != kErrorOk) |
|
| 3666 |
+ return self->setError(kErrorNoHeapMemory); |
|
| 3667 |
+ } |
|
| 3666 | 3668 |
|
| 3667 | 3669 |
if (label->offset != -1) {
|
| 3668 | 3670 |
// Bound label. |
| 3669 |
- reloc.data += static_cast<SignedPtr>(label->offset); |
|
| 3671 |
+ self->_relocList[relocId].data += static_cast<SignedPtr>(label->offset); |
|
| 3670 | 3672 |
EMIT_DWORD(0); |
| 3671 | 3673 |
} |
| 3672 | 3674 |
else {
|
| ... | ... |
@@ -3925,18 +3927,20 @@ _EmitAvxV: |
| 3925 | 3927 |
label = self->getLabelData(rmMem->_vmem.base); |
| 3926 | 3928 |
relocId = self->_relocList.getLength(); |
| 3927 | 3929 |
|
| 3928 |
- RelocData reloc; |
|
| 3929 |
- reloc.type = kRelocRelToAbs; |
|
| 3930 |
- reloc.size = 4; |
|
| 3931 |
- reloc.from = static_cast<Ptr>(static_cast<uintptr_t>(cursor - self->_buffer)); |
|
| 3932 |
- reloc.data = static_cast<SignedPtr>(dispOffset); |
|
| 3930 |
+ {
|
|
| 3931 |
+ RelocData rd; |
|
| 3932 |
+ rd.type = kRelocRelToAbs; |
|
| 3933 |
+ rd.size = 4; |
|
| 3934 |
+ rd.from = static_cast<Ptr>(static_cast<uintptr_t>(cursor - self->_buffer)); |
|
| 3935 |
+ rd.data = static_cast<SignedPtr>(dispOffset); |
|
| 3933 | 3936 |
|
| 3934 |
- if (self->_relocList.append(reloc) != kErrorOk) |
|
| 3935 |
- return self->setError(kErrorNoHeapMemory); |
|
| 3937 |
+ if (self->_relocList.append(rd) != kErrorOk) |
|
| 3938 |
+ return self->setError(kErrorNoHeapMemory); |
|
| 3939 |
+ } |
|
| 3936 | 3940 |
|
| 3937 | 3941 |
if (label->offset != -1) {
|
| 3938 | 3942 |
// Bound label. |
| 3939 |
- reloc.data += static_cast<SignedPtr>(label->offset); |
|
| 3943 |
+ self->_relocList[relocId].data += static_cast<SignedPtr>(label->offset); |
|
| 3940 | 3944 |
EMIT_DWORD(0); |
| 3941 | 3945 |
} |
| 3942 | 3946 |
else {
|