139 return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc());
140 }
141
142 frame os::current_frame() {
143 intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()();
144 frame myframe(sp, frame::unpatchable,
145 CAST_FROM_FN_PTR(address, os::current_frame));
146 if (os::is_first_C_frame(&myframe)) {
147 // stack is not walkable
148 return frame(NULL, frame::unpatchable, NULL);
149 } else {
150 return os::get_sender_for_C_frame(&myframe);
151 }
152 }
153
154 address os::current_stack_pointer() {
155 register void *sp __asm__ ("sp");
156 return (address)sp;
157 }
158
159 static void current_stack_region(address* bottom, size_t* size) {
160 if (os::Linux::is_initial_thread()) {
161 // initial thread needs special handling because pthread_getattr_np()
162 // may return bogus value.
163 *bottom = os::Linux::initial_thread_stack_bottom();
164 *size = os::Linux::initial_thread_stack_size();
165 } else {
166 pthread_attr_t attr;
167
168 int rslt = pthread_getattr_np(pthread_self(), &attr);
169
170 // JVM needs to know exact stack location, abort if it fails
171 if (rslt != 0) {
172 if (rslt == ENOMEM) {
173 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
174 } else {
175 fatal("pthread_getattr_np failed with errno = %d", rslt);
176 }
177 }
178
179 if (pthread_attr_getstack(&attr, (void**)bottom, size) != 0) {
180 fatal("Can not locate current stack attributes!");
181 }
182
183 pthread_attr_destroy(&attr);
184 }
185 assert(os::current_stack_pointer() >= *bottom &&
186 os::current_stack_pointer() < *bottom + *size, "just checking");
187 }
188
189 address os::current_stack_base() {
190 address bottom;
191 size_t size;
192 current_stack_region(&bottom, &size);
193 return bottom + size;
194 }
195
196 size_t os::current_stack_size() {
197 // stack size includes normal stack and HotSpot guard pages
198 address bottom;
199 size_t size;
200 current_stack_region(&bottom, &size);
201 return size;
202 }
203
204 char* os::non_memory_address_word() {
205 // Must never look like an address returned by reserve_memory,
206 // even in its subfields (as defined by the CPU immediate fields,
207 // if the CPU splits constants across multiple instructions).
208 // On SPARC, 0 != %hi(any real address), because there is no
209 // allocation in the first 1Kb of the virtual address space.
210 return (char*) 0;
211 }
212
213 void os::initialize_thread(Thread* thr) {}
214
215 void os::print_context(outputStream *st, const void *context) {
216 if (context == NULL) return;
217
218 const ucontext_t* uc = (const ucontext_t*)context;
219 sigcontext* sc = (sigcontext*)context;
220 st->print_cr("Registers:");
221
222 st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT
223 " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT,
718 if (addr != NULL) {
719 release_memory(addr, bytes);
720 }
721
722 return addr != NULL;
723 #endif // _LP64
724 }
725
726 ///////////////////////////////////////////////////////////////////////////////
727 // thread stack
728
729 size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
730 size_t os::Posix::_java_thread_min_stack_allowed = 128 * K;
731 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
732
733 // return default stack size for thr_type
734 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
735 // default stack size (compiler thread needs larger stack)
736 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
737 return s;
738 }
739
740 size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
741 // Creating guard page is very expensive. Java thread has HotSpot
742 // guard page, only enable glibc guard page for non-Java threads.
743 return (thr_type == java_thread ? 0 : page_size());
744 }
745
746 #ifndef PRODUCT
747 void os::verify_stack_alignment() {
748 }
749 #endif
750
751 int os::extra_bang_size_in_bytes() {
752 // SPARC does not require the additional stack bang.
753 return 0;
754 }
|
139 return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc());
140 }
141
142 frame os::current_frame() {
143 intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()();
144 frame myframe(sp, frame::unpatchable,
145 CAST_FROM_FN_PTR(address, os::current_frame));
146 if (os::is_first_C_frame(&myframe)) {
147 // stack is not walkable
148 return frame(NULL, frame::unpatchable, NULL);
149 } else {
150 return os::get_sender_for_C_frame(&myframe);
151 }
152 }
153
154 address os::current_stack_pointer() {
155 register void *sp __asm__ ("sp");
156 return (address)sp;
157 }
158
159 char* os::non_memory_address_word() {
160 // Must never look like an address returned by reserve_memory,
161 // even in its subfields (as defined by the CPU immediate fields,
162 // if the CPU splits constants across multiple instructions).
163 // On SPARC, 0 != %hi(any real address), because there is no
164 // allocation in the first 1Kb of the virtual address space.
165 return (char*) 0;
166 }
167
168 void os::initialize_thread(Thread* thr) {}
169
170 void os::print_context(outputStream *st, const void *context) {
171 if (context == NULL) return;
172
173 const ucontext_t* uc = (const ucontext_t*)context;
174 sigcontext* sc = (sigcontext*)context;
175 st->print_cr("Registers:");
176
177 st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT
178 " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT,
673 if (addr != NULL) {
674 release_memory(addr, bytes);
675 }
676
677 return addr != NULL;
678 #endif // _LP64
679 }
680
681 ///////////////////////////////////////////////////////////////////////////////
682 // thread stack
683
684 size_t os::Posix::_compiler_thread_min_stack_allowed = 128 * K;
685 size_t os::Posix::_java_thread_min_stack_allowed = 128 * K;
686 size_t os::Posix::_vm_internal_thread_min_stack_allowed = 128 * K;
687
688 // return default stack size for thr_type
689 size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
690 // default stack size (compiler thread needs larger stack)
691 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
692 return s;
693 }
694
695 #ifndef PRODUCT
696 void os::verify_stack_alignment() {
697 }
698 #endif
699
700 int os::extra_bang_size_in_bytes() {
701 // SPARC does not require the additional stack bang.
702 return 0;
703 }
|