X64: Fixed conversion between tread_id (int) and void*.

Thread id's are always int size values (generated from an int counter).

Review URL: http://codereview.chromium.org/113030


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1883 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
lrn@chromium.org 2009-05-06 13:11:56 +00:00
parent 275a27d6bd
commit 374dea34ef
2 changed files with 12 additions and 3 deletions

View File

@ -350,7 +350,16 @@ class Thread: public ThreadHandle {
static LocalStorageKey CreateThreadLocalKey();
static void DeleteThreadLocalKey(LocalStorageKey key);
static void* GetThreadLocal(LocalStorageKey key);
static int GetThreadLocalInt(LocalStorageKey key) {
return static_cast<int>(reinterpret_cast<intptr_t>(GetThreadLocal(key)));
}
static void SetThreadLocal(LocalStorageKey key, void* value);
static void SetThreadLocalInt(LocalStorageKey key, int value) {
SetThreadLocal(key, reinterpret_cast<void*>(static_cast<intptr_t>(value)));
}
static bool HasThreadLocal(LocalStorageKey key) {
return GetThreadLocal(key) != NULL;
}
// A hint to the scheduler to let another thread run.
static void YieldCPU();

View File

@ -309,13 +309,13 @@ void ThreadManager::MarkCompactEpilogue(bool is_compacting) {
int ThreadManager::CurrentId() {
return bit_cast<int, void*>(Thread::GetThreadLocal(thread_id_key));
return Thread::GetThreadLocalInt(thread_id_key);
}
void ThreadManager::AssignId() {
if (Thread::GetThreadLocal(thread_id_key) == NULL) {
Thread::SetThreadLocal(thread_id_key, bit_cast<void*, int>(next_id_++));
if (!Thread::HasThreadLocal(thread_id_key)) {
Thread::SetThreadLocalInt(thread_id_key, next_id_++);
}
}