Commit Graph

39 Commits

Author SHA1 Message Date
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Simon Wanner
1d68c64b98 LibX86: Apply REX.W to B9-BF MOVs
All the MOVs in the B8-BF range can use the REX.W prefix, not just B8.
Previously instructions like `48 B9... mov rcx, imm64` were interpreted
as `mov rcx, imm32` because the REX.W prefix was only applied to
`48 B8... mov rax, imm64`.
2023-10-27 21:49:55 +02:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Simon Wanner
0c8da1478a LibX86: Use '+' format parameter to include signs for displacements 2022-11-26 12:50:38 +01:00
Simon Wanner
2ae228dac7 LibX86: Add basic x86-64 support
Most of the 64-bit instructions default to 32-bit operands and select
64-bit using REX.W prefixes. Because of that instead of defining new
instruction formats, this reuses the 32-bit formats and changes them
to take the REX prefixes into account when necessary.

Additionally this removes, adds or modifies the instruction
descriptors in the 64-bit table, where they are different from 32-bit.

Using 'disasm' these changes seem to cover pretty much all of our
64-bit binaries (except for AVX) :^)

Note that UserspaceEmulator will need to account for these prefixed
versions in its 32-bit instruction handlers before being usable on
x86-64.
2022-11-26 12:50:38 +01:00
Simon Wanner
735fd5f5db LibX86: Split up the ModRM and SIB bytes into multiple members
This will allow adding extra bits with REX prefixes
2022-11-26 12:50:38 +01:00
Simon Wanner
4041ea835c LibX86: Add OP_regW_immW
This is a variation of OP_reg32_imm32 that turns into
"OP_reg64_imm64" with a REX.W prefix.
2022-11-26 12:50:38 +01:00
Simon Wanner
ab1f28d566 LibX86: Templatize the opcode table builders 2022-11-26 12:50:38 +01:00
Simon Wanner
06ece474e9 LibX86: Add {Address,Operand}Size::Size64
For now the opcode tables for OperandSize::Size64 are empty
2022-11-26 12:50:38 +01:00
Simon Wanner
a7268c3c74 LibX86+UserspaceEmulator: Introduce AddressSize and OperandSize enums
These replace the bools a32 and o32, which will make implementing
64-bit sizes possible. :^)
2022-11-26 12:50:38 +01:00
Nico Weber
2af028132a AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most places
Doesn't use them in libc headers so that those don't have to pull in
AK/Platform.h.

AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is
defined in clang builds as well.) Using AK_COMPILER_GCC simplifies
things some.

AK_COMPILER_CLANG isn't as much of a win, other than that it's
consistent with AK_COMPILER_GCC.
2022-10-04 23:35:07 +01:00
Brian Gianforcaro
d0a1775369 Everywhere: Fix a variety of typos
Spelling fixes found by `codespell`.
2022-09-14 04:46:49 +00:00
sin-ack
c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack
a4c251f858 LibX86: Convert register names to StringViews 2022-07-12 23:11:35 +02:00
Hendiadyoin1
f602bbf135 LibX86+disasm: Use an output format closer to objdump
This mainly does two things,
1. Removes spaces after commas
2. Elides "0x" and leading zeros in most contexts

Remaining differences are:
1. objdump always has memory size annotations
   We lack these and probably have some annotations wrong
2. Boolean check names
   We use jump-zero, while objdump uses jump-equal for example
3. We sometimes add "00 00" symbols, which objdump elides
4. We always demangle (This is a good thing)
5. We always resolve relocations (This is a good thing)
6. We seem to detect some symbols differently/incorrectly
2022-04-07 16:50:34 +02:00
Hendiadyoin1
7ba2e5e3e7 LibX86: Add CMPXCHG8B, RDRAND and RDSEED
With this we can run following script with no errors:
```sh
for /usr/lib/*.so {
    disasm "$it" > /dev/zero
}
```
2022-04-06 18:30:22 +02:00
Hendiadyoin1
3e3b677852 LibX86: Support SSE2 :^)
This allows disassembly of binaries with SSE2 instructions in them.
SSE2 also extends all MMX instructions without affecting the mnemonic,
therefore these are just directed to the same function for now.
The UserspaceEmulator does not know this as of
this commit.
2022-04-06 18:30:22 +02:00
Hendiadyoin1
fd2af972ed LibX86: Correct CVTSS2SI's register signature
This was annotated the wrong way around.
2022-04-06 18:30:22 +02:00
Hendiadyoin1
b7a8cfdde9 LibX86: Correctly name CVTTSS2SI_r32_xmm2m32
This was previously erroneously called CVTTPS2PI_r32_xmm2m32, while
the mnemonic was correctly CVTTSS2SI.
2022-04-02 18:37:38 +02:00
Hendiadyoin1
1432b6ab0a LibX86: Use the correct code for UNPCKLS
We were accidentally using 0x15, which was immediately overridden by
UNPCKHS
2022-04-02 18:37:38 +02:00
Hendiadyoin1
3cae69a6c2 LibX86: Correctly name the first xmm argument
We were accidentally calling it a mm-register
2022-04-02 18:37:38 +02:00
Hendiadyoin1
f951849fd5 LibX86: Don't print repz prefix for SSE instructions 2022-04-02 18:37:38 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
mjz19910
10ec98dd38 Everywhere: Fix spelling mistakes 2022-01-07 15:44:42 +01:00
Hediadyoin1
3ad6d87a45 LibX86: Add SSE support
This only adds the decodeing support for SSE, not SSE2, etc.
may contain traces of SSE2.
2021-10-17 13:06:23 -07:00
Brian Gianforcaro
18d6f9ed5c Libraries: Remove unused header includes 2021-08-01 08:10:16 +02:00
Hendiadyoin1
eb6af29421 LibX86: Add missing MovD and MovQ instructions
These are placeholders for now
2021-07-22 23:33:21 +02:00
Hendiadyoin1
efa42c4d45 LibX86: Use names closer to the spec for the Modrm
This gets rid of a lot of magic number shifts and ands.
2021-07-22 23:33:21 +02:00
Andreas Kling
e7136399a1 LibX86: Add INT1 instruction (needed for disassembly) 2021-07-20 18:05:05 +02:00
Linus Groh
d60ebbbba6 Revert "Userland: static vs non-static constexpr variables"
This reverts commit 800ea8ea96.

Booting the system no longer worked after these changes.
2021-05-21 10:30:52 +01:00
Lenny Maiorani
800ea8ea96 Userland: static vs non-static constexpr variables
Problem:
- `static` variables consume memory and sometimes are less
  optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
  every time the function is run.

Solution:
- If a global `static` variable is only used in a single function then
  move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
  `constexpr`.
2021-05-21 10:07:06 +01:00
Andreas Kling
32080452e3 LibX86: Convert StringBuilder::appendf() => AK::Format 2021-05-07 21:12:09 +02:00
Hendiadyoin1
f6aad70541 LibX86+UserspaceEmulator: Add MMX insns prototypes 2021-05-01 08:56:52 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
dba58ad9ec LibX86: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
13d7c09125 Libraries: Move to Userland/Libraries/ 2021-01-12 12:17:46 +01:00