Author: Anton Gulenko <[email protected]>
Branch: storage
Changeset: r714:31857c8f49b5
Date: 2014-03-28 11:23 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/31857c8f49b5/
Log: Fixed some rpython errors.
diff --git a/spyvm/interpreter_proxy.py b/spyvm/interpreter_proxy.py
--- a/spyvm/interpreter_proxy.py
+++ b/spyvm/interpreter_proxy.py
@@ -192,7 +192,7 @@
@expose_on_virtual_machine_proxy([oop], int)
def byteSizeOf(w_object):
- return w_object.bytesize(IProxy.space)
+ return w_object.bytesize()
@expose_on_virtual_machine_proxy([int, oop], list)
def fetchArrayofObject(fieldIndex, w_object):
diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -646,6 +646,10 @@
return self._get_shadow().store(n0, w_value)
def size(self):
+ if not self.has_shadow():
+ # TODO - this happens only for objects bootstrapped in ObjSpace.
+ # Think of a way to avoid this check. Usually, self.shadow is
never None.
+ return 0
return self._get_shadow().size()
def instsize(self):
@@ -1142,6 +1146,7 @@
"""
repr_classname = "W_CompiledMethod"
+ bytes_per_slot = 1
_immutable_fields_ = ["_shadow?"]
_attrs_ = ["bytes", "_likely_methodname", "header", "argsize", "primitive",
"literals", "tempsize", "literalsize", "islarge", "_shadow"]
@@ -1251,13 +1256,8 @@
hasattr(self, 'primitive') and
self.primitive is not None)
- def bytesize(self, space):
- # This is very special: words and bytes are mixed here.
+ def size(self):
return self.headersize() + self.getliteralsize() + len(self.bytes)
-
- def size(self):
- # One word for the header.
- return 1 + self.literalsize + len(self.bytes)
def gettempsize(self):
return self.tempsize
diff --git a/spyvm/primitives.py b/spyvm/primitives.py
--- a/spyvm/primitives.py
+++ b/spyvm/primitives.py
@@ -24,6 +24,7 @@
def assert_pointers(w_obj):
if not isinstance(w_obj, model.W_PointersObject):
raise PrimitiveFailedError
+ return w_obj
# ___________________________________________________________________________
# Primitive table: it is filled in at initialization time with the
@@ -466,7 +467,7 @@
@expose_primitive(NEW, unwrap_spec=[object])
def func(interp, s_frame, w_cls):
- assert_pointers(w_cls)
+ w_cls = assert_pointers(w_cls)
s_class = w_cls.as_class_get_shadow(interp.space)
if s_class.isvariable():
raise PrimitiveFailedError()
@@ -474,7 +475,7 @@
@expose_primitive(NEW_WITH_ARG, unwrap_spec=[object, int])
def func(interp, s_frame, w_cls, size):
- assert_pointers(w_cls)
+ w_cls = assert_pointers(w_cls)
s_class = w_cls.as_class_get_shadow(interp.space)
if not s_class.isvariable() and size != 0:
raise PrimitiveFailedError()
@@ -492,7 +493,7 @@
"Fetches a fixed field from the object, and fails otherwise"
s_class = w_rcvr.class_shadow(interp.space)
assert_bounds(n0, 0, s_class.instsize())
- assert_pointers(w_rcvr)
+ w_cls = assert_pointers(w_rcvr)
return w_rcvr.fetch(interp.space, n0)
@expose_primitive(INST_VAR_AT_PUT, unwrap_spec=[object, index1_0, object])
@@ -500,7 +501,7 @@
"Stores a value into a fixed field from the object, and fails otherwise"
s_class = w_rcvr.class_shadow(interp.space)
assert_bounds(n0, 0, s_class.instsize())
- assert_pointers(w_rcvr)
+ w_rcvr = assert_pointers(w_rcvr)
w_rcvr.store(interp.space, n0, w_value)
return w_value
@@ -513,7 +514,7 @@
@expose_primitive(STORE_STACKP, unwrap_spec=[object, int])
def func(interp, s_frame, w_frame, stackp):
assert stackp >= 0
- assert_pointers(w_frame)
+ w_frame = assert_pointers(w_frame)
w_frame.store(interp.space, constants.CTXPART_STACKP_INDEX,
interp.space.wrap_int(stackp))
return w_frame
@@ -909,7 +910,7 @@
s_cm = w_rcvr.as_compiledmethod_get_shadow(interp.space)
w_class = s_cm.w_compiledin
if w_class:
- assert_pointers(w_class)
+ w_class = assert_pointers(w_class)
w_class.as_class_get_shadow(interp.space).flush_method_caches()
return w_rcvr
@@ -1282,7 +1283,7 @@
# the new BlockContext's home context. Otherwise, the home
# context of the receiver is used for the new BlockContext.
# Note that in our impl, MethodContext.w_home == self
- assert_pointers(w_context)
+ w_context = assert_pointers(w_context)
w_method_context = w_context.as_context_get_shadow(interp.space).w_home()
# The block bytecodes are stored inline: so we skip past the
@@ -1318,8 +1319,7 @@
interp.space.w_BlockContext):
raise PrimitiveFailedError()
- assert_pointers(w_block_ctx)
-
+ w_block_ctx = assert_pointers(w_block_ctx)
s_block_ctx = w_block_ctx.as_blockcontext_get_shadow(interp.space)
exp_arg_cnt = s_block_ctx.expected_argument_count()
@@ -1341,7 +1341,7 @@
result_is_new_frame=True)
def func(interp, s_frame, w_block_ctx, args_w):
- assert_pointers(w_block_ctx)
+ w_block_ctx = assert_pointers(w_block_ctx)
s_block_ctx = w_block_ctx.as_blockcontext_get_shadow(interp.space)
exp_arg_cnt = s_block_ctx.expected_argument_count()
@@ -1434,7 +1434,7 @@
@expose_primitive(FLUSH_CACHE, unwrap_spec=[object])
def func(interp, s_frame, w_rcvr):
- assert_pointers(w_rcvr)
+ w_rcvr = assert_pointers(w_rcvr)
s_class = w_rcvr.as_class_get_shadow(interp.space)
s_class.flush_method_caches()
return w_rcvr
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit