RexxLA / NetRexx

Other
6 stars 0 forks source link

Execution error: nrc -exec rexxcps.nrx #63

Open jlfaucher opened 2 weeks ago

jlfaucher commented 2 weeks ago

Tested with NetRexx-4.06-GA

nrc -exec rexxcps.nrx

raises

NetRexx portable processor 4.06-GA build 152-20240304-0612
Copyright (c) RexxLA, 2011,2024.   All rights reserved.
Parts Copyright (c) IBM Corporation, 1995,2008.
Program rexxcps.nrx
    function subroutine(Rexx,Rexx)
    function formatThousands(Rexx)
===== Exec: rexxcps =====
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "netrexx.lang.Rexx.toCharArray()" because "<parameter1>" is null
    at netrexx.lang.RexxParse.parse(RexxParse.java:116)
    at org.netrexx.process.NrParse.interpret(NrParse.java:598)
    at org.netrexx.process.RxInterpreter.runfree(RxInterpreter.java:1323)
    at org.netrexx.process.RxInterpreter.callMethod(RxInterpreter.java:1169)
    at org.netrexx.process.RxInterpreter.callMethod(RxInterpreter.java:824)
    at org.netrexx.process.RxTranslator.exec(RxTranslator.java:806)
    at org.netrexx.process.NetRexxC.process(NetRexxC.java:553)
    at org.netrexx.process.NetRexxC.main2(NetRexxC.java:360)
    at org.netrexx.process.NetRexxC.main2(NetRexxC.java:339)
    at org.netrexx.process.NetRexxC.main2(NetRexxC.java:335)
    at org.netrexx.process.NetRexxC.main(NetRexxC.java:180)

No error with this sequence:

nrc rexxcps.nrx
java rexxcps
remesm commented 2 weeks ago

Can you attach rexxcps.nrx? Thanks

jlfaucher commented 2 weeks ago

Github does not allow file attachment with nrx suffix. Added .txt rexxcps.nrx.txt This file is located in the "examples" directory.

remesm commented 1 week ago

root cause is that you parse a special word into a variable named identically. During interpretation, parse re-evaluates the tokens, and 'parse source' tries to get the value of the 'source' variable which has been created in pass #2 instead of the special word.

Fixed in commit [fa8de7] :

$ nrc rexxcps
NetRexx portable processor 4.07-alpha build 2,803-20240705-1502
Copyright (c) RexxLA, 2011,2024.   All rights reserved.
Parts Copyright (c) IBM Corporation, 1995,2008.
Program rexxcps.nrx
    function subroutine(Rexx,Rexx)
    function formatThousands(Rexx)
Compilation of 'rexxcps.nrx' successful

$ java rexxcps
----- REXXCPS 2.1n -- Measuring NetRexx clauses/second -----
 NetRexx version is: NetRexx 4.07 11 Mar 2024
          System is: Java
          Averaging: 100 measures of 100 iterations

Total (full DO): 0.01282540867 secs (average of 100 measures of 100 iterations)
Time for one iteration (1000 clauses) was: 0.0001282540867 seconds

     Performance: 7_797_022_502_208 NetRexx clauses per second
                ( 7.797E+12 cps)

$ nrc -exec rexxcps
NetRexx portable processor 4.07-alpha build 2,803-20240705-1502
Copyright (c) RexxLA, 2011,2024.   All rights reserved.
Parts Copyright (c) IBM Corporation, 1995,2008.
Program rexxcps.nrx
    function subroutine(Rexx,Rexx)
    function formatThousands(Rexx)
===== Exec: rexxcps =====
----- REXXCPS 2.1n -- Measuring NetRexx clauses/second -----
 NetRexx version is: NetRexx 4.07 11 Mar 2024
          System is: Java
          Averaging: 100 measures of 100 iterations

Total (full DO): 0.92475210765 secs (average of 100 measures of 100 iterations)
Time for one iteration (1000 clauses) was: 0.0092475210765 seconds

     Performance: 108_137_087_953 NetRexx clauses per second
                ( 108.137E+9 cps)

Processing of 'rexxcps.nrx' complete
rvjansen commented 1 week ago

Chapeau!

Is this fixable or do we need to document it for interpreted execution?

best regards,

René.

On 5 Jul 2024, at 15:19, remesm @.***> wrote:

root cause is that you parse a special word into a variable named identically. During interpretation, parse re-evaluates the tokens, and 'parse source' tries to get the value of the 'source' variable which has been created in pass #2 https://github.com/RexxLA/NetRexx/issues/2 instead of the special word.

Fixed in commit [fa8de7] :

$ nrc rexxcps NetRexx portable processor 4.07-alpha build 2,803-20240705-1502 Copyright (c) RexxLA, 2011,2024. All rights reserved. Parts Copyright (c) IBM Corporation, 1995,2008. Program rexxcps.nrx function subroutine(Rexx,Rexx) function formatThousands(Rexx) Compilation of 'rexxcps.nrx' successful

$ java rexxcps ----- REXXCPS 2.1n -- Measuring NetRexx clauses/second ----- NetRexx version is: NetRexx 4.07 11 Mar 2024 System is: Java Averaging: 100 measures of 100 iterations

Total (full DO): 0.01282540867 secs (average of 100 measures of 100 iterations) Time for one iteration (1000 clauses) was: 0.0001282540867 seconds

 Performance: 7_797_022_502_208 NetRexx clauses per second
            ( 7.797E+12 cps)

$ nrc -exec rexxcps NetRexx portable processor 4.07-alpha build 2,803-20240705-1502 Copyright (c) RexxLA, 2011,2024. All rights reserved. Parts Copyright (c) IBM Corporation, 1995,2008. Program rexxcps.nrx function subroutine(Rexx,Rexx) function formatThousands(Rexx) ===== Exec: rexxcps ===== ----- REXXCPS 2.1n -- Measuring NetRexx clauses/second ----- NetRexx version is: NetRexx 4.07 11 Mar 2024 System is: Java Averaging: 100 measures of 100 iterations

Total (full DO): 0.92475210765 secs (average of 100 measures of 100 iterations) Time for one iteration (1000 clauses) was: 0.0092475210765 seconds

 Performance: 108_137_087_953 NetRexx clauses per second
            ( 108.137E+9 cps)

Processing of 'rexxcps.nrx' complete

— Reply to this email directly, view it on GitHub https://github.com/RexxLA/NetRexx/issues/63#issuecomment-2210867016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3WJQKLDZPT6SVMYYBDZKTZK2MPHAVCNFSM6AAAAABJ6LING2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJQHA3DOMBRGY. You are receiving this because you are subscribed to this thread.

jlfaucher commented 1 week ago

Thanks!

I get these numbers on my laptop:

18_407_194_702_387 NetRexx clauses per second        -- netrexx compiled
   302_886_536_330 NetRexx clauses per second        -- netrexx interpreted
        23_736_393 REXX clauses per second           -- oorexx

The difference with oorexx is stunning... After comparing the sources, I think there is an error in rexxcps.nrx I will create another ticket for that.

rvjansen commented 1 week ago

Hi Jean-Louis,

we cannot change CPS, ever. We cannot repeat old measurements which go back to the early eighties. The case with NetRexx is that the JVM JIT eliminates a number of calls when the output is not used. Apart from that, it is faster whenever it compiles fragments of code to native.

There is a NetRexx version - by MFC - which is in the repository as nrxcps.nrx and there is a presentation which discusses some of these phenomena: https://www.rexxla.org/presentations/2019/cps2019.pdf "30 years of CPS".

I am open for working on a "new generation CPS"; but the classic one is what it is.

best regards,

René.

On 6 Jul 2024, at 11:21, jlfaucher @.***> wrote:

Thanks!

I get these numbers on my laptop:

18_407_194_702_387 NetRexx clauses per second -- netrexx compiled 302_886_536_330 NetRexx clauses per second -- netrexx interpreted 23_736_393 REXX clauses per second -- oorexx The difference with oorexx is stunning... After comparing the sources, I think there is an error in rexxcps.nrx I will create another ticket for that.

— Reply to this email directly, view it on GitHub https://github.com/RexxLA/NetRexx/issues/63#issuecomment-2211717655, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3WJQO6HJBKC4FU6KRUVMLZK6ZKDAVCNFSM6AAAAABJ6LING2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJRG4YTONRVGU. You are receiving this because you commented.

remesm commented 1 week ago

Can be closed, fixed in commit [fa8de7]