You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/11/14 23:45:46 UTC

svn commit: r475029 - in /incubator/harmony/enhanced/drlvm/trunk/vm: tests/smoke/ tests/smoke/exception/ thread/src/ vmcore/include/ vmcore/src/exception/ vmcore/src/jit/ vmcore/src/util/linux/ vmcore/src/util/win/em64t/ vmcore/src/util/win/ia32/ vmcor...

Author: gshimansky
Date: Tue Nov 14 14:45:45 2006
New Revision: 475029

URL: http://svn.apache.org/viewvc?view=rev&rev=475029
Log:
Applied HARMONY-2018 [DRLVM] Fix support of SOE and other runtime exceptions in VM native code

Also added forgotten IPF file from HARMONY-2004.

Tested on windows XP, Ubuntu6, FC5, SLES9, Gentoo and SLES10 x86_64.

Tests passed except gc.LOS for XP, j.l.ThreadTest on many platforms, j.l.ClassGenericsTest4 (interpreter) on many platforms and StackTest and exception.FinalizeStackTest on x86_64 (crashed).

The j.l.ClassGenericsTest4 is a regression. But without this patch it fails too. I am not sure but classlib may be the cause of regression.


Added:
    incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/exception/FinalizeStackTest.java
    incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_helpers_ipf.c
Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ipf/nt_exception_filter.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/StackTest.java Tue Nov 14 14:45:45 2006
@@ -27,8 +27,11 @@
     public static void main(String[] args) {
         try {
             func();
+            System.out.println("FAIL");
+        } catch (StackOverflowError soe) {
+            System.out.println("PASS : First SOE depth = " + depth + " : " + soe);
         } catch (Throwable th) {
-            System.out.println("PASS : First SOE depth = " + depth + " : " + th);
+            System.out.println("FAIL");
         }
     }
 }

Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/exception/FinalizeStackTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/exception/FinalizeStackTest.java?view=auto&rev=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/exception/FinalizeStackTest.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/smoke/exception/FinalizeStackTest.java Tue Nov 14 14:45:45 2006
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+/**
+ * @author Pavel Afremov
+ * @version $Revision: 1.0 $
+ */
+package exception;
+
+class FinalizeStackTest {
+    private static final int MAX_DEPTH = 1000000;
+
+    FinalizeStackTest(int c) {
+        if (c > 0) {
+            new FinalizeStackTest(c - 1);
+        } else {
+            System.out.println("PASS");
+        }
+    }
+
+    protected void finalize() {
+        // empty
+    }
+
+    public static void main(String[] args) {
+        try {
+            new FinalizeStackTest(MAX_DEPTH);
+            System.out.println("FAIL");
+        } catch (StackOverflowError soe) {
+            System.out.println("PASS : " + soe);
+        } catch (Throwable th) {
+            System.out.println("FAIL");
+        }
+    }
+}

Added: incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_helpers_ipf.c
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_helpers_ipf.c?view=auto&rev=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_helpers_ipf.c (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/thread/src/thread_helpers_ipf.c Tue Nov 14 14:45:45 2006
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+/**
+ * @author Ivan Volosyuk
+ */  
+
+/** 
+ * @file thread_helpers_ipf.c
+ * Missing definition to ipf compile
+ */  
+
+#include <open/hythread_ext.h>
+#include <open/thread_helpers.h>
+#include "thread_private.h"
+#include "open/thread_externals.h"
+#include "open/jthread.h"
+
+#include <assert.h>
+
+void *dummy_tls_func() {
+    assert(0);
+    abort();
+}
+
+
+fast_tls_func* get_tls_helper(hythread_tls_key_t key) {
+    return dummy_tls_func;
+}
+

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/exceptions_jit.h Tue Nov 14 14:45:45 2006
@@ -42,7 +42,7 @@
 // Must be called with the current thread "suspended" in managed code and regs holds the suspended values.
 // Exception defined as in previous two functions.
 // Mutates the regs value, which should be used to "resume" the managed code.
-void exn_athrow_regs(Registers* regs, Class_Handle exn_class);
+void exn_athrow_regs(Registers* regs, Class_Handle exn_class, bool java_code);
 
 // exception catch callback to restore stack after Stack Overflow Error
 void exception_catch_callback();

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions.cpp Tue Nov 14 14:45:45 2006
@@ -348,8 +348,12 @@
     } else if (NULL != p_TLS_vmthread->thread_exception.exc_class) {
         Class * exc_class = p_TLS_vmthread->thread_exception.exc_class;
         const char* exc_message = p_TLS_vmthread->thread_exception.exc_message;
-        jthrowable exc_cause = oh_allocate_local_handle();
-        exc_cause->object = p_TLS_vmthread->thread_exception.exc_cause;
+        jthrowable exc_cause = NULL;
+
+        if (p_TLS_vmthread->thread_exception.exc_cause){
+            exc_cause = oh_allocate_local_handle();
+            exc_cause->object = p_TLS_vmthread->thread_exception.exc_cause;
+        }
         clear_exception_internal();
         exn_throw_by_class_internal(exc_class, exc_message, exc_cause);
     } else {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_impl.cpp Tue Nov 14 14:45:45 2006
@@ -26,6 +26,7 @@
 #include "Class.h"
 #include "classloader.h"
 #include "exceptions.h"
+#include "exceptions_impl.h"
 #include "exceptions_jit.h"
 #include "exceptions_type.h"
 #include "environment.h"
@@ -36,6 +37,7 @@
 Class *get_exc_class(const char *exception_name)
 {
     ASSERT_RAISE_AREA;
+    assert(hythread_is_suspend_enabled());
     Global_Env *env = VM_Global_State::loader_env;
     String *exc_str = env->string_pool.lookup(exception_name);
     Class *exc_class =
@@ -299,7 +301,6 @@
 void exn_throw_by_class_internal(Class* exc_class, const char* exc_message,
     jthrowable exc_cause)
 {
-    assert(is_unwindable());
 #ifdef VM_LAZY_EXCEPTION
     set_unwindable(false);
 
@@ -369,6 +370,7 @@
     }
     tmn_suspend_enable_recursive();
 #else
+    assert(hythread_is_suspend_enabled());
     jthrowable exc_object = exn_create(exc_class, exc_message, exc_cause);
 
     if (exn_raised()){

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/exception/exceptions_jit.cpp Tue Nov 14 14:45:45 2006
@@ -445,18 +445,27 @@
 // Exception defined as in previous two functions.
 // Mutates the regs value, which should be used to "resume" the managed code.
 
-void exn_athrow_regs(Registers * regs, Class_Handle exn_class)
+void exn_athrow_regs(Registers * regs, Class_Handle exn_class, bool java_code)
 {
     assert(exn_class);
 #ifndef _IPF_
-    M2nFrame *m2nf = m2n_push_suspended_frame(regs);
+    M2nFrame *m2nf;
+
+    if (java_code) {
+        m2nf = m2n_push_suspended_frame(regs);
+    }
+
     StackIterator *si = si_create_from_native();
     ManagedObject *local_exn_obj = NULL;
     exn_propagate_exception(si, &local_exn_obj, exn_class, NULL, NULL, NULL);
     si_copy_to_registers(si, regs);
+
     m2n_set_last_frame(si_get_m2n(si));
     si_free(si);
-    STD_FREE(m2nf);
+
+    if (java_code) {
+        STD_FREE(m2nf);
+    }
 #endif
 }   //exn_athrow_regs
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jit/jit_runtime_support.cpp Tue Nov 14 14:45:45 2006
@@ -2002,7 +2002,13 @@
         unsigned size, Allocation_Handle ah, void *tp) {
     ASSERT_THROW_AREA;
     assert(!hythread_is_suspend_enabled());
-    void *result = gc_alloc(size,ah,tp);
+
+    void *result = NULL;
+    BEGIN_RAISE_AREA;
+    result = gc_alloc(size,ah,tp);
+    END_RAISE_AREA;
+    exn_rethrow_if_pending();
+
     if (!result) {
         exn_throw_object(VM_Global_State::loader_env->java_lang_OutOfMemoryError);
         return 0; // whether this return is reached or not is solved via is_unwindable state

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_em64t.cpp Tue Nov 14 14:45:45 2006
@@ -113,8 +113,9 @@
     linux_ucontext_to_regs(&regs, uc);
 
     DebugUtilsTI* ti = VM_Global_State::loader_env->TI;
+    bool java_code = (vm_identify_eip((void *)regs.rip) == VM_TYPE_JAVA);
 
-    exn_athrow_regs(&regs, exc_clss);
+    exn_athrow_regs(&regs, exc_clss, java_code);
     linux_regs_to_ucontext(uc, &regs);
 }
 
@@ -131,24 +132,6 @@
     return true;
 }
 
-static bool linux_throw_from_sigcontext(ucontext_t *uc, Class* exc_clss)
-{
-    ASSERT_NO_INTERPRETER;
-    unsigned *rip = (unsigned *) uc->uc_mcontext.gregs[REG_RIP];
-    VM_Code_Type vmct = vm_identify_eip((void *)rip);
-    if(vmct != VM_TYPE_JAVA) {
-        return false;
-    }
-
-    Registers regs;
-    linux_ucontext_to_regs(&regs, uc);
-
-    exn_athrow_regs(&regs, exc_clss);
-
-    linux_regs_to_ucontext(uc, &regs);
-    return true;
-}
-
 /**
  * the saved copy of the executable name.
  */
@@ -305,6 +288,8 @@
     sigalt.ss_size = guard_stack_size;
 
     err = sigaltstack (&sigalt, NULL);
+
+    p_TLS_vmthread->restore_guard_page = false;
 }
 
 size_t get_available_stack_size() {
@@ -318,7 +303,8 @@
 
 bool check_available_stack_size(size_t required_size) {
     if (get_available_stack_size() < required_size) {
-        exn_raise_by_name("java/lang/StackOverflowError");
+        Global_Env *env = VM_Global_State::loader_env;
+        exn_raise_by_class(env->java_lang_StackOverflowError_Class);
         return false;
     } else {
         return true;
@@ -341,6 +327,8 @@
     sigalt.ss_size = guard_stack_size;
 
     err = sigaltstack (&sigalt, NULL);
+
+    p_TLS_vmthread->restore_guard_page = true;
 }
 
 bool check_stack_overflow(siginfo_t *info, ucontext_t *uc) {
@@ -381,7 +369,7 @@
                 uc, env->java_lang_StackOverflowError_Class);
         } else {
             remove_guard_stack();
-            exn_raise_by_name("java/lang/StackOverflowError");
+            exn_raise_by_class(env->java_lang_StackOverflowError_Class);
             p_TLS_vmthread->restore_guard_page = true;
         }
     }
@@ -401,7 +389,7 @@
     if (env->shutting_down != 0) {
         fprintf(stderr, "null_java_reference_handler(): called in shutdown stage\n");
     } else if (!interpreter_enabled()) {
-        if (linux_throw_from_sigcontext(
+        if (java_throw_from_sigcontext(
                     uc, env->java_lang_NullPointerException_Class)) {
             return;
         }
@@ -420,7 +408,7 @@
     if (env->shutting_down != 0) {
         fprintf(stderr, "null_java_divide_by_zero_handler(): called in shutdown stage\n");
     } else if (!interpreter_enabled()) {
-        if (linux_throw_from_sigcontext(
+        if (java_throw_from_sigcontext(
                     uc, env->java_lang_ArithmeticException_Class)) {
             return;
         }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp Tue Nov 14 14:45:45 2006
@@ -152,7 +152,8 @@
 
     uint32 exception_esp = regs.esp;
     DebugUtilsTI* ti = VM_Global_State::loader_env->TI;
-    exn_athrow_regs(&regs, exc_clss);
+    bool java_code = (vm_identify_eip((void *)regs.eip) == VM_TYPE_JAVA);
+    exn_athrow_regs(&regs, exc_clss, java_code);
     assert(exception_esp <= regs.esp);
     if (ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_EXCEPTION_EVENT)) {
         regs.esp = regs.esp - 4;
@@ -282,6 +283,7 @@
     pthread_attr_init(&pthread_attr);
     err = pthread_attr_getguardsize(&pthread_attr, &guard_size);
     pthread_attr_destroy(&pthread_attr);
+    
     return guard_size;
 }
 
@@ -305,52 +307,78 @@
     return common_guard_page_size;
 }
 
+static void __attribute__ ((cdecl)) stack_holder(char* addr) {
+    char buf[1024];
+    
+    if (addr > (buf + ((size_t)1024))) {
+        return;
+    }
+    stack_holder(addr);
+}
 
 void init_stack_info() {
-    p_TLS_vmthread->stack_addr = find_stack_addr();
+    // fins stack parametrs
+    char* stack_addr = (char *)find_stack_addr();
+    p_TLS_vmthread->stack_addr = stack_addr;
     common_stack_size = find_stack_size();
     common_guard_stack_size = find_guard_stack_size();
     common_guard_page_size =find_guard_page_size();
 
+    // stack should be mapped so it's result of future mapping
+    char* res;
+
+    // begin of the stack can be protected by OS, but this part already mapped
+    // found address of current stack page
+    char* current_page_addr =
+            (char*)(((size_t)&res) & (~(common_guard_page_size-1)));
+
+    // leave place for mmap work
+    char* mapping_page_addr = current_page_addr - common_guard_page_size;
+
+    // makes sure that stack allocated till mapping_page_addr
+    stack_holder(mapping_page_addr);
+
+    // found size of the stack area which should be maped
+    size_t stack_mapping_size = (size_t)mapping_page_addr
+            - (size_t)stack_addr + common_stack_size;
+
+    // maps unmapped part of the stack
+    res = (char*) mmap(stack_addr - common_stack_size,
+            stack_mapping_size,
+            PROT_READ | PROT_WRITE,
+            MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS | MAP_GROWSDOWN,
+            -1,
+            0);
+
+    // stack should be mapped, checks result
+    assert(res == (stack_addr - common_stack_size));
+
+    // set guard page
     set_guard_stack();
 }
 
 void set_guard_stack() {
     int err;
-    
     char* stack_addr = (char*) get_stack_addr();
     size_t stack_size = get_stack_size();
     size_t guard_stack_size = get_guard_stack_size();
     size_t guard_page_size = get_guard_page_size();
 
-    // map the guard page and protect it
-    void UNUSED *res = mmap(stack_addr - stack_size + guard_page_size +
-    guard_stack_size, guard_page_size,  PROT_READ | PROT_WRITE,
-    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-
-    assert(res!=MAP_FAILED);
-
     err = mprotect(stack_addr - stack_size  + guard_page_size +  
-    guard_stack_size, guard_page_size, PROT_NONE );
-   
-    assert(!err);
-
-    //map the alternate stack on which we want to handle the signal
-    void UNUSED *res2 = mmap(stack_addr - stack_size + guard_page_size,
-    guard_stack_size,  PROT_READ | PROT_WRITE,
-    MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-
-    assert(res2!=MAP_FAILED);
+            guard_stack_size, guard_page_size, PROT_NONE );
 
+    assert(!err);
 
+    // sets alternative, guard stack
     stack_t sigalt;
     sigalt.ss_sp = stack_addr - stack_size + guard_page_size;
     sigalt.ss_flags = SS_ONSTACK;
     sigalt.ss_size = guard_stack_size;
-
     err = sigaltstack (&sigalt, NULL);
     assert(!err);
 
+    // notify that stack is OK and there are no needs to restore it
+    p_TLS_vmthread->restore_guard_page = false;
 }
 
 size_t get_available_stack_size() {
@@ -367,7 +395,8 @@
 }
 bool check_available_stack_size(size_t required_size) {
     if (get_available_stack_size() < required_size) {
-        exn_raise_by_name("java/lang/StackOverflowError");
+        Global_Env *env = VM_Global_State::loader_env;
+        exn_raise_by_class(env->java_lang_StackOverflowError_Class);
         return false;
     } else {
         return true;
@@ -393,6 +422,7 @@
 
     err = sigaltstack (&sigalt, NULL);
 
+    p_TLS_vmthread->restore_guard_page = true;
 }
 
 bool check_stack_overflow(siginfo_t *info, ucontext_t *uc) {
@@ -404,6 +434,9 @@
     char* guard_page_begin = stack_addr - stack_size + guard_page_size + guard_stack_size;
     char* guard_page_end = guard_page_begin + guard_page_size;
 
+    // FIXME: Workaround for main thread
+    guard_page_end += guard_page_size;
+
     char* fault_addr = (char*)(info->si_addr);
     //char* esp_value = (char*)(uc->uc_mcontext.gregs[REG_ESP]);
 
@@ -434,7 +467,7 @@
                 uc, env->java_lang_StackOverflowError_Class);
         } else {
             remove_guard_stack();
-            exn_raise_by_name("java/lang/StackOverflowError");
+            exn_raise_by_class(env->java_lang_StackOverflowError_Class);
             p_TLS_vmthread->restore_guard_page = true;
         }
     }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/em64t/nt_exception_filter.cpp Tue Nov 14 14:45:45 2006
@@ -126,7 +126,8 @@
 
     nt_to_vm_context(p_NT_exception->ContextRecord, &regs);
 
-    exn_athrow_regs(&regs, exc_clss);
+    bool java_code = (vm_identify_eip((void *)regs.eip) == VM_TYPE_JAVA);
+    exn_athrow_regs(&regs, exc_clss, java_code);
 
     vm_to_nt_context(&regs, p_NT_exception->ContextRecord);
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp Tue Nov 14 14:45:45 2006
@@ -28,6 +28,8 @@
 #include "stack_dump.h"
 #include "jvmti_break_intf.h"
 
+#include "m2n.h"
+
 // Windows specific
 #include <string>
 #include <excpt.h>
@@ -211,7 +213,8 @@
 }
 bool check_available_stack_size(size_t required_size) {
     if (get_available_stack_size() < required_size) {
-        exn_raise_by_name("java/lang/StackOverflowError");
+        Global_Env *env = VM_Global_State::loader_env;
+        exn_raise_by_class(env->java_lang_StackOverflowError_Class);
         return false;
     } else {
         return true;
@@ -325,7 +328,9 @@
                 }
                 run_default_handler = false;
             } else {
-                exn_raise_by_name("java/lang/StackOverflowError");
+                M2nFrame* frame = m2n_get_last_frame();
+                Global_Env *env = VM_Global_State::loader_env;
+                exn_raise_by_class(env->java_lang_StackOverflowError_Class);
                 p_TLS_vmthread->restore_guard_page = true;
                 return EXCEPTION_CONTINUE_EXECUTION;
             }
@@ -456,7 +461,8 @@
     uint32 exception_esp = regs.esp;
     DebugUtilsTI* ti = VM_Global_State::loader_env->TI;
 
-    exn_athrow_regs(&regs, exc_clss);
+    bool java_code = (vm_identify_eip((void *)regs.eip) == VM_TYPE_JAVA);
+    exn_athrow_regs(&regs, exc_clss, java_code);
 
     assert(exception_esp <= regs.esp);
     if (ti->get_global_capability(DebugUtilsTI::TI_GC_ENABLE_EXCEPTION_EVENT)) {

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ipf/nt_exception_filter.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ipf/nt_exception_filter.cpp?view=diff&rev=475029&r1=475028&r2=475029
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ipf/nt_exception_filter.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ipf/nt_exception_filter.cpp Tue Nov 14 14:45:45 2006
@@ -186,7 +186,7 @@
 
     // The exception object of class exc_clss will be created by vm_null_ptr_throw.
     assert(exc_clss);
-    exn_athrow_regs(&regs, exc_clss);
+    exn_athrow_regs(&regs, exc_clss, true);
 
     vm_to_nt_context(&regs, p_NT_exception->ContextRecord);