dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and to


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET engine, compilers and tools (pnet) branch, master, updated. 6f7a4aaef216dd887992502f386c4e2cbd715173
Date: Tue, 08 Sep 2009 13:02:20 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET engine, compilers and tools (pnet)".

The branch, master has been updated
       via  6f7a4aaef216dd887992502f386c4e2cbd715173 (commit)
      from  443d1db9241c1c222e225478cdf764526d5c593a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnet.git/commit/?id=6f7a4aaef216dd887992502f386c4e2cbd715173

commit 6f7a4aaef216dd887992502f386c4e2cbd715173
Author: Klaus Treichel <address@hidden>
Date:   Tue Sep 8 15:01:56 2009 +0200

    Add interrupt based exception handling support for x86_64 with cvm.

diff --git a/ChangeLog b/ChangeLog
index df3ac93..4fa51a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-09-08  Klaus Treichel  <address@hidden>
+
+       * engine/cvm.c: Add support for restoring the interpreter state after
+       returnining to the interpreter from a longjmp for X86_64.
+
+       * engine/engine.h: Add x86_64 to the platforms that support interrupt
+       based exception handling.
+
+       * support/interrupt.h: Add the declaration of the interrupt context for
+       x86_64.
+
+       * support/interrupt_posix.c (__sigaction_handler): Copy the information
+       from the signal context to the interrupt context for x86_64 now too.
+
 2009-09-07  Klaus Treichel  <address@hidden>
 
        * configure.in: Add check for the functions _setjmp, _lingjmp and
diff --git a/engine/cvm.c b/engine/cvm.c
index 02012e6..e88d7b5 100644
--- a/engine/cvm.c
+++ b/engine/cvm.c
@@ -90,6 +90,9 @@ extern        "C" {
                return ILMemCmp(dst, src, len);
        }
 #elif defined(CVM_X86_64) && defined(__GNUC__) && !defined(IL_NO_ASM)
+
+       #define REGISTER_ASM_X86_64 1
+
        /* 16 registers - so we can avoid using esi, edi and ebx. */
        #define REGISTER_ASM_PC(x)              register x asm("r12")
        #define REGISTER_ASM_STACK(x)           register x asm("r14") 
@@ -248,6 +251,24 @@ extern     "C" {
                                ( "mov %0, %%esi;" : : "m"(tempreg) ); \
                        } \
                        while (0);
+       #elif defined(IL_INTERRUPT_HAVE_X86_64_CONTEXT) && 
defined(REGISTER_ASM_X86_64)
+               /*
+                * If the interrupt subsystem can provide us the x86_64 
registers
+                * at the time of interrupt then we don't need to save anything
+                */
+               #define INTERRUPT_BACKUP_FRAME()
+               #define INTERRUPT_BACKUP_PC_STACKTOP_FRAME()
+
+               /* We can restore locals directly from the register state
+                  at the time of interrupt */
+               #define INTERRUPT_RESTORE_FROM_THREAD() \
+                       do \
+                       { \
+                               pc = (unsigned char 
*)thread->interruptContext.R12; \
+                               stacktop = (CVMWord 
*)thread->interruptContext.R14; \
+                               frame = (CVMWord 
*)thread->interruptContext.R15; \
+                       } \
+                       while (0);
        #else
                #define INTERRUPT_RESTORE_FROM_THREAD()
        #endif
diff --git a/engine/engine.h b/engine/engine.h
index 8bd10c3..885389c 100644
--- a/engine/engine.h
+++ b/engine/engine.h
@@ -59,7 +59,9 @@ extern        "C" {
 
 /* Determine the interrupts we should catch */
 
-#if defined(IL_INTERRUPT_HAVE_X86_CONTEXT) || !defined(__GNUC__) || 
defined(IL_NO_ASM)
+#if defined(IL_INTERRUPT_HAVE_X86_CONTEXT) || \
+       defined(IL_INTERRUPT_HAVE_X86_64_CONTEXT) || \
+       !defined(__GNUC__) || defined(IL_NO_ASM)
 
 #if defined(IL_INTERRUPT_SUPPORTS_ILLEGAL_MEMORY_ACCESS)       
        #define IL_USE_INTERRUPT_BASED_X (1)
diff --git a/support/interrupt.h b/support/interrupt.h
index b5f5928..b585119 100755
--- a/support/interrupt.h
+++ b/support/interrupt.h
@@ -50,6 +50,45 @@ struct _tagILInterruptContext
        unsigned int Esp;
 };
 
+#elif defined(__x86_64__) || defined(__x86_64) 
+
+/*
+ * Note: The SysV ABI specifies that the long type is 64 bits wide.
+ * On 64 bit Windows the long datatype is still 32 bits wide.
+ * So we have to use ILUInt64 for the general purpose registers to be
+ * portable.
+ * We don't save the xmm and floating point registers in the context
+ * for now.
+ */
+struct _tagILInterruptContext
+{
+       int type;
+       
+       void *memoryAddress;
+       void *instructionAddress;
+
+       /* General purpose registers */
+       ILUInt64        Rax;
+       ILUInt64        Rbx;
+       ILUInt64        Rcx;
+       ILUInt64        Rdx;
+       ILUInt64        Rsi;
+       ILUInt64        Rdi;
+       ILUInt64        R8;
+       ILUInt64        R9;
+       ILUInt64        R10;
+       ILUInt64        R11;
+       ILUInt64        R12;
+       ILUInt64        R13;
+       ILUInt64        R14;
+       ILUInt64        R15;
+
+       /* Control registers */
+       ILUInt64        Rbp;
+       ILUInt64        Rip;
+       ILUInt64        Rsp;
+};
+
 #else
 
 struct _tagILInterruptContext
@@ -115,9 +154,12 @@ struct _tagILInterruptContext
                        #define IL_INTERRUPT_SUPPORTS_INT_OVERFLOW 1
                #endif
 
-               #if (defined(__i386) || defined(__i386__)) \
-                       && defined(HAVE_SIGACTION) && 
defined(HAVE_SYS_UCONTEXT_H)
-                       #define IL_INTERRUPT_HAVE_X86_CONTEXT 1
+               #if defined(HAVE_SIGACTION) && defined(HAVE_SYS_UCONTEXT_H)
+                       #if (defined(__i386) || defined(__i386__))
+                               #define IL_INTERRUPT_HAVE_X86_CONTEXT 1
+                       #elif defined(__x86_64__) || defined(__x86_64) 
+                               #define IL_INTERRUPT_HAVE_X86_64_CONTEXT 1
+                       #endif
                #endif
        #endif
 #endif
diff --git a/support/interrupt_posix.c b/support/interrupt_posix.c
index 1ada568..610a15b 100755
--- a/support/interrupt_posix.c
+++ b/support/interrupt_posix.c
@@ -62,6 +62,9 @@ extern        "C" {
        #if !defined(REG_ESP) && defined(ESP)
                #define REG_ESP ESP
        #endif
+
+#elif defined(IL_INTERRUPT_HAVE_X86_64_CONTEXT)
+       #include <sys/ucontext.h>
 #endif
 
 #if defined(IL_INTERRUPT_SUPPORTS)
@@ -75,6 +78,9 @@ static void __sigaction_handler(int signo, siginfo_t *info, 
void *ctx)
 #if defined(IL_INTERRUPT_HAVE_X86_CONTEXT)
        ucontext_t *uc;
        uc = (ucontext_t *)ctx;
+#elif defined(IL_INTERRUPT_HAVE_X86_64_CONTEXT)
+       ucontext_t *uc;
+       uc = (ucontext_t *)ctx;
 #endif
 
        thread = _ILThreadGetSelf();
@@ -111,6 +117,28 @@ static void __sigaction_handler(int signo, siginfo_t 
*info, void *ctx)
        #endif
        
        context.instructionAddress = (void *)context.Eip;
+#elif defined(IL_INTERRUPT_HAVE_X86_64_CONTEXT)
+       /* Integer registers */
+       context.Rax = uc->uc_mcontext.gregs[REG_RAX];
+       context.Rbx = uc->uc_mcontext.gregs[REG_RBX];
+       context.Rcx = uc->uc_mcontext.gregs[REG_RCX];
+       context.Rdx = uc->uc_mcontext.gregs[REG_RDX];
+       context.Rdi = uc->uc_mcontext.gregs[REG_RDI];
+       context.Rsi = uc->uc_mcontext.gregs[REG_RSI];
+       context.R8 = uc->uc_mcontext.gregs[REG_R8];
+       context.R9 = uc->uc_mcontext.gregs[REG_R9];
+       context.R10 = uc->uc_mcontext.gregs[REG_R10];
+       context.R11 = uc->uc_mcontext.gregs[REG_R11];
+       context.R12 = uc->uc_mcontext.gregs[REG_R12];
+       context.R13 = uc->uc_mcontext.gregs[REG_R13];
+       context.R14 = uc->uc_mcontext.gregs[REG_R14];
+       context.R15 = uc->uc_mcontext.gregs[REG_R15];
+
+       context.Rbp = uc->uc_mcontext.gregs[REG_RBP];
+       context.Rip = uc->uc_mcontext.gregs[REG_RIP];
+       context.Rsp = uc->uc_mcontext.gregs[REG_RSP];
+
+       context.instructionAddress = (void *)context.Rip;
 #else
        context.instructionAddress = 0;
 #endif

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                 |   14 +++++++++++++
 engine/cvm.c              |   21 +++++++++++++++++++
 engine/engine.h           |    4 ++-
 support/interrupt.h       |   48 ++++++++++++++++++++++++++++++++++++++++++--
 support/interrupt_posix.c |   28 ++++++++++++++++++++++++++
 5 files changed, 111 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
DotGNU Portable.NET engine, compilers and tools (pnet)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]