author | Claus Gittinger <cg@exept.de> |
Wed, 06 Dec 1995 18:23:42 +0100 | |
changeset 157 | d7f68808a258 |
parent 154 | 04716b86ad29 |
child 259 | a469695d8d19 |
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 |
|
141 | 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' |
120 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'System-Compiler' |
|
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 |
||
154 | 52 |
!ObjectFileHandle methodsFor:'copying'! |
53 |
||
54 |
postCopy |
|
55 |
sysHandle1 := sysHandle2 := moduleID := nil |
|
56 |
||
57 |
"Created: 5.12.1995 / 21:10:49 / cg" |
|
58 |
! ! |
|
59 |
||
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
60 |
!ObjectFileHandle methodsFor:'change & update'! |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
61 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
62 |
update:something with:aParameter from:changedObject |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
63 |
"my method/class object was collected - unload the underlying objectfile" |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
64 |
|
152
d7c2314f393e
selective unloading - thats better
Claus Gittinger <cg@exept.de>
parents:
151
diff
changeset
|
65 |
self isObsolete ifTrue:[ |
d7c2314f393e
selective unloading - thats better
Claus Gittinger <cg@exept.de>
parents:
151
diff
changeset
|
66 |
('OBJFLOADER: unloading ' , pathName , ' (method/classes were garbageCollected)') infoPrintNL. |
d7c2314f393e
selective unloading - thats better
Claus Gittinger <cg@exept.de>
parents:
151
diff
changeset
|
67 |
ObjectFileLoader unloadObjectFile:pathName |
d7c2314f393e
selective unloading - thats better
Claus Gittinger <cg@exept.de>
parents:
151
diff
changeset
|
68 |
]. |
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
69 |
|
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
70 |
"Created: 5.12.1995 / 18:05:08 / cg" |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
71 |
! ! |
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
72 |
|
114 | 73 |
!ObjectFileHandle methodsFor:'accessing'! |
74 |
||
122 | 75 |
classes |
76 |
"return the classes" |
|
77 |
||
125 | 78 |
weakClassRefs isNil ifTrue:[^nil]. |
122 | 79 |
^ weakClassRefs asArray |
80 |
||
81 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
82 |
! |
|
83 |
||
84 |
classes:aCollectionOfClasses |
|
85 |
"set the classes collection" |
|
86 |
||
87 |
weakClassRefs := WeakArray withAll:aCollectionOfClasses. |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
88 |
weakClassRefs addDependent:self. |
122 | 89 |
handleType := #classLibraryObject |
90 |
||
91 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
92 |
! |
|
93 |
||
120 | 94 |
method |
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
95 |
"return the method" |
120 | 96 |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
97 |
weakMethodRef isNil ifTrue:[^ nil]. |
120 | 98 |
^ weakMethodRef at:1 |
99 |
||
100 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
101 |
! |
|
102 |
||
103 |
method:something |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
104 |
"set the method" |
120 | 105 |
|
106 |
weakMethodRef := WeakArray with:something. |
|
151
7f46f760ba45
automatically unload modules for garbage collected methods/classes
Claus Gittinger <cg@exept.de>
parents:
148
diff
changeset
|
107 |
weakMethodRef addDependent:self. |
122 | 108 |
handleType := #methodObject. |
120 | 109 |
|
110 |
"Created: 14.9.1995 / 21:13:13 / claus" |
|
141 | 111 |
! |
112 |
||
113 |
moduleID |
|
114 |
"return moduleID" |
|
115 |
||
116 |
^ moduleID |
|
117 |
||
118 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
119 |
! |
|
120 |
||
121 |
moduleID:something |
|
122 |
"set moduleID" |
|
123 |
||
124 |
moduleID := something. |
|
125 |
||
126 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
127 |
! |
|
128 |
||
129 |
pathName |
|
130 |
"return pathName" |
|
131 |
||
132 |
^ pathName |
|
133 |
||
134 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
135 |
! |
|
136 |
||
137 |
pathName:something |
|
138 |
"set pathName" |
|
139 |
||
140 |
pathName := something. |
|
141 |
||
142 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
143 |
! |
|
144 |
||
145 |
sysHandle1 |
|
146 |
"return sysHandle1" |
|
147 |
||
148 |
^ sysHandle1 |
|
149 |
||
150 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
151 |
! |
|
152 |
||
153 |
sysHandle1:something |
|
154 |
"set sysHandle1" |
|
155 |
||
156 |
sysHandle1 := something. |
|
157 |
||
158 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
159 |
! |
|
160 |
||
161 |
sysHandle2 |
|
162 |
"return sysHandle2" |
|
163 |
||
164 |
^ sysHandle2 |
|
165 |
||
166 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
167 |
! |
|
168 |
||
169 |
sysHandle2:something |
|
170 |
"set sysHandle2" |
|
171 |
||
172 |
sysHandle2 := something. |
|
173 |
||
174 |
"Created: 14.9.1995 / 21:13:12 / claus" |
|
114 | 175 |
! ! |
141 | 176 |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
177 |
!ObjectFileHandle methodsFor:'printing'! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
178 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
179 |
printOn:aStream |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
180 |
aStream nextPutAll:self class name; nextPutAll:'(handle=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
181 |
sysHandle1 printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
182 |
aStream nextPutAll:' '. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
183 |
sysHandle2 printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
184 |
aStream nextPutAll:'> path='''. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
185 |
pathName printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
186 |
aStream nextPutAll:''' id='. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
187 |
moduleID printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
188 |
aStream nextPutAll:' type='. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
189 |
handleType printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
190 |
aStream nextPutAll:' method=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
191 |
self method printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
192 |
aStream nextPutAll:'> classes=<'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
193 |
self classes printOn:aStream. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
194 |
aStream nextPutAll:'>'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
195 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
196 |
aStream nextPutAll:')'. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
197 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
198 |
"Modified: 6.12.1995 / 18:11:53 / cg" |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
199 |
! ! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
200 |
|
141 | 201 |
!ObjectFileHandle methodsFor:'queries'! |
202 |
||
203 |
isClassLibHandle |
|
204 |
"return true, if I am a handle for a class library" |
|
205 |
||
206 |
^ handleType == #classLibraryObject |
|
207 |
! |
|
208 |
||
209 |
isMethodHandle |
|
210 |
"return true, if I am a handle for a single compiled method" |
|
211 |
||
212 |
^ handleType == #methodObject |
|
213 |
! |
|
214 |
||
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
215 |
isForCollectedObject |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
216 |
"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
|
217 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
218 |
handleType == #classLibraryObject ifTrue:[ |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
219 |
^ (weakClassRefs findFirst:[:x | x notNil]) == 0 |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
220 |
]. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
221 |
handleType == #methodObject ifTrue:[ |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
222 |
^ (weakMethodRef at:1) isNil |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
223 |
]. |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
224 |
^ false |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
225 |
|
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
226 |
"Created: 6.12.1995 / 17:46:58 / cg" |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
227 |
! |
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
228 |
|
141 | 229 |
isObsolete |
230 |
"return true, if my clases/method has already been removed from |
|
231 |
the image. I.e. if the object file can be unloaded without danger." |
|
232 |
||
154 | 233 |
moduleID notNil ifTrue:[ |
234 |
handleType == #classLibraryObject ifTrue:[ |
|
235 |
^ (weakClassRefs findFirst:[:x | x notNil]) == 0 |
|
236 |
]. |
|
237 |
handleType == #methodObject ifTrue:[ |
|
238 |
^ (weakMethodRef at:1) isNil |
|
239 |
]. |
|
141 | 240 |
]. |
241 |
^ false |
|
242 |
! ! |
|
243 |
||
148 | 244 |
!ObjectFileHandle class methodsFor:'documentation'! |
245 |
||
246 |
version |
|
157
d7f68808a258
reload objects in the previous order
Claus Gittinger <cg@exept.de>
parents:
154
diff
changeset
|
247 |
^ '$Header: /cvs/stx/stx/libcomp/ObjectFileHandle.st,v 1.12 1995-12-06 17:23:29 cg Exp $' |
148 | 248 |
! ! |