161
162 address os::current_stack_pointer() {
163 register void *sp __asm__ ("sp");
164 return (address)sp;
165 }
166
167 static void current_stack_region(address* bottom, size_t* size) {
168 if (os::Linux::is_initial_thread()) {
169 // initial thread needs special handling because pthread_getattr_np()
170 // may return bogus value.
171 *bottom = os::Linux::initial_thread_stack_bottom();
172 *size = os::Linux::initial_thread_stack_size();
173 } else {
174 pthread_attr_t attr;
175
176 int rslt = pthread_getattr_np(pthread_self(), &attr);
177
178 // JVM needs to know exact stack location, abort if it fails
179 if (rslt != 0) {
180 if (rslt == ENOMEM) {
181 vm_exit_out_of_memory(0, "pthread_getattr_np");
182 } else {
183 fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
184 }
185 }
186
187 if (pthread_attr_getstack(&attr, (void**)bottom, size) != 0) {
188 fatal("Can not locate current stack attributes!");
189 }
190
191 pthread_attr_destroy(&attr);
192 }
193 assert(os::current_stack_pointer() >= *bottom &&
194 os::current_stack_pointer() < *bottom + *size, "just checking");
195 }
196
197 address os::current_stack_base() {
198 address bottom;
199 size_t size;
200 current_stack_region(&bottom, &size);
201 return bottom + size;
|
161
162 address os::current_stack_pointer() {
163 register void *sp __asm__ ("sp");
164 return (address)sp;
165 }
166
167 static void current_stack_region(address* bottom, size_t* size) {
168 if (os::Linux::is_initial_thread()) {
169 // initial thread needs special handling because pthread_getattr_np()
170 // may return bogus value.
171 *bottom = os::Linux::initial_thread_stack_bottom();
172 *size = os::Linux::initial_thread_stack_size();
173 } else {
174 pthread_attr_t attr;
175
176 int rslt = pthread_getattr_np(pthread_self(), &attr);
177
178 // JVM needs to know exact stack location, abort if it fails
179 if (rslt != 0) {
180 if (rslt == ENOMEM) {
181 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
182 } else {
183 fatal(err_msg("pthread_getattr_np failed with errno = %d", rslt));
184 }
185 }
186
187 if (pthread_attr_getstack(&attr, (void**)bottom, size) != 0) {
188 fatal("Can not locate current stack attributes!");
189 }
190
191 pthread_attr_destroy(&attr);
192 }
193 assert(os::current_stack_pointer() >= *bottom &&
194 os::current_stack_pointer() < *bottom + *size, "just checking");
195 }
196
197 address os::current_stack_base() {
198 address bottom;
199 size_t size;
200 current_stack_region(&bottom, &size);
201 return bottom + size;
|