[pypy-svn] r47896 - in pypy/dist/pypy/lang/smalltalk: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Thu Oct 25 10:42:24 CEST 2007
Author: cfbolz
Date: Thu Oct 25 10:42:23 2007
New Revision: 47896
Modified:
pypy/dist/pypy/lang/smalltalk/classtable.py
pypy/dist/pypy/lang/smalltalk/mirror.py
pypy/dist/pypy/lang/smalltalk/squeakimage.py
pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py
Log:
reuse the prebuilt mirror instances when loading the image
Modified: pypy/dist/pypy/lang/smalltalk/classtable.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/classtable.py (original)
+++ pypy/dist/pypy/lang/smalltalk/classtable.py Thu Oct 25 10:42:23 2007
@@ -58,17 +58,20 @@
# Other classes
def define_cls(cls_nm, supercls_nm, instvarsize=0, format=mirror.POINTERS):
+ assert cls_nm.startswith("m_")
meta_nm = cls_nm + "Class"
meta_super_nm = supercls_nm + "Class"
m_meta_cls = globals()[meta_nm] = classtable[meta_nm] = \
bootstrap_classmirror(0, # XXX
classtable[meta_super_nm],
- m_Metaclass)
+ m_Metaclass,
+ name=meta_nm[2:])
m_cls = globals()[cls_nm] = classtable[cls_nm] = \
bootstrap_classmirror(instvarsize,
classtable[supercls_nm],
m_meta_cls,
- format=format)
+ format=format,
+ name=cls_nm[2:])
define_cls("m_Magnitude", "m_Object")
define_cls("m_Character", "m_Magnitude", instvarsize=1)
Modified: pypy/dist/pypy/lang/smalltalk/mirror.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/mirror.py (original)
+++ pypy/dist/pypy/lang/smalltalk/mirror.py Thu Oct 25 10:42:23 2007
@@ -147,4 +147,8 @@
mirror.check()
return mirror
+ def assign_existing_mirror(self, w_class, m_class):
+ assert w_class not in self.cache
+ self.cache[w_class] = m_class
+
mirrorcache = MirrorCache()
Modified: pypy/dist/pypy/lang/smalltalk/squeakimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/squeakimage.py (original)
+++ pypy/dist/pypy/lang/smalltalk/squeakimage.py Thu Oct 25 10:42:23 2007
@@ -83,6 +83,7 @@
self.init_compactclassesarray()
self.init_g_objects()
self.init_w_objects()
+ self.assign_mirrors()
self.fillin_w_objects()
def read_header(self):
@@ -116,6 +117,26 @@
for chunk in self.chunks.itervalues():
chunk.g_object.init_w_object()
+ def assign_mirrors(self):
+ # assign the mirrors to the classes already in classtable
+ from pypy.lang.smalltalk import classtable, constants
+ for so_index, name in [
+ (constants.SO_SMALLINTEGER_CLASS, "m_SmallInteger"),
+ (constants.SO_STRING_CLASS, "m_String"),
+ (constants.SO_FLOAT_CLASS, "m_Float"),
+ #(constants.SO_METHODCONTEXT_CLASS, "m_MethodContext"),
+ (constants.SO_CHARACTER_CLASS, "m_Character"),
+ (constants.SO_BYTEARRAY_CLASS, "m_ByteArray"),
+ (constants.SO_COMPILEDMETHOD_CLASS, "m_CompiledMethod")]:
+ mirrorcache.assign_existing_mirror(
+ self.special_object(so_index),
+ getattr(classtable, name))
+ # XXX more missing
+
+ def special_object(self, index):
+ special = self.chunks[self.specialobjectspointer].g_object.pointers
+ return special[index].w_object
+
def fillin_w_objects(self):
for chunk in self.chunks.itervalues():
chunk.g_object.fillin_w_object()
@@ -212,7 +233,6 @@
self.init_data(chunk) # for pointers
self.chunk = chunk # for bytes, words and compiledmethod
self.w_object = None
- self.init_w_object()
def init_class(self, chunk):
if chunk.iscompact():
@@ -354,7 +374,7 @@
primitive = primitive)
w_compiledmethod.literals = literals
-
+
class ImageChunk(object):
Modified: pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py (original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_miniimage.py Thu Oct 25 10:42:23 2007
@@ -202,3 +202,10 @@
# Fails due to same reason because of which
# classmirror-methodlookup fails
test_lookup_abs_in_integer(-3)
+
+def test_map_mirrors_to_classtable():
+ from pypy.lang.smalltalk import classtable, mirror
+ w_compiledmethod_class = image.special(sqc.SO_COMPILEDMETHOD_CLASS)
+ m_compiledmethod_class = mirror.mirrorcache.getmirror(
+ w_compiledmethod_class)
+ assert m_compiledmethod_class is classtable.m_CompiledMethod
More information about the Pypy-commit
mailing list