Rework stack trace emulation flag.
Patch by: bobv
Review by: bruce
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5971 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
index 813f944..4c94359 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/JavaToJavaScriptCompiler.java
@@ -272,15 +272,8 @@
/*
* Creates new variables, must run before code splitter and namer.
- *
- * TODO(bobv): This is a temporary hack to conditionally map in this pass.
- * Once deferred-binding properties can specify a subset of the
- * permutation matrix, revisit this if statement.
*/
- if (jprogram.getDeclaredTypes().contains(
- jprogram.getFromTypeMap("com.google.gwt.core.client.impl.StackTraceCreator.CollectorEmulated"))) {
- JsStackEmulator.exec(jsProgram, propertyOracles);
- }
+ JsStackEmulator.exec(jsProgram, propertyOracles);
// (10) Split up the program into fragments
SoycArtifact dependencies = null;
diff --git a/dev/core/src/com/google/gwt/dev/js/JsStackEmulator.java b/dev/core/src/com/google/gwt/dev/js/JsStackEmulator.java
index 5451e3a..fb1d93e 100644
--- a/dev/core/src/com/google/gwt/dev/js/JsStackEmulator.java
+++ b/dev/core/src/com/google/gwt/dev/js/JsStackEmulator.java
@@ -17,7 +17,10 @@
import com.google.gwt.core.ext.BadPropertyValueException;
import com.google.gwt.core.ext.PropertyOracle;
+import com.google.gwt.core.ext.SelectionProperty;
+import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.dev.jjs.HasSourceInfo;
+import com.google.gwt.dev.jjs.InternalCompilerException;
import com.google.gwt.dev.jjs.SourceInfo;
import com.google.gwt.dev.js.ast.JsArrayAccess;
import com.google.gwt.dev.js.ast.JsArrayLiteral;
@@ -64,6 +67,8 @@
*/
public class JsStackEmulator {
+ private static final String PROPERTY_NAME = "compiler.emulatedStack";
+
/**
* Resets the global stack depth to the local stack index and top stack frame
* after calls to Exceptions.caught. This is created by
@@ -776,7 +781,21 @@
}
public static void exec(JsProgram program, PropertyOracle[] propertyOracles) {
- (new JsStackEmulator(program, propertyOracles)).execImpl();
+ SelectionProperty property;
+ try {
+ property = propertyOracles[0].getSelectionProperty(TreeLogger.NULL,
+ PROPERTY_NAME);
+ } catch (BadPropertyValueException e) {
+ // Should be inherited via Core.gwt.xml
+ throw new InternalCompilerException("Expected property " + PROPERTY_NAME
+ + " not defined", e);
+ }
+
+ String value = property.getCurrentValue();
+ assert value != null : property.getName() + " did not have a value";
+ if (Boolean.valueOf(value)) {
+ (new JsStackEmulator(program, propertyOracles)).execImpl();
+ }
}
private JsFunction caughtFunction;
diff --git a/user/src/com/google/gwt/core/CompilerParameters.gwt.xml b/user/src/com/google/gwt/core/CompilerParameters.gwt.xml
index d583502..f8bbb27 100644
--- a/user/src/com/google/gwt/core/CompilerParameters.gwt.xml
+++ b/user/src/com/google/gwt/core/CompilerParameters.gwt.xml
@@ -22,14 +22,6 @@
<define-configuration-property name='compiler.splitpoint.initial.sequence'
is-multi-valued='true' />
- <!-- If set to true, this will add line number data to the stack trace data -->
- <define-configuration-property name="compiler.emulatedStack.recordLineNumbers"
- is-multi-valued="false" />
-
- <!-- Implies recordLineNumbers and adds source file name data to emitted JS -->
- <define-configuration-property name="compiler.emulatedStack.recordFileNames"
- is-multi-valued="false" />
-
<!-- From here down, the properties are unsupported and are only available for test cases -->
<!--
diff --git a/user/src/com/google/gwt/core/Core.gwt.xml b/user/src/com/google/gwt/core/Core.gwt.xml
index 8a830ac..9fbff87 100644
--- a/user/src/com/google/gwt/core/Core.gwt.xml
+++ b/user/src/com/google/gwt/core/Core.gwt.xml
@@ -22,6 +22,7 @@
<inherits name="com.google.gwt.emul.Emulation" />
<inherits name="com.google.gwt.xhr.XMLHttpRequest" />
<inherits name="com.google.gwt.core.CompilerParameters" />
+ <inherits name="com.google.gwt.core.EmulateJsStack" />
<super-source path="translatable" />
diff --git a/user/src/com/google/gwt/core/CoreWithUserAgent.gwt.xml b/user/src/com/google/gwt/core/CoreWithUserAgent.gwt.xml
index f6a87e2..cd34b6b 100644
--- a/user/src/com/google/gwt/core/CoreWithUserAgent.gwt.xml
+++ b/user/src/com/google/gwt/core/CoreWithUserAgent.gwt.xml
@@ -18,6 +18,7 @@
<replace-with class="com.google.gwt.core.client.impl.StackTraceCreator.CollectorMoz">
<when-type-is class="com.google.gwt.core.client.impl.StackTraceCreator.Collector" />
+ <when-property-is name="compiler.emulatedStack" value="false" />
<any>
<when-property-is name="user.agent" value="gecko" />
<when-property-is name="user.agent" value="gecko1_8" />
@@ -26,6 +27,7 @@
<replace-with class="com.google.gwt.core.client.impl.StackTraceCreator.CollectorOpera">
<when-type-is class="com.google.gwt.core.client.impl.StackTraceCreator.Collector" />
+ <when-property-is name="compiler.emulatedStack" value="false" />
<any>
<when-property-is name="user.agent" value="opera" />
</any>
diff --git a/user/src/com/google/gwt/core/EmulateJsStack.gwt.xml b/user/src/com/google/gwt/core/EmulateJsStack.gwt.xml
index 5e4b20f..849cc54 100644
--- a/user/src/com/google/gwt/core/EmulateJsStack.gwt.xml
+++ b/user/src/com/google/gwt/core/EmulateJsStack.gwt.xml
@@ -13,11 +13,25 @@
<!-- implied. License for the specific language governing permissions and -->
<!-- limitations under the License. -->
-<!-- TODO(bobv): Implement the subset-of-permutation-matrix predicates -->
+<!-- Defines support for emulating the JS stack -->
<module>
<inherits name="com.google.gwt.core.Core" />
+
+ <!-- If set to true, emulated stack frames will be emitted into the JS -->
+ <define-property name="compiler.emulatedStack" values="true,false" />
+ <set-property name="compiler.emulatedStack" value="false" />
+
+ <!-- If set to true, this will add line number data to the stack trace data -->
+ <define-configuration-property name="compiler.emulatedStack.recordLineNumbers"
+ is-multi-valued="false" />
+
+ <!-- Implies recordLineNumbers and adds source file name data to emitted JS -->
+ <define-configuration-property name="compiler.emulatedStack.recordFileNames"
+ is-multi-valued="false" />
+
<replace-with
class="com.google.gwt.core.client.impl.StackTraceCreator.CollectorEmulated">
<when-type-is class="com.google.gwt.core.client.impl.StackTraceCreator.Collector" />
+ <when-property-is name="compiler.emulatedStack" value="true" />
</replace-with>
</module>
diff --git a/user/src/com/google/gwt/junit/JUnit.gwt.xml b/user/src/com/google/gwt/junit/JUnit.gwt.xml
index 25a5abc..21f8231 100644
--- a/user/src/com/google/gwt/junit/JUnit.gwt.xml
+++ b/user/src/com/google/gwt/junit/JUnit.gwt.xml
@@ -31,18 +31,16 @@
<when-type-assignable class="com.google.gwt.junit.client.GWTTestCase"/>
</generate-with>
- <!-- TODO(bobv): This is temporary until subset-of-permutation-matrix work is done. -->
<!-- We want to provide good stack traces on browsers that don't provide good native stack traces. -->
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true" />
- <replace-with
- class="com.google.gwt.core.client.impl.StackTraceCreator.CollectorEmulated">
- <when-type-is class="com.google.gwt.core.client.impl.StackTraceCreator.Collector" />
+ <set-property name="compiler.emulatedStack" value="true" />
+ <set-property name="compiler.emulatedStack" value="false">
<none>
<when-property-is name="user.agent" value="gecko" />
<when-property-is name="user.agent" value="gecko1_8" />
<when-property-is name="user.agent" value="opera" />
</none>
- </replace-with>
+ </set-property>
<servlet path='/junithost' class='com.google.gwt.junit.server.JUnitHostImpl'/>