Compiling Cog (merge with eem.87)

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

Compiling Cog (merge with eem.87)

Igor Stasenko
 
/Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
required as left operand of assignment
/Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
required as left operand of assignment

here the problematic line:

        case SSConstant:
                                inst = (shouldAnnotateObjectReference((self_in_storeToReg->constant))
                        ? annotateobjRef(gMoveCwR((self_in_storeToReg->constant), reg),
(self_in_storeToReg->constant))
>>> : /* begin MoveCq:R: */quickConstant = (self_in_storeToReg->constant),genoperandoperand(MoveCqR, quickConstant, reg));
                break;


seems like code generator producing bad code.
Or maybe i'm not initializing stuff properly (since there are new
options which may need to be passed?)

--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: Compiling Cog (merge with eem.87)

Igor Stasenko

On 28 June 2011 12:32, Igor Stasenko <[hidden email]> wrote:

> /Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
> required as left operand of assignment
> /Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
> required as left operand of assignment
>
> here the problematic line:
>
>        case SSConstant:
>                                inst = (shouldAnnotateObjectReference((self_in_storeToReg->constant))
>                        ? annotateobjRef(gMoveCwR((self_in_storeToReg->constant), reg),
> (self_in_storeToReg->constant))
>>>>                     : /* begin MoveCq:R: */quickConstant = (self_in_storeToReg->constant),genoperandoperand(MoveCqR, quickConstant, reg));
>                break;
>
>
> seems like code generator producing bad code.
> Or maybe i'm not initializing stuff properly (since there are new
> options which may need to be passed?)
>

The fix is to change the generator to produce a following:

({ statement a; statement b; })

instead of

statement a, statement b

If you consider a slang code like:

v := self something ifTrue: [ 1 ] ifFalse: [ x := self doSomething.
self returnValue].

a generator should produce something like following:

v = something() ? 1 : ({ x = doSomething(); returnValue(); });

Then it will work well (at least in GCC).

I changed the C code to check if compiler can swallow it:

inst = (shouldAnnotateObjectReference((self_in_storeToReg->constant))
                        ? annotateobjRef(gMoveCwR ( (self_in_storeToReg->constant), reg),
(self_in_storeToReg->constant))
                                                : /* begin MoveCq:R: */({ quickConstant =
(self_in_storeToReg->constant); genoperandoperand(MoveCqR,
quickConstant, reg);}) );


Anyways, a code generator needs to be fixed, or code in #storeToReg:
and #popToReg: needs to be rewritten to not confuse the generator.


Another issue is with
/Users/sig/projects/cog/blessed/src/vm/gcc3x-cointerp.c:10137: error:
‘cmDynSuperEntryOffset’ undeclared (first use in this function)
/Users/sig/projects/cog/blessed/src/vm/gcc3x-cointerp.c:10137: error:
(Each undeclared identifier is reported only once
/Users/sig/projects/cog/blessed/src/vm/gcc3x-cointerp.c:10137: error:
for each function it appears in.)

as far as i see, this variable is used only when compiling newspeak vm
(there are a lot of places with
#if NEWSPEAK .. #else , and this variable used only in newspeak blocks.

But somehow it slept through and introduced in cog.
Probably #ceDynamicSuperSend:to:numArgs:
should also contain
        self cppIf: NewspeakVM
                ifTrue: []
clause.

> --
> Best regards,
> Igor Stasenko AKA sig.
>



--
Best regards,
Igor Stasenko AKA sig.
Reply | Threaded
Open this post in threaded view
|

Re: Compiling Cog (merge with eem.87)

Eliot Miranda-2
In reply to this post by Igor Stasenko
 


On Tue, Jun 28, 2011 at 3:32 AM, Igor Stasenko <[hidden email]> wrote:

/Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
required as left operand of assignment
/Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
required as left operand of assignment

here the problematic line:

       case SSConstant:
                               inst = (shouldAnnotateObjectReference((self_in_storeToReg->constant))
                       ? annotateobjRef(gMoveCwR((self_in_storeToReg->constant), reg),
(self_in_storeToReg->constant))
>>>                     : /* begin MoveCq:R: */quickConstant = (self_in_storeToReg->constant),genoperandoperand(MoveCqR, quickConstant, reg));
               break;


seems like code generator producing bad code.

Yes.  It needs a pair of parentheses around quickConstant = (self_in_storeToReg->constant), otherwise its trying to assign an AbstractInstruction * (genoperandoperand) to a sqInt (quickConstant)

Or maybe i'm not initializing stuff properly (since there are new
options which may need to be passed?)

--
Best regards,
Igor Stasenko AKA sig.



--
best,
Eliot

Reply | Threaded
Open this post in threaded view
|

Re: Compiling Cog (merge with eem.87)

Eliot Miranda-2
In reply to this post by Igor Stasenko
 


On Tue, Jun 28, 2011 at 5:33 AM, Igor Stasenko <[hidden email]> wrote:

On 28 June 2011 12:32, Igor Stasenko <[hidden email]> wrote:
> /Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
> required as left operand of assignment
> /Users/sig/projects/cog/blessed/src/vm/cogit.c:15864: error: lvalue
> required as left operand of assignment
>
> here the problematic line:
>
>        case SSConstant:
>                                inst = (shouldAnnotateObjectReference((self_in_storeToReg->constant))
>                        ? annotateobjRef(gMoveCwR((self_in_storeToReg->constant), reg),
> (self_in_storeToReg->constant))
>>>>                     : /* begin MoveCq:R: */quickConstant = (self_in_storeToReg->constant),genoperandoperand(MoveCqR, quickConstant, reg));
>                break;
>
>
> seems like code generator producing bad code.
> Or maybe i'm not initializing stuff properly (since there are new
> options which may need to be passed?)
>

The fix is to change the generator to produce a following:

({ statement a; statement b; })

No. ({ ... }) is a gcc-speciofic extension.  See previous message for correct fix (checking in now).
 

instead of

statement a, statement b

If you consider a slang code like:

v := self something ifTrue: [ 1 ] ifFalse: [ x := self doSomething.
self returnValue].

a generator should produce something like following:

v = something() ? 1 : ({ x = doSomething(); returnValue(); });

Then it will work well (at least in GCC).

I changed the C code to check if compiler can swallow it:

inst = (shouldAnnotateObjectReference((self_in_storeToReg->constant))
                       ? annotateobjRef(gMoveCwR ( (self_in_storeToReg->constant), reg),
(self_in_storeToReg->constant))
                                               : /* begin MoveCq:R: */({ quickConstant =
(self_in_storeToReg->constant); genoperandoperand(MoveCqR,
quickConstant, reg);}) );


Anyways, a code generator needs to be fixed, or code in #storeToReg:
and #popToReg: needs to be rewritten to not confuse the generator.


Another issue is with
/Users/sig/projects/cog/blessed/src/vm/gcc3x-cointerp.c:10137: error:
‘cmDynSuperEntryOffset’ undeclared (first use in this function)
/Users/sig/projects/cog/blessed/src/vm/gcc3x-cointerp.c:10137: error:
(Each undeclared identifier is reported only once
/Users/sig/projects/cog/blessed/src/vm/gcc3x-cointerp.c:10137: error:
for each function it appears in.)

as far as i see, this variable is used only when compiling newspeak vm
(there are a lot of places with
#if NEWSPEAK .. #else , and this variable used only in newspeak blocks.

But somehow it slept through and introduced in cog.

Because it is marked as <api> it is retained.  <api> marks methods used outside the source file (e.g. in cogit.c).  So if it is marked <api> but optional it needs to be filtered out.  I implemented <option: #SomeKey) for this and eliminated the <cogit: #CogitClassName> tag, since it is now subsumed by <option: ...>.

Thanks, Igor!

Probably #ceDynamicSuperSend:to:numArgs:
should also contain
       self cppIf: NewspeakVM
               ifTrue: []
clause.

> --
> Best regards,
> Igor Stasenko AKA sig.
>



--
Best regards,
Igor Stasenko AKA sig.



--
best,
Eliot