Author: Anton Gulenko <[email protected]>
Branch: rstrategies
Changeset: r1055:de3e0bdda188
Date: 2014-09-25 11:31 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/de3e0bdda188/
Log: Enabled logging of storage-operations on image startup and object
creation.
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -574,8 +574,8 @@
self.initialize_storage(space, size, weak)
def initialize_storage(self, space, size, weak=False):
- storage = space.strategy_factory.empty_storage(self, size, weak)
- self.store_shadow(storage)
+ storage_type = space.strategy_factory.empty_storage_type(self, size,
weak)
+ space.strategy_factory.set_initial_strategy(self, storage_type, size)
def fillin(self, space, g_self):
W_AbstractObjectWithClassReference.fillin(self, space, g_self)
@@ -584,10 +584,7 @@
g_obj.fillin(space)
pointers = g_self.get_pointers()
storage_type = space.strategy_factory.strategy_type_for(pointers,
g_self.isweak())
- storage = storage_type(space, self, len(pointers))
- assert self.shadow is None, "Shadow should not be initialized yet!"
- self.store_shadow(storage)
- self.store_all(space, pointers)
+ space.strategy_factory.set_initial_strategy(self, storage_type,
len(pointers), pointers)
def is_weak(self):
from storage import WeakListStorageShadow
diff --git a/spyvm/storage.py b/spyvm/storage.py
--- a/spyvm/storage.py
+++ b/spyvm/storage.py
@@ -100,17 +100,27 @@
def strategy_type_for(self, objects, weak=False):
if weak:
- WeakListStorageShadow
+ return WeakListStorageShadow
if self.no_specialized_storage.is_set():
return ListStorageShadow
return rstrat.StrategyFactory.strategy_type_for(self, objects)
- def empty_storage(self, w_self, size, weak=False):
+ def empty_storage_type(self, w_self, size, weak=False):
if weak:
- return WeakListStorageShadow(self.space, w_self, size)
+ return WeakListStorageShadow
if self.no_specialized_storage.is_set():
- return ListStorageShadow(self.space, w_self, size)
- return AllNilStorageShadow(self.space, w_self, size)
+ return ListStorageShadow
+ return AllNilStorageShadow
+
+ def set_initial_strategy(self, w_object, strategy_type, size,
elements=None):
+ assert w_object.shadow is None, "Shadow should not be initialized yet!"
+ strategy = strategy_type(self.space, w_object, size)
+ w_object.store_shadow(strategy)
+ if elements:
+ w_object.store_all(self.space, elements)
+ strategy.strategy_switched()
+ if self.logger.active:
+ self.log(strategy)
def instantiate_and_switch(self, old_strategy, size, strategy_class):
w_self = old_strategy.w_self()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit