[gs-cvs] rev 7449 - trunk/gs/lib
lpd at ghostscript.com
lpd at ghostscript.com
Mon Dec 4 19:28:10 PST 2006
Author: lpd
Date: 2006-12-04 19:28:09 -0800 (Mon, 04 Dec 2006)
New Revision: 7449
Modified:
trunk/gs/lib/gs_cidcm.ps
trunk/gs/lib/gs_res.ps
trunk/gs/lib/gs_resmp.ps
Log:
Fixes bugs: many places in the implementation of resourceforall did not
always create temporary objects in local VM, which is necessary because some
of their elements may be in local VM. Fixes the cash06 diff in PS3 CET
30-07-3.
Modified: trunk/gs/lib/gs_cidcm.ps
===================================================================
--- trunk/gs/lib/gs_cidcm.ps 2006-12-04 22:25:49 UTC (rev 7448)
+++ trunk/gs/lib/gs_cidcm.ps 2006-12-05 03:28:09 UTC (rev 7449)
@@ -355,19 +355,28 @@
} ifelse
} bind def
+% Define a local-VM equivalent of ]. It should be called
+% .localvmarraytomark, but we're going to be using it a lot....
+/.la2mark {
+ counttomark .localvmarray astore exch pop
+} bind def
+
/ResourceForAll { % <template> <proc> <scratch> ResourceForAll -
% We suppose that the resourceforall procedure does not
% define or install new fonts, CMaps, and/or CIDFonts.
+ % Note that all temporary objects that might reference fonts, CMaps,
+ % or CIDFonts must be created in local VM, since these objects might be
+ % in local VM themselves.
+
% First we create 3 temporary dictionaries to store temporary data
% about fonts, CMaps and CIDFonts.
% These dictionaries must be created dynamically, to allow for a possible
% recursive call to resourceforall from the resourceforall procedure.
- currentglobal false setglobal
- 20 dict 20 dict 20 dict
- 4 -1 roll setglobal % (templ) proc (scr) <<CIDFont>> <<CMap>> <<Fonts>>
+ 20 .localvmdict 20 .localvmdict 20 .localvmdict
+ % (templ) proc (scr) <<CIDFont>> <<CMap>> <<Fonts>>
% Store resource identifiers into local dictionaries
% A resource instance can have a key that is not a name or a string. In this
@@ -380,13 +389,15 @@
{ /.DisableResourceOrdering pop % gs_resmp accesses this through execstack - don't remove !
- 5 index [ 2 index {exch //null put} aload pop ] cvx bind 5 index //ResourceForAll exec
+ 5 index [
+ 2 index {exch //null put} aload pop
+ .la2mark cvx bind 5 index //ResourceForAll exec
(*) [ 3 index {exch dup type /stringtype eq { cvn dup put } { pop pop } ifelse } aload pop
- ] cvx bind 5 index /CMap resourceforall
+ .la2mark cvx bind 5 index /CMap resourceforall
(*) [ 4 index {exch dup type /stringtype eq { cvn dup put } { pop pop } ifelse } aload pop
- ] cvx bind 5 index /CIDFont resourceforall
+ .la2mark cvx bind 5 index /CIDFont resourceforall
exit
} loop % This loop is a pattern for execstack_lookup - don't remove !
Modified: trunk/gs/lib/gs_res.ps
===================================================================
--- trunk/gs/lib/gs_res.ps 2006-12-04 22:25:49 UTC (rev 7448)
+++ trunk/gs/lib/gs_res.ps 2006-12-05 03:28:09 UTC (rev 7449)
@@ -336,12 +336,6 @@
{ 3 -1 roll //.rfnstring cvs concatstrings exch copy
} bind def
-% Define a procedure for making a packed array in local VM.
-/.localpackedarray { % <obj1> ... <objn> <n> .localpackedarray <packedarray>
- .currentglobal false .setglobal 1 index 2 add 1 roll
- packedarray exch .setglobal
-} bind def
-
% Define the Generic category.
/Generic mark
@@ -478,19 +472,19 @@
% Construct a new procedure to hold the arguments.
% All objects constructed here must be in local VM to avoid
% a possible invalidaccess.
- currentdict 4 .localpackedarray % [template proc scratch resdict]
+ currentdict 4 .localvmpackedarray % [template proc scratch resdict]
% We must pop the resource dictionary off the dict stack
% when doing the actual iteration, and restore it afterwards.
.currentglobal not {
.LocalInstances length 0 ne {
% We must do local instances, and do them first.
- //.localresourceforall {exec} 0 get 3 .localpackedarray cvx
+ //.localresourceforall {exec} 0 get 3 .localvmpackedarray cvx
.LocalInstances exch {forall} 0 get 1 index 0 get
currentdict end 3 .execn begin
} if
} if
% Do global instances next.
- //.globalresourceforall {exec} 0 get 3 .localpackedarray cvx
+ //.globalresourceforall {exec} 0 get 3 .localvmpackedarray cvx
.Instances exch cvx {forall} 0 get 1 index 0 get
currentdict end 3 .execn begin
mark % args [
@@ -498,7 +492,7 @@
2 index 0 get % args [ (c/) (t)
dup length 3 1 roll % args [ l (c/) (t)
concatstrings % args [ l (c/t)
- [
+ [
true /LIBPATH .systemvar 3 index
.generate_dir_list_templates_with_length % args (t) [ l [(pt) Lp ...]
% also add on the Resources as specified by the GenericResourceDir
@@ -508,7 +502,8 @@
true [ currentsystemparams /GenericResourceDir get]
counttomark 1 add index .file_name_separator (*)
concatstrings concatstrings .generate_dir_list_templates_with_length
- ] exch pop
+ % Do the equivalent of .localvm].
+ counttomark .localvmarray astore exch pop exch pop
dup length 1 sub 0 exch 2 exch { % args [ l [] i
2 copy get % args [ l [] i (pt)
exch 2 index exch 1 add get % args [ l [] (pt) Lp
@@ -524,13 +519,17 @@
pop % args [ /n1 /n1 ... /nN /nN l []
} for % args [ /n1 /n1 ... /nN /nN l []
pop pop
- .dicttomark % An easy way to exclude duplicates. % args <</n/n>>
+ % Do the equivalent of .localvmdicttomark.
+ counttomark 2 idiv .localvmdict
+ dup maxlength {
+ dup 4 -2 roll put
+ } repeat exch pop % An easy way to exclude duplicates. % args <</n/n>>
% {
{ pop } 0 get
2 index 2 get { cvs 0 } aload pop 5 index
//.externalresourceforall {exec} 0 get
% }
- 7 .localpackedarray cvx
+ 7 .localvmpackedarray cvx
3 2 roll pop % args
{ forall } 0 get
currentdict end 2 .execn begin
Modified: trunk/gs/lib/gs_resmp.ps
===================================================================
--- trunk/gs/lib/gs_resmp.ps 2006-12-04 22:25:49 UTC (rev 7448)
+++ trunk/gs/lib/gs_resmp.ps 2006-12-05 03:28:09 UTC (rev 7449)
@@ -44,6 +44,11 @@
languagelevel 2 .setlanguagelevel
currentglobal true setglobal
+% See BindWithCurrentdict for the explanation of .bwcdarray.
+% We can't use /array load, because we don't want this to be bound,
+% and we can't make it executable, because bind would make it readonly.
+/.bwcdarray [/array load] def
+
/MappedCategoryRedefiner 10 dict begin % The procset.
currentpacking false setpacking
@@ -97,8 +102,13 @@
% bound recursively.
% Caution2 : this code don't bind packedarrays. This was done
% intentionally for a termination of the procedure tree.
+ % Note that we must create the copy in local VM, because some of the
+ % values in currentdict might be in local VM. However, during
+ % initialization we must create the copy in current (global) VM.
+ % We handle this by changing the definition of .bwcdarray after
+ % initialization.
- dup length array copy
+ dup length //.bwcdarray cvx exec copy
dup length 1 sub -1 0 {
2 copy get % {precopy} i {elem}
dup dup type /arraytype eq exch xcheck and {
@@ -134,9 +144,11 @@
% To work around this, we create a copy of the enumeration procedure and
% bind it dynamically with a temporary dictionary, which contains
% local variables for the currently executing instance of resourceforall.
+ % Note that this dictionary must be in local VM, since some of its
+ % values may be in local VM.
currentdict % Category
- 6 dict begin % the temporary dictionary
+ 6 .localvmdict begin % the temporary dictionary
/Category exch def %
/InstancesStatus exch def
/scr exch def
@@ -382,7 +394,7 @@
/Redefine % <OptionsDict> Redefine -
{ % Before calling this proc, the OptionsDict must specify options for
- % the catregory to be redefined :
+ % the category to be redefined :
% CategoryName - a name of category to redefine;
% MapFileName - a string for the resource map file name;
% VerifyMap - a procedure :
@@ -417,7 +429,6 @@
% the scanning until all redefinitions are done, but it requires
% to implement a queue of "refinish" methods and execute it
% at very end of the prelude.
-
begin % OptionsDict
CategoryName /Category findresource /OldCategory exch def
OldCategory /.IsRedefinedWithMap known {
@@ -503,6 +514,8 @@
//MethodsToRedefine {
//BindWithCurrentdict exec NewCategory 3 1 roll put
} forall
+ % Switch BindWithCurrentdict to local VM for actual use.
+ //.bwcdarray 0 /.localvmarray load put
CategoryName /CIDFont ne {
NewCategory /GetCIDSystemInfoFromMap undef
% This is some ugly, sorry.
More information about the gs-cvs
mailing list