Author: Anton Gulenko <anton.gule...@googlemail.com> Branch: storage Changeset: r876:f77d391e1255 Date: 2014-07-07 18:46 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/f77d391e1255/
Log: Added a suppress_process_switch flag as a hack to enable the -r flag in the Squeak image. diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py --- a/spyvm/interpreter.py +++ b/spyvm/interpreter.py @@ -86,6 +86,7 @@ s_new_context = s_sender s_new_context.push(nlr.value) except ProcessSwitch, p: + assert not self.space.suppress_process_switch, "ProcessSwitch should be disabled..." if self.trace: print "====== Switched process from: %s" % s_new_context.short_str() print "====== to: %s " % p.s_new_context.short_str() diff --git a/spyvm/objspace.py b/spyvm/objspace.py --- a/spyvm/objspace.py +++ b/spyvm/objspace.py @@ -21,6 +21,9 @@ self.make_bootstrap_classes() self.make_bootstrap_objects() + + # This is a hack; see compile_code() in targetimageloadingsmalltalk.py + self.suppress_process_switch = False def find_executable(self, executable): if os.sep in executable or (os.name == "nt" and ":" in executable): diff --git a/spyvm/wrapper.py b/spyvm/wrapper.py --- a/spyvm/wrapper.py +++ b/spyvm/wrapper.py @@ -93,8 +93,9 @@ active_priority = active_process.priority() priority = self.priority() if priority > active_priority: - active_process.deactivate(s_current_frame) - self.activate() + if not self.space.suppress_process_switch: + active_process.deactivate(s_current_frame) + self.activate() else: self.put_to_sleep() @@ -103,10 +104,11 @@ def suspend(self, s_current_frame): if self.is_active_process(): - assert self.my_list().is_nil(self.space) - w_process = scheduler(self.space).pop_highest_priority_process() - self.deactivate(s_current_frame, put_to_sleep=False) - ProcessWrapper(self.space, w_process).activate() + if not self.space.suppress_process_switch: + assert self.my_list().is_nil(self.space) + w_process = scheduler(self.space).pop_highest_priority_process() + self.deactivate(s_current_frame, put_to_sleep=False) + ProcessWrapper(self.space, w_process).activate() else: if not self.my_list().is_nil(self.space): process_list = ProcessListWrapper(self.space, self.my_list()) diff --git a/targetimageloadingsmalltalk.py b/targetimageloadingsmalltalk.py --- a/targetimageloadingsmalltalk.py +++ b/targetimageloadingsmalltalk.py @@ -172,13 +172,22 @@ space = interp.space w_receiver_class = w_receiver.getclass(space) try: - w_result = interp.perform( - w_receiver_class, - "compile:classified:notifying:", - w_arguments = [space.wrap_string("%s\r\n%s" % (selector, code)), - space.wrap_string("spy-run-code"), - space.w_nil] - ) + try: + # The suppress_process_switch flag is a hack/workaround to enable compiling code + # before having initialized the image cleanly. The problem is that the TimingSemaphore is not yet + # registered (primitive 136 not called), so the idle process will never be left once it is entered. + # TODO - Find a way to cleanly initialize the image, without executing the active_context of the image. + # Instead, we want to execute our own context. Then remove this flag (and all references to it) + interp.space.suppress_process_switch = True + w_result = interp.perform( + w_receiver_class, + "compile:classified:notifying:", + w_arguments = [space.wrap_string("%s\r\n%s" % (selector, code)), + space.wrap_string("spy-run-code"), + space.w_nil] + ) + finally: + interp.space.suppress_process_switch = False # TODO - is this expected in every image? if not isinstance(w_result, model.W_BytesObject) or w_result.as_string() != selector: print "Compilation failed, unexpected result: %s" % result_string(w_result) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit