-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Serialize negative constants according to the operand type #118814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9a24051
3831af7
4686534
98ce373
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12646,16 +12646,32 @@ void emitter::emitDispConstant(const instrDesc* id, bool skipComma) const | |||||
|
|
||||||
| if ((val > -1000) && (val < 1000)) | ||||||
| { | ||||||
| printf("%d", (int)val); | ||||||
| } | ||||||
| else if ((val > 0) || (val < -0xFFFFFF)) | ||||||
| { | ||||||
| printf("0x%zX", (ssize_t)val); | ||||||
| printf("%d", static_cast<int>(val)); | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| // (val < 0) | ||||||
| printf("-0x%zX", (ssize_t)-val); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The below code will never print negative values anymore. I do not think we want that to change. FWIW, the jit disasm is a power user scenario for curious users only. It is not meant to be full fidelity/correct assembly output, and in various cases the produced disassembly will not be fully faithful. That is expected. |
||||||
| switch (id->idOpSize()) | ||||||
| { | ||||||
| case EA_1BYTE: | ||||||
| printf("0x%X", static_cast<uint8_t>(val)); | ||||||
| break; | ||||||
|
|
||||||
| case EA_2BYTE: | ||||||
| printf("0x%X", static_cast<uint16_t>(val)); | ||||||
| break; | ||||||
|
|
||||||
| case EA_4BYTE: | ||||||
| printf("0x%X", static_cast<uint32_t>(val)); | ||||||
| break; | ||||||
|
|
||||||
| case EA_8BYTE: | ||||||
| printf("0x%X", static_cast<uint64_t>(val)); | ||||||
|
||||||
| printf("0x%X", static_cast<uint64_t>(val)); | |
| printf("0x%llX", static_cast<unsigned long long>(val)); |
Copilot
AI
Aug 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting a potentially negative ssize_t value to size_t (unsigned) may not preserve the intended bit pattern. Consider using the original (ssize_t)val cast to maintain sign information, or ensure the truncation behavior is intentional.
| printf("0x%zX", static_cast<size_t>(val)); | |
| printf("0x%zX", static_cast<ssize_t>(val)); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we were printing decimal here not hex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes! Good catch. Fixed.