guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 01/04: Add instrument-entry to continuations


From: Andy Wingo
Subject: [Guile-commits] 01/04: Add instrument-entry to continuations
Date: Tue, 7 Aug 2018 05:07:56 -0400 (EDT)

wingo pushed a commit to branch lightning
in repository guile.

commit 8f25f75bf1c732a25011ed8d52ff26458ea2c8f0
Author: Andy Wingo <address@hidden>
Date:   Mon Aug 6 14:59:48 2018 +0200

    Add instrument-entry to continuations
    
    * libguile/continuations.c (goto_continuation_code):
    * libguile/control.c (compose_continuation_code): Add JIT
      instrumentation.  Unlike foreign or subr routines, we leave these as
      closures; it doesn't make sense to JIT for any particular
      continuation.
---
 libguile/continuations.c | 24 ++++++++++++++++++++----
 libguile/control.c       | 25 ++++++++++++++++++++-----
 2 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/libguile/continuations.c b/libguile/continuations.c
index 5380a5e..c7e008f 100644
--- a/libguile/continuations.c
+++ b/libguile/continuations.c
@@ -41,6 +41,7 @@
 #include "gsubr.h"
 #include "init.h"
 #include "instructions.h"
+#include "jit.h"
 #include "list.h"
 #include "numbers.h"
 #include "pairs.h"
@@ -75,10 +76,25 @@ static scm_t_bits tc16_continuation;
    of that trampoline function.
  */
 
-static const uint32_t continuation_stub_code[] =
+struct goto_continuation_code
+{
+  struct scm_jit_function_data data;
+  uint32_t code[3];
+};
+
+struct goto_continuation_code goto_continuation_code = {
   {
-    SCM_PACK_OP_24 (continuation_call, 0)
-  };
+    /* mcode = */ 0,
+    /* counter = */ 0,
+    /* start = */ sizeof (struct scm_jit_function_data),
+    /* end = */ sizeof (struct goto_continuation_code)
+  },
+  {
+    SCM_PACK_OP_24 (instrument_entry, 0),
+    ((uint32_t) -(sizeof (struct scm_jit_function_data) / 4)),
+    SCM_PACK_OP_24 (continuation_call, 0),
+  }
+};
 
 static SCM
 make_continuation_trampoline (SCM contregs)
@@ -88,7 +104,7 @@ make_continuation_trampoline (SCM contregs)
   scm_t_bits flags = SCM_F_PROGRAM_IS_CONTINUATION;
 
   ret = scm_words (scm_tc7_program | (nfree << 16) | flags, nfree + 2);
-  SCM_SET_CELL_WORD_1 (ret, continuation_stub_code);
+  SCM_SET_CELL_WORD_1 (ret, goto_continuation_code.code);
   SCM_PROGRAM_FREE_VARIABLE_SET (ret, 0, contregs);
 
   return ret;
diff --git a/libguile/control.c b/libguile/control.c
index 2e10b58..61ead5e 100644
--- a/libguile/control.c
+++ b/libguile/control.c
@@ -28,6 +28,7 @@
 #include "frames.h"
 #include "gsubr.h"
 #include "instructions.h"
+#include "jit.h"
 #include "list.h"
 #include "pairs.h"
 #include "programs.h"
@@ -68,11 +69,25 @@ scm_i_prompt_pop_abort_args_x (struct scm_vm *vp,
 }
 
 
-static const uint32_t compose_continuation_code[] =
-  {
-    SCM_PACK_OP_24 (compose_continuation, 0)
-  };
+struct compose_continuation_code
+{
+  struct scm_jit_function_data data;
+  uint32_t code[3];
+};
 
+struct compose_continuation_code compose_continuation_code = {
+  {
+    /* mcode = */ 0,
+    /* counter = */ 0,
+    /* start = */ sizeof (struct scm_jit_function_data),
+    /* end = */ sizeof (struct compose_continuation_code)
+  },
+  {
+    SCM_PACK_OP_24 (instrument_entry, 0),
+    ((uint32_t) -(sizeof (struct scm_jit_function_data) / 4)),
+    SCM_PACK_OP_24 (compose_continuation, 0),
+  }
+};
 
 SCM
 scm_i_make_composable_continuation (SCM vmcont)
@@ -82,7 +97,7 @@ scm_i_make_composable_continuation (SCM vmcont)
   SCM ret;
 
   ret = scm_words (scm_tc7_program | (nfree << 16) | flags, nfree + 2);
-  SCM_SET_CELL_WORD_1 (ret, compose_continuation_code);
+  SCM_SET_CELL_WORD_1 (ret, compose_continuation_code.code);
   SCM_PROGRAM_FREE_VARIABLE_SET (ret, 0, vmcont);
 
   return ret;



reply via email to

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