< prev index next >
src/hotspot/os/solaris/os_solaris.cpp
Print this page
rev 52189 : [mq]: tinit
@@ -722,31 +722,32 @@
static thread_t main_thread;
// Thread start routine for all newly created threads
extern "C" void* thread_native_entry(void* thread_addr) {
+
+ Thread* thread = (Thread*)thread_addr;
+
+ thread->record_stack_base_and_size();
+
// Try to randomize the cache line index of hot stack frames.
// This helps when threads of the same stack traces evict each other's
// cache lines. The threads can be either from the same JVM instance, or
// from different JVM instances. The benefit is especially true for
// processors with hyperthreading technology.
static int counter = 0;
int pid = os::current_process_id();
alloca(((pid ^ counter++) & 7) * 128);
int prio;
- Thread* thread = (Thread*)thread_addr;
thread->initialize_thread_current();
OSThread* osthr = thread->osthread();
osthr->set_lwp_id(_lwp_self()); // Store lwp in case we are bound
- log_info(os, thread)("Thread is alive (tid: " UINTX_FORMAT ").",
- os::current_thread_id());
-
if (UseNUMA) {
int lgrp_id = os::numa_get_group_id();
if (lgrp_id != -1) {
thread->set_lgrp_id(lgrp_id);
}
@@ -773,11 +774,14 @@
assert(osthr->get_state() == RUNNABLE, "invalid os thread state");
// initialize signal mask for this thread
os::Solaris::hotspot_sigmask(thread);
- thread->run();
+ os::Solaris::init_thread_fpu_state();
+ std::set_terminate(_handle_uncaught_cxx_exception);
+
+ thread->call_run();
// One less thread is executing
// When the VMThread gets here, the main thread may have already exited
// which frees the CodeHeap containing the Atomic::dec code
if (thread != VMThread::vm_thread() && VMThread::vm_thread() != NULL) {
@@ -1092,14 +1096,16 @@
void _handle_uncaught_cxx_exception() {
VMError::report_and_die("An uncaught C++ exception");
}
+// CR 7190089: on Solaris, primordial thread's stack is adjusted
+// in initialize_thread(). Without the adjustment, stack size is
+// incorrect if stack is set to unlimited (ulimit -s unlimited).
+void os::Solaris::correct_stack_boundaries_for_primordial_thread(Thread* thr) {
+ assert(is_primordial_thread(), "Call only for primordial thread");
-// First crack at OS-specific initialization, from inside the new thread.
-void os::initialize_thread(Thread* thr) {
- if (is_primordial_thread()) {
JavaThread* jt = (JavaThread *)thr;
assert(jt != NULL, "Sanity check");
size_t stack_size;
address base = jt->stack_base();
if (Arguments::created_by_java_launcher()) {
@@ -1116,11 +1122,11 @@
// 6269555: If we were not created by a Java launcher, i.e. if we are
// running embedded in a native application, treat the primordial thread
// as much like a native attached thread as possible. This means using
// the current stack size from thr_stksegment(), unless it is too large
// to reliably setup guard pages. A reasonable max size is 8MB.
- size_t current_size = current_stack_size();
+ size_t current_size = os::current_stack_size();
// This should never happen, but just in case....
if (current_size == 0) current_size = 2 * K * K;
stack_size = current_size > (8 * K * K) ? (8 * K * K) : current_size;
}
address bottom = align_up(base - stack_size, os::vm_page_size());;
@@ -1142,17 +1148,11 @@
vm_exit(1);
}
assert(jt->stack_size() >= stack_size,
"Attempt to map more stack than was allocated");
jt->set_stack_size(stack_size);
- }
- // With the T2 libthread (T1 is no longer supported) threads are always bound
- // and we use stackbanging in all cases.
-
- os::Solaris::init_thread_fpu_state();
- std::set_terminate(_handle_uncaught_cxx_exception);
}
// Free Solaris resources related to the OSThread
< prev index next >