The Inbox: Kernel-ct.1306.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Kernel-ct.1306.mcz

commits-2
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1306.mcz

==================== Summary ====================

Name: Kernel-ct.1306
Author: ct
Time: 24 February 2020, 12:55:18.032323 pm
UUID: a5ad7256-3b26-b943-a1f7-ff445738c497
Ancestors: Kernel-mt.1304

Implement missing simulation of objects as methods.

In the past, it was not possible to debug/simulate code that used objects as methods properly. (Thanks to Marcel for the hint!) This very simple commit adds support of the OaM protocol [1] to the simulation machinery. Now you can debug all tests in TestObjectsAsMethods as you would expect, instead of crashing your image!

[1] "The [Objects as Methods] contract is that, when the VM encounters an ordinary object (rather than a compiled method) in the method dictionary during lookup, it sends it the special selector #run:with:in: providing the original selector, arguments, and receiver.". DOI: 10.1145/2991041.2991062.

=============== Diff against Kernel-mt.1304 ===============

Item was changed:
  ----- Method: Context>>send:to:with:lookupIn: (in category 'controlling') -----
  send: selector to: rcvr with: arguments lookupIn: lookupClass
+ "Simulate the action of sending a message with selector and arguments to rcvr. The argument, lookupClass, is the class in which to lookup the message.  This is the receiver's class for normal messages, but for super messages it will be some specific class related to the source method."
- "Simulate the action of sending a message with selector and arguments
- to rcvr. The argument, lookupClass, is the class in which to lookup the
- message.  This is the receiver's class for normal messages, but for super
- messages it will be some specific class related to the source method."
 
  | meth primIndex val ctxt |
  (meth := lookupClass lookupSelector: selector) ifNil:
  [^self send: #doesNotUnderstand:
  to: rcvr
  with: {(Message selector: selector arguments: arguments) lookupClass: lookupClass}
  lookupIn: lookupClass].
+ meth isCompiledMethod ifFalse: [
+ ^ self send: #run:with:in:
+ to: meth
+ with: {selector. arguments. rcvr}].
  meth numArgs ~= arguments size ifTrue:
  [^self error: 'Wrong number of arguments in simulated message ', selector printString].
  (primIndex := meth primitive) > 0 ifTrue:
  [val := self doPrimitive: primIndex method: meth receiver: rcvr args: arguments.
  (self isPrimFailToken: val) ifFalse:
  [^val]].
  (selector == #doesNotUnderstand: and: [lookupClass == ProtoObject]) ifTrue:
  [^self error: 'Simulated message ', arguments first selector, ' not understood'].
  ctxt := Context sender: self receiver: rcvr method: meth arguments: arguments.
  primIndex > 0 ifTrue:
  [ctxt failPrimitiveWith: val].
  ^ctxt!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-ct.1306.mcz

Christoph Thiede



This is such a small change that I wonder whether we could treat is as a bugfix and include it into the release?


By the way: The previous bug when debugging OaM was another instance of the debugger chain issue which could be avoided when loading the proposed patch.


[1] "The [Objects as Methods] contract is that, when the VM encounters an ordinary object (rather than a compiled method) in the method dictionary during lookup, it sends it the special selector #run:with:in: providing the original selector, arguments, and receiver.". DOI: 10.1145/2991041.2991062.


I am aware of the fact this is not the best reference for the documentation of VM features. Please feel free to draw my attention to any more official reference of this protocol! :-)

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Montag, 24. Februar 2020 12:55:22
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Kernel-ct.1306.mcz
 
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1306.mcz

==================== Summary ====================

Name: Kernel-ct.1306
Author: ct
Time: 24 February 2020, 12:55:18.032323 pm
UUID: a5ad7256-3b26-b943-a1f7-ff445738c497
Ancestors: Kernel-mt.1304

Implement missing simulation of objects as methods.

In the past, it was not possible to debug/simulate code that used objects as methods properly. (Thanks to Marcel for the hint!) This very simple commit adds support of the OaM protocol [1] to the simulation machinery. Now you can debug all tests in TestObjectsAsMethods as you would expect, instead of crashing your image!

[1] "The [Objects as Methods] contract is that, when the VM encounters an ordinary object (rather than a compiled method) in the method dictionary during lookup, it sends it the special selector #run:with:in: providing the original selector, arguments, and receiver.". DOI: 10.1145/2991041.2991062.

=============== Diff against Kernel-mt.1304 ===============

Item was changed:
  ----- Method: Context>>send:to:with:lookupIn: (in category 'controlling') -----
  send: selector to: rcvr with: arguments lookupIn: lookupClass
+        "Simulate the action of sending a message with selector and arguments to rcvr. The argument, lookupClass, is the class in which to lookup the message.  This is the receiver's class for normal messages, but for super messages it will be some specific class related to the source method."
-        "Simulate the action of sending a message with selector and arguments
-         to rcvr. The argument, lookupClass, is the class in which to lookup the
-         message.  This is the receiver's class for normal messages, but for super
-         messages it will be some specific class related to the source method."
 
         | meth primIndex val ctxt |
         (meth := lookupClass lookupSelector: selector) ifNil:
                 [^self send: #doesNotUnderstand:
                                 to: rcvr
                                 with: {(Message selector: selector arguments: arguments) lookupClass: lookupClass}
                                 lookupIn: lookupClass].
+        meth isCompiledMethod ifFalse: [
+                ^ self send: #run:with:in:
+                        to: meth
+                        with: {selector. arguments. rcvr}].
         meth numArgs ~= arguments size ifTrue:
                 [^self error: 'Wrong number of arguments in simulated message ', selector printString].
         (primIndex := meth primitive) > 0 ifTrue:
                 [val := self doPrimitive: primIndex method: meth receiver: rcvr args: arguments.
                  (self isPrimFailToken: val) ifFalse:
                         [^val]].
         (selector == #doesNotUnderstand: and: [lookupClass == ProtoObject]) ifTrue:
                 [^self error: 'Simulated message ', arguments first selector, ' not understood'].
         ctxt := Context sender: self receiver: rcvr method: meth arguments: arguments.
         primIndex > 0 ifTrue:
                 [ctxt failPrimitiveWith: val].
         ^ctxt!




Carpe Squeak!
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Kernel-ct.1306.mcz

marcel.taeumel
Hi Christoph,

since the overall tool support for object-as-method is not that good anyway and we are in "feature freeze", I will not include this change/fix in the release.

Best,
Marcel

Am 24.02.2020 13:00:47 schrieb Thiede, Christoph <[hidden email]>:



This is such a small change that I wonder whether we could treat is as a bugfix and include it into the release?


By the way: The previous bug when debugging OaM was another instance of the debugger chain issue which could be avoided when loading the proposed patch.


[1] "The [Objects as Methods] contract is that, when the VM encounters an ordinary object (rather than a compiled method) in the method dictionary during lookup, it sends it the special selector #run:with:in: providing the original selector, arguments, and receiver.". DOI: 10.1145/2991041.2991062.


I am aware of the fact this is not the best reference for the documentation of VM features. Please feel free to draw my attention to any more official reference of this protocol! :-)

Best,
Christoph


Von: Squeak-dev <[hidden email]> im Auftrag von [hidden email] <[hidden email]>
Gesendet: Montag, 24. Februar 2020 12:55:22
An: [hidden email]
Betreff: [squeak-dev] The Inbox: Kernel-ct.1306.mcz
 
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-ct.1306.mcz

==================== Summary ====================

Name: Kernel-ct.1306
Author: ct
Time: 24 February 2020, 12:55:18.032323 pm
UUID: a5ad7256-3b26-b943-a1f7-ff445738c497
Ancestors: Kernel-mt.1304

Implement missing simulation of objects as methods.

In the past, it was not possible to debug/simulate code that used objects as methods properly. (Thanks to Marcel for the hint!) This very simple commit adds support of the OaM protocol [1] to the simulation machinery. Now you can debug all tests in TestObjectsAsMethods as you would expect, instead of crashing your image!

[1] "The [Objects as Methods] contract is that, when the VM encounters an ordinary object (rather than a compiled method) in the method dictionary during lookup, it sends it the special selector #run:with:in: providing the original selector, arguments, and receiver.". DOI: 10.1145/2991041.2991062.

=============== Diff against Kernel-mt.1304 ===============

Item was changed:
  ----- Method: Context>>send:to:with:lookupIn: (in category 'controlling') -----
  send: selector to: rcvr with: arguments lookupIn: lookupClass
+        "Simulate the action of sending a message with selector and arguments to rcvr. The argument, lookupClass, is the class in which to lookup the message.  This is the receiver's class for normal messages, but for super messages it will be some specific class related to the source method."
-        "Simulate the action of sending a message with selector and arguments
-         to rcvr. The argument, lookupClass, is the class in which to lookup the
-         message.  This is the receiver's class for normal messages, but for super
-         messages it will be some specific class related to the source method."
 
         | meth primIndex val ctxt |
         (meth := lookupClass lookupSelector: selector) ifNil:
                 [^self send: #doesNotUnderstand:
                                 to: rcvr
                                 with: {(Message selector: selector arguments: arguments) lookupClass: lookupClass}
                                 lookupIn: lookupClass].
+        meth isCompiledMethod ifFalse: [
+                ^ self send: #run:with:in:
+                        to: meth
+                        with: {selector. arguments. rcvr}].
         meth numArgs ~= arguments size ifTrue:
                 [^self error: 'Wrong number of arguments in simulated message ', selector printString].
         (primIndex := meth primitive) > 0 ifTrue:
                 [val := self doPrimitive: primIndex method: meth receiver: rcvr args: arguments.
                  (self isPrimFailToken: val) ifFalse:
                         [^val]].
         (selector == #doesNotUnderstand: and: [lookupClass == ProtoObject]) ifTrue:
                 [^self error: 'Simulated message ', arguments first selector, ' not understood'].
         ctxt := Context sender: self receiver: rcvr method: meth arguments: arguments.
         primIndex > 0 ifTrue:
                 [ctxt failPrimitiveWith: val].
         ^ctxt!