Mercurial > hg > truffle
comparison src/os_cpu/linux_x86/vm/os_linux_x86.cpp @ 50:485d403e94e1
6452081: 3/4 Allow for Linux builds with Sun Studio Linux compilers
Summary: (for Serguei) Allow for Linux builds with Sun Studio Linux compilers
Reviewed-by: sspitsyn, ohair
author | dcubed |
---|---|
date | Wed, 12 Mar 2008 18:37:03 -0700 |
parents | a61af66fc99e |
children | 75b0f3cb1943 |
comparison
equal
deleted
inserted
replaced
49:31000d79ec71 | 50:485d403e94e1 |
---|---|
60 #define SPELL_REG_SP "esp" | 60 #define SPELL_REG_SP "esp" |
61 #define SPELL_REG_FP "ebp" | 61 #define SPELL_REG_FP "ebp" |
62 #endif // AMD64 | 62 #endif // AMD64 |
63 | 63 |
64 address os::current_stack_pointer() { | 64 address os::current_stack_pointer() { |
65 #ifdef SPARC_WORKS | |
66 register void *esp; | |
67 __asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp)); | |
68 return (address) ((char*)esp + sizeof(long)*2); | |
69 #else | |
65 register void *esp __asm__ (SPELL_REG_SP); | 70 register void *esp __asm__ (SPELL_REG_SP); |
66 return (address) esp; | 71 return (address) esp; |
72 #endif | |
67 } | 73 } |
68 | 74 |
69 char* os::non_memory_address_word() { | 75 char* os::non_memory_address_word() { |
70 // Must never look like an address returned by reserve_memory, | 76 // Must never look like an address returned by reserve_memory, |
71 // even in its subfields (as defined by the CPU immediate fields, | 77 // even in its subfields (as defined by the CPU immediate fields, |
137 frame os::get_sender_for_C_frame(frame* fr) { | 143 frame os::get_sender_for_C_frame(frame* fr) { |
138 return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); | 144 return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); |
139 } | 145 } |
140 | 146 |
141 intptr_t* _get_previous_fp() { | 147 intptr_t* _get_previous_fp() { |
148 #ifdef SPARC_WORKS | |
149 register intptr_t **ebp; | |
150 __asm__("mov %%"SPELL_REG_FP", %0":"=r"(ebp)); | |
151 #else | |
142 register intptr_t **ebp __asm__ (SPELL_REG_FP); | 152 register intptr_t **ebp __asm__ (SPELL_REG_FP); |
153 #endif | |
143 return (intptr_t*) *ebp; // we want what it points to. | 154 return (intptr_t*) *ebp; // we want what it points to. |
144 } | 155 } |
145 | 156 |
146 | 157 |
147 frame os::current_frame() { | 158 frame os::current_frame() { |
573 // amd64: pthread on amd64 is always in floating stack mode | 584 // amd64: pthread on amd64 is always in floating stack mode |
574 bool os::Linux::supports_variable_stack_size() { return true; } | 585 bool os::Linux::supports_variable_stack_size() { return true; } |
575 #else | 586 #else |
576 size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; | 587 size_t os::Linux::min_stack_allowed = (48 DEBUG_ONLY(+4))*K; |
577 | 588 |
589 #ifdef __GNUC__ | |
578 #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) | 590 #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;}) |
591 #endif | |
579 | 592 |
580 // Test if pthread library can support variable thread stack size. LinuxThreads | 593 // Test if pthread library can support variable thread stack size. LinuxThreads |
581 // in fixed stack mode allocates 2M fixed slot for each thread. LinuxThreads | 594 // in fixed stack mode allocates 2M fixed slot for each thread. LinuxThreads |
582 // in floating stack mode and NPTL support variable stack size. | 595 // in floating stack mode and NPTL support variable stack size. |
583 bool os::Linux::supports_variable_stack_size() { | 596 bool os::Linux::supports_variable_stack_size() { |
604 // a native application that plays with %gs, we might see non-zero %gs | 617 // a native application that plays with %gs, we might see non-zero %gs |
605 // even LinuxThreads is running in fixed stack mode. As the result, we'll | 618 // even LinuxThreads is running in fixed stack mode. As the result, we'll |
606 // return true and skip _thread_safety_check(), so we may not be able to | 619 // return true and skip _thread_safety_check(), so we may not be able to |
607 // detect stack-heap collisions. But otherwise it's harmless. | 620 // detect stack-heap collisions. But otherwise it's harmless. |
608 // | 621 // |
622 #ifdef __GNUC__ | |
609 return (GET_GS() != 0); | 623 return (GET_GS() != 0); |
624 #else | |
625 return false; | |
626 #endif | |
610 } | 627 } |
611 } | 628 } |
612 #endif // AMD64 | 629 #endif // AMD64 |
613 | 630 |
614 // return default stack size for thr_type | 631 // return default stack size for thr_type |