mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
LibJS: Implement extract_pointer_bits for ppc64
On PowerPC 64 pointers can use all 64 bits, however by convention on Linux user-space addresses use only the lower 43 bits. I'm not 100% certain that the masking off of the 16 high bits is the proper solution, but it matches the rest of the LibJS code which assumes pointers only use the lower 48 bits. https://www.kernel.org/doc/ols/2001/ppc64.pdf
This commit is contained in:
parent
7604d15b99
commit
e007c24ec9
Notes:
sideshowbarker
2024-07-17 03:25:24 +09:00
Author: https://github.com/sideeffect42 Commit: https://github.com/LadybirdBrowser/ladybird/commit/e007c24ec9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/504
|
@ -435,8 +435,11 @@ public:
|
||||||
// For x86_64 and riscv64 the top 16 bits should be sign extending the "real" top bit (47th).
|
// For x86_64 and riscv64 the top 16 bits should be sign extending the "real" top bit (47th).
|
||||||
// So first shift the top 16 bits away then using the right shift it sign extends the top 16 bits.
|
// So first shift the top 16 bits away then using the right shift it sign extends the top 16 bits.
|
||||||
return static_cast<FlatPtr>((static_cast<i64>(encoded << 16)) >> 16);
|
return static_cast<FlatPtr>((static_cast<i64>(encoded << 16)) >> 16);
|
||||||
#elif ARCH(AARCH64)
|
#elif ARCH(AARCH64) || ARCH(PPC64) || ARCH(PPC64LE)
|
||||||
// For AArch64 the top 16 bits of the pointer should be zero.
|
// For AArch64 the top 16 bits of the pointer should be zero.
|
||||||
|
// For PPC64: all 64 bits can be used for pointers, however on Linux only
|
||||||
|
// the lower 43 bits are used for user-space addresses, so
|
||||||
|
// masking off the top 16 bits should match the rest of LibJS.
|
||||||
return static_cast<FlatPtr>(encoded & 0xffff'ffff'ffffULL);
|
return static_cast<FlatPtr>(encoded & 0xffff'ffff'ffffULL);
|
||||||
#else
|
#else
|
||||||
# error "Unknown architecture. Don't know whether pointers need to be sign-extended."
|
# error "Unknown architecture. Don't know whether pointers need to be sign-extended."
|
||||||
|
|
Loading…
Reference in a new issue