Moving threading utils to poly.
This commit is contained in:
@@ -29,21 +29,20 @@
|
||||
#include <alloy/hir/hir_builder.h>
|
||||
#include <alloy/runtime/runtime.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::backend;
|
||||
using namespace alloy::backend::x64;
|
||||
using namespace alloy::hir;
|
||||
using namespace alloy::runtime;
|
||||
namespace alloy {
|
||||
namespace backend {
|
||||
namespace x64 {
|
||||
|
||||
using namespace Xbyak;
|
||||
|
||||
// TODO(benvanik): direct usings.
|
||||
using namespace alloy::hir;
|
||||
using namespace alloy::runtime;
|
||||
|
||||
// Utilities/types used only in this file:
|
||||
#include <alloy/backend/x64/x64_sequence.inl>
|
||||
|
||||
namespace {
|
||||
static std::unordered_multimap<uint32_t, SequenceSelectFn> sequence_table;
|
||||
} // namespace
|
||||
|
||||
std::unordered_multimap<uint32_t, SequenceSelectFn> sequence_table;
|
||||
|
||||
// Selects the right byte/word/etc from a vector. We need to flip logical
|
||||
// indices (0,1,2,3,4,5,6,7,...) = (3,2,1,0,7,6,5,4,...)
|
||||
@@ -5121,3 +5120,7 @@ bool alloy::backend::x64::SelectSequence(X64Emitter& e, const Instr* i, const In
|
||||
XELOGE("No sequence match for variant %s", i->opcode->name);
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace x64
|
||||
} // namespace backend
|
||||
} // namespace alloy
|
||||
|
||||
@@ -48,7 +48,7 @@ Entry::Status EntryTable::GetOrCreate(uint64_t address, Entry** out_entry) {
|
||||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
Sleep(0);
|
||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
||||
lock_.lock();
|
||||
} while (entry->status == Entry::STATUS_COMPILING);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ SymbolInfo* Module::LookupSymbol(uint64_t address, bool wait) {
|
||||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
Sleep(0);
|
||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
||||
lock_.lock();
|
||||
} while (symbol_info->status() == SymbolInfo::STATUS_DECLARING);
|
||||
} else {
|
||||
@@ -75,7 +75,7 @@ SymbolInfo::Status Module::DeclareSymbol(SymbolInfo::Type type,
|
||||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
Sleep(0);
|
||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
||||
lock_.lock();
|
||||
} while (symbol_info->status() == SymbolInfo::STATUS_DECLARING);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ SymbolInfo::Status Module::DefineSymbol(SymbolInfo* symbol_info) {
|
||||
do {
|
||||
lock_.unlock();
|
||||
// TODO(benvanik): sleep for less time?
|
||||
Sleep(0);
|
||||
poly::threading::Sleep(std::chrono::microseconds(100));
|
||||
lock_.lock();
|
||||
} while (symbol_info->status() == SymbolInfo::STATUS_DEFINING);
|
||||
status = symbol_info->status();
|
||||
|
||||
@@ -26,7 +26,7 @@ ThreadState::ThreadState(Runtime* runtime, uint32_t thread_id)
|
||||
if (thread_id_ == UINT_MAX) {
|
||||
// System thread. Assign the system thread ID with a high bit
|
||||
// set so people know what's up.
|
||||
uint32_t system_thread_handle = GetCurrentThreadId();
|
||||
uint32_t system_thread_handle = poly::threading::current_thread_id();
|
||||
thread_id_ = 0x80000000 | system_thread_handle;
|
||||
}
|
||||
backend_data_ = runtime->backend()->AllocThreadData();
|
||||
|
||||
Reference in New Issue
Block a user