From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Aur=C3=A9lien_Aptel?= Newsgroups: gmane.emacs.devel Subject: Re: Dynamic loading progress Date: Thu, 5 Mar 2015 14:12:29 +0100 Message-ID: References: <83pp9cwky8.fsf@gnu.org> <85a90ggf2d.fsf@stephe-leake.org> <54E0A40F.5080603@dancol.org> <83sie7un20.fsf@gnu.org> <54E0D181.2080802@dancol.org> <83r3trulse.fsf@gnu.org> <54E0D7E0.305@87.69.4.28> <83h9unukbg.fsf@gnu.org> <54E0DEF8.7020901@dancol> <83egpruiyp.fsf@gnu.org> <54E0FF93.2000104@dancol.org> <833865vp4d.fsf@gnu.org> <54E2355A.90@87.69.4.28> <83vbj1u020.fsf@gnu.org> <54E24CA4.9020601@dancol.org> <83h9uk7ddb.fsf@gnu.org> <54E382A5.5030408@dancol.org> <54F789B2.6030105@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1425561166 14719 80.91.229.3 (5 Mar 2015 13:12:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Mar 2015 13:12:46 +0000 (UTC) Cc: Eli Zaretskii , Stephen Leake , Stefan Monnier , Emacs development discussions To: Daniel Colascione Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Mar 05 14:12:44 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YTVZz-0001J3-3f for ged-emacs-devel@m.gmane.org; Thu, 05 Mar 2015 14:12:43 +0100 Original-Received: from localhost ([::1]:51701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTVZy-0001Da-7Q for ged-emacs-devel@m.gmane.org; Thu, 05 Mar 2015 08:12:42 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:32820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTVZt-00019M-0R for emacs-devel@gnu.org; Thu, 05 Mar 2015 08:12:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTVZr-0006B9-QD for emacs-devel@gnu.org; Thu, 05 Mar 2015 08:12:36 -0500 Original-Received: from mail-ie0-x230.google.com ([2607:f8b0:4001:c03::230]:44939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTVZn-00069m-8L; Thu, 05 Mar 2015 08:12:31 -0500 Original-Received: by iecar1 with SMTP id ar1so76176204iec.11; Thu, 05 Mar 2015 05:12:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=oWNYnmShqKmxroMCH/4iisBRJCZb5hKwlpqcp7eiB/4=; b=DLQlzBlsACgRiX5ZUtgLCXKb1jYdWTWio1tZ9czN41RvXiqL5br7mVq+7DHDenx1rG G/4nE2ZdnhQcRztV5grh32/ruv4mwEtnkmYOJpJ4Ct9Nba3k/BasPyebxn2380iF9ShM bAjx7Q6UIs5q5V4XtLeIQXMi1Hie1Ui3LPwDRvCqVF2Z/b19c0cRo938TaPDXWYv2YY7 c8iedCae2XuFLimgNemyYBlAjbeiN+p9DuLVryG3BIRY3d/Yvko6OhwoqoQy0kuWh8NY qKxflSRkJqu4vgxXlrurESnd1+HDLHVeHHQ5JOH9rko/I4yGTpIi7JP1baXQeqOTn2S3 7PTA== X-Received: by 10.50.67.100 with SMTP id m4mr47134222igt.22.1425561150285; Thu, 05 Mar 2015 05:12:30 -0800 (PST) Original-Received: by 10.36.49.13 with HTTP; Thu, 5 Mar 2015 05:12:29 -0800 (PST) In-Reply-To: <54F789B2.6030105@dancol.org> X-Google-Sender-Auth: 0Nx-IeNRP9srbC4hWD8znlvF0hg X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4001:c03::230 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183667 Archived-At: The dynamic-modules-2 branch is implemented from scratch (well, from the master branch) in case that wasn't clear. I'll summarize what the code is doing, to make sure with everyone I'm not doing anything wrong. Emacs core has a new module.c[0] file which provides various function pointers to modules via a struct (actually 2 struct, there's emacs_environment and emacs_runtime). These structs are defined in src/emacs_module.h [1]. A module has an emacs_module_init function which is called when the module is loaded. This function is passed an emacs_environment pointer which is used by the module to get a emacs_runtime pointer which has all the useful function pointers to interact with emacs. Lisp_Object are exposed via the emacs_value type which is opaque. From emacs_module.h: typedef void* emacs_value; To convert a Lisp_Objet to an emacs_value I simply cast, currently. >From Emacs' module.c: static emacs_value module_make_fixnum (emacs_env *env, int64_t n) { return (emacs_value) make_number (n); } (let's just ignore the overflow and error checking for now and focus on the architecture) Daniel's last message made me understand the GC problem. Since emacs integers are stored directly "in" the Lisp_Object there's no problem with the GC because there's no memory to free. But for other more complex types (where the Lisp_Object is actually a pointer) an emacs_value stored by the module can become invalid between 2 emacs->module calls because it was garbage collected. So what I should do is make another Lisp_Object-like union type that owns its memory (ie. not handled by the GC) and use that as emacs_value (still opaque for the module). Correct? 0: https://github.com/aaptel/emacs-dynamic-module/blob/dynamic-modules-2/src/module.c 1: https://github.com/aaptel/emacs-dynamic-module/blob/dynamic-modules-2/src/emacs_module.h