Tracing temporary variables in a BlockContext

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
tty
Reply | Threaded
Open this post in threaded view
|

Tracing temporary variables in a BlockContext

tty

The BlueBook page 582 shows the layout of a BlockContext. Note that the MethodContext has an area labeled 'other temporaries' and the BlockContext does not.

I have modified Eliot's "push n first' factorial copy example as such:


| factorial n |

thisContext inspect.
factorial := [:factorialArgument  |
    n := factorialArgument.
    n = 1
    ifTrue:[
           Transcript show: (n asString), '->',  thisContext identityHash asString;cr.
           thisContext inspect.
        1]
    ifFalse:[
           Transcript show: (n asString), '->',  thisContext identityHash asString;cr.       
             thisContext inspect.
        n * (factorial copy value: n-1)]].

(3 to: 5) collect: factorial copy.


What I am trying to verify (and I think it is true, but I want to run it by you) is that in the BlockContext section of the CompiledMethod, there are several pushTemps.


70 <C8> send: blockCopy:
71 <A4 36> jumpTo: 127
73 <6A> popIntoTemp: 2
74 <12> pushTemp: 2
75 <69> popIntoTemp: 1
76 <11> pushTemp: 1

77 <76> pushConstant: 1
78 <B6> send: =
79 <AC 14> jumpFalse: 101
81 <41> pushLit: Transcript
82 <88> dup
83 <11> pushTemp: 1
84 <D4> send: asString
85 <25> pushConstant: '->'
86 <E3> send: ,
87 <89> pushThisContext:
88 <D6> send: identityHash
89 <D4> send: asString
90 <E3> send: ,
91 <E2> send: show:
92 <87> pop
93 <D7> send: cr
94 <87> pop
95 <89> pushThisContext:
96 <D0> send: inspect
97 <87> pop
98 <76> pushConstant: 1
99 <A4 19> jumpTo: 126
101 <41> pushLit: Transcript
102 <88> dup
103 <11> pushTemp: 1
104 <D4> send: asString
105 <25> pushConstant: '->'
106 <E3> send: ,
107 <89> pushThisContext:
108 <D6> send: identityHash
109 <D4> send: asString
110 <E3> send: ,
111 <E2> send: show:
112 <87> pop
113 <D7> send: cr
114 <87> pop
115 <89> pushThisContext:
116 <D0> send: inspect
117 <87> pop
118 <11> pushTemp: 1
119 <10> pushTemp: 0
120 <D8> send: copy
121 <11> pushTemp: 1
122 <76> pushConstant: 1
123 <B1> send: -
124 <CA> send: value:
125 <B8> send: *
126 <7D> blockReturn

My assumption is, that as the BlockContexts switch in and out, these pushTemps are referencing the 'other temporaries' on the MethodContext, even though we are operating within a BlockContext.

Yes or No appreciated.

thx for your time.

tty


_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners