Nekotekina
ca5f0444bf
shared_ptr.hpp: add wait support for atomic_ptr<>
...
As well as default mask and value transformation function overload.
2020-12-15 12:52:21 +03:00
Nekotekina
4a883ba6ea
atomic.hpp: use SFINAE for waitable atomic detection
...
Add default_mask<> variable.
Refactor get_value<>().
2020-12-15 12:50:44 +03:00
Nekotekina
e321765c54
Split BEType.h to util/v128.hpp and util/to_endian.hpp
2020-12-13 16:34:45 +03:00
Nekotekina
09d293592e
shared_ptr.hpp: fix is_same_ptr<>() trait
...
Implemented as constexpr function.
2020-12-13 15:39:36 +03:00
Nekotekina
a6a5292cd7
Use uptr (std::uintptr_t alias)
2020-12-12 16:29:55 +03:00
Nekotekina
b59f142d4e
Move types.h to util/types.hpp
2020-12-12 15:12:01 +03:00
Nekotekina
6e05dcadb6
Reduce std::numeric_limits dependency
...
Please, stop pretending...
You need these templates for generic code.
In other words, in another templates.
Stop increasing compilation time for no reason.
2020-12-12 12:35:18 +03:00
Nekotekina
33c3977036
endian.hpp: minor simplification
...
And stop pretending...
2020-12-11 22:00:26 +03:00
Nekotekina
aa3aef4beb
std::chrono cleanup: always use steady_clock
2020-12-11 19:01:56 +03:00
Nekotekina
36c8654fb8
Remove HERE macro
...
Some cleanup.
Add location to some functions.
2020-12-10 12:30:22 +03:00
Nekotekina
e055d16b2c
Replace verify() with ensure() with auto src location.
...
Expression ensure(x) returns x.
Using comma operator removed.
2020-12-09 15:43:38 +03:00
Nekotekina
062c605eb1
atomic.hpp: fixup (rsp addressing)
2020-12-08 08:51:27 +03:00
RipleyTom
51dcb4a79d
Remove bom from .hpp files
2020-12-07 20:03:44 +03:00
Nekotekina
24e4e329ed
atomic.hpp: add atomic_t<bool> specialization
...
May be required in future, plus adds/hides some methods.
2020-12-07 17:13:12 +03:00
Nekotekina
b16cc618b5
atomic.hpp: add some features and optimizations
...
Add atomic_t<>::observe() (relaxed load)
Add atomic_fence_XXX() (barrier functions)
Get rid of MFENCE instruction, replace with no-op LOCK OR on stack.
Remove <atomic> dependence from stdafx.h and relevant headers.
2020-12-07 17:13:12 +03:00
Nekotekina
77aa9e58f2
shared_ptr.hpp: add trivial conversion for shared/single types
...
These conversions don't exist in std::shared_ptr-alike types.
But I don't want to bother with == operators until we have proper C++20.
Removed trivial conversion for atomic_ptr because it's heavyweight.
2020-12-07 15:33:28 +03:00
RipleyTom
af8c661a64
Remove BOM markers
2020-12-06 15:30:12 +03:00
Nekotekina
d1e7837422
atomic_t: cleanup type requirements
...
Add C++17 requirements.
Remove alignment requirements (auto-align type).
What's missing is to detect padding and forbid it.
2020-12-04 19:11:36 +03:00
Nekotekina
8efc22bd45
atomic.hpp: simplify and unify bit test instructions
...
Also make them available on all platform.
Rename some rare methods.
2020-12-04 14:33:38 +03:00
Nekotekina
983439076b
shared_ptr.hpp: fixups and updates
...
Fix atomic_ptr load() edge case.
Implement atomic_ptr::peek_op() to make possible to reduce load() overhead.
Implement atomic_ptr::compare_exchange() and friends.
Implement null_ptr constant, remove nullptr_t assignment/construction.
2020-12-04 14:10:53 +03:00
Nekotekina
019f566239
atomic.cpp: more phase splitting in notify_all()
2020-12-04 14:10:53 +03:00
Nekotekina
332410d20b
shared_ptr.hpp: improve atomic_ptr methods
2020-12-04 14:10:53 +03:00
Nekotekina
13a0b88755
atomic.cpp: improve hashtable access
...
Simplified, tried to use all ptr bits.
Try to prevent self-collisions (bug).
Hashtable size doubled (to 8 MiB).
2020-12-01 10:19:31 +03:00
Nekotekina
3b8e3a9714
stdafx.h: remove BOM from custom included headers
...
Also add warnings about adding them.
2020-11-29 15:35:05 +03:00
Nekotekina
872655369a
shared_ptr.hpp: fix critical bugs
...
Fix array initialization.
Fix reference counting.
Fix offset to refctr.
Add some features.
2020-11-27 14:32:41 +03:00
Nekotekina
b5d498ffda
Homebrew atomic_ptr rewritten (util/shared_ptr.hpp)
...
It's analogous to C++20 atomic std::shared_ptr
The following things brought into global namespace:
single_ptr
shared_ptr
atomic_ptr
make_single
2020-11-26 20:11:26 +03:00
Nekotekina
bd90e3e37f
atomic.cpp: shrink and simplify main hashtable
...
Reduce collision detection to 1 or 0 for now.
I think it should be offloaded to notifiers.
2020-11-26 20:11:26 +03:00
Nekotekina
8b6d615aa6
atomic.hpp: remove/deprecate incomplete notify features
...
Notification with "phantom value" could be useful in theory.
As an alternative way of sending signal from the notifier.
But current implementation is just useless.
Also fixed slow_mutex (not used anywhere).
2020-11-26 06:31:36 +03:00
Nekotekina
2b674d4d8c
utils::shm: allow 2M hugepages on demand
2020-11-25 10:41:17 +03:00
Nekotekina
487b572aa6
Linux: remove assertions on MADV_HUGEPAGE
...
It's a hint and is allowed to fail.
2020-11-25 10:41:17 +03:00
Nekotekina
600c0ea5ba
atomic.cpp: fix windows/std path
...
Always check condition after rearming internal semaphore.
2020-11-25 10:41:17 +03:00
Nekotekina
00e64920c8
Implement "slow mutex" without spin-waiting.
...
Benefits: only 1 byte.
Testing atomic wait.
2020-11-25 10:41:17 +03:00
Nekotekina
d8e9382573
asm.hpp: constexpr refactoring
...
Removed asm (what an irony), made many functions constexpr.
Removed some unused function, readding them should be trivial.
2020-11-24 13:20:40 +03:00
Nekotekina
ab248e170c
vm_native.cpp: add MADV_HUGEPAGE
...
It enables Transparend Huge Pages for some regions on Linux.
Although it can't be actively useful, it seems to do something.
Maybe it's even harmful for recompilers.
2020-11-24 12:31:11 +03:00
Nekotekina
27097cbcfe
atomic.hpp: alter atomic_storage<>::store a bit
...
Always fallback to exchange. May improve codegen on gcc.
2020-11-24 12:31:11 +03:00
Nekotekina
43952e18e2
Implement prefetch_write() and prefetch_exec() wrappers
...
Do some refactoring to prefetch_read() in util/asm.hpp as well.
Make all these function constexpr because they are no-ops.
2020-11-24 12:31:11 +03:00
Nekotekina
14fa96fdef
atomic.cpp: don't use empty notify callback
...
Instead, allow setting it to null and check for null.
Similar could be done for wait cb, but it's set for all named threads.
2020-11-24 01:09:04 +03:00
Nekotekina
16cc88dd0e
atomic.hpp: fix atomic_wait::list regression
...
Typo-regressions. Also improve static asserts.
2020-11-23 09:26:25 +03:00
Nekotekina
280f5f0b54
atomic.hpp: redefine op::ne to actually mean "not equal"
...
WTF is "native endianness", it's native by default.
2020-11-23 09:24:16 +03:00
Nekotekina
d70ab11477
atomic.cpp: remove redundant constexpr
...
Static initialization is all-zeros anyway.
But constexpr was killing my intellisense.
And probably also affected compile time.
Also make some internal structures hidden ("static").
2020-11-22 12:07:49 +03:00
Nekotekina
e89a568765
Attempt to fix Emu.Quit()
...
There was some kind of "initialization order fiasco" of g_fxo.
Not only should it be used after main, but also destroyed before exit.
2020-11-21 18:27:16 +03:00
Nekotekina
60cff6f3d4
Attempt to fix #9271
2020-11-21 07:09:48 +03:00
Nekotekina
5f010c2f4c
atomic.cpp: optimize "cond" allocation with TLS
...
Billions of events can reduce to thousands, saving CPU time a few s.
Only 4 slots are available (arbitrarily), and only 1 is usually used.
Other slots are used only for waiting on multiple atomics.
2020-11-20 19:13:22 +03:00
Nekotekina
6c18e00977
atomic.cpp: use deterministic "cond" allocation
...
Takes ~80 ns instead of ~40 ns, same about deallocation.
Loops don't exist here, only 4-level semaphore tree.
Worst case only happens with concurrence, not from looping.
This optimization is not really necessary at current state of RPCS3.
This is more like to test C++ compilers and MSVC u128 implementation.
2020-11-20 15:04:17 +03:00
Nekotekina
72ac1aa537
atomic.cpp: use some actual hash for hashtable (std::minstd_rand)
...
Should only take about 5ns for initialization.
Should also make collisions almost impossible.
I also suspect I fixed some bad bug in process...
2020-11-20 15:04:17 +03:00
Nekotekina
3dd48a24ce
atomic.cpp: remove tiny redundancy
2020-11-17 15:22:04 +03:00
Nekotekina
984e97cbdc
Potential fix for Linux compilation
2020-11-17 15:22:04 +03:00
Nekotekina
333fe9a561
atomic.cpp: fix notification on windows
2020-11-15 04:40:44 +03:00
Nekotekina
badb3dc2dd
atomic.cpp/threads: remove old wait callback
...
Add new wait callback which simply collects statistics.
Shift workarounds towards actual problem detection.
2020-11-14 18:16:27 +03:00
Nekotekina
3ac819ee70
atomic.cpp: fix waiting on multiple variables
...
Silly bugs are so silly...
2020-11-14 17:25:02 +03:00