harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r692051 - in /harmony/enhanced/drlvm/trunk/vm: port/src/thread/linux/thread_em64t.c vmcore/src/ncai/utils/ncai_utils_em64t.cpp
Date Thu, 04 Sep 2008 14:30:11 GMT
Author: hindessm
Date: Thu Sep  4 07:30:09 2008
New Revision: 692051

URL: http://svn.apache.org/viewvc?rev=692051&view=rev
Log:
Register handling for freebsd/x86_64.

Modified:
    harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/ncai/utils/ncai_utils_em64t.cpp

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c?rev=692051&r1=692050&r2=692051&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/thread/linux/thread_em64t.c Thu Sep  4 07:30:09
2008
@@ -20,6 +20,53 @@
 #include <sys/ucontext.h>
 #include "port_thread.h"
 
+#if defined(FREEBSD)
+
+void port_thread_context_to_regs(Registers* regs, ucontext_t *uc)
+{
+    regs->rax = uc->uc_mcontext.mc_rax;
+    regs->rcx = uc->uc_mcontext.mc_rcx;
+    regs->rdx = uc->uc_mcontext.mc_rdx;
+    regs->rdi = uc->uc_mcontext.mc_rdi;
+    regs->rsi = uc->uc_mcontext.mc_rsi;
+    regs->rbx = uc->uc_mcontext.mc_rbx;
+    regs->rbp = uc->uc_mcontext.mc_rbp;
+    regs->rip = uc->uc_mcontext.mc_rip;
+    regs->rsp = uc->uc_mcontext.mc_rsp;
+    regs->r8  = uc->uc_mcontext.mc_r8;
+    regs->r9  = uc->uc_mcontext.mc_r9;
+    regs->r10 = uc->uc_mcontext.mc_r10;
+    regs->r11 = uc->uc_mcontext.mc_r11;
+    regs->r12 = uc->uc_mcontext.mc_r12;
+    regs->r13 = uc->uc_mcontext.mc_r13;
+    regs->r14 = uc->uc_mcontext.mc_r14;
+    regs->r15 = uc->uc_mcontext.mc_r15;
+    regs->eflags = uc->uc_mcontext.mc_flags;
+}
+
+void port_thread_regs_to_context(ucontext_t *uc, Registers* regs)
+{
+    uc->uc_mcontext.mc_rax = regs->rax;
+    uc->uc_mcontext.mc_rcx = regs->rcx;
+    uc->uc_mcontext.mc_rdx = regs->rdx;
+    uc->uc_mcontext.mc_rdi = regs->rdi;
+    uc->uc_mcontext.mc_rsi = regs->rsi;
+    uc->uc_mcontext.mc_rbx = regs->rbx;
+    uc->uc_mcontext.mc_rbp = regs->rbp;
+    uc->uc_mcontext.mc_rip = regs->rip;
+    uc->uc_mcontext.mc_rsp = regs->rsp;
+    uc->uc_mcontext.mc_r8  = regs->r8;
+    uc->uc_mcontext.mc_r9  = regs->r9;
+    uc->uc_mcontext.mc_r10 = regs->r10;
+    uc->uc_mcontext.mc_r11 = regs->r11;
+    uc->uc_mcontext.mc_r12 = regs->r12;
+    uc->uc_mcontext.mc_r13 = regs->r13;
+    uc->uc_mcontext.mc_r14 = regs->r14;
+    uc->uc_mcontext.mc_r15 = regs->r15;
+    uc->uc_mcontext.mc_flags = regs->eflags;
+}
+
+#else
 
 void port_thread_context_to_regs(Registers* regs, ucontext_t *uc)
 {
@@ -64,3 +111,4 @@
     uc->uc_mcontext.gregs[REG_R15] = regs->r15;
     uc->uc_mcontext.gregs[REG_EFL] = regs->eflags;
 }
+#endif

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/ncai/utils/ncai_utils_em64t.cpp
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/ncai/utils/ncai_utils_em64t.cpp?rev=692051&r1=692050&r2=692051&view=diff
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/ncai/utils/ncai_utils_em64t.cpp (original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/ncai/utils/ncai_utils_em64t.cpp Thu Sep  4
07:30:09 2008
@@ -64,6 +64,60 @@
     return sizeof(g_ncai_reg_table)/sizeof(g_ncai_reg_table[0]);
 }
 
+#if defined(FREEBSD)
+
+static void ncai_context_to_registers(ucontext_t* pcontext, NcaiRegisters* pregs)
+{
+    pregs->rax  = pcontext->uc_mcontext.mc_rax;
+    pregs->rbx  = pcontext->uc_mcontext.mc_rbx;
+    pregs->rcx  = pcontext->uc_mcontext.mc_rcx;
+    pregs->rdx  = pcontext->uc_mcontext.mc_rdx;
+    pregs->rsp  = pcontext->uc_mcontext.mc_rsp;
+    pregs->rbp  = pcontext->uc_mcontext.mc_rbp;
+    pregs->rsi  = pcontext->uc_mcontext.mc_rsi;
+    pregs->rdi  = pcontext->uc_mcontext.mc_rdi;
+    pregs->r8   = pcontext->uc_mcontext.mc_r8;
+    pregs->r9   = pcontext->uc_mcontext.mc_r9;
+    pregs->r10  = pcontext->uc_mcontext.mc_r10;
+    pregs->r11  = pcontext->uc_mcontext.mc_r11;
+    pregs->r12  = pcontext->uc_mcontext.mc_r12;
+    pregs->r13  = pcontext->uc_mcontext.mc_r13;
+    pregs->r14  = pcontext->uc_mcontext.mc_r14;
+    pregs->r15  = pcontext->uc_mcontext.mc_r15;
+    pregs->fs = 0;
+    pregs->gs = 0;
+    pregs->ss = 0;
+    pregs->cs = 0;
+    pregs->rip    = pcontext->uc_mcontext.mc_rip;
+    pregs->eflags = pcontext->uc_mcontext.mc_flags;
+}
+
+static void ncai_registers_to_context(NcaiRegisters* pregs, ucontext_t* pcontext)
+{
+    pcontext->uc_mcontext.mc_rax  = pregs->rax;
+    pcontext->uc_mcontext.mc_rbx  = pregs->rbx;
+    pcontext->uc_mcontext.mc_rcx  = pregs->rcx;
+    pcontext->uc_mcontext.mc_rdx  = pregs->rdx;
+    pcontext->uc_mcontext.mc_rsp  = pregs->rsp;
+    pcontext->uc_mcontext.mc_rbp  = pregs->rbp;
+    pcontext->uc_mcontext.mc_rsi  = pregs->rsi;
+    pcontext->uc_mcontext.mc_rdi  = pregs->rdi;
+    pcontext->uc_mcontext.mc_r8   = pregs->r8;
+    pcontext->uc_mcontext.mc_r9   = pregs->r9;
+    pcontext->uc_mcontext.mc_r10  = pregs->r10;
+    pcontext->uc_mcontext.mc_r11  = pregs->r11;
+    pcontext->uc_mcontext.mc_r12  = pregs->r12;
+    pcontext->uc_mcontext.mc_r13  = pregs->r13;
+    pcontext->uc_mcontext.mc_r14  = pregs->r14;
+    pcontext->uc_mcontext.mc_r15  = pregs->r15;
+    // cs, gs, fs and ss registers are not restored, because there is
+    // no storage for them
+    pcontext->uc_mcontext.mc_rip  = pregs->rip;
+    pcontext->uc_mcontext.mc_flags  = pregs->eflags;
+}
+
+#else // # defined(FREEBSD)
+
 #ifdef PLATFORM_POSIX
 
 static void ncai_context_to_registers(ucontext_t* pcontext, NcaiRegisters* pregs)
@@ -178,6 +232,8 @@
 
 #endif // #ifdef PLATFORM_POSIX
 
+#endif // # defined(FREEBSD)
+
 bool ncai_get_register_value(hythread_t thread, jint reg_number, void* buf_ptr)
 {
     thread_context_t context;



Mime
View raw message