You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2019/06/27 18:23:17 UTC

[royale-compiler] branch develop updated (2ce996c -> 562c244)

This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git.


    from 2ce996c  compiler-jx: most console output during compilation is hidden and can be re-enabled with the -verbose option
     new 490a0a5  JSRoyaleEmitter, MXMLRoyaleEmitter: minor optimization to avoid extra string comparisons during post-process step
     new 8994964  MXMLRoyalePublisher: small optimization to sortClosureFile()
     new 562c244  MXMLRoyalePublisher: does not create or populate JSClosureCompilerWrapper for debug builds

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../codegen/js/royale/JSRoyaleEmitter.java         |  15 +-
 .../codegen/mxml/royale/MXMLRoyaleEmitter.java     |  15 +-
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 184 +++++++++++----------
 3 files changed, 119 insertions(+), 95 deletions(-)


[royale-compiler] 01/03: JSRoyaleEmitter, MXMLRoyaleEmitter: minor optimization to avoid extra string comparisons during post-process step

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 490a0a5cfcf40cde55e6f780b9135b7494d8aa9c
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Jun 27 09:42:03 2019 -0700

    JSRoyaleEmitter, MXMLRoyaleEmitter: minor optimization to avoid extra string comparisons during post-process step
---
 .../internal/codegen/js/royale/JSRoyaleEmitter.java       | 15 +++++++++------
 .../internal/codegen/mxml/royale/MXMLRoyaleEmitter.java   | 15 +++++++++------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
index 9523f29..a5f43e6 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
@@ -181,14 +181,17 @@ public class JSRoyaleEmitter extends JSGoogEmitter implements IJSRoyaleEmitter
             String line = lines[i];
     		if (stillSearching)
     		{
-                int c = line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-                if (c != -1)
+                if (provideIndex == -1 || !sawRequires)
                 {
-                    // if zero requires are found, require Language after the
-                    // call to goog.provide
-                    provideIndex = addIndex = i + 1;
+                    int c = line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+                    if (c != -1)
+                    {
+                        // if zero requires are found, require Language after the
+                        // call to goog.provide
+                        provideIndex = addIndex = i + 1;
+                    }
                 }
-	            c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+	            int c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
 	            if (c != -1)
 	            {
                     // we found other requires, so we'll just add Language at
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
index 9abdddf..826f44e 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
@@ -206,14 +206,17 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements
             String line = lines[i];
     		if (stillSearching)
     		{
-                int c = line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-                if (c != -1)
+                if (provideIndex == -1 || !sawRequires)
                 {
-                    // if zero requires are found, require Language after the
-                    // call to goog.provide
-                    provideIndex = i + 1;
+                    int c = line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+                    if (c != -1)
+                    {
+                        // if zero requires are found, require Language after the
+                        // call to goog.provide
+                        provideIndex = i + 1;
+                    }
                 }
-	            c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+	            int c = line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
 	            if (c > -1)
 	            {
 	                int c2 = line.indexOf(")");


[royale-compiler] 02/03: MXMLRoyalePublisher: small optimization to sortClosureFile()

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 89949646f233f76a9ecf069088762525a0d6f2ce
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Jun 27 10:23:00 2019 -0700

    MXMLRoyalePublisher: small optimization to sortClosureFile()
---
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 73 ++++++++++++----------
 1 file changed, 39 insertions(+), 34 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
index 80c6fba..6840385 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
@@ -619,23 +619,23 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
     	for (String dep : deps)
     	{
     		int open = dep.indexOf("[");
-    		int close = dep.indexOf("]");
+    		int close = dep.indexOf("]", open + 1);
 			String list = dep.substring(open + 1, close);
 			String[] parts = list.split(",");
-			ArrayList<String> provideds = new ArrayList<String>();
 			for (String part : parts)
 			{
 				part = part.trim();
-				if (part.startsWith("'"))
-					part = part.substring(1, part.length() - 1);
-				provideds.add(part);    				
+                if (part.startsWith("'"))
+                {
+                    part = part.substring(1, part.length() - 1);
+                }
+                if(part.equals(name))
+                {
+                    open = dep.indexOf("'");
+                    close = dep.indexOf("'", open + 1);
+                    return dep.substring(open + 1, close);    
+                }
 			}
-    		if (provideds.contains(name))
-    		{
-    			open = dep.indexOf("'");
-    			close = dep.indexOf("'", open + 1);
-    			return dep.substring(open + 1, close);    			
-    		}
     	}
     	return null;
     }
@@ -645,35 +645,40 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
     	for (String dep : deps)
     	{
     		int open = dep.indexOf("[");
-    		int close = dep.indexOf("]");
+    		int close = dep.indexOf("]", open + 1);
 			String list = dep.substring(open + 1, close);
 			String[] parts = list.split(",");
-			ArrayList<String> provideds = new ArrayList<String>();
 			for (String part : parts)
 			{
 				part = part.trim();
-				if (part.startsWith("'"))
-					part = part.substring(1, part.length() - 1);
-				provideds.add(part);    				
+                if (part.startsWith("'"))
+                {
+                    part = part.substring(1, part.length() - 1);
+                }
+                
+                if(part.equals(name))
+                {
+                    open = dep.indexOf("[", close + 1);
+                    close = dep.indexOf("]", open + 1);
+                    if (open + 1 == close)
+                    {
+                        return null;
+                    }
+                    String list2 = dep.substring(open + 1, close);
+                    String[] parts2 = list2.split(",");
+                    ArrayList<String> reqs = new ArrayList<String>();
+                    for (String part2 : parts2)
+                    {
+                        part2 = part2.trim();
+                        if (part2.startsWith("'"))
+                        {
+                            part2 = part2.substring(1, part2.length() - 1);
+                        }
+                        reqs.add(part2);    				
+                    }
+                    return reqs;
+                }				
 			}
-    		if (provideds.contains(name))
-    		{
-    			open = dep.indexOf("[", close + 1);
-    			close = dep.indexOf("]", open + 1);
-    			if (open + 1 == close)
-    				return null;
-    			String list2 = dep.substring(open + 1, close);
-    			String[] parts2 = list2.split(",");
-    			ArrayList<String> reqs = new ArrayList<String>();
-    			for (String part : parts2)
-    			{
-    				part = part.trim();
-    				if (part.startsWith("'"))
-    					part = part.substring(1, part.length() - 1);
-    				reqs.add(part);    				
-    			}
-    			return reqs;
-    		}
     	}
     	return null;
     }    


[royale-compiler] 03/03: MXMLRoyalePublisher: does not create or populate JSClosureCompilerWrapper for debug builds

Posted by jo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 562c244061a2e2293c568ed2bdfa9be4947f9892
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Jun 27 11:22:39 2019 -0700

    MXMLRoyalePublisher: does not create or populate JSClosureCompilerWrapper for debug builds
    
    This shaves off a few hundred milliseconds when compiling TourDeJewel
---
 .../codegen/mxml/royale/MXMLRoyalePublisher.java   | 111 ++++++++++++---------
 1 file changed, 62 insertions(+), 49 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
index 6840385..0dbf01b 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyalePublisher.java
@@ -367,19 +367,25 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
         // Prepare the closure compilation.
         /////////////////////////////////////////////////////////////////////////////////
 
-        JSClosureCompilerWrapper compilerWrapper = new JSClosureCompilerWrapper(googConfiguration.getJSCompilerOptions());
+        JSClosureCompilerWrapper compilerWrapper = null;
+        if (configuration.release())
+        {
+            compilerWrapper = new JSClosureCompilerWrapper(googConfiguration.getJSCompilerOptions());
+        }
 
+        if (compilerWrapper != null)
+        {
+            /////////////////////////////////////////////////////////////////////////////////
+            // Add all the closure lib files to the compilation unit.
+            /////////////////////////////////////////////////////////////////////////////////
 
-        /////////////////////////////////////////////////////////////////////////////////
-        // Add all the closure lib files to the compilation unit.
-        /////////////////////////////////////////////////////////////////////////////////
+            for (SourceFile closureSourceFile : closureSourceFiles) {
+                compilerWrapper.addJSSourceFile(closureSourceFile);
+            }
 
-        for (SourceFile closureSourceFile : closureSourceFiles) {
-            compilerWrapper.addJSSourceFile(closureSourceFile);
+            writeExportedNames(compilerWrapper);
         }
 
-        writeExportedNames(compilerWrapper);
-
         /////////////////////////////////////////////////////////////////////////////////
         // Add all the externs to the compilation
         /////////////////////////////////////////////////////////////////////////////////
@@ -390,29 +396,32 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
         List<ISWC> allswcs = new ArrayList<ISWC>();
         allswcs.addAll(swcs);
         allswcs.addAll(themeSWCs);
-        for (ISWC swc : allswcs)
+        if (compilerWrapper != null)
         {
-            Map<String, ISWCFileEntry> files = swc.getFiles();
-            for (String key : files.keySet())
+            for (ISWC swc : allswcs)
             {
-                if (key.startsWith(ROYALE_EXTERNS))
+                Map<String, ISWCFileEntry> files = swc.getFiles();
+                for (String key : files.keySet())
                 {
-                    ISWCFileEntry fileEntry = swc.getFile(key);
-                    if (fileEntry != null)
+                    if (key.startsWith(ROYALE_EXTERNS))
                     {
-                        InputStream is = fileEntry.createInputStream();
-                        String code = IOUtils.toString(is, "UTF-8");
-                        is.close();
-                        JarSourceFile externFile = new JarSourceFile(key, code,true);
-                        if (googConfiguration.isVerbose())
+                        ISWCFileEntry fileEntry = swc.getFile(key);
+                        if (fileEntry != null)
                         {
-                            System.out.println("using extern: " + key);
-                        }
-                        compilerWrapper.addJSExternsFile(externFile);
+                            InputStream is = fileEntry.createInputStream();
+                            String code = IOUtils.toString(is, "UTF-8");
+                            is.close();
+                            JarSourceFile externFile = new JarSourceFile(key, code,true);
+                            if (googConfiguration.isVerbose())
+                            {
+                                System.out.println("using extern: " + key);
+                            }
+                            compilerWrapper.addJSExternsFile(externFile);
 
-                        // Write the extern into the filesystem.
-                        // FIXME: I don't know why we need to do this.
-                        //FileUtils.write(new File(intermediateDir, key), externFile.getCode());
+                            // Write the extern into the filesystem.
+                            // FIXME: I don't know why we need to do this.
+                            //FileUtils.write(new File(intermediateDir, key), externFile.getCode());
+                        }
                     }
                 }
             }
@@ -429,31 +438,35 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
         // js files of used dependencies.
         ArrayList<String> sourceExternFiles = new ArrayList<String>();
         ArrayList<String> fileList = gdw.getListOfFiles(project, sourceExternFiles, problems);
-        for (String sourceExtern : project.sourceExterns)
-        {
-        	String sourceExternFileName = sourceExtern.replace(".", "/") + ".js";
-        	File sourceExternFile = new File(intermediateDir, sourceExternFileName);
-        	if (sourceExternFile.exists())
-        	{
-        		String sourceExternPath = sourceExternFile.getAbsolutePath();
-        		if (!sourceExternFiles.contains(sourceExternPath))
-        			sourceExternFiles.add(sourceExternPath);
-        	}
-        }
         if (fileList == null)
-        	return false; // some error occurred
-        for (String file : fileList) {
-            compilerWrapper.addJSSourceFile(file);
-            if (googConfiguration.isVerbose())
-            {            
-                System.out.println("using source file: " + file);
-            }
-        }
-        for (String file : sourceExternFiles) {
-        	compilerWrapper.addJSExternsFile(file);
-            if (googConfiguration.isVerbose())
+            return false; // some error occurred
+        
+        if (compilerWrapper != null)
+        {
+            for (String sourceExtern : project.sourceExterns)
             {
-                System.out.println("using extern file: " + file);
+                String sourceExternFileName = sourceExtern.replace(".", "/") + ".js";
+                File sourceExternFile = new File(intermediateDir, sourceExternFileName);
+                if (sourceExternFile.exists())
+                {
+                    String sourceExternPath = sourceExternFile.getAbsolutePath();
+                    if (!sourceExternFiles.contains(sourceExternPath))
+                        sourceExternFiles.add(sourceExternPath);
+                }
+            }
+            for (String file : fileList) {
+                compilerWrapper.addJSSourceFile(file);
+                if (googConfiguration.isVerbose())
+                {            
+                    System.out.println("using source file: " + file);
+                }
+            }
+            for (String file : sourceExternFiles) {
+                compilerWrapper.addJSExternsFile(file);
+                if (googConfiguration.isVerbose())
+                {
+                    System.out.println("using extern file: " + file);
+                }
             }
         }
 
@@ -514,7 +527,7 @@ public class MXMLRoyalePublisher extends JSGoogPublisher implements IJSPublisher
         // If we are doing a release build, let the closure compiler do it's job.
         /////////////////////////////////////////////////////////////////////////////////
 
-        if (configuration.release()) {
+        if (compilerWrapper != null) {
             boolean ok = true;
             final File projectReleaseMainFile = new File(releaseDir, outputFileName);
             compilerWrapper.setOptions(projectReleaseMainFile.getCanonicalPath(), useStrictPublishing, !googConfiguration.getRemoveCirculars(), projectName);