From edfaec9a6b1dabc87aa3c6cfa95af91952a48767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Sun, 5 Nov 2023 11:03:07 +0100 Subject: [PATCH] cmp: add a comment that explains the purpose of OPTIMIZE-CXX-DATA --- src/cmp/cmpbackend-cxx/cmppass2-data.lsp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cmp/cmpbackend-cxx/cmppass2-data.lsp b/src/cmp/cmpbackend-cxx/cmppass2-data.lsp index c26f8bc20..56ed15fce 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-data.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-data.lsp @@ -345,6 +345,22 @@ (and errorp (cmperr "Unable to find object ~s." object)))) +;;; The vector *REFERENCED-OBJECTS* contains all referenced objects collected in +;;; the first pass. The function OPTIMIZE-CXX-DATA is responsible for inlining +;;; them when possible, and putting them in a temporary/permanent data segments +;;; otherwise. Objects in data segment require an explicit initialization when +;;; the the module is loaded. The following inline strategies are tried: +;;; +;;; - using a symbol from the core :: ECL_SYM(\"*BREAK-ON-SIGNALS*\",27) +;;; - using a cvalue inline value :: cl_core.single_float_zero, FLT_MAX +;;; - using a static constructor :: ecl_def_ct_single_float -> _ecl_static_7 +;;; - coercing an immediate value :: ecl_make_fixnum(42) +;;; +;;; Otherwise the object is put in VV or VVtemp vector, and is created when the +;;; module is loaded. Then the code refers to such objects as VV[13]. +;;; +;;; TODO we could further optimize immediate values by duplicating some entries +;;; depending on the expected rep-type, to avoid unnecessary coercions. (defun optimize-cxx-data (objects) (flet ((optimize-vv (object) (let ((value (vv-value object)))