def _become(self, w_other): if isinstance(w_other, W_AbstractFloat): raise error.PrimitiveFailedError self_value, w_other_value = self.getvalue(), w_other.getvalue() self.setvalue(w_other_value) w_other.setvalue(self_value) W_AbstractObjectWithIdentityHash._become(self, w_other)
def pointers_become_one_way(self, space, from_w, to_w): W_AbstractObjectWithIdentityHash.pointers_become_one_way(self, space, from_w, to_w) idx = -1 try: idx = from_w.index(self.compiledin_class) except ValueError: pass if idx >= 0: compiledin_class = self.compiledin_class new_w_class = to_w[idx] assert isinstance(new_w_class, W_PointersObject) self.compiledin_class = new_w_class compiledin_class.post_become_one_way(new_w_class) new_w_class.as_class_get_shadow(space).flush_method_caches() compiledin_class.as_class_get_shadow(space).flush_method_caches() idx = -1 try: idx = from_w.index(self.lookup_class) except ValueError: pass if idx >= 0: lookup_class = self.lookup_class new_w_class = to_w[idx] assert isinstance(new_w_class, W_PointersObject) self.lookup_class = new_w_class lookup_class.post_become_one_way(new_w_class) new_w_class.as_class_get_shadow(space).flush_method_caches() lookup_class.as_class_get_shadow(space).flush_method_caches()
def _become(self, w_other): if isinstance(w_other, W_AbstractFloat): raise error.PrimitiveFailedError self_value, w_other_value = self.getvalue(), w_other.getvalue() self.setvalue(w_other_value) w_other.setvalue(self_value) W_AbstractObjectWithIdentityHash._become(self, w_other)
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) # Recursive fillin required to enable specialized storage strategies. pointers_w = g_self.pointers assert len(pointers_w) == 1 pointers_w[0].fillin(space) self.value = space.unwrap_int(pointers_w[0].w_object)
def _become(self, w_other): if not isinstance(w_other, W_BlockClosure): raise error.PrimitiveFailedError self.changed() # aborts trace self._w_outerContext, w_other._w_outerContext = w_other._w_outerContext, self._w_outerContext self._startpc_stacklen_args, w_other._startpc_stacklen_args = w_other._startpc_stacklen_args, self._startpc_stacklen_args self._stack, w_other._stack = w_other._stack, self._stack W_AbstractObjectWithIdentityHash._become(self, w_other)
def _become(self, w_other): if not isinstance(w_other, W_BlockClosure): raise error.PrimitiveFailedError self.changed() # aborts trace self._w_outerContext, w_other._w_outerContext = w_other._w_outerContext, self._w_outerContext self._startpc_stacklen_args, w_other._startpc_stacklen_args = w_other._startpc_stacklen_args, self._startpc_stacklen_args self._stack, w_other._stack = w_other._stack, self._stack W_AbstractObjectWithIdentityHash._become(self, w_other)
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) self.lookup_selector = "unknown%d" % self.gethash() self.bytes = [] # make sure the attribute is defined # Implicitly sets the header, including self.literalsize for i, w_object in enumerate(g_self.get_pointers()): self.literalatput0(space, i, w_object, initializing=True) self.setbytes(g_self.get_bytes()[self.bytecodeoffset():]) self.post_init()
def __init__(self, space, size, depth): W_AbstractObjectWithIdentityHash.__init__(self) self._squeak_pixel_buffer = lltype.malloc(rffi.CArray(rffi.UINT), size, flavor='raw') self._realsize = size self._depth = depth self._display = space.display() self.relinquish_display()
def __init__(self, space, w_cls): """ Initialize immutable pointers object, but avoid initializing storage by calling `W_AbstractObjectWithIdentityHash.__init__(self)` instead of `W_PointersObject.__init__(self)`. Additionally, reuse `self.strategy` slot to store class shadow. """ W_AbstractObjectWithIdentityHash.__init__(self) self.strategy = w_cls.as_class_get_shadow(space)
def __init__(self, space, w_cls): """ Initialize immutable pointers object, but avoid initializing storage by calling `W_AbstractObjectWithIdentityHash.__init__(self)` instead of `W_PointersObject.__init__(self)`. Additionally, reuse `self.strategy` slot to store class shadow. """ W_AbstractObjectWithIdentityHash.__init__(self) self.strategy = w_cls.as_class_get_shadow(space)
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) # Recursive fillin required to enable specialized storage strategies. for g_obj in g_self.pointers: g_obj.fillin(space) pointers = g_self.get_pointers() storage_type = space.strategy_factory.strategy_type_for(pointers, weak=False) # do not fill in weak lists, yet space.strategy_factory.set_initial_strategy(self, storage_type, g_self.get_class(), len(pointers), pointers)
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) # Recursive fillin required to enable specialized storage strategies. for g_obj in g_self.pointers: g_obj.fillin(space) pointers = g_self.get_pointers() storage_type = space.strategy_factory.strategy_type_for( pointers, weak=False) # do not fill in weak lists, yet space.strategy_factory.set_initial_strategy(self, storage_type, g_self.get_class(), len(pointers), pointers)
def __init__(self, space, w_rcvr=None, method_name='', args_w=None, is_send=False, break_on_exceptions=False): W_AbstractObjectWithIdentityHash.__init__(self) self._space = space self.w_rcvr = w_rcvr self.method_name = method_name self.args_w = args_w or [] self._done = False self.w_result = None self.w_error = None self._is_send = is_send self._break_on_exceptions = break_on_exceptions
def pointers_become_one_way(self, space, from_w, to_w): W_AbstractObjectWithIdentityHash.pointers_become_one_way(self, space, from_w, to_w) ptrs = self.fetch_all(space) ptridx = 0 for i, w_from in enumerate(from_w): try: ptridx = ptrs.index(w_from) except ValueError: continue w_to = to_w[i] ptrs[ptridx] = w_to w_from.post_become_one_way(w_to) self.store_all(space, ptrs)
def pointers_become_one_way(self, space, from_w, to_w): W_AbstractObjectWithIdentityHash.pointers_become_one_way(self, space, from_w, to_w) ptrs = self.fetch_all(space) ptridx = 0 for i, w_from in enumerate(from_w): try: ptridx = ptrs.index(w_from) except ValueError: continue w_to = to_w[i] ptrs[ptridx] = w_to w_from.post_become_one_way(w_to) self.store_all(space, ptrs)
def __init__(self, space, w_outerctxt, startpc, numArgs, size, stack=None): W_AbstractObjectWithIdentityHash.__init__(self) self._startpc_stacklen_args = r_uint(0) self._w_outerContext = w_outerctxt self.set_startpc(startpc) self.set_numArgs(numArgs) if stack: self.set_stack(stack) elif size == 0: self.set_stack(self.empty_stack) else: self.set_stack([space.w_nil] * size) self._fillin_w_method(space) self._fillin_w_receiver(space)
def __init__(self, space, w_outerctxt, startpc, numArgs, size, stack=None): W_AbstractObjectWithIdentityHash.__init__(self) self._startpc_stacklen_args = r_uint(0) self._w_outerContext = w_outerctxt self.set_startpc(startpc) self.set_numArgs(numArgs) if stack: self.set_stack(stack) elif size == 0: self.set_stack(self.empty_stack) else: self.set_stack([space.w_nil] * size) self._fillin_w_method(space) self._fillin_w_receiver(space)
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) self._startpc_stacklen_args = r_uint(0) self.set_stack([space.w_nil] * len(g_self.pointers)) for i, g_obj in enumerate(g_self.pointers): g_obj.fillin(space) if i >= constants.BLKCLSR_SIZE: self.atput0(space, i - constants.BLKCLSR_SIZE, g_obj.w_object) elif i == constants.BLKCLSR_OUTER_CONTEXT: self._w_outerContext = g_obj.w_object elif i == constants.BLKCLSR_STARTPC: self.set_startpc(space.unwrap_int(g_obj.w_object)) elif i == constants.BLKCLSR_NUMARGS: self.set_numArgs(space.unwrap_int(g_obj.w_object)) else: assert False
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) self._startpc_stacklen_args = r_uint(0) self.set_stack([space.w_nil] * len(g_self.pointers)) for i, g_obj in enumerate(g_self.pointers): g_obj.fillin(space) if i >= constants.BLKCLSR_SIZE: self.atput0(space, i - constants.BLKCLSR_SIZE, g_obj.w_object) elif i == constants.BLKCLSR_OUTER_CONTEXT: self._w_outerContext = g_obj.w_object elif i == constants.BLKCLSR_STARTPC: self.set_startpc(space.unwrap_int(g_obj.w_object)) elif i == constants.BLKCLSR_NUMARGS: self.set_numArgs(space.unwrap_int(g_obj.w_object)) else: assert False
def __init__(self, space, w_rcvr=None, method_name='', args_w=None, is_send=False, break_on_exceptions=False): W_AbstractObjectWithIdentityHash.__init__(self) self._space = space self.w_rcvr = w_rcvr self.method_name = method_name self.args_w = args_w or [] self._done = False self.w_result = None self.w_error = None self._is_send = is_send self._break_on_exceptions = break_on_exceptions
def _become(self, w_other): if not isinstance(w_other, W_PointersObject): raise error.PrimitiveFailedError # Make sure our class shadow is initialized, we will need it if self.getclass(None) and self.getclass(None).has_space(): self.class_shadow(self.getclass(None).space()) if w_other.getclass(None) and w_other.getclass(None).has_space(): w_other.class_shadow(w_other.getclass(None).space()) # Only one strategy will handle the become (or none of them). # The receivers strategy gets the first shot. # If it doesn't want to, let the w_other's strategy handle it. if self.has_strategy() and self._get_strategy().handles_become(): self.strategy.become(w_other) elif w_other.has_strategy() and w_other._get_strategy().handles_become(): w_other.strategy.become(self) self.strategy, w_other.strategy = w_other.strategy, self.strategy self._storage, w_other._storage = w_other._storage, self._storage W_AbstractObjectWithIdentityHash._become(self, w_other)
def _become(self, w_other): if not isinstance(w_other, W_PointersObject): raise error.PrimitiveFailedError # Make sure our class shadow is initialized, we will need it if self.getclass(None) and self.getclass(None).has_space(): self.class_shadow(self.getclass(None).space()) if w_other.getclass(None) and w_other.getclass(None).has_space(): w_other.class_shadow(w_other.getclass(None).space()) # Only one strategy will handle the become (or none of them). # The receivers strategy gets the first shot. # If it doesn't want to, let the w_other's strategy handle it. if self.has_strategy() and self._get_strategy().handles_become(): self.strategy.become(w_other) elif w_other.has_strategy() and w_other._get_strategy().handles_become( ): w_other.strategy.become(self) self.strategy, w_other.strategy = w_other.strategy, self.strategy self._storage, w_other._storage = w_other._storage, self._storage W_AbstractObjectWithIdentityHash._become(self, w_other)
def _become(self, w_other): if not isinstance(w_other, W_CompiledMethod): raise error.PrimitiveFailedError self.argsize, w_other.argsize = w_other.argsize, self.argsize self._primitive, w_other._primitive = w_other._primitive, self._primitive self.literals, w_other.literals = w_other.literals, self.literals self._tempsize, w_other._tempsize = w_other._tempsize, self._tempsize self.bytes, w_other.bytes = w_other.bytes, self.bytes self.header, w_other.header = w_other.header, self.header self.literalsize, w_other.literalsize = w_other.literalsize, self.literalsize self.islarge, w_other.islarge = w_other.islarge, self.islarge self.lookup_selector, w_other.lookup_selector = w_other.lookup_selector, self.lookup_selector self.compiledin_class, w_other.compiledin_class = w_other.compiledin_class, self.compiledin_class W_AbstractObjectWithIdentityHash._become(self, w_other) if isinstance(self.compiledin_class, W_PointersObject): space = self.compiledin_class.space() self.compiledin_class.as_class_get_shadow(space).flush_method_caches() if isinstance(w_other.compiledin_class, W_PointersObject): space = w_other.compiledin_class.space() w_other.compiledin_class.as_class_get_shadow(space).flush_method_caches()
def __init__(self, space, bytecount=0, header=0): W_AbstractObjectWithIdentityHash.__init__(self) self.lookup_selector = "unknown%d" % self.gethash() self.bytes = ["\x00"] * bytecount self.setheader(space, header, initializing=True) self.post_init()
def __init__(self): W_AbstractObjectWithIdentityHash.__init__(self) self.w_class = None
def trace_pointers(self, space): ptrs = W_AbstractObjectWithIdentityHash.trace_pointers(self, space) return ptrs + self.literals
def __str__(self): if self.has_strategy() and self.strategy.provides_getname: return self._get_strategy().getname() else: return W_AbstractObjectWithIdentityHash.__str__(self)
def invariant(self): from rsqueakvm import storage_classes return (W_AbstractObjectWithIdentityHash.invariant(self) and isinstance( self.getclass(None).strategy, storage_classes.ClassShadow))
def __init__(self, space, w_class, size, weak=False): """Create new object with size = fixed + variable size.""" W_AbstractObjectWithIdentityHash.__init__(self) self._initialize_storage(space, w_class, size, weak)
def __str__(self): if self.has_strategy() and self.strategy.provides_getname: return self._get_strategy().getname() else: return W_AbstractObjectWithIdentityHash.__str__(self)
def __init__(self, space, w_class, size, weak=False): """Create new object with size = fixed + variable size.""" W_AbstractObjectWithIdentityHash.__init__(self) self._initialize_storage(space, w_class, size, weak)
def _become(self, w_other): if not isinstance(w_other, W_Character): raise error.PrimitiveFailedError self.value, w_other.value = w_other.value, self.value W_AbstractObjectWithIdentityHash._become(self, w_other)
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) high, low = g_self.get_ruints(required_len=2) if g_self.reader.version.has_floats_reversed: low, high = high, low self.fillin_fromwords(space, high, low)
def invariant(self): from rsqueakvm import storage_classes return (W_AbstractObjectWithIdentityHash.invariant(self) and isinstance(self.getclass(None).strategy, storage_classes.ClassShadow))
def __init__(self): W_AbstractObjectWithIdentityHash.__init__(self) self.w_class = None
def fillin(self, space, g_self): W_AbstractObjectWithIdentityHash.fillin(self, space, g_self) high, low = g_self.get_ruints(required_len=2) if g_self.reader.version.has_floats_reversed: low, high = high, low self.fillin_fromwords(space, high, low)