summary refs log tree commit diff stats
path: root/results/scraper/fex/1791
blob: 8c882dd384c99f45b07768090cb7c29da90a97eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Aggressive spilling when initializing large unordered_maps
While working on #1760, I hit an interesting edge case in our JIT: Initializing large `std::unordered_map`s (>3000 entries) causes the JIT to spill a lot of registers, but only if the running application was compiled with optimizations enabled.

Steps to reproduce:
1. Write a list of all libGL functions to `mylist.inl` using
```
<FEX-build-folder>/Bin/thunkgen ThunkLibs/libGL/libGL_interface.cpp libGL -symbol_list mylist.inl -- -std=c++17 -isystem ThunkLibs/include/
```
2. Create a new file called `test.cpp` with these contents:
```cpp
#include <cstdint>
#include <unordered_map>
#include <string_view>
#include "mylist.inl"

static std::unordered_map<std::string_view, uintptr_t> HostPtrInvokers{};

int main() {
#define PAIR(name, unused) { #name, 0 },
  HostPtrInvokers = {
    FOREACH_internal_SYMBOL(PAIR)
  };
}
```
3. Compile for x86-64 using `x86_64-linux-gnu-g++ -O0 test.cpp`. Running the output binary in FEX should quickly finish.
4. Compile for x86-64 using `x86_64-linux-gnu-g++ -O2 test.cpp`. This optimized binary takes several seconds to run in FEX