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

Print this page
rev 611 : Merge

@@ -1,10 +1,7 @@
-#ifdef USE_PRAGMA_IDENT_SRC
-#pragma ident "@(#)os_linux_x86.cpp     1.98 07/11/15 11:29:19 JVM"
-#endif
 /*
- * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -63,12 +60,18 @@
 #define SPELL_REG_SP "esp"
 #define SPELL_REG_FP "ebp"
 #endif // AMD64
 
 address os::current_stack_pointer() {
+#ifdef SPARC_WORKS
+  register void *esp;
+  __asm__("mov %%"SPELL_REG_SP", %0":"=r"(esp));
+  return (address) ((char*)esp + sizeof(long)*2);
+#else
   register void *esp __asm__ (SPELL_REG_SP);
   return (address) esp;
+#endif
 }
 
 char* os::non_memory_address_word() {
   // Must never look like an address returned by reserve_memory,
   // even in its subfields (as defined by the CPU immediate fields,

@@ -140,11 +143,16 @@
 frame os::get_sender_for_C_frame(frame* fr) {
   return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
 }
 
 intptr_t* _get_previous_fp() {
+#ifdef SPARC_WORKS
+  register intptr_t **ebp;
+  __asm__("mov %%"SPELL_REG_FP", %0":"=r"(ebp));
+#else
   register intptr_t **ebp __asm__ (SPELL_REG_FP);
+#endif
   return (intptr_t*) *ebp;   // we want what it points to.
 }
 
 
 frame os::current_frame() {

@@ -412,14 +420,15 @@
       
       // In conservative mode, don't unguard unless the address is in the VM
       if (addr != last_addr &&
           (UnguardOnExecutionViolation > 1 || os::address_is_in_vm(addr))) {
         
-        // Unguard and retry
+        // Set memory to RWX and retry
         address page_start =
           (address) align_size_down((intptr_t) addr, (intptr_t) page_size);
-        bool res = os::unguard_memory((char*) page_start, page_size);
+        bool res = os::protect_memory((char*) page_start, page_size,
+                                      os::MEM_PROT_RWX);
 
         if (PrintMiscellaneous && Verbose) {
           char buf[256];
           jio_snprintf(buf, sizeof(buf), "Execution protection violation "
                        "at " INTPTR_FORMAT

@@ -561,11 +570,13 @@
 // amd64: pthread on amd64 is always in floating stack mode
 bool os::Linux::supports_variable_stack_size() {  return true; }
 #else
 size_t os::Linux::min_stack_allowed  =  (48 DEBUG_ONLY(+4))*K;
 
+#ifdef __GNUC__
 #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;})
+#endif
 
 // Test if pthread library can support variable thread stack size. LinuxThreads
 // in fixed stack mode allocates 2M fixed slot for each thread. LinuxThreads 
 // in floating stack mode and NPTL support variable stack size.
 bool os::Linux::supports_variable_stack_size() {

@@ -585,18 +596,22 @@
     // %gs (either as LDT selector or GDT selector, depending on kernel)
     // to access thread specific data. 
     //
     // Note that %gs is a reserved glibc register since early 2001, so 
     // applications are not allowed to change its value (Ulrich Drepper from 
-    // Redhat confirmed that all known offenders have been modified to use
+    // Red Hat confirmed that all known offenders have been modified to use
     // either %fs or TSD). In the worst case scenario, when VM is embedded in 
     // a native application that plays with %gs, we might see non-zero %gs 
     // even LinuxThreads is running in fixed stack mode. As the result, we'll 
     // return true and skip _thread_safety_check(), so we may not be able to 
     // detect stack-heap collisions. But otherwise it's harmless.
     //
+#ifdef __GNUC__
     return (GET_GS() != 0);
+#else
+    return false;
+#endif
   }
 }
 #endif // AMD64
 
 // return default stack size for thr_type