You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/07/27 20:12:42 UTC

[1/2] lucy-clownfish git commit: Make ivars offsets and sizes a uint32_t

Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 5e2478048 -> f6035fad2


Make ivars offsets and sizes a uint32_t


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/f6035fad
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/f6035fad
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/f6035fad

Branch: refs/heads/master
Commit: f6035fad216984dc1096029481ead147f4f1b4d8
Parents: 25c561a
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Apr 17 21:45:27 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Jul 27 19:03:42 2015 +0200

----------------------------------------------------------------------
 compiler/src/CFCBindClass.c      | 4 ++--
 compiler/src/CFCBindCore.c       | 2 +-
 compiler/src/CFCBindSpecs.c      | 4 ++--
 runtime/core/Clownfish/Class.c   | 6 +++---
 runtime/core/Clownfish/Class.cfh | 6 +++---
 5 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/f6035fad/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c
index 70dd211..69acd22 100644
--- a/compiler/src/CFCBindClass.c
+++ b/compiler/src/CFCBindClass.c
@@ -164,7 +164,7 @@ S_ivars_func(CFCBindClass *self) {
     const char *full_offset  = CFCClass_full_ivars_offset(client);
     const char *PREFIX       = CFCClass_get_PREFIX(client);
     char pattern[] =
-        "extern size_t %s;\n"
+        "extern uint32_t %s;\n"
         "typedef struct %s %s;\n"
         "static CFISH_INLINE %s*\n"
         "%s(%s *self) {\n"
@@ -312,7 +312,7 @@ CFCBindClass_to_c_data(CFCBindClass *self) {
         " * can be found.\n"
         " */\n"
         "\n"
-        "size_t %s;\n"
+        "uint32_t %s;\n"
         "\n"
         "/* Offsets for method pointers, measured in bytes, from the top\n"
         " * of this class's singleton object.\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/f6035fad/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index 5b20de8..5c8eae2 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -226,7 +226,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
         "     ((_full_meth ## _t)cfish_super_method(_class, \\\n"
         "                                           _full_meth ## _OFFSET))\n"
         "\n"
-        "extern CFISH_VISIBLE size_t cfish_Class_offset_of_parent;\n"
+        "extern CFISH_VISIBLE uint32_t cfish_Class_offset_of_parent;\n"
         "static CFISH_INLINE cfish_method_t\n"
         "cfish_super_method(const void *klass, uint32_t offset) {\n"
         "    char *class_as_char = (char*)klass;\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/f6035fad/compiler/src/CFCBindSpecs.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindSpecs.c b/compiler/src/CFCBindSpecs.c
index 7c5c2a3..28da29c 100644
--- a/compiler/src/CFCBindSpecs.c
+++ b/compiler/src/CFCBindSpecs.c
@@ -124,8 +124,8 @@ CFCBindSpecs_get_typedefs() {
         "    cfish_Class **klass;\n"
         "    cfish_Class **parent;\n"
         "    const char   *name;\n"
-        "    size_t        ivars_size;\n"
-        "    size_t       *ivars_offset_ptr;\n"
+        "    uint32_t      ivars_size;\n"
+        "    uint32_t     *ivars_offset_ptr;\n"
         "    uint32_t      num_novel_meths;\n"
         "    uint32_t      num_overridden_meths;\n"
         "    uint32_t      num_inherited_meths;\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/f6035fad/runtime/core/Clownfish/Class.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.c b/runtime/core/Clownfish/Class.c
index d2de1ff..d16c3b8 100644
--- a/runtime/core/Clownfish/Class.c
+++ b/runtime/core/Clownfish/Class.c
@@ -42,7 +42,7 @@
 #define InheritedMethSpec        cfish_InheritedMethSpec
 #define ClassSpec                cfish_ClassSpec
 
-size_t Class_offset_of_parent = offsetof(Class, parent);
+uint32_t Class_offset_of_parent = offsetof(Class, parent);
 
 static void
 S_set_name(Class *self, const char *utf8, size_t size);
@@ -109,7 +109,7 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
         Class *klass  = *spec->klass;
         Class *parent = spec->parent ? *spec->parent : NULL;
 
-        size_t ivars_offset = 0;
+        uint32_t ivars_offset = 0;
         if (spec->ivars_offset_ptr != NULL) {
             if (parent) {
                 Class *ancestor = parent;
@@ -240,7 +240,7 @@ Class_Get_Parent_IMP(Class *self) {
     return self->parent;
 }
 
-size_t
+uint32_t
 Class_Get_Obj_Alloc_Size_IMP(Class *self) {
     return self->obj_alloc_size;
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/f6035fad/runtime/core/Clownfish/Class.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.cfh b/runtime/core/Clownfish/Class.cfh
index 4a789eb..c32d316 100644
--- a/runtime/core/Clownfish/Class.cfh
+++ b/runtime/core/Clownfish/Class.cfh
@@ -30,12 +30,12 @@ final class Clownfish::Class inherits Clownfish::Obj {
     String             *name_internal;
     uint32_t            flags;
     int32_t             parcel_id;
-    size_t              obj_alloc_size;
+    uint32_t            obj_alloc_size;
     uint32_t            class_alloc_size;
     Method            **methods;
     cfish_method_t[1]   vtable; /* flexible array */
 
-    inert size_t offset_of_parent;
+    inert uint32_t offset_of_parent;
 
     inert void
     bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
@@ -130,7 +130,7 @@ final class Clownfish::Class inherits Clownfish::Obj {
     Class*
     Get_Parent(Class *self);
 
-    size_t
+    uint32_t
     Get_Obj_Alloc_Size(Class *self);
 
     /** Return novel methods of the class.


[2/2] lucy-clownfish git commit: Make method offsets a uint32_t

Posted by nw...@apache.org.
Make method offsets a uint32_t

Also make class_alloc_size a uint32_t.

See CLOWNFISH-15.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/25c561a4
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/25c561a4
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/25c561a4

Branch: refs/heads/master
Commit: 25c561a4fe43b32fce10a61dc056974cd6e4bdbe
Parents: 5e24780
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Apr 17 21:25:53 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Mon Jul 27 19:03:42 2015 +0200

----------------------------------------------------------------------
 compiler/src/CFCBindClass.c       |  2 +-
 compiler/src/CFCBindCore.c        |  8 ++++----
 compiler/src/CFCBindMethod.c      |  2 +-
 compiler/src/CFCBindSpecs.c       | 10 +++++-----
 runtime/core/Clownfish/Class.c    | 30 +++++++++++++++---------------
 runtime/core/Clownfish/Class.cfh  |  4 ++--
 runtime/core/Clownfish/Method.c   |  4 ++--
 runtime/core/Clownfish/Method.cfh |  6 +++---
 8 files changed, 33 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindClass.c b/compiler/src/CFCBindClass.c
index f19a174..70dd211 100644
--- a/compiler/src/CFCBindClass.c
+++ b/compiler/src/CFCBindClass.c
@@ -293,7 +293,7 @@ CFCBindClass_to_c_data(CFCBindClass *self) {
 
         // Define method offset variable.
         char *full_offset_sym = CFCMethod_full_offset_sym(method, client);
-        offsets = CFCUtil_cat(offsets, "size_t ", full_offset_sym, ";\n",
+        offsets = CFCUtil_cat(offsets, "uint32_t ", full_offset_sym, ";\n",
                               NULL);
         FREEMEM(full_offset_sym);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index ce0f9f7..5b20de8 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -201,7 +201,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
         "     ((_full_meth ## _t)cfish_method(_class, _full_meth ## _OFFSET))\n"
         "\n"
         "static CFISH_INLINE cfish_method_t\n"
-        "cfish_method(const void *klass, size_t offset) {\n"
+        "cfish_method(const void *klass, uint32_t offset) {\n"
         "    union { char *cptr; cfish_method_t *fptr; } ptr;\n"
         "    ptr.cptr = (char*)klass + offset;\n"
         "    return ptr.fptr[0];\n"
@@ -215,7 +215,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
         "/* Access the function pointer for a given method from the object.\n"
         " */\n"
         "static CFISH_INLINE cfish_method_t\n"
-        "cfish_obj_method(const void *object, size_t offset) {\n"
+        "cfish_obj_method(const void *object, uint32_t offset) {\n"
         "    cfish_Dummy *dummy = (cfish_Dummy*)object;\n"
         "    return cfish_method(dummy->klass, offset);\n"
         "}\n"
@@ -228,7 +228,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
         "\n"
         "extern CFISH_VISIBLE size_t cfish_Class_offset_of_parent;\n"
         "static CFISH_INLINE cfish_method_t\n"
-        "cfish_super_method(const void *klass, size_t offset) {\n"
+        "cfish_super_method(const void *klass, uint32_t offset) {\n"
         "    char *class_as_char = (char*)klass;\n"
         "    cfish_Class **parent_ptr\n"
         "        = (cfish_Class**)(class_as_char + cfish_Class_offset_of_parent);\n"
@@ -237,7 +237,7 @@ S_write_parcel_h(CFCBindCore *self, CFCParcel *parcel) {
         "\n"
         "typedef void\n"
         "(*cfish_destroy_t)(void *vself);\n"
-        "extern CFISH_VISIBLE size_t CFISH_Obj_Destroy_OFFSET;\n"
+        "extern CFISH_VISIBLE uint32_t CFISH_Obj_Destroy_OFFSET;\n"
         "\n"
         "/** Invoke the [](cfish:.Destroy) method found in `klass` on\n"
         " * `self`.\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindMethod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindMethod.c b/compiler/src/CFCBindMethod.c
index e4d7301..400d554 100644
--- a/compiler/src/CFCBindMethod.c
+++ b/compiler/src/CFCBindMethod.c
@@ -127,7 +127,7 @@ S_method_def(CFCMethod *method, CFCClass *klass, int optimized_final_meth) {
     }
 
     const char pattern[] =
-        "extern %sVISIBLE size_t %s;\n"
+        "extern %sVISIBLE uint32_t %s;\n"
         "static CFISH_INLINE %s\n"
         "%s(%s%s) {\n"
         "%s"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/compiler/src/CFCBindSpecs.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindSpecs.c b/compiler/src/CFCBindSpecs.c
index 4db517b..7c5c2a3 100644
--- a/compiler/src/CFCBindSpecs.c
+++ b/compiler/src/CFCBindSpecs.c
@@ -99,21 +99,21 @@ CFCBindSpecs_get_typedefs() {
         " */\n"
         "\n"
         "typedef struct cfish_NovelMethSpec {\n"
-        "    size_t         *offset;\n"
+        "    uint32_t       *offset;\n"
         "    const char     *name;\n"
         "    cfish_method_t  func;\n"
         "    cfish_method_t  callback_func;\n"
         "} cfish_NovelMethSpec;\n"
         "\n"
         "typedef struct cfish_OverriddenMethSpec {\n"
-        "    size_t         *offset;\n"
-        "    size_t         *parent_offset;\n"
+        "    uint32_t       *offset;\n"
+        "    uint32_t       *parent_offset;\n"
         "    cfish_method_t  func;\n"
         "} cfish_OverriddenMethSpec;\n"
         "\n"
         "typedef struct cfish_InheritedMethSpec {\n"
-        "    size_t *offset;\n"
-        "    size_t *parent_offset;\n"
+        "    uint32_t *offset;\n"
+        "    uint32_t *parent_offset;\n"
         "} cfish_InheritedMethSpec;\n"
         "\n"
         "typedef enum {\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Class.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.c b/runtime/core/Clownfish/Class.c
index 5f30de2..d2de1ff 100644
--- a/runtime/core/Clownfish/Class.c
+++ b/runtime/core/Clownfish/Class.c
@@ -70,12 +70,12 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
         const ClassSpec *spec = &specs[i];
         Class *parent = spec->parent ? *spec->parent : NULL;
 
-        size_t novel_offset = parent
-                              ? parent->class_alloc_size
-                              : offsetof(Class, vtable);
-        size_t class_alloc_size = novel_offset
-                                  + spec->num_novel_meths
-                                    * sizeof(cfish_method_t);
+        uint32_t novel_offset = parent
+                                ? parent->class_alloc_size
+                                : offsetof(Class, vtable);
+        uint32_t class_alloc_size = novel_offset
+                                    + spec->num_novel_meths
+                                      * sizeof(cfish_method_t);
 
         Class *klass = (Class*)Memory_wrapped_calloc(class_alloc_size, 1);
 
@@ -128,12 +128,12 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
         // recalculated.
         Class_Init_Obj_IMP(CLASS, klass);
 
-        size_t novel_offset = parent
-                              ? parent->class_alloc_size
-                              : offsetof(Class, vtable);
-        size_t class_alloc_size = novel_offset
-                                  + spec->num_novel_meths
-                                    * sizeof(cfish_method_t);
+        uint32_t novel_offset = parent
+                                ? parent->class_alloc_size
+                                : offsetof(Class, vtable);
+        uint32_t class_alloc_size = novel_offset
+                                    + spec->num_novel_meths
+                                      * sizeof(cfish_method_t);
 
         klass->parent           = parent;
         klass->parcel_id        = parcel_id;
@@ -161,8 +161,8 @@ Class_bootstrap(const cfish_ClassSpec *specs, size_t num_specs,
 
         if (parent) {
             // Copy parent vtable.
-            size_t parent_vt_size = parent->class_alloc_size
-                                    - offsetof(Class, vtable);
+            uint32_t parent_vt_size = parent->class_alloc_size
+                                      - offsetof(Class, vtable);
             memcpy(klass->vtable, parent->vtable, parent_vt_size);
         }
 
@@ -224,7 +224,7 @@ Class_Destroy_IMP(Class *self) {
 }
 
 void
-Class_Override_IMP(Class *self, cfish_method_t method, size_t offset) {
+Class_Override_IMP(Class *self, cfish_method_t method, uint32_t offset) {
     union { char *char_ptr; cfish_method_t *func_ptr; } pointer;
     pointer.char_ptr = ((char*)self) + offset;
     pointer.func_ptr[0] = method;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Class.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.cfh b/runtime/core/Clownfish/Class.cfh
index 733e06e..4a789eb 100644
--- a/runtime/core/Clownfish/Class.cfh
+++ b/runtime/core/Clownfish/Class.cfh
@@ -31,7 +31,7 @@ final class Clownfish::Class inherits Clownfish::Obj {
     uint32_t            flags;
     int32_t             parcel_id;
     size_t              obj_alloc_size;
-    size_t              class_alloc_size;
+    uint32_t            class_alloc_size;
     Method            **methods;
     cfish_method_t[1]   vtable; /* flexible array */
 
@@ -97,7 +97,7 @@ final class Clownfish::Class inherits Clownfish::Obj {
     /** Replace a function pointer in the Class's vtable.
      */
     void
-    Override(Class *self, cfish_method_t method_ptr, size_t offset);
+    Override(Class *self, cfish_method_t method_ptr, uint32_t offset);
 
     /** Create an empty object of the type defined by the Class: allocate,
      * assign its class and give it an initial refcount of 1.  The caller is

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Method.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Method.c b/runtime/core/Clownfish/Method.c
index 5fc02da..c75bd4c 100644
--- a/runtime/core/Clownfish/Method.c
+++ b/runtime/core/Clownfish/Method.c
@@ -23,14 +23,14 @@
 #include "Clownfish/Class.h"
 
 Method*
-Method_new(String *name, cfish_method_t callback_func, size_t offset) {
+Method_new(String *name, cfish_method_t callback_func, uint32_t offset) {
     Method *self = (Method*)Class_Make_Obj(METHOD);
     return Method_init(self, name, callback_func, offset);
 }
 
 Method*
 Method_init(Method *self, String *name, cfish_method_t callback_func,
-            size_t offset) {
+            uint32_t offset) {
     /* The `name` member which Method exposes via the `Get_Name` accessor uses
      * a "wrapped" string because that is effectively threadsafe: an INCREF
      * results in a copy and the only reference is owned by an immortal

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/25c561a4/runtime/core/Clownfish/Method.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Method.cfh b/runtime/core/Clownfish/Method.cfh
index 4fb4f28..3fa8633 100644
--- a/runtime/core/Clownfish/Method.cfh
+++ b/runtime/core/Clownfish/Method.cfh
@@ -26,15 +26,15 @@ final class Clownfish::Method inherits Clownfish::Obj {
     String         *host_alias;
     String         *host_alias_internal;
     cfish_method_t  callback_func;
-    size_t          offset;
+    uint32_t        offset;
     bool            is_excluded;
 
     inert Method*
-    new(String *name, cfish_method_t callback_func, size_t offset);
+    new(String *name, cfish_method_t callback_func, uint32_t offset);
 
     inert Method*
     init(Method *self, String *name, cfish_method_t callback_func,
-         size_t offset);
+         uint32_t offset);
 
     String*
     Get_Name(Method *self);