Return-Path: X-Original-To: apmail-lucy-dev-archive@www.apache.org Delivered-To: apmail-lucy-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9C7C79704 for ; Wed, 25 Apr 2012 23:03:35 +0000 (UTC) Received: (qmail 2172 invoked by uid 500); 25 Apr 2012 23:03:35 -0000 Delivered-To: apmail-lucy-dev-archive@lucy.apache.org Received: (qmail 2135 invoked by uid 500); 25 Apr 2012 23:03:35 -0000 Mailing-List: contact dev-help@lucy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucy.apache.org Delivered-To: mailing list dev@lucy.apache.org Received: (qmail 2126 invoked by uid 99); 25 Apr 2012 23:03:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2012 23:03:35 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.210.50] (HELO mail-pz0-f50.google.com) (209.85.210.50) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Apr 2012 23:03:29 +0000 Received: by dakh32 with SMTP id h32so793274dak.23 for ; Wed, 25 Apr 2012 16:03:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding :x-gm-message-state; bh=FDKPv1ePEkhlFO8x14mdbmwjMAzvHdRswq+gGOZF4m8=; b=MC/zHPV2yDnyepuKCmuOBfzSwp5xmTixdmwgNec3/6lXv/iYfsDLd8CLQvhe58zm2m CsgYwVG4L0k0Gb6UG1QjAAv009EnTc7/dRN4YBKiH5s2vMrzeY1iqN+8rMyRUNI+zakE KY1IbdXox39ZCMan6fIOwVTbu+pc2TKNSPVbMZKnQI4TiJpFuDd4vHTwQhH0YpR1PWmr O2HL2MtywX+LcmQN/XMJjh71jJOZ2MC7rNmmuDLiEwdYUSdZ2nAJOGkU6Ee/EumvSiFk 9N+0OJ7CWyZ47+ojVn7m9rydIXfsqMoejZijz9PZUTN+9e9OpLm3JJpQnxAc5RuCN1iE mFtw== MIME-Version: 1.0 Received: by 10.68.189.229 with SMTP id gl5mr5027266pbc.148.1335394988954; Wed, 25 Apr 2012 16:03:08 -0700 (PDT) Received: by 10.142.241.8 with HTTP; Wed, 25 Apr 2012 16:03:08 -0700 (PDT) X-Originating-IP: [206.190.64.2] In-Reply-To: References: <4F903955.5020608@aevum.de> <4F913440.10100@aevum.de> <4F941F97.4090504@aevum.de> <4F95385B.7070701@aevum.de> Date: Wed, 25 Apr 2012 16:03:08 -0700 Message-ID: From: Marvin Humphrey To: dev@lucy.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlgeGbS9GgfFPxw/TnY0j7UFmSZESjyzh77z01KRwo+CIqBgvXOJE2xGgwM+cleuj+YeQeF X-Virus-Checked: Checked by ClamAV on apache.org Subject: Re: [lucy-dev] OFFSET globals On Wed, Apr 25, 2012 at 3:27 PM, Nathan Kurz wrote: > Yes, very helpful. =A0That's essentially what I determined, but I got > lost around S_bequeath_methods. =A0It's difficult reading through the > sprintf()'s. > > Going one layer deeper to the object code level, which symbols are we > currently using? I think I found where the OFFSETS come in, but I > haven't figured out how overrides are signalled. The output of CFC is definitely easier to understand than the code like S_bequeath_methods() that does the work. :) Let's look at some generated code. Here are TermQuery's methods: cfish_method_t LUCY_TERMQUERY_METHODS[] =3D { (cfish_method_t)lucy_Obj_make, (cfish_method_t)lucy_Obj_get_refcount, (cfish_method_t)lucy_Obj_inc_refcount, (cfish_method_t)lucy_Obj_dec_refcount, (cfish_method_t)lucy_Obj_to_host, (cfish_method_t)lucy_Obj_clone, (cfish_method_t)lucy_TermQuery_destroy, (cfish_method_t)lucy_TermQuery_equals, (cfish_method_t)lucy_Obj_compare_to, (cfish_method_t)lucy_Obj_hash_sum, (cfish_method_t)lucy_Obj_get_vtable, (cfish_method_t)lucy_Obj_get_class_name, (cfish_method_t)lucy_Obj_is_a, (cfish_method_t)lucy_TermQuery_to_string, (cfish_method_t)lucy_Obj_to_i64, (cfish_method_t)lucy_Obj_to_f64, (cfish_method_t)lucy_Obj_to_bool, (cfish_method_t)lucy_TermQuery_serialize, (cfish_method_t)lucy_TermQuery_deserialize, (cfish_method_t)lucy_TermQuery_dump, (cfish_method_t)lucy_TermQuery_load, (cfish_method_t)lucy_Obj_mimic, (cfish_method_t)lucy_TermQuery_make_compiler, (cfish_method_t)lucy_Query_set_boost, (cfish_method_t)lucy_Query_get_boost, (cfish_method_t)lucy_TermQuery_get_field, (cfish_method_t)lucy_TermQuery_get_term, NULL }; So, TermQuery overrides the following methods with its own "fresh" implementations: Destroy <--- Obj Equals <--- Obj To_String <--- Obj Serialize <--- Obj Deserialize <--- Obj Make_Compiler <--- Query TermQuery inherits many implementations from Obj. It also inherits two implementations from Query: Set_Boost Get_Boost And then, TermQuery defines two "novel" methods of its own: Get_Field Get_Term I wouldn't say that TermQuery "signals" to anyone that it has overridden a method. It's more that when somebody invokes a method on a TermQuery -- le= t's pick Equals() -- the caller goes to the slot indicated by Lucy_TermQuery_Equals_OFFSET and uses whatever function pointer happens to = be there. Here's the actual method invocation code: static CHY_INLINE chy_bool_t Lucy_TermQuery_Equals(const lucy_TermQuery *self, lucy_Obj* other) { char *const method_address =3D *(char**)self + Lucy_TermQuery_Equals_OFFSET; const Lucy_TermQuery_Equals_t method =3D *((Lucy_TermQuery_Equals_t*)method_address); return method((lucy_TermQuery*)self, other); } Note that *(char**)self is a way of getting at the first member variable of the lucy_TermQuery struct, which is a VTable*. The problem that Nick has been working on is how to cut down on the number = of OFFSET vars. In order to guarantee that certain seemingly innocuous refactoring actions won't break the ABI, the current release of Lucy genera= tes a huge number of OFFSET vars -- and they're all exposed as globals in the DSO. Under the new design, we will have far fewer OFFSET vars, and when th= e build environment supports it, they will not be visible as global symbols i= n the DSO. Marvin Humphrey