From 7d40377ec0db465382a2f3b5e8daa60b376d4800 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Thu, 31 Dec 2009 10:42:05 +0100 Subject: [PATCH] When processing the externalizable data, places for data created with load-forms must not be eliminated. --- src/new-cmp/cmpc-data.lsp | 35 ++++++++++++++++++++--------------- src/new-cmp/cmpc-ffi.lsp | 1 - src/new-cmp/cmpdata.lsp | 3 +++ src/new-cmp/cmpglobals.lsp | 2 +- src/new-cmp/cmppackage.lsp | 1 + 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/new-cmp/cmpc-data.lsp b/src/new-cmp/cmpc-data.lsp index 59049f897..1f5ef01f0 100644 --- a/src/new-cmp/cmpc-data.lsp +++ b/src/new-cmp/cmpc-data.lsp @@ -168,15 +168,18 @@ static cl_object VV[VM]; (unless (or *compiler-constants* (not *use-static-constants-p*)) (let ((static-constants 0)) (flet ((try-turning-static (record) - (destructuring-bind (object (&whole location vv-tag index object-copy) - index-copy) + (unless (or (null record) + (load-form-data-place-p record)) + (destructuring-bind (object (&whole location vv-tag index object-copy) + index-copy) + record (let ((builder (static-constant-expression object))) (when builder (let* ((next-index (incf static-constants)) (name (format nil "_ecl_static_~D" next-index))) (setf (second location) name) (funcall builder name object stream) - (setf record nil))))) + (setf record nil)))))) record)) (map-into *permanent-objects* #'try-turning-static *permanent-objects*) (map-into *temporary-objects* #'try-turning-static *temporary-objects*))))) @@ -191,19 +194,21 @@ static cl_object VV[VM]; (defun replace-optimizable-constants () (let ((found nil)) (flet ((try-inlining (record) - (destructuring-bind (object (&whole location vv-tag index - &optional object-copy) - index-copy) - record - (let* ((x (assoc object +optimizable-constants+)) - (new-location (cdr x))) - (when new-location - (setf found t) - (format *dump-output* "~&;;; Replacing constant ~A with ~A" + (unless (or (null record) + (load-form-data-place-p record)) + (destructuring-bind (object (&whole location vv-tag index + &optional object-copy) + index-copy) + record + (let* ((x (assoc object +optimizable-constants+)) + (new-location (cdr x))) + (when new-location + (setf found t) + (format *dump-output* "~&;;; Replacing constant ~A with ~A" object (second new-location)) - (setf (second location) (second new-location) - (first location) (first new-location) - record nil)))) + (setf (second location) (second new-location) + (first location) (first new-location) + record nil))))) record)) (map-into *permanent-objects* #'try-inlining *permanent-objects*) (map-into *temporary-objects* #'try-inlining *temporary-objects*) diff --git a/src/new-cmp/cmpc-ffi.lsp b/src/new-cmp/cmpc-ffi.lsp index 196cbf4ee..28b6b02e3 100644 --- a/src/new-cmp/cmpc-ffi.lsp +++ b/src/new-cmp/cmpc-ffi.lsp @@ -337,7 +337,6 @@ (t (when (and (consp object) (eq (first object) 'QUOTE)) (setq object (second object))) - (error ") (wt (add-object object :permanent t)))))) (#\# (let* ((k (read-char s)) diff --git a/src/new-cmp/cmpdata.lsp b/src/new-cmp/cmpdata.lsp index 9b5491c48..4b705101b 100644 --- a/src/new-cmp/cmpdata.lsp +++ b/src/new-cmp/cmpdata.lsp @@ -55,6 +55,9 @@ (defun data-empty-loc () (add-object 0 :duplicate t :permanent t)) +(defun load-form-data-place-p (data-record) + (typep (first data-record) 'fixnum)) + (defun add-load-form (object location) (when (clos::need-to-make-load-form-p object) (if (not (eq *compiler-phase* 't1)) diff --git a/src/new-cmp/cmpglobals.lsp b/src/new-cmp/cmpglobals.lsp index 7e3edcaf2..630be3177 100644 --- a/src/new-cmp/cmpglobals.lsp +++ b/src/new-cmp/cmpglobals.lsp @@ -214,7 +214,7 @@ lines are inserted, but the order is preserved") ;;; where each vv-index should be given an object before ;;; defining the current function during loading process. -(defvar *use-static-constants-p* nil) ; T/NIL flag to determine whether one may +(defvar *use-static-constants-p* t) ; T/NIL flag to determine whether one may ; generate lisp constant values as C structs (defvar *compiler-constants* nil) ; a vector with all constants diff --git a/src/new-cmp/cmppackage.lsp b/src/new-cmp/cmppackage.lsp index 7162de9fd..6f42cca3a 100644 --- a/src/new-cmp/cmppackage.lsp +++ b/src/new-cmp/cmppackage.lsp @@ -82,6 +82,7 @@ "DATA-PERMANENT-STORAGE-SIZE" "DATA-TEMPORARY-STORAGE-SIZE" "DATA-SIZE" "DATA-GET-ALL-OBJECTS" "DATA-INIT" "ADD-OBJECT" "ADD-SYMBOL" "ADD-KEYWORDS" + "LOAD-FORM-DATA-PLACE-P" "*COMPILER-CONSTANTS*" )