Top


定義場所(file name)

hotspot/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp

名前(function name)

void ThreadLocalStorage::pd_set_thread(Thread* thread) {

本体部(body)

  {- -------------------------------------------
  (1) os::thread_local_storage_at_put() を呼んで Thread オブジェクトを登録
      ---------------------------------------- -}

      os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);

  {- -------------------------------------------
  (1) x86-32 の場合は, 
      ThreadLocalStorage::_sp_map 配列の中で
      このネイティブスレッドのスタック領域(stack base から stack top まで)に該当する範囲を
      登録対象の Thread オブジェクトに変更しておく.
      (See: ThreadLocalStorage)
      ---------------------------------------- -}

    #ifndef AMD64
      address stack_top = os::current_stack_base();
      size_t stack_size = os::current_stack_size();

      for (address p = stack_top - stack_size; p < stack_top; p += PAGE_SIZE) {
        // pd_set_thread() is called with non-NULL value when a new thread is
        // created/attached, or with NULL value when a thread is about to exit.
        // If both "thread" and the corresponding _sp_map[] entry are non-NULL,
        // they should have the same value. Otherwise it might indicate that the
        // stack page is shared by multiple threads. However, a more likely cause
        // for this assertion to fail is that an attached thread exited without
        // detaching itself from VM, which is a program error and could cause VM
        // to crash.
        assert(thread == NULL || _sp_map[(uintptr_t)p >> PAGE_SHIFT] == NULL ||
               thread == _sp_map[(uintptr_t)p >> PAGE_SHIFT],
               "thread exited without detaching from VM??");
        _sp_map[(uintptr_t)p >> PAGE_SHIFT] = thread;
      }
    #endif // !AMD64
    }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.