About Us
Products
Purchase
Downloads
Support
Forums
Contact Us
Site
 Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Sat Oct 27, 2007 7:41 pm   

[2.09] Loop optimization suggestion
 
I use some rather large loops sometimes so I would like to see some loop optimization in certain cases. Currently these two aliases compile completely differently:

Alias:

Code:
<alias name="loop1" id="2448">
  <value>#2 {
  #echo 1
  #2 {#echo 2}
  }</value>
</alias>


Compiled code:

Code:
0000   INT   2
0008   PUSHLOC   0024
0016   JUMP   0100
0024   INT   1
0032   CMD   echo   (1)
0044   INT   2
0052   PUSHLOC   0068
0060   JUMP   0088
0068   INT   2
0076   CMD   echo   (1)
0088   CMD   repeat   (2)
0100   CMD   repeat   (2)


Alias:

Code:
<alias name="loop2" id="2449">
  <value>#echo 1
#echo 2
#echo 2

#echo 1
#echo 2
#echo 2</value>
</alias>


Compiled code:

Code:
0000   INT   1
0008   CMD   echo   (1)
0020   INT   2
0028   CMD   echo   (1)
0040   INT   2
0048   CMD   echo   (1)
0060   INT   1
0068   CMD   echo   (1)
0080   INT   2
0088   CMD   echo   (1)
0100   INT   2
0108   CMD   echo   (1)


Both of these have the same exact result, but from my experience the 2nd example should be faster since it doesn't have to jump. I'd like to see the first alias be optimized to compile exactly like the 2nd alias in cases where constant numbers are used. I actually have no idea how much faster this would make anything, if even at all but I'm just throwing it out there.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Oct 29, 2007 8:47 pm   
 
CMUD already has loop optimization within the #REPEAT and various #LOOP commands. Just because the compiled code is different, don't just assume that it is slower. But to answer your general question, no I do not plan to perform any fancy compiler optimizations. In general, the compiler is not the speed bottle-neck in CMUD. If you want the fastest compiled scripts, use Lua instead within CMUD since it has more optimizations in it.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net