author | Claus Gittinger <cg@exept.de> |
Thu, 25 Apr 1996 09:53:22 +0200 | |
changeset 259 | a469695d8d19 |
parent 157 | d7f68808a258 |
child 263 | 3b21d0991eff |
permissions | -rw-r--r-- |
141 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
114 | 12 |
|
13 |
Object subclass:#ObjectFileHandle |
|
259 | 14 |
instanceVariableNames:'sysHandle1 sysHandle2 pathName moduleID handleType weakMethodRef |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
15 |
weakClassRefs' |
259 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'System-Compiler' |
|
120 | 19 |
! |
20 |
||
21 |
!ObjectFileHandle class methodsFor:'documentation'! |
|
22 |
||
141 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
114 | 35 |
! |
36 |
||
120 | 37 |
documentation |
38 |
" |
|
123 | 39 |
not for public use - used by ObjectFileLoader to keep track of loaded modules, |
40 |
associating objectFile names and moduleIDs to classes/methods. |
|
120 | 41 |
" |
114 | 42 |
|
120 | 43 |
"Created: 14.9.1995 / 21:10:55 / claus" |
44 |
! |
|
114 | 45 |
|
120 | 46 |
history |
47 |
||
48 |
"Created: 14.9.1995 / 21:10:55 / claus" |
|
49 |
"Modified: 14.9.1995 / 21:10:55 / claus" |
|
114 | 50 |
! ! |
51 |
||
52 |
!ObjectFileHandle methodsFor:'accessing'! |
|
53 |
||
122 | 54 |
classes |
55 |
"return the classes" |
|
56 |
||
125 | 57 |
weakClassRefs isNil ifTrue:[^nil]. |
122 | 58 |
^ weakClassRefs asArray |
59 |
||
60 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
61 |
! |
|
62 |
||
63 |
classes:aCollectionOfClasses |
|
64 |
"set the classes collection" |
|
65 |
||
66 |
weakClassRefs := WeakArray withAll:aCollectionOfClasses. |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
67 |
weakClassRefs addDependent:self. |
122 | 68 |
handleType := #classLibraryObject |
69 |
||
70 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
71 |
! |
|
72 |
||
120 | 73 |
method |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
74 |
"return the method" |
120 | 75 |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
76 |
weakMethodRef isNil ifTrue:[^ nil]. |
120 | 77 |
^ weakMethodRef at:1 |
78 |
||
79 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
80 |
! |
|
81 |
||
82 |
method:something |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
83 |
"set the method" |
120 | 84 |
|
85 |
weakMethodRef := WeakArray with:something. |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
86 |
weakMethodRef addDependent:self. |
122 | 87 |
handleType := #methodObject. |
120 | 88 |
|
89 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
141 | 90 |
! |
91 |
||
92 |
moduleID |
|
93 |
"return moduleID" |
|
94 |
||
95 |
^ moduleID |
|
96 |
||
97 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
98 |
! |
|
99 |
||
100 |
moduleID:something |
|
101 |
"set moduleID" |
|
102 |
||
103 |
moduleID := something. |
|
104 |
||
105 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
106 |
! |
|
107 |
||
108 |
pathName |
|
109 |
"return pathName" |
|
110 |
||
111 |
^ pathName |
|
112 |
||
113 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
114 |
! |
|
115 |
||
116 |
pathName:something |
|
117 |
"set pathName" |
|
118 |
||
119 |
pathName := something. |
|
120 |
||
121 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
122 |
! |
|
123 |
||
124 |
sysHandle1 |
|
125 |
"return sysHandle1" |
|
126 |
||
127 |
^ sysHandle1 |
|
128 |
||
129 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
130 |
! |
|
131 |
||
132 |
sysHandle1:something |
|
133 |
"set sysHandle1" |
|
134 |
||
135 |
sysHandle1 := something. |
|
136 |
||
137 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
138 |
! |
|
139 |
||
140 |
sysHandle2 |
|
141 |
"return sysHandle2" |
|
142 |
||
143 |
^ sysHandle2 |
|
144 |
||
145 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
146 |
! |
|
147 |
||
148 |
sysHandle2:something |
|
149 |
"set sysHandle2" |
|
150 |
||
151 |
sysHandle2 := something. |
|
152 |
||
153 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
114 | 154 |
! ! |
141 | 155 |
|
259 | 156 |
!ObjectFileHandle methodsFor:'change & update'! |
157 |
||
158 |
update:something with:aParameter from:changedObject |
|
159 |
"my method/class object was collected - unload the underlying objectfile" |
|
160 |
||
161 |
self isObsolete ifTrue:[ |
|
162 |
('OBJFLOADER: unloading ' , pathName , ' (method/classes were garbageCollected)') infoPrintNL. |
|
163 |
ObjectFileLoader unloadObjectFile:pathName |
|
164 |
]. |
|
165 |
||
166 |
"Created: 5.12.1995 / 18:05:08 / cg" |
|
167 |
! ! |
|
168 |
||
169 |
!ObjectFileHandle methodsFor:'copying'! |
|
170 |
||
171 |
postCopy |
|
172 |
"flush module handles of the copy" |
|
173 |
||
174 |
sysHandle1 := sysHandle2 := moduleID := nil |
|
175 |
||
176 |
"Created: 5.12.1995 / 21:10:49 / cg" |
|
177 |
"Modified: 25.4.1996 / 09:43:53 / cg" |
|
178 |
! ! |
|
179 |
||
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
180 |
!ObjectFileHandle methodsFor:'printing'! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
181 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
182 |
printOn:aStream |
259 | 183 |
"append a printed representation of the receiver to aStream" |
184 |
||
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
185 |
aStream nextPutAll:self class name; nextPutAll:'(handle=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
186 |
sysHandle1 printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
187 |
aStream nextPutAll:' '. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
188 |
sysHandle2 printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
189 |
aStream nextPutAll:'> path='''. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
190 |
pathName printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
191 |
aStream nextPutAll:''' id='. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
192 |
moduleID printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
193 |
aStream nextPutAll:' type='. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
194 |
handleType printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
195 |
aStream nextPutAll:' method=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
196 |
self method printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
197 |
aStream nextPutAll:'> classes=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
198 |
self classes printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
199 |
aStream nextPutAll:'>'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
200 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
201 |
aStream nextPutAll:')'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
202 |
|
259 | 203 |
"Modified: 25.4.1996 / 09:44:08 / cg" |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
204 |
! ! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
205 |
|
141 | 206 |
!ObjectFileHandle methodsFor:'queries'! |
207 |
||
208 |
isClassLibHandle |
|
209 |
"return true, if I am a handle for a class library" |
|
210 |
||
211 |
^ handleType == #classLibraryObject |
|
212 |
! |
|
213 |
||
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
214 |
isForCollectedObject |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
215 |
"return true, if my clases/method has already been garbage collected" |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
216 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
217 |
handleType == #classLibraryObject ifTrue:[ |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
218 |
^ (weakClassRefs findFirst:[:x | x notNil]) == 0 |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
219 |
]. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
220 |
handleType == #methodObject ifTrue:[ |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
221 |
^ (weakMethodRef at:1) isNil |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
222 |
]. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
223 |
^ false |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
224 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
225 |
"Created: 6.12.1995 / 17:46:58 / cg" |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
226 |
! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
227 |
|
259 | 228 |
isMethodHandle |
229 |
"return true, if I am a handle for a single compiled method" |
|
230 |
||
231 |
^ handleType == #methodObject |
|
232 |
! |
|
233 |
||
141 | 234 |
isObsolete |
235 |
"return true, if my clases/method has already been removed from |
|
236 |
the image. I.e. if the object file can be unloaded without danger." |
|
237 |
||
154 | 238 |
moduleID notNil ifTrue:[ |
239 |
handleType == #classLibraryObject ifTrue:[ |
|
240 |
^ (weakClassRefs findFirst:[:x | x notNil]) == 0 |
|
241 |
]. |
|
242 |
handleType == #methodObject ifTrue:[ |
|
243 |
^ (weakMethodRef at:1) isNil |
|
244 |
]. |
|
141 | 245 |
]. |
246 |
^ false |
|
247 |
! ! |
|
248 |
||
148 | 249 |
!ObjectFileHandle class methodsFor:'documentation'! |
250 |
||
251 |
version |
|
259 | 252 |
^ '$Header: /cvs/stx/stx/libcomp/Attic/ObjFHandle.st,v 1.13 1996-04-25 07:52:57 cg Exp $' |
148 | 253 |
! ! |