Author Topic: Has anyone been able to mod Toolset?  (Read 8805 times)

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #45 on: June 24, 2011, 09:46:58 pm »


               With this script snippet, I observe identical code generation to the BioWare compiler without optimizations when using the standalone ASC build, and identical code generation to the PRC build with optimizations when using the standalone ASC build.

Can you verify that if you build the script locally using the ASC's NWNScriptCompiler.exe that it functions as expected?
               
               

               
            

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #46 on: June 24, 2011, 10:18:45 pm »


               After a bit more analysis, I can confirm that this is a pre-existing code generation problem with the optimizer.  The same script is incorrectly optimized by the PRC build as well.

I'll get back to you on a fix for the optimizer.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #47 on: June 24, 2011, 10:24:27 pm »


               Thank you '<img'>
               
               

               
            

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #48 on: June 25, 2011, 12:18:01 am »


               Please try this compiler build:

http://valera-ext.ny...CompilerDll.ndl

The optimizer bug (longstanding issue as far as I can tell) may cause incorrect code generation in cases where there is a global that is written to only during its initialization expression, and for which the initilization expression involves a function call, action service handler call, or intrinsic call.

I'll release an updated ASC build later to correct the code generation issue in the standalone compiler.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #49 on: June 25, 2011, 03:54:13 am »


               Getting No compiler errors, but getting stack underflows.
               
               

               
            

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #50 on: June 25, 2011, 06:18:49 am »


               Is this with the same script source text?  Are you sure that you rebuilt it with the new compiler?

If you link me the .ncs file, I can check that (if it's the .ncs for the source text you provided above).
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #51 on: June 25, 2011, 06:31:50 am »


               No it not with sample script it with a bunch of other scripts. A lot of it runs though a big include, prob. my lousy scripting practices that why I did not go into it. I started to read how I messed up. What are stack underflows? Could you give me a sample of one?  When I do searches it go to old forum or does not mention nwn. Sorry for all the trouble. I find one of the scripts it saying it and all custom functions in it if you want.
               
               

               


                     Modifié par ShadowM, 25 juin 2011 - 05:33 .
                     
                  


            

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #52 on: June 25, 2011, 08:34:19 am »


               It generally means that something has mismanaged the execution stack of the script.  If the script works with the BioWare compiler, then it's probably a code generation issue of some sort.  If you can isolate a specific script that is having problems, drop me a copy of it and the include dependencies that I will need to compile it, and I can take a more detailed look.
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #53 on: June 25, 2011, 06:54:05 pm »


               Yeah , these only pop up after a full compile with the latest .ndl you gave me. If I compile with bioware old compiler or the other compilers I do not get the stack underflow errors. I get you that stuff, prob. tomorrow thank you for the help.
               
               

               


                     Modifié par ShadowM, 25 juin 2011 - 05:54 .
                     
                  


            

Legacy_virusman

  • Sr. Member
  • ****
  • Posts: 448
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #54 on: June 25, 2011, 07:07:15 pm »


               I can confirm this: I'm having issues with DMFI and other scripts in my module after compiling with the latest version. Previous build (from NWNTX 1.0.1) worked fine.
               
               

               
            

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #55 on: June 25, 2011, 11:28:48 pm »


               The fix for the problem with globals being incorrectly optimized into constant expressions exposed several other pre-existing code generation bugs relating to usage of global variables that reference other global variables in their initializer expressions.  I'm working on a fix for these.
               
               

               
            

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #56 on: June 26, 2011, 05:36:18 am »


               ShadowM: Please give this build a shot:

http://valera-ext.ny...CompilerDll.ndl

There were several problems here.

1) There was a longstanding bug in the compiler (also in the PRC builds) where, in the event that a global variable was assigned to during global variable initialization but never written to afterwards, it would be promoted into a 'constant expression' even if the assignment included a function call. The 'constant expression' was then inlined every time the global was referenced. This behavior was erroneous as replicating the function call changes program behavior and can in some cases lead to stack mismanagement (which was the original issue ShadowM reported). This issue only occurred if optimizations were enabled.

2) There was a seperate longstanding and very subtle bug in the compiler (also in the PRC builds) where assigments to global variables during global variable initialization would use an incorrect stack offset in the event where the global variable initialization expression referenced another global variable, and the initialization expression was of the optimized form (enabled if optimizations are turned on) and not the 'traditional' form used by the BioWare compiler. The issue occurred because the compiler was not correctly taking into account that, while traditional initialization results in storage space for the variable being reserved at the start of the initialization expression, optimized initialization results in storage space for the variable being reserved at the end of the initialization expression. As a result, references to globals during optimized global initialization would read the wrong global. This bug was hidden by the fact that, due to the global constant expression optimization issue, most of the global references that would be impacted were being inlined out of #globals.

3) There was an additional separate longstanding bug in the compiler (also in the PRC builds) where assignments of a variable to itself during initialization would not work correctly if a constant or global was involved. This was also partially hidden (in some cases) by the global constant expression optimization bug.

I've made the following code generation changes to fix these problems:

- The compiler scans the initialization expressions of all globals to determine whether a function call, action service handler call, or internal compiler intrinsic call is present before permitting promotion of the global to a constant expression. This fixes the issue with globals that involved function calls causing the function call to be improperly replicated to each call site if optimizations were enabled.

- When processing a global variable initializer, the compiler now correctly takes into account whether storage space for the global variable on the execution stack is logically allocated at the start of the expression or at the end of the expression. This fixes the problem with global initializers that referenced other global variables working improperly if optimizations were enabled (and the global wasn't treated as a constant expression).

- When processing a variable initializer expression where the variable being initialized is referenced within the expression itself, the initializer expression is forced to the traditional, non-optimized form so that stack space for the variable is available throughout the expression. This allows operators that operate on the variable to work correctly even if optimizations were turned on.

Additionally, the compiler previously did not allow default initialization for some esoteric corner cases such as "struct mystruc global1 = global1;" that the BioWare compiler permits (though not particularly usefully); these are now allowed.
               
               

               


                     Modifié par SkywingvL, 26 juin 2011 - 04:38 .
                     
                  


            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #57 on: June 26, 2011, 07:02:59 am »


               Ok took a break from playing pen and paper D&D with friends and checked on this. I tried the new ndl and everything seem to be working. '<img'> This is with just some quick tests before going back. Thank you for you hard work tracking this all down. I do some more testing and give some more feedback some time tomorrow. '<img'> Thank  you again.
               
               

               
            

Legacy_virusman

  • Sr. Member
  • ****
  • Posts: 448
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #58 on: June 26, 2011, 10:23:05 am »


               New release!
NWNTX Compiler 1.0.2
http://data.virusman...piler-1.0.2.rar
Added an ini file to enable/disable compiler optimizations and extensions.
Also, the compiler now generates debug data if it's enabled in nwtoolset.ini.
New compiler dll and msvcr100.dll are bundled with the package.
               
               

               


                     Modifié par virusman, 26 juin 2011 - 09:23 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Has anyone been able to mod Toolset?
« Reply #59 on: June 26, 2011, 10:41:28 am »


               Had a thought, though this isn't entirely compiler related. Figured I'd mention it on the off chance it was workable with NWNTX, and not too complicated.

At present, the toolset does not recognize function comments in this format:

/* Return a StringList struct containing strings extracted from sString
 * separated by sSep. */
struct StringList GetStringList (string sString, string sSep=" ", int nLimit=16);

/* Return an IntList struct containing integers extracted from sString
 * separated by sSep. */
struct IntList GetIntList (string sString, string sSep=" ", int nLimit=10);

/* Justify a string to a given number of pixels wide. */
string JustifyString (string sStr, int nPixelWidth, int bRight=FALSE, int nFont=0, string sJustifyWith=" ");

/* Return either the resref or playername of oObject. */
string GetObjectString (object oObject);

/* Return vPos in string form X, Y, Z. */
string GetPositionStringFromVector (vector vPos);

They simply won't appear in the help section - only // comments will. Unfortunately, we use an auto-formatter which converts comments to the /* */ format. Any chance there's a magic switch you can flip somewhere? I know this is pretty nitty gritty stuff without much broad utility.

Funky