Issue 4412 in pharo: CompiledMethod >> #valueWithReceiver:arguments: instead of Object >> #withArgs:executeMethod:

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

Issue 4412 in pharo: CompiledMethod >> #valueWithReceiver:arguments: instead of Object >> #withArgs:executeMethod:

pharo
Status: Accepted
Owner: [hidden email]
Labels: Milestone-1.4

New issue 4412 by [hidden email]: CompiledMethod >>  
#valueWithReceiver:arguments: instead of Object >> #withArgs:executeMethod:
http://code.google.com/p/pharo/issues/detail?id=4412

Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.595.mcz

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

Name: Kernel-ul.595
Author: ul
Time: 13 June 2011, 11:52:02.639 am
UUID: 992b01d8-bccb-604d-8348-6ece685506db
Ancestors: Kernel-ul.594

- added CompiledMethod class >> #receiver:withArguments:executeMethod:  
which uses primitive 188 with three arguments (not all VMs support this  
yet, pre r2393 Cog VMs may crash when used with certain methods). If the  
primitive fails the fallback mechanism tries to use primitive 188 with two  
arguments (supported by all VMs).  CompiledMethod >>  
#valueWithReceiver:arguments: should use this method in the future, because  
it doesn't send any messages to the receiver. The change was postponed,  
because older Cog versions would crash with this change.
- updated ContextPart >> #doPrimitive:method:receiver:args: to support both  
two and three arguments variants of primitive 188 and added support for  
primitive 189, so it won't "escape from the debugger" anymore.

=============== Diff against Kernel-ul.594 ===============

Item was added:
+ ----- Method: CompiledMethod class>>receiver:withArguments:executeMethod:  
(in category 'evaluating') -----
+ receiver: receiver withArguments: argArray executeMethod: compiledMethod
+       "Execute compiledMethod against the receiver and the arguments in  
argArray"
+
+       <primitive: 188>
+       ^receiver withArgs: argArray executeMethod: compiledMethod!

Item was changed:
  ----- Method: CompiledMethod>>valueWithReceiver:arguments: (in  
category 'evaluating') -----
  valueWithReceiver: aReceiver arguments: anArray

+       "This should be changed after the release of Squeak 4.3 to
+               ^self class receiver: aReceiver withArguments: anArray  
executeMethod: self"
        ^ aReceiver withArgs: anArray executeMethod: self!

Item was changed:
  ----- Method: ContextPart>>doPrimitive:method:receiver:args: (in  
category 'private') -----
  doPrimitive: primitiveIndex method: meth receiver: receiver args: arguments
        "Simulate a primitive method whose index is primitiveIndex.  The
         simulated receiver and arguments are given as arguments to this  
message.
         Any primitive which provikes execution needs to be intercepted and  
simulated
         to avoid execution running away."

        | value |
        <primitive: 19> "Simulation guard"
        "If successful, push result and return resuming context,
                else ^ PrimitiveFailToken"
        (primitiveIndex = 19) ifTrue:
                [ToolSet
                        debugContext: self
                        label:'Code simulation error'
                        contents: nil].

        "ContextPart>>blockCopy:; simulated to get startpc right"
        (primitiveIndex = 80 and: [receiver isKindOf: ContextPart])
                ifTrue: [^self push: ((BlockContext newForMethod: receiver  
method)
                                                home: receiver home
                                                startpc: pc + 2
                                                nargs: (arguments at: 1))].
        (primitiveIndex = 81 and: [receiver isMemberOf:  
BlockContext]) "BlockContext>>value[:value:...]"
                ifTrue: [^receiver pushArgs: arguments from: self].
        (primitiveIndex = 82 and: [receiver isMemberOf:  
BlockContext]) "BlockContext>>valueWithArguments:"
                ifTrue: [^receiver pushArgs: arguments first from: self].
        primitiveIndex = 83 "afr 9/11/1998  
19:50" "Object>>perform:[with:...]"
                ifTrue: [^self send: arguments first to: receiver
                                        with: arguments allButFirst
                                        super: false].
        primitiveIndex = 84 "afr 9/11/1998  
19:50" "Object>>perform:withArguments:"
                ifTrue: [^self send: arguments first to: receiver
                                        with: (arguments at: 2)
                                        super: false].
+       primitiveIndex = 188 ifTrue: [
+               arguments size = 2 ifTrue: [ "eem 5/27/2008 11:10  
Object>>withArgs:executeMethod:"
+                       ^MethodContext
+                               sender: self
+                               receiver: receiver
+                               method: (arguments at: 2)
+                               arguments: (arguments at: 1) ].
+               arguments size = 3 ifTrue: [ "CompiledMethod class >>  
#receiver:withArguments:executeMethod:"
+                       ^MethodContext
+                               sender: self
+                               receiver: (arguments at: 1)
+                               method: (arguments at: 3)
+                               arguments: (arguments at: 2) ] ].
+       primitiveIndex = 189 ifTrue: [ "Object >> (#with:)*executeMethod"
+               ^MethodContext
-       primitiveIndex = 188 ifTrue: "eem 5/27/2008 11:10  
Object>>withArgs:executeMethod:"
-               [^MethodContext
                        sender: self
                        receiver: receiver
+                       method: arguments last
+                       arguments: arguments allButLast ].
-                       method: (arguments at: 2)
-                       arguments: (arguments at: 1)].

        "Closure primitives"
        (primitiveIndex = 200 and: [receiver == self]) ifTrue:
                "ContextPart>>closureCopy:copiedValues:; simulated to get  
startpc right"
                [^self push: (BlockClosure
                                                outerContext: receiver
                                                startpc: pc + 2
                                                numArgs: arguments first
                                                copiedValues: arguments  
last)].
        ((primitiveIndex between: 201 and:  
205)                  "BlockClosure>>value[:value:...]"
        or: [primitiveIndex between: 221 and: 222])  
ifTrue: "BlockClosure>>valueNoContextSwitch[:]"
                [^receiver simulateValueWithArguments: arguments caller:  
self].
        primitiveIndex = 206  
ifTrue:                                            "BlockClosure>>valueWithArguments:"
                [^receiver simulateValueWithArguments: arguments first  
caller: self].

        primitiveIndex = 120 ifTrue:[ "FFI method"
                value := meth literals first tryInvokeWithArguments:  
arguments.
        ] ifFalse:[
                arguments size > 6 ifTrue: [^PrimitiveFailToken].
                value := primitiveIndex = 117 "named primitives"
                                ifTrue:[self tryNamedPrimitiveIn: meth for:  
receiver withArgs: arguments]
                                ifFalse:[receiver tryPrimitive:  
primitiveIndex withArgs: arguments].
        ].
        ^value == PrimitiveFailToken
                ifTrue: [PrimitiveFailToken]
                ifFalse: [self push: value]!



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 4412 in pharo: CompiledMethod >> #valueWithReceiver:arguments: instead of Object >> #withArgs:executeMethod:

pharo
Updates:
        Status: closed

Comment #1 on issue 4412 by [hidden email]: CompiledMethod >>  
#valueWithReceiver:arguments: instead of Object >> #withArgs:executeMethod:
http://code.google.com/p/pharo/issues/detail?id=4412

in 14012


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker