Bernhard Schmalhofer wrote:
> Ron Blaschke via RT schrieb:
>> In all three sections a value is loaded into a register and then set as
>> an attribute on an object.
>>
>> In the first hunk only the used register is changed from 0x12 to 0x13.
>> In the second hunks it's register 0x11 to 0x12.
>>
>> With hunk three it's getting interesting because only the first
>> occurrence changes from 0x13 to 0x11.  set_attribute still uses 0x13,
>> which is wrong I think.
>>
>> In the end, the wrong (Sub) value is put into the object's attribute
>> because the wrong register is used.  The error that comes up later is
>> not because the arguments are wrong, but because the wrong sub is called.
>>
>> Can anyone tell if I'm on the right track?
>>   
> Yes, I can see the pattern. One possibility to verify this, is to add a
> 'dummy_5' PMC.
> I'd expect three hunks again, but the third hunk should than conform to
> the two first hunks.

Here's what happens if ".local pmc dummy_5" is added, compared to the
current repository version with ".local pmc dummy_[1-4]".

--- lisp.pbc.workaround 2007-09-01 17:02:22.000000000 +0200
+++ lisp.pbc.workaround2        2007-09-02 20:24:32.000000000 +0200
@@ -1445,7 +1445,7 @@
  116b:  00000262 00000006 0000008f
callmethodcc_p_sc
  116e:  000002bb 00000003 00000045                            new_p_sc
  1171:  0000032f 00000019 000001a2                            set_p_pc
- 1174:  000002a6 00000003 00000047 00000019
setattribute_p_sc_p
+ 1174:  000002a6 00000003 00000047 00000011
setattribute_p_sc_p
  1178:  000002bb 0000001a 00000035                            new_p_sc
  117b:  00000336 0000001a 0000015d                            set_p_sc
  117e:  00000024 0000000d                                     set_args_pc

> Is this a register allocator bug?

Not sure yet.  I think I've found the source that corresponds to the
opcodes.  It's C<FUNCTION> in F<include/macros/types.pir>.

#.macro FUNCTION(F,L)
#
#    .F = new "LispFunction"
116e:  000002bb 00000003 00000045                            new_p_sc
    == new, P3, constant 0x45 ("LispFunction")

#    .const .Sub _func = .L
1171:  0000032f 00000019 000001a2                            set_p_pc
    == set P25, ???

#    setattribute .F, "body", _func
1174:  000002a6 00000003 00000047 00000019        setattribute_p_sc_p
    == setattribute P3, constant 0x47 ("body"), P25

# but when this go bad:
1174:  000002a6 00000003 00000047 00000011        setattribute_p_sc_p
    == setattribute P3, constant 0x47 ("body"), P17
#
#.endm

The constants (0x45 and 0x47) are indexes into the constant pool.

# 69:
[ 'PFC_STRING', {
    FLAGS    => 0x61100,
    CHARSET  => 3961080,
    SIZE     => 12,
    DATA     => 'LispFunction'
} ],

# 71:
[ 'PFC_STRING', {
    FLAGS    => 0x61100,
    CHARSET  => 3961080,
    SIZE     => 4,
    DATA     => 'body'
} ],


The situation in the previous posting was this.

#.macro FUNCTION(F,L)
#
#    .F = new "LispFunction"
1030:  000002bb 00000003 00000045                            new_p_sc
    == new, P3, constant 0x45 ("LispFunction")

#    .const .Sub _func = .L
1033:  0000032f 00000013 000001b2                            set_p_pc
    == set P19, ???

# or:
1033:  0000032f 00000011 000001b2                            set_p_pc
    == set P17, ???


#    setattribute .F, "body", _func
1036:  000002a6 00000003 00000047 00000013        setattribute_p_sc_p
    == setattribute P3, constant 0x47 ("body"), P19

#
#.endm

I'm currently trying to understand the code well enough to step through
this with a debugger when the instructions are generated.

Ron

Reply via email to