Author: Conrad Calmez <con...@calmez.net> Branch: stmgc-c7 Changeset: r894:9b35a2b871a0 Date: 2014-07-10 18:25 +0200 http://bitbucket.org/pypy/lang-smalltalk/changeset/9b35a2b871a0/
Log: fixed OS lock primitives so that they raise a PrimitiveFailedError in case of misuse credit goes to: @hubx diff --git a/images/Squeak4.5-12568.changes b/images/Squeak4.5-12568.changes --- a/images/Squeak4.5-12568.changes +++ b/images/Squeak4.5-12568.changes @@ -15094,4 +15094,4 @@ ifFalse: [ self organizeMeetingWith: chameleon. first := nil. ] ] atomic value. " tmpString := 'A Chameneos was in the meeting place and first is now: ' . SPyVM print: tmpString. "! ! !CPBChameneos methodsFor: 'as yet unclassified' stamp: 'hh 7/10/2014 15:12' prior: 34771049! run: meetingPlace [ color == #faded ] whileFalse: [ "SPyVM print: 'Chameneos goes to meeting place' , self color." meetingPlace reachedBy: self. - waitingForPair lock. "SPyVM print: 'Chameneos met another one and releases lock' , self color." ]! ! ----QUIT----{10 July 2014 . 3:13 pm} Squeak4.5-benchmarks.image priorSource: 1252802! ----STARTUP----{10 July 2014 . 3:16:52 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! ----QUIT/NOSAVE----{10 July 2014 . 3:17:21 pm} Squeak4.5-benchmarks.image priorSource: 1253908! ----QUIT/NOSAVE----{10 July 2014 . 1:19:47 pm} Squeak4.5-benchmarks.image priorSource: 1253908! ----STARTUP----{10 July 2014 . 5:00:09 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 7/10/2014 17:01'! OSLockTest | lock | lock := OSLock new. lock release.! ! ----QUIT----{10 July 2014 . 5:01:29 pm} Squeak4.5-benchmarks.image priorSource: 1253908! ----STARTUP----{10 July 2014 . 5:04:01 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! ----QUIT/NOSAVE----{10 July 2014 . 5:05:51 pm} Squeak4.5-benchmarks.image priorSource: 1254571! ----STARTUP----{10 July 2014 . 5:35:54 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! ----QUIT/NOSAVE----{10 July 2014 . 5:36:06 pm} Squeak4.5-benchmarks.image priorSource: 1254571! ----STARTUP----{10 July 2014 . 5:44:18 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! ----QUIT/NOSAVE----{10 July 2014 . 5:44:25 pm} Squeak4.5-12568.image priorSource: 1254571! \ No newline at end of file + waitingForPair lock. "SPyVM print: 'Chameneos met another one and releases lock' , self color." ]! ! ----QUIT----{10 July 2014 . 3:13 pm} Squeak4.5-benchmarks.image priorSource: 1252802! ----STARTUP----{10 July 2014 . 3:16:52 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! ----QUIT/NOSAVE----{10 July 2014 . 3:17:21 pm} Squeak4.5-benchmarks.image priorSource: 1253908! ----QUIT/NOSAVE----{10 July 2014 . 1:19:47 pm} Squeak4.5-benchmarks.image priorSource: 1253908! ----STARTUP----{10 July 2014 . 5:00:09 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! !Integer methodsFor: '*SPy-Benchmarks' stamp: 'hh 7/10/2014 17:01'! OSLockTest | lock | lock := OSLock new. lock release.! ! ----QUIT----{10 July 2014 . 5:01:29 pm} Squeak4.5-benchmarks.image priorSource: 1253908! ----STARTUP----{10 July 2014 . 5:04:01 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! ----QUIT/NOSAVE----{10 July 2014 . 5:05:51 pm} Squeak4.5-benchmarks.image priorSource: 1254571! ----STARTUP----{10 July 2014 . 5:35:54 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/images/Squeak4.5-benchmarks.image! ----QUIT/NOSAVE----{10 July 2014 . 5:36:06 pm} Squeak4.5-benchmarks.image priorSource: 1254571! ----STARTUP----{10 July 2014 . 5:44:18 pm} as /home/hub/hpi/stm/src/lang-smalltalk/images/Squeak4.5-12568.image! ----QUIT/NOSAVE----{10 July 2014 . 5:44:25 pm} Squeak4.5-12568.image priorSource: 1254571! ----QUIT/NOSAVE----{10 July 2014 . 6:11:07 pm} Squeak4.5-12568.image priorSource: 1254571! ----STARTUP----{10 July 2014 . 6:11:32 pm} as /Users/conrad/Repositories/master-project/lang-smalltalk/images/Squeak4.5-12568.image! ----QUIT/NOSAVE----{10 July 2014 . 6:22:16 pm} Squeak4.5-12568.image priorSource: 1254571! \ No newline at end of file diff --git a/spyvm/primitives.py b/spyvm/primitives.py --- a/spyvm/primitives.py +++ b/spyvm/primitives.py @@ -1548,23 +1548,29 @@ @expose_primitive(OS_LOCK_LOCK, unwrap_spec=[object], no_result=True) def func(interp, s_frame, w_rcvr): - from rpython.rlib import rthread + from rpython.rlib.rthread import RThreadError if not isinstance(w_rcvr, model.W_PointersObject): - raise PrimitiveFailedError("OS_LOCK_LOCK primitive was not called on an OSLock Object") + raise PrimitiveFailedError("OS_LOCK_LOCK primitive was not called on an OSLock Object") lock_shadow = w_rcvr.as_special_get_shadow(interp.space, shadow.OSLockShadow) - lock_shadow.os_lock() + try: + lock_shadow.os_lock() + except RThreadError as e: + raise PrimitiveFailedError("OS_LOCK_LOCK primitive failed: " + str(e)) @expose_primitive(OS_LOCK_RELEASE, unwrap_spec=[object], no_result=True) def func(interp, s_frame, w_rcvr): - from rpython.rlib import rthread + from rpython.rlib.rthread import RThreadError if not isinstance(w_rcvr, model.W_PointersObject): - raise PrimitiveFailedError("OS_LOCK_LOCK primitive was not called on an OSLock Object") + raise PrimitiveFailedError("OS_LOCK_LOCK primitive was not called on an OSLock Object") lock_shadow = w_rcvr.as_special_get_shadow(interp.space, shadow.OSLockShadow) - lock_shadow.os_release() + try: + lock_shadow.os_release() + except RThreadError as e: + raise PrimitiveFailedError("OS_LOCK_RELEASE primitive failed: " + str(e)) # ___________________________________________________________________________ # BlockClosure Primitives _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit