Searching for "thisContext selector"
Alejandro F. Reimondo
aleReimondo at sugarweb.com
Mon Aug 17 00:56:10 UTC 1998
Hi,
I'm trying to build a reduced image to be used in the web.
I don't want to shrink the image.
I've built a swapOut/In mechanism to fileOut all (non-basic)
methods in binary mode to external files (one per class)
that can be reloaded (without compilation) from a file server
or an http server.
I've replaced all the swappedOut methods with a method
like this (all methods will be replaced with the same
method to reduce space):
.. . . . . . . . . . . . . . . . . . . . . . . . . . .
warningShrinkedMethod
" WARNING: DO NOT modify/save this method."
| selector |
selector := thisContext selector.
SwapInManager
restoreSelector: selector
in: self class.
^self
perform: selector
withArguments: ((1 to: selector numArgs)
collect: [:i| thisContext tempAt: i]) asArray !
.. . . . . . . . . . . . . . . . . . . . . . . . . . .
The problem is with the expression "thisContext selector"
that find the selector searching in the receiver's class
for the selector who is implemented using "thisContext method"
As I use the same method for all the swappedOut methods
then, the returned selector is the first selector implemented in
the receiver's class!
What can I do to get the sent selector of thisContext
from the VM stack (or current method) ?
If I can use the same method to replace all the swappedOut
methods the most space needed for compiled methods
(and strings/arrays/floats in literal frames) will be reduced.
Class # instances inst space %
------------ ----------------- ------------ -------
CompiledMethod 13754 847485 21.2
Bitmap 810 794356 19.9
Array 9091 635672 15.9
String 8288 583664 14.6
ByteArray 200 364454 9.1
Color 4586 91720 2.3
Float 2445 39120 1.0
MethodDict. 1050 59176 1.5
Symbol 11560 223167 5.6
thanks,
Ale.
---Spanish version follows (for SUGAR's people)---
Hola!
Estoy tratando de armar un image reducido para la WEB.
No deseo recortar el image (perdiendo funcionalidad).
Por lo que he construido un mecanismo de swapeo
para leer transparentemente los metodos (en modo binario)
de archivos (uno por clase) que pueden ser cargados
desde disco (sin compilar) o de un servidor http.
He reemplazado todos los metodos swapeados por un
unico metodo como el que sigue (para reducir el espacio):
.. . . . . . . . . . . . . . . . . . . . . . . . . . .
warningShrinkedMethod
" WARNING: DO NOT modify/save this method."
| selector |
selector := thisContext selector.
SwapInManager
restoreSelector: selector
in: self class.
^self
perform: selector
withArguments: ((1 to: selector numArgs)
collect: [:i| thisContext tempAt: i]) asArray !
.. . . . . . . . . . . . . . . . . . . . . . . . . . .
El problema es que la expresion "thisContext selector"
busca el selector buscando el mensaje que es implementado
por el metodo activo.
Como yo uso el mismo metodo para muchos mensajes,
el selector devuelto es siempre el primero implemenmtado
en la clase del receptor!
Que podría hacer para conocer el nombre del mensaje
que se ha enviado sacandolo del stack (o de la
activacion actual) ?
Si puedo usar el mismo metodo para todos los metodos
swapeados la mayoria del espacio usado por los metodos
compilados (strings arrays y floats en literales) seria liberado!.
Consideren la siguiente lista de espacio usado por clase...
Class # instances inst space %
------------ ----------------- ------------ -------
CompiledMethod 13754 847485 21.2
Bitmap 810 794356 19.9
Array 9091 635672 15.9
String 8288 583664 14.6
ByteArray 200 364454 9.1
Color 4586 91720 2.3
Float 2445 39120 1.0
MethodDict. 1050 59176 1.5
Symbol 11560 223167 5.6
Gracias,
Ale.
More information about the Squeak-dev
mailing list
|