[Laszlo-dev] [Laszlo-checkins] r13447 - in openlaszlo/trunk/WEB-INF/lps: config server/src/org/openlaszlo/sc
Max Carlson
max at openlaszlo.org
Tue Mar 24 21:23:46 PDT 2009
Can we change the LFC build scripts to force catcherrors to be false? I
noticed a huge drop in performance when I compiled the DHTML LFC using
'buildlfcdebug --runtime=dhtml' when catcherrors was turned on in
lps.properties...
This should only affect user code/LZX compiles, right?
dda at openlaszlo.org wrote:
> Author: dda
> Date: 2009-03-24 09:26:38 -0700 (Tue, 24 Mar 2009)
> New Revision: 13447
>
> Modified:
> openlaszlo/trunk/WEB-INF/lps/config/lps.properties
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
> openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
> Log:
> Change 20090320-dda-M by dda at lester-2.local on 2009-03-20 16:17:11 EDT
> in /Users/dda/laszlo/src/svn/openlaszlo/trunk-b
> for http://svn.openlaszlo.org/openlaszlo/trunk
>
> Summary: Initial implementation of catcherrors for DHTML
>
> New Features:
>
> Bugs Fixed: LPP-7824: Add compiler option to turn on catch-errors (currently swf9) in DHTML
>
> Technical Reviewer: ptw (pending)
> QA Reviewer: (pending)
> Doc Reviewer: (pending)
>
> Documentation:
>
> Release Notes:
> The property name for catcherrors has changed.
> Now, if you set compiler.catcherrors=true in your lps.properties file,
> you will enable catcherrors behavior. This works for SWF9 and DHTML runtimes.
> The property used to be called compiler.swf9.catcherrors; that property is now ignored.
>
> Details:
> This changeset enables the catcherrors code for DHTML.
>
> - The property name to drive the feature has changed (see Release Notes above)
>
> - Fixed a mistake in matchingAncestor() so that it now works as advertised.
>
> - For DHTML, I attempted to use the $lzsc$runtime class (currently only enabled for SWF9),
> but that class was not able to successfully call reportSourceWarning in DHTML.
> For the time being, I'm calling $reportSourceWarning directly in DHTML.
> A TODO has been left in, we should either find a way to resolve this or call
> reportSourceWarning directly for all runtimes.
>
> - The implementation continues to use Compiler.PassThroughNodes for the fragments that implement
> the variable declaration and try/catch block. Without this, I've encountered problems probably
> related to an ordering problem - the references to the rewritten variable names are changed before
> the variable in the try block is created. (not sure about this). At any rate, DHTML continues
> to use PassThroughNodes. One consequence is that a 'warnUndefinedReferences' pragma is inserted
> into the parsedFragment and is not removed. So this change moves a change in SWF9ParseTreePrinter
> into ParseTreePrinter - pragmas are shown as commented (also fixed a newline error when moving that!)
> This allows the pragma to appear. Better long term solutions are to remove the pragmas or
> better, solve the underlying problem that requires PassThroughNodes.
>
> Tests:
> 1. For regression, the usual {smokecheck,weather,lzpix} x {swf9,swf8,dhtml} -- with catcherrors enabled.
> Note that I did not build the LFC with catcherrors enabled, we'll save that for another day.
>
> 2. For functionality, here is the minimal test case I use:
>
> <canvas debug="true">
> <simplelayout spacing="10" axis="y" />
>
> <method name="canvas_f">
> t1.setText("Before exception");
> throwexcept(7,0);
> t2.setText("After exception");
> </method>
> <method name="returnnull">
> return null;
> </method>
> <method name="throwexcept" args="w, x">
> // an array reference of a non array gives an exception
> return w + x + returnnull().foo;
> </method>
>
> <button name="b1" onclick="this.parent.canvas_f()" width="100" height="30" y="10">Press me</button>
> <text name="t1" bgcolor="#ccffcc" width="100" height="30" y="50"/>
> <text name="t2" bgcolor="#ccffcc" width="100" height="30" y="100"/>
> <script>
> </script>
> </canvas>
>
> In SWF8, this gives:
> WARNING @LPP-7270g.lzx#14: reference to undefined property 'foo'
> In SWF9, this gives:
> ERROR @LPP-7270g.lzx#12: TypeError: Error #1009
> In DHTML, this now gives:
> ERROR @LPP-7270g.lzx#12: TypeError: Null value
>
> For SWF9/DHTML, the line number refers to the top of the function, as the try/catch
> block applies to the entire function.
>
>
>
> Modified: openlaszlo/trunk/WEB-INF/lps/config/lps.properties
> ===================================================================
> --- openlaszlo/trunk/WEB-INF/lps/config/lps.properties 2009-03-24 15:56:44 UTC (rev 13446)
> +++ openlaszlo/trunk/WEB-INF/lps/config/lps.properties 2009-03-24 16:26:38 UTC (rev 13447)
> @@ -164,8 +164,8 @@
> # Tell SWF9 external compiler to issue warnings.
> compiler.swf9.warnings=false
> compiler.swf9.execflex=false
> -# Tell swf9 compiler to catch errors in debug mode
> -#compiler.swf9.catcherrors=true
> +# Tell compiler to catch errors in debug mode
> +#compiler.catcherrors=true
> # Sets whether applications compiled make proxied data requests by default
> compiler.proxied=true
>
>
> Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java
> ===================================================================
> --- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java 2009-03-24 15:56:44 UTC (rev 13446)
> +++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/Compiler.java 2009-03-24 16:26:38 UTC (rev 13447)
> @@ -268,11 +268,11 @@
> options.putBoolean(DEBUG_SWF9, options.getBoolean(DEBUG));
> options.putBoolean(DEBUG, false);
> options.putBoolean(DEBUG_BACKTRACE, false);
> - if (! options.containsKey(CATCH_FUNCTION_EXCEPTIONS)) {
> - options.put(CATCH_FUNCTION_EXCEPTIONS,
> - Boolean.valueOf(LPS.getProperty("compiler.swf9.catcherrors", "false")));
> - }
> }
> + if (! options.containsKey(CATCH_FUNCTION_EXCEPTIONS)) {
> + options.put(CATCH_FUNCTION_EXCEPTIONS,
> + Boolean.valueOf(LPS.getProperty("compiler.catcherrors", "false")));
> + }
>
> // TODO: [2008-05-18 dda] It may be possible to clean this up
> // a little now that we know this is only called once.
>
> Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java
> ===================================================================
> --- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java 2009-03-24 15:56:44 UTC (rev 13446)
> +++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/JavascriptGenerator.java 2009-03-24 16:26:38 UTC (rev 13447)
> @@ -1249,9 +1249,17 @@
> String tryType = "";
> if (tryAll) {
> if (options.getBoolean(Compiler.DEBUG) || options.getBoolean(Compiler.DEBUG_SWF9)) {
> - error.add(parseFragment("$lzsc$runtime.reportException(" +
> - ScriptCompiler.quote(filename) + ", " +
> - functionNameIdentifier.beginLine + ", $lzsc$e);"));
> + // TODO: [2009-03-20 dda] In DHTML, having trouble successfully defining
> + // the $lzsc$runtime class, so we'll report the warning more directly.
> + if (this instanceof SWF9Generator) {
> + error.add(parseFragment("$lzsc$runtime.reportException(" +
> + ScriptCompiler.quote(filename) + ", " +
> + functionNameIdentifier.beginLine + ", $lzsc$e);"));
> + } else {
> + error.add(parseFragment("$reportSourceWarning(" +
> + ScriptCompiler.quote(filename) + ", " +
> + functionNameIdentifier.beginLine + ", $lzsc$e.name + \": \" + $lzsc$e.message, true);"));
> + }
> }
>
> predecls.add(new Compiler.PassThroughNode(parseFragment("var $lzsc$ret:* = 0;")));
> @@ -1595,7 +1603,7 @@
> if (includeThis && matchClass.equals(node.getClass())) {
> return node;
> }
> - includeThis = false;
> + includeThis = true;
> node = node.getParent();
> }
> return null;
>
> Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java
> ===================================================================
> --- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java 2009-03-24 15:56:44 UTC (rev 13446)
> +++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/ParseTreePrinter.java 2009-03-24 16:26:38 UTC (rev 13447)
> @@ -529,8 +529,11 @@
> children[0] = maybeAddParens(thisPrec, c, children[0]);
> return "new " + children[0] + "(" + children[1] + ")";
> }
> + // TODO: [2009-03-23 dda] Should not need to comment the #pragma as they
> + // should not normally appear in emitted code. But LPP-7824 requires it
> + // for now.
> public String visitPragmaDirective(SimpleNode node, String[] children) {
> - return "#pragma " + children[0];
> + return "// #pragma " + children[0] + "\n";
> }
> public String visitPassthroughDirective(SimpleNode node, String[] children) {
> return ((ASTPassthroughDirective)node).getText();
>
> Modified: openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java
> ===================================================================
> --- openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java 2009-03-24 15:56:44 UTC (rev 13446)
> +++ openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/sc/SWF9ParseTreePrinter.java 2009-03-24 16:26:38 UTC (rev 13447)
> @@ -1,7 +1,7 @@
> /* -*- mode: Java; c-basic-offset: 2; -*- */
>
> /* J_LZ_COPYRIGHT_BEGIN *******************************************************
> -* Copyright 2007-2008 Laszlo Systems, Inc. All Rights Reserved. *
> +* Copyright 2007-2009 Laszlo Systems, Inc. All Rights Reserved. *
> * Use is subject to license terms. *
> * J_LZ_COPYRIGHT_END *********************************************************/
>
> @@ -311,9 +311,6 @@
> }
> }
>
> - public String visitPragmaDirective(SimpleNode node, String[] children) {
> - return "// (ignored) pragma " + children[0];
> - }
> public String visitPassthroughDirective(SimpleNode node, String[] children) {
> ASTPassthroughDirective passthrough = (ASTPassthroughDirective)node;
> String text = passthrough.getText();
>
>
> _______________________________________________
> Laszlo-checkins mailing list
> Laszlo-checkins at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins
--
Regards,
Max Carlson
OpenLaszlo.org
More information about the Laszlo-dev
mailing list