You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2015/02/13 22:46:04 UTC

[14/16] lucy-clownfish git commit: Consolidate SvSHARE calls on cached host obj.

Consolidate SvSHARE calls on cached host obj.

Call SvSHARE on all cached host objects before they are even cached.
This allows us to eliminate method overriding for To_Host for both Class
and LockFreeRegistry.  Also, other immortals are now shared properly.


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

Branch: refs/heads/master
Commit: 55b19f459b049cc22f00890f6099eec64e0fb9b2
Parents: afde943
Author: Marvin Humphrey <ma...@rectangular.com>
Authored: Sun Feb 8 21:34:08 2015 -0800
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Sun Feb 8 21:34:08 2015 -0800

----------------------------------------------------------------------
 runtime/c/src/Clownfish/Class.c                 |  7 -----
 runtime/c/src/Clownfish/LockFreeRegistry.c      | 32 --------------------
 runtime/core/Clownfish/Class.cfh                |  3 --
 runtime/core/Clownfish/LockFreeRegistry.cfh     |  3 --
 runtime/example-lang/src/Clownfish/Class.c      |  6 ----
 .../src/Clownfish/LockFreeRegistry.c            | 28 -----------------
 runtime/perl/xs/XSBind.c                        | 28 +----------------
 7 files changed, 1 insertion(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/55b19f45/runtime/c/src/Clownfish/Class.c
----------------------------------------------------------------------
diff --git a/runtime/c/src/Clownfish/Class.c b/runtime/c/src/Clownfish/Class.c
index 82a5892..1ad617d 100644
--- a/runtime/c/src/Clownfish/Class.c
+++ b/runtime/c/src/Clownfish/Class.c
@@ -69,10 +69,3 @@ Class_find_parent_class(String *class_name) {
     UNREACHABLE_RETURN(String*);
 }
 
-void*
-Class_To_Host_IMP(Class *self) {
-    UNUSED_VAR(self);
-    THROW(ERR, "TODO");
-    UNREACHABLE_RETURN(void*);
-}
-

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/55b19f45/runtime/c/src/Clownfish/LockFreeRegistry.c
----------------------------------------------------------------------
diff --git a/runtime/c/src/Clownfish/LockFreeRegistry.c b/runtime/c/src/Clownfish/LockFreeRegistry.c
deleted file mode 100644
index 396b78b..0000000
--- a/runtime/c/src/Clownfish/LockFreeRegistry.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define C_CFISH_LOCKFREEREGISTRY
-#define CFISH_USE_SHORT_NAMES
-
-#include "charmony.h"
-
-#include "Clownfish/LockFreeRegistry.h"
-#include "Clownfish/Err.h"
-
-void*
-LFReg_To_Host_IMP(LockFreeRegistry *self) {
-    UNUSED_VAR(self);
-    THROW(ERR, "TODO");
-    UNREACHABLE_RETURN(void*);
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/55b19f45/runtime/core/Clownfish/Class.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Class.cfh b/runtime/core/Clownfish/Class.cfh
index 23623b7..566f29f 100644
--- a/runtime/core/Clownfish/Class.cfh
+++ b/runtime/core/Clownfish/Class.cfh
@@ -138,9 +138,6 @@ class Clownfish::Class inherits Clownfish::Obj {
     public incremented Class*
     Clone(Class *self);
 
-    void*
-    To_Host(Class *self);
-
     public void
     Destroy(Class *self);
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/55b19f45/runtime/core/Clownfish/LockFreeRegistry.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/LockFreeRegistry.cfh b/runtime/core/Clownfish/LockFreeRegistry.cfh
index bb41fbd..330507b 100644
--- a/runtime/core/Clownfish/LockFreeRegistry.cfh
+++ b/runtime/core/Clownfish/LockFreeRegistry.cfh
@@ -37,9 +37,6 @@ class Clownfish::LockFreeRegistry nickname LFReg inherits Clownfish::Obj {
 
     nullable Obj*
     Fetch(LockFreeRegistry *self, Obj *key);
-
-    void*
-    To_Host(LockFreeRegistry *self);
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/55b19f45/runtime/example-lang/src/Clownfish/Class.c
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/Clownfish/Class.c b/runtime/example-lang/src/Clownfish/Class.c
index 19abca4..ca0f89d 100644
--- a/runtime/example-lang/src/Clownfish/Class.c
+++ b/runtime/example-lang/src/Clownfish/Class.c
@@ -54,9 +54,3 @@ cfish_Class_find_parent_class(const cfish_String *class_name) {
     UNREACHABLE_RETURN(cfish_String*);
 }
 
-void*
-CFISH_Class_To_Host_IMP(cfish_Class *self) {
-    THROW(CFISH_ERR, "TODO");
-    UNREACHABLE_RETURN(void*);
-}
-

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/55b19f45/runtime/example-lang/src/Clownfish/LockFreeRegistry.c
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/Clownfish/LockFreeRegistry.c b/runtime/example-lang/src/Clownfish/LockFreeRegistry.c
deleted file mode 100644
index cbc0c60..0000000
--- a/runtime/example-lang/src/Clownfish/LockFreeRegistry.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define C_CFISH_LOCKFREEREGISTRY
-
-#include "CFBind.h"
-#include "Clownfish/LockFreeRegistry.h"
-
-void*
-CFISH_LFReg_To_Host_IMP(cfish_LockFreeRegistry *self) {
-    THROW(CFISH_ERR, "TODO");
-    UNREACHABLE_RETURN(void*);
-}
-
-

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/55b19f45/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/runtime/perl/xs/XSBind.c b/runtime/perl/xs/XSBind.c
index ae5591a..2534c8d 100644
--- a/runtime/perl/xs/XSBind.c
+++ b/runtime/perl/xs/XSBind.c
@@ -653,6 +653,7 @@ S_lazy_init_host_obj(cfish_Obj *self) {
     // Overwrite refcount with host object.
     cfish_Class *klass = self->klass;
     if (SI_immortal(klass) || SI_threadsafe_but_not_immortal(klass)) {
+        SvSHARE(inner_obj);
         if (!cfish_Atomic_cas_ptr((void**)&self->ref, old_ref.host_obj, inner_obj)) {
             // Another thread beat us to it.  Now we have a Perl object to defuse.
             SvSTASH_set(inner_obj, NULL);
@@ -842,19 +843,6 @@ cfish_Class_find_parent_class(cfish_String *class_name) {
     return parent_class;
 }
 
-void*
-CFISH_Class_To_Host_IMP(cfish_Class *self) {
-    bool first_time = self->ref.count & XSBIND_REFCOUNT_FLAG ? true : false;
-    CFISH_Class_To_Host_t to_host
-        = CFISH_SUPER_METHOD_PTR(CFISH_CLASS, CFISH_Class_To_Host);
-    SV *host_obj = (SV*)to_host(self);
-    if (first_time) {
-        SvSHARE((SV*)self->ref.host_obj);
-    }
-    return host_obj;
-}
-
-
 /*************************** Clownfish::Method ******************************/
 
 cfish_String*
@@ -1031,20 +1019,6 @@ cfish_Err_trap(CFISH_Err_Attempt_t routine, void *context) {
     return error;
 }
 
-/*********************** Clownfish::LockFreeRegistry ************************/
-
-void*
-CFISH_LFReg_To_Host_IMP(cfish_LockFreeRegistry *self) {
-    bool first_time = self->ref.count & XSBIND_REFCOUNT_FLAG ? true : false;
-    CFISH_LFReg_To_Host_t to_host
-        = CFISH_SUPER_METHOD_PTR(CFISH_LOCKFREEREGISTRY, CFISH_LFReg_To_Host);
-    SV *host_obj = (SV*)to_host(self);
-    if (first_time) {
-        SvSHARE((SV*)self->ref.host_obj);
-    }
-    return host_obj;
-}
-
 /*********************** Clownfish::Test::TestThreads ***********************/
 
 void