From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: MPS: Forwording symbols Date: Sun, 16 Jun 2024 11:43:11 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12479"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Helmut Eller , Eli Zaretskii To: Emacs Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 16 11:44:09 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sImQi-000382-Pt for ged-emacs-devel@m.gmane-mx.org; Sun, 16 Jun 2024 11:44:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sImPx-0003Pa-Uc; Sun, 16 Jun 2024 05:43:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sImPt-0003PM-5s for emacs-devel@gnu.org; Sun, 16 Jun 2024 05:43:17 -0400 Original-Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sImPq-0004av-Uf; Sun, 16 Jun 2024 05:43:16 -0400 Original-Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a6efe62f583so343659666b.3; Sun, 16 Jun 2024 02:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718530993; x=1719135793; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=xhatve+z92t6WbHnP/Qxb5mR0nXPRO7WI7L6EO+nGGU=; b=I7dMy6m2yj06mTSgmz7PejRiKmoXVZnskRAOfPWDQcEy9iY/aZQeJHnGJQkbLgjAbQ lihkNzqY/3SSsO73DNqxJk/b9EZz8We39GMlRhmAtp1JqBhWjb7BQrVxALezY3kI90oM zz1/NXM6I5wHEz2saiRrbHGEiGBvGRaKMF+pznsHWbsEb5I9BRm4nnSZ+vjpPN7fW4KR uYYAVlpY5/y5clRKJR2NTjcbWtFqZ20xgMury/FnX/oFVMDrQetHAfwdD8yCwftubc52 3u1d51OiUbERo2eR4Vfslgg67N3ly7jLpUViQsWIHmB2t/UACecU0M9HX5DfbEllyMUP qYAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718530993; x=1719135793; h=mime-version:user-agent:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=xhatve+z92t6WbHnP/Qxb5mR0nXPRO7WI7L6EO+nGGU=; b=BFgAbvsdtXsgHtL4+EHrbDqlBxzifiY+RfQjgxPz7AsM7A5d5BVtkhOrWQ+t7VO9Lq d+fFpRIEApfeQAZP3W1ZlbUu1QU4gEZ7lf9rSEaBc1w1KHI2Hs6Y9spUvg96nQ+B2HDP GDkT4lCYjCgollLLUQEza2qbiP8LYChruEjdypaXtC68ulGCK2YCYQPNbfaWIhaHYlFR DlJJXHkdz3EEWofb7+SM6jEYS1HBxHIwzoOCKP6+CAt5mu3M+3z/WLpYWhA+Y8tLxO0v I+Ophk9Ba7GBVBdxoKJhhEiaPuOyX5egaTqIyPvnKRIwSYR1MrfENZF2EOjU9OR/vhVk FL3w== X-Forwarded-Encrypted: i=1; AJvYcCVQ+VJepZDuqXqbc23HmEGHeQdsRUErZiyne7mrcf8fr0cSv2dhgb/MgJQUvIcmaztulNMmgOws4dOZHs0= X-Gm-Message-State: AOJu0YxDcbmk+VINm640TSh/ebTYrBYhBo6WuQn3otacZpAiJ/TEhInI zUU8kqpvkMOZ3Zfe9g9slBvrM5W2Xk2ZabKeMbFHl0R2fqikjWTQcnTi9Q== X-Google-Smtp-Source: AGHT+IEX1LZ5e9vE/ykFZkVSWXd507YZ5LrlLqitScxAc0TYCl4F/C82npEulpkpHCmuuQpTQd/k/Q== X-Received: by 2002:a17:906:451:b0:a6f:2b19:e82f with SMTP id a640c23a62f3a-a6f60d298bbmr417582666b.28.1718530992742; Sun, 16 Jun 2024 02:43:12 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e36751.dip0.t-ipconnect.de. [217.227.103.81]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56f427casm393555566b.176.2024.06.16.02.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jun 2024 02:43:12 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=gerd.moellmann@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:320186 Archived-At: Ok, I've looked a bit closer, and I think we can avoid dumping the the forwarding structs altogether. There are 5 types of forwarding structs enum Lisp_Fwd_Type { Lisp_Fwd_Int, /* Fwd to a C `int' variable. */ Lisp_Fwd_Bool, /* Fwd to a C boolean var. */ Lisp_Fwd_Obj, /* Fwd to a C Lisp_Object variable. */ Lisp_Fwd_Buffer_Obj, /* Fwd to a Lisp_Object field of buffers. */ Lisp_Fwd_Kboard_Obj /* Fwd to a Lisp_Object field of kboards. */ }; Four of them contain only the type and either integer offsets or pointers to variables in Emacs' data segment. The only interesting one is Lisp_Fwd_Buffer_Obj which looks like struct Lisp_Buffer_Objfwd { enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Buffer_Obj */ int offset; /* One of Qnil, Qintegerp, Qsymbolp, Qstringp, Qfloatp or Qnumberp. */ Lisp_Object predicate; }; which has an additional member for the predicate. AFAICT, the comment is true, and thus predicate is also a constant because it is always from a DEFSYM, i.e. it is a symbol from lispsym. Means that dumping the fwd structs is not strictly needed. (And maybe one should replace the Lisp_Object predicate member with an enum, to make that sure for the future.) If we don't dump_fwd, we would have to make sure though not to overwrite the existing values for symbols in lispsym, which happens in dump_do_dump_relocation case RELOC_DUMP_TO_EMACS_PTR_RAW: { uintptr_t value = dump_read_word_from_dump (dump_base, reloc_offset); eassert (dump_reloc_size (reloc) == sizeof (value)); value += emacs_basis (); dump_write_word_to_dump (dump_base, reloc_offset, value); break; } The name dump_write_word_to_dump is misleading. It does a memcpy to Emacs' data segment. Maybe one could introduce a new RELOC_xyz type to signify that a forwarding symbol is patched and save the fwd value around the memcpy if needed. Or something like that?