guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 21/86: "extern"-related cleanup, and further implementat


From: Andy Wingo
Subject: [Guile-commits] 21/86: "extern"-related cleanup, and further implementation
Date: Wed, 3 Apr 2019 11:38:51 -0400 (EDT)

wingo pushed a commit to branch lightening
in repository guile.

commit 47970773bc0ccc0749b879b08d6b1da793fb2b58
Author: Andy Wingo <address@hidden>
Date:   Wed Oct 31 21:45:16 2018 +0100

    "extern"-related cleanup, and further implementation
---
 jit.h         | 46 ++++++++++++++++++++++++++--------------------
 jit/arm-swf.c |  4 ++--
 jit/arm.h     |  4 ++--
 jit/jit.c     | 21 +++++++++++++--------
 jit/private.h | 46 ++++++++++++++++++++++------------------------
 jit/x86.h     |  4 ++--
 6 files changed, 67 insertions(+), 58 deletions(-)

diff --git a/jit.h b/jit.h
index 140c390..14feaf5 100644
--- a/jit.h
+++ b/jit.h
@@ -47,6 +47,12 @@ typedef intptr_t     jit_imm_t;
 typedef uintptr_t      jit_uimm_t;
 typedef struct jit_reloc *jit_reloc_t;
 
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#  define JIT_API              extern __attribute__ 
((__visibility__("hidden")))
+#else
+#  define JIT_API              extern
+#endif
+
 #if defined(__i386__) || defined(__x86_64__)
 #  include "jit/x86.h"
 #elif defined(__mips__)
@@ -105,39 +111,39 @@ typedef struct jit_arg
   } loc;
 } jit_arg_t;
 
-extern void init_jit(void);
+JIT_API void init_jit(void);
 
-extern jit_state_t *jit_new_state(void);
-extern void jit_destroy_state(jit_state_t*);
+JIT_API jit_state_t *jit_new_state(void);
+JIT_API void jit_destroy_state(jit_state_t*);
 
-extern void jit_begin(jit_state_t*, jit_addr_t, size_t);
-extern void jit_reset(jit_state_t*);
-extern jit_addr_t jit_end(jit_state_t*, size_t*);
+JIT_API void jit_begin(jit_state_t*, jit_addr_t, size_t);
+JIT_API void jit_reset(jit_state_t*);
+JIT_API jit_addr_t jit_end(jit_state_t*, size_t*);
 
-extern void jit_align(jit_state_t*, unsigned);
-extern void jit_allocai(jit_state_t*, size_t);
-extern void jit_allocar(jit_state_t*, jit_gpr_t, jit_gpr_t);
+JIT_API void jit_align(jit_state_t*, unsigned);
+JIT_API void jit_allocai(jit_state_t*, size_t);
+JIT_API void jit_allocar(jit_state_t*, jit_gpr_t, jit_gpr_t);
 
-extern jit_pointer_t jit_address(jit_state_t*);
-extern void jit_patch_here(jit_state_t*, jit_reloc_t);
-extern void jit_patch_there(jit_state_t*, jit_reloc_t, jit_pointer_t);
+JIT_API jit_pointer_t jit_address(jit_state_t*);
+JIT_API void jit_patch_here(jit_state_t*, jit_reloc_t);
+JIT_API void jit_patch_there(jit_state_t*, jit_reloc_t, jit_pointer_t);
 
-extern void jit_calli(jit_state_t *, jit_pointer_t f,
+JIT_API void jit_calli(jit_state_t *, jit_pointer_t f,
                       size_t argc, const jit_arg_t *argv);
-extern void jit_callr(jit_state_t *, jit_gpr_t f,
+JIT_API void jit_callr(jit_state_t *, jit_gpr_t f,
                       size_t argc, const jit_arg_t *argv);
-extern void jit_receive(jit_state_t*, size_t argc, jit_arg_t *argv);
+JIT_API void jit_receive(jit_state_t*, size_t argc, jit_arg_t *argv);
 
 #define JIT_PROTO_0(stem, ret) \
-  extern ret jit_##stem (jit_state_t*)
+  JIT_API ret jit_##stem (jit_state_t*)
 #define JIT_PROTO_1(stem, ret, a) \
-  extern ret jit_##stem (jit_state_t*, jit_##a##_t)
+  JIT_API ret jit_##stem (jit_state_t*, jit_##a##_t)
 #define JIT_PROTO_2(stem, ret, a, b) \
-  extern ret jit_##stem (jit_state_t*, jit_##a##_t, jit_##b##_t)
+  JIT_API ret jit_##stem (jit_state_t*, jit_##a##_t, jit_##b##_t)
 #define JIT_PROTO_3(stem, ret, a, b, c) \
-  extern ret jit_##stem (jit_state_t*, jit_##a##_t, jit_##b##_t, jit_##c##_t)
+  JIT_API ret jit_##stem (jit_state_t*, jit_##a##_t, jit_##b##_t, jit_##c##_t)
 #define JIT_PROTO_4(stem, ret, a, b, c, d) \
-  extern ret jit_##stem (jit_state_t*, jit_##a##_t, jit_##b##_t, jit_##c##_t, 
jit_##d##_t)
+  JIT_API ret jit_##stem (jit_state_t*, jit_##a##_t, jit_##b##_t, jit_##c##_t, 
jit_##d##_t)
 
 #define JIT_PROTO_RFF__(stem) JIT_PROTO_2(stem, jit_reloc_t, fpr, fpr)
 #define JIT_PROTO_RGG__(stem) JIT_PROTO_2(stem, jit_reloc_t, gpr, gpr)
diff --git a/jit/arm-swf.c b/jit/arm-swf.c
index aee52a5..b32ec9e 100644
--- a/jit/arm-swf.c
+++ b/jit/arm-swf.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2017  Free Software Foundation, Inc.
+ * Copyright (C) 2012-2018  Free Software Foundation, Inc.
  *
  * This file is part of GNU lightning.
  *
@@ -474,7 +474,7 @@ __aeabi_f2d(float u)
     return (u);
 }
 
-extern int
+int
 __aeabi_f2iz(float u)
 {
     return (u);
diff --git a/jit/arm.h b/jit/arm.h
index a456254..9177f13 100644
--- a/jit/arm.h
+++ b/jit/arm.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2017  Free Software Foundation, Inc.
+ * Copyright (C) 2012-2018  Free Software Foundation, Inc.
  *
  * This file is part of GNU lightning.
  *
@@ -122,6 +122,6 @@ typedef struct {
 /*
  * Initialization
  */
-extern jit_cpu_t               jit_cpu;
+JIT_API jit_cpu_t              jit_cpu;
 
 #endif /* _jit_arm_h */
diff --git a/jit/jit.c b/jit/jit.c
index 1f53514..c14fe24 100644
--- a/jit/jit.c
+++ b/jit/jit.c
@@ -41,9 +41,12 @@
 #define jit_regload_isdead             2       /* delete and unset live bit */
 
 
-/*
- * Implementation
- */
+static void jit_get_cpu(void);
+static void jit_flush(jit_state_t *, const char *, const char *);
+static void jit_nop(jit_state_t *, unsigned);
+static void jit_patch(jit_state_t *, const uint8_t *loc, const uint8_t *addr);
+static void jit_patch_last(jit_state_t *, const uint8_t *loc, const uint8_t 
*addr);
+
 void
 init_jit(void)
 {
@@ -134,18 +137,20 @@ jit_align(jit_state_t *_jit, unsigned align)
 }
 
 void
-jit_patch_here(jit_state_t *_jit, jit_reloc_t *reloc)
+jit_patch_here(jit_state_t *_jit, jit_reloc_t reloc)
 {
   jit_patch_there (_jit, reloc, jit_address (_jit));
 }
 
 void
-jit_patch_there(jit_state_t* _jit, jit_reloc_t *reloc, jit_pointer_t *addr)
+jit_patch_there(jit_state_t* _jit, jit_reloc_t reloc, jit_pointer_t addr)
 {
-  if (reloc == _jit->last_instruction)
-    jit_patch_last (_jit, reloc, addr);
+  const uint8_t *loc = jit_reloc_instruction (reloc);
+
+  if (loc == _jit->last_instruction_start)
+    jit_patch_last (_jit, loc, addr);
   else
-    jit_patch (_jit, reloc, addr);
+    jit_patch (_jit, loc, addr);
 }
 
 #if defined(__i386__) || defined(__x86_64__)
diff --git a/jit/private.h b/jit/private.h
index 41bbdc1..e0af19c 100644
--- a/jit/private.h
+++ b/jit/private.h
@@ -130,34 +130,32 @@
                                                 * returned by a "user" call
                                                 * to jit_get_reg() */
 
-/*
- * Types
- */
-typedef struct jit_register    jit_register_t;
-
-struct jit_state {
-    union {
-       uint8_t  *uc;
-       uint16_t         *us;
-       uint32_t         *ui;
-       uint64_t         *ul;
-       jit_word_t        w;
-    } pc;
-    struct {
-       uint8_t *ptr;
-       uint8_t *end;
-       jit_word_t       length;
-    } code;
+struct jit_state
+{
+  union {
+    uint8_t *uc;
+    uint16_t *us;
+    uint32_t *ui;
+    uint64_t *ul;
+    intptr_t w;
+    uintptr_t uw;
+  } pc;
+  uint8_t *start;
+  uint8_t *last_instruction_start;
+  uint8_t *end;
 };
 
-struct jit_register {
-    jit_reg_t           spec;
-    char               *name;
+struct jit_register
+{
+  jit_reg_t spec;
+  char *name;
 };
 
-extern void jit_get_cpu(void);
-extern void jit_flush(void *fptr, void *tptr);
+typedef struct jit_register jit_register_t;
+
+static void jit_get_cpu(void);
+static void jit_flush(void *fptr, void *tptr);
 
-extern jit_register_t   _rvs[];
+static jit_register_t _rvs[];
 
 #endif /* _jit_private_h */
diff --git a/jit/x86.h b/jit/x86.h
index fb49c1e..7e37f95 100644
--- a/jit/x86.h
+++ b/jit/x86.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2017  Free Software Foundation, Inc.
+ * Copyright (C) 2012-2018  Free Software Foundation, Inc.
  *
  * This file is part of GNU lightning.
  *
@@ -194,6 +194,6 @@ typedef struct {
 /*
  * Initialization
  */
-extern jit_cpu_t               jit_cpu;
+JIT_API jit_cpu_t              jit_cpu;
 
 #endif /* _jit_x86_h */



reply via email to

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