harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ibere...@apache.org
Subject svn commit: r663088 - in /harmony/enhanced/drlvm/trunk/vm: port/src/signals/win/signals_common.cpp port/src/thread/win/thread_os.c vmcore/src/exception/exceptions_jit.cpp
Date Wed, 04 Jun 2008 13:07:10 GMT
Author: iberezhn
Date: Wed Jun  4 06:07:09 2008
New Revision: 663088

URL: http://svn.apache.org/viewvc?rev=663088&view=rev
Log:
Applied patch from HARMONY-5859
[drlvm][signals] Regression test H4265 fails after r660062 commit


Modified:
    harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_common.cpp
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_common.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_common.cpp?rev=663088&r1=663087&r2=663088&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_common.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/signals/win/signals_common.cpp Wed Jun  4 06:07:09
2008
@@ -111,10 +111,10 @@
         {
             port_thread_restore_guard_page();
             tlsdata->restore_guard_page = FALSE;
-
-            if (port_thread_detach_temporary() == 0)
-                STD_FREE(tlsdata);
         }
+
+        if (port_thread_detach_temporary() == 0)
+            STD_FREE(tlsdata);
         return;
     }
 
@@ -250,6 +250,8 @@
 
     if (code == STATUS_STACK_OVERFLOW)
     {
+        tlsdata->guard_page_set = FALSE; // GUARD_PAGE was cleared by OS
+
         if (!tlsdata->restore_guard_page)
             tlsdata->restore_guard_page = TRUE;
     }

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c?rev=663088&r1=663087&r2=663088&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/win/thread_os.c Wed Jun  4 06:07:09 2008
@@ -109,7 +109,8 @@
     startstr->arg = data;
     startstr->stack_size = stacksize;
 
-    handle = _beginthreadex(NULL, stacksize, thread_start_func, startstr, STACK_SIZE_PARAM_IS_A_RESERVATION,
NULL);
+    handle = _beginthreadex(NULL, (int)stacksize, thread_start_func,
+                            startstr, STACK_SIZE_PARAM_IS_A_RESERVATION, NULL);
 
     if (handle != (uintptr_t)-1L)
     {
@@ -127,6 +128,10 @@
 
 static int set_guard_page(port_tls_data_t* tlsdata, Boolean set)
 {
+    DWORD oldProtect;
+    void* guard_addr;
+    size_t guard_size;
+
     if (!tlsdata)
         tlsdata = get_private_tls_data();
 
@@ -137,28 +142,36 @@
         return 0;
 
     if ((set && tlsdata->guard_page_set) ||
-         !set && !tlsdata->guard_page_set)
+        (!set && !tlsdata->guard_page_set))
         return 0; // Already in needed state
 
+#ifdef _EM64T_
+    /* Windows x86_64 protects both guard page and guard stack area
+       specified by SetThreadStackGuarantee() with PAGE_GUARD flag */
+    guard_addr = tlsdata->guard_stack_addr;
+    guard_size = tlsdata->guard_stack_size + tlsdata->guard_page_size;
+#else
+    guard_addr = tlsdata->guard_page_addr;
+    guard_size = tlsdata->guard_page_size;
+#endif
+
     if (set)
     {
         if ((size_t)&set - PSD->mem_protect_size
                 < (size_t)tlsdata->guard_page_addr + tlsdata->guard_page_size)
             return -1;
 
-        if (!VirtualAlloc(tlsdata->guard_page_addr, tlsdata->guard_page_size,
-                            MEM_COMMIT, PAGE_GUARD | PAGE_READWRITE))
+        if (!VirtualProtect(guard_addr, guard_size,
+                            PAGE_GUARD | PAGE_READWRITE, &oldProtect))
             // should be successful always
             return -1;
     }
     else
     {
-        DWORD oldProtect;
-
         if ((size_t)&set < (size_t)tlsdata->guard_page_addr + tlsdata->guard_page_size)
             return -1;
 
-        if (!VirtualProtect(tlsdata->guard_page_addr, tlsdata->guard_page_size,
+        if (!VirtualProtect(guard_addr, guard_size,
                             PAGE_READWRITE, &oldProtect))
             // should be successful always
             return -1;
@@ -237,11 +250,7 @@
             < (size_t)tlsdata->guard_page_addr + tlsdata->guard_page_size)
         return -1;
 
-    if (!VirtualFree(tlsdata->guard_stack_addr,
-                        tlsdata->guard_stack_size, MEM_DECOMMIT))
-        // should be successful always
-        return -1;
-
+    tlsdata->guard_page_set = TRUE; // GUARD_PAGE is set by default
     return 0;
 }
 
@@ -297,12 +306,7 @@
     res = init_stack(tlsdata, stack_size, temp);
     if (res != 0) return res;
 
-    res = set_private_tls_data(tlsdata);
-
-    if (res != 0)
-        set_guard_page(tlsdata, FALSE);
-
-    return res;
+    return set_private_tls_data(tlsdata);
 }
 
 int port_thread_attach()

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?rev=663088&r1=663087&r2=663088&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Wed Jun  4 06:07:09
2008
@@ -590,21 +590,19 @@
     }
 
     if (ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_EXCEPTION_EVENT)) {
-        Registers regs = {0};
         VM_thread *thread = p_TLS_vmthread;
         NativeCodePtr callback = (NativeCodePtr)
                 jvmti_exception_catch_callback;
 
-        si_copy_to_registers(si, &regs);
-        vm_set_exception_registers(thread, regs);
+        si_copy_to_registers(si, regs);
+        vm_set_exception_registers(thread, *regs);
         si_set_callback(si, &callback);
     } else if (p_TLS_vmthread->restore_guard_page) {
-        Registers regs = {0};
         VM_thread *thread = p_TLS_vmthread;
         NativeCodePtr callback = (NativeCodePtr)
                 exception_catch_callback;
-        si_copy_to_registers(si, &regs);
-        vm_set_exception_registers(thread, regs);
+        si_copy_to_registers(si, regs);
+        vm_set_exception_registers(thread, *regs);
         si_set_callback(si, &callback);
     }
 



Mime
View raw message