harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ge...@apache.org
Subject svn commit: r452481 - in /incubator/harmony/enhanced/drlvm/trunk/vm: port/src/lil/ia32/pim/ vmcore/include/ vmcore/src/jvmti/ vmcore/src/util/linux/ vmcore/src/util/win/ia32/
Date Tue, 03 Oct 2006 13:16:06 GMT
Author: geirm
Date: Tue Oct  3 06:16:05 2006
New Revision: 452481

URL: http://svn.apache.org/viewvc?view=rev&rev=452481
Log:
HARMONY-1657

Earlier, exception/signal handler returned control to interrupted code during JIT breakpoint
processing, so it 
restored all unmodified processor registers including processor flags.

Now control is returned to interrupted code directly from breakpoint handler using si_transfer_control
function. This 
function restores general processor registers, but it does not restore processor flags modified
during breakpoint 
processing. 


Ubuntu smoke, c-unit, ~kernel



Modified:
    incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/stack_iterator_ia32.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_core_types.h
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ia32.cpp
    incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/win/ia32/nt_exception_filter.cpp

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/stack_iterator_ia32.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/stack_iterator_ia32.cpp?view=diff&rev=452481&r1=452480&r2=452481
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/stack_iterator_ia32.cpp
(original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ia32/pim/stack_iterator_ia32.cpp
Tue Oct  3 06:16:05 2006
@@ -88,6 +88,7 @@
         si->c.p_esi = &m2nfl->regs->esi;
         si->c.p_edi = &m2nfl->regs->edi;
         si->c.p_ebp = &m2nfl->regs->ebp;
+        si->c.eflags = m2nfl->regs->eflags;
     } else if (over_popped &&
             (FRAME_MODIFIED_STACK == (FRAME_MODIFIED_STACK & m2n_get_frame_type(m2nfl))))
{
         si->c.esp = m2nfl->pop_regs->esp;
@@ -100,6 +101,7 @@
         si->c.p_esi = &m2nfl->pop_regs->esi;
         si->c.p_edi = &m2nfl->pop_regs->edi;
         si->c.p_ebp = &m2nfl->pop_regs->ebp;
+        si->c.eflags = m2nfl->pop_regs->eflags;
     } else {
         // Normal M2nFrame, eip is past instruction, esp is implicitly address just beyond
the frame, callee saves registers in M2nFrame
         si->c.esp   = (uint32)m2nfl + m2n_sizeof_m2n_frame;
@@ -129,7 +131,7 @@
         return addr;
     }
 
-    const int stub_size = 64;
+    const int stub_size = 0x47;
     char *stub = (char *)malloc_fixed_code_for_jit(stub_size, DEFAULT_CODE_ALIGNMENT, CODE_BLOCK_HEAT_COLD,
CAA_Allocate);
 #ifdef _DEBUG
     memset(stub, 0xcc /*int 3*/, stub_size);
@@ -162,6 +164,17 @@
 
     ss = get_reg(ss, &eax_opnd, eax_reg, edx_reg, (unsigned)&((StackIterator*)0)->c.p_eax);
     ss = get_reg(ss, &ebx_opnd, ebx_reg, edx_reg, (unsigned)&((StackIterator*)0)->c.p_ebx);
+
+    ss = mov(ss, ecx_opnd,  M_Base_Opnd(edx_reg, (unsigned)&((StackIterator*)0)->c.eflags));
+    ss = test(ss, ecx_opnd, ecx_opnd);
+    ss = branch8(ss, Condition_Z,  Imm_Opnd(size_8, 0));
+    char* patch_offset = ((char *)ss) - 1; // Store location for jump patch
+    ss = push(ss,  ecx_opnd);
+    *ss++ = (char)0x9D; // POPFD
+    // Patch conditional jump
+    signed offset = (signed)ss - (signed)patch_offset - 1;
+    *patch_offset = (char)offset;
+
     ss = get_reg(ss, &ecx_opnd, ecx_reg, edx_reg, (unsigned)&((StackIterator*)0)->c.p_ecx);
     ss = get_reg(ss, &edx_opnd, edx_reg, edx_reg, (unsigned)&((StackIterator*)0)->c.p_edx);
 
@@ -191,6 +204,12 @@
         mov         eax,dword ptr [eax]
         mov         ebx,dword ptr [edx+18h]
         mov         ebx,dword ptr [ebx]
+        mov         ecx,dword ptr [edx+28h]
+        test        ecx,ecx
+        je          _label_
+        push        ecx
+        popfd
+_label_:
         mov         ecx,dword ptr [edx+20h]
         mov         ecx,dword ptr [ecx]
         mov         edx,dword ptr [edx+24h]
@@ -249,8 +268,9 @@
     memset(res, 0, sizeof(StackIterator));
 
     // Setup current frame
+    // It's possible that registers represent native code and res->cci==NULL
     res->cci = vm_methods->find((NativeCodePtr)regs->eip, is_ip_past);
-    assert(res->cci);
+
     res->c.esp = regs->esp;
     res->c.p_eip = &regs->eip;
     res->c.p_ebp = &regs->ebp;
@@ -261,6 +281,7 @@
     res->c.p_ecx = &regs->ecx;
     res->c.p_edx = &regs->edx;
     res->c.is_ip_past = is_ip_past;
+    res->c.eflags = regs->eflags;
     res->m2nfl = lm2nf;
 
     return res;
@@ -504,6 +525,7 @@
     ASSERT_NO_INTERPRETER
 
     regs->esp = si->c.esp;
+    regs->eflags = si->c.eflags;
     regs->eip = unref_reg(si->c.p_eip);
     regs->ebp = unref_reg(si->c.p_ebp);
     regs->edi = unref_reg(si->c.p_edi);

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h?view=diff&rev=452481&r1=452480&r2=452481
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jit_export_rt.h Tue Oct  3 06:16:05
2006
@@ -109,6 +109,9 @@
     uint32 *p_ecx;
     uint32 *p_edx;
 
+    // To restore processor flags during transfer
+    uint32 eflags;
+
     Boolean is_ip_past;
 } JitFrameContext;
 

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_core_types.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_core_types.h?view=diff&rev=452481&r1=452480&r2=452481
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_core_types.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/vm_core_types.h Tue Oct  3 06:16:05
2006
@@ -114,6 +114,7 @@
     uint32 ebp;
     uint32 esp;
     uint32 eip;
+    uint32 eflags;
 
     void reset_ip() { eip = 0; }
     void* get_ip() { return (void*)eip; }

Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp?view=diff&rev=452481&r1=452480&r2=452481
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp Tue Oct
 3 06:16:05 2006
@@ -610,14 +610,7 @@
         << (bp->method ? method_get_descriptor((Method*)bp->method) : "")
         << " :" << bp->location << " :" << bp->addr);
 
-    bool push_frame = (vm_identify_eip(addr) == VM_TYPE_JAVA);
-    M2nFrame* m2nf;
-
-    if (push_frame) {
-        m2nf = m2n_push_suspended_frame(&regs);
-    } else {
-        m2nf = m2n_get_last_frame();
-    }
+    M2nFrame* m2nf = m2n_push_suspended_frame(&regs);
 
     jbyte *instruction_buffer;
     BEGIN_RAISE_AREA;
@@ -811,12 +804,6 @@
     // had before breakpoint happened
     StackIterator *si =
         si_create_from_registers(&regs, false, m2n_get_previous_frame(m2nf));
-
-    if (push_frame)
-    {
-        m2n_set_last_frame(m2n_get_previous_frame(m2nf));
-        STD_FREE(m2nf);
-    }
 
     si_set_ip(si, instruction_buffer, false);
     si_transfer_control(si);

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=452481&r1=452480&r2=452481
==============================================================================
--- 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 Oct
 3 06:16:05 2006
@@ -89,6 +89,7 @@
     regs->ebp = uc->uc_mcontext.gregs[REG_EBP];
     regs->eip = uc->uc_mcontext.gregs[REG_EIP];
     regs->esp = uc->uc_mcontext.gregs[REG_ESP];
+    regs->eflags = uc->uc_mcontext.gregs[REG_EFL];
 }
 
 void linux_regs_to_ucontext(ucontext_t *uc, Registers* regs)
@@ -102,6 +103,7 @@
     uc->uc_mcontext.gregs[REG_EBP] = regs->ebp;
     uc->uc_mcontext.gregs[REG_EIP] = regs->eip;
     uc->uc_mcontext.gregs[REG_ESP] = regs->esp;
+    uc->uc_mcontext.gregs[REG_EFL] = regs->eflags;
 }
 
 // exception catch support for JVMTI

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=452481&r1=452480&r2=452481
==============================================================================
--- 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 Oct  3 06:16:05 2006
@@ -51,6 +51,7 @@
     regs->ebp = context->Ebp;
     regs->eip = context->Eip;
     regs->esp = context->Esp;
+    regs->eflags = context->EFlags;
 }
 
 void vm_to_nt_context(Registers* regs, PCONTEXT context)
@@ -64,6 +65,7 @@
     context->Eax = regs->eax;
     context->Ecx = regs->ecx;
     context->Edx = regs->edx;
+    context->EFlags = regs->eflags;
 }
 
 static void print_state(LPEXCEPTION_POINTERS nt_exception, const char *msg)



Mime
View raw message