8044786: Some tests fail with non-optimistic compilation
authorattila
Wed, 06 Aug 2014 10:42:46 +0200
changeset 25828 077046a5d726
parent 25827 c406ec905701
child 25829 1a5e1de71e57
8044786: Some tests fail with non-optimistic compilation Reviewed-by: hannesw, jlaskey
nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java
nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java
nashorn/test/script/basic/JDK-8030182_2.js
nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED
nashorn/test/script/basic/optimistic_arithmetic_check_type.js
nashorn/test/script/basic/optimistic_assignment_check_type.js
nashorn/test/script/basic/optimistic_check_type.js
nashorn/test/script/trusted/event_queue.js
nashorn/test/script/trusted/optimistic_recompilation.js
--- a/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Wed Aug 06 10:42:46 2014 +0200
@@ -80,7 +80,8 @@
 
         private static final MethodHandle GET_ELEM = specialCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "getElem", int.class, int.class).methodHandle();
         private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "setElem", void.class, int.class, int.class).methodHandle();
-        private static final MethodHandle RINT     = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", double.class, double.class).methodHandle();
+        private static final MethodHandle RINT_D   = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", double.class, double.class).methodHandle();
+        private static final MethodHandle RINT_O   = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "rint", Object.class, Object.class).methodHandle();
         private static final MethodHandle CLAMP_LONG = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "clampLong", long.class, long.class).methodHandle();
 
         private Uint8ClampedArrayData(final ByteBuffer nb, final int start, final int end) {
@@ -109,8 +110,10 @@
         public MethodHandle getElementSetter(final Class<?> elementType) {
             final MethodHandle setter = super.getElementSetter(elementType); //getContinuousElementSetter(getClass(), setElem(), elementType);
             if (setter != null) {
-                if (elementType == double.class) {
-                    return MH.filterArguments(setter, 2, RINT);
+                if (elementType == Object.class) {
+                    return MH.filterArguments(setter, 2, RINT_O);
+                } else if (elementType == double.class) {
+                    return MH.filterArguments(setter, 2, RINT_D);
                 } else if (elementType == long.class) {
                     return MH.filterArguments(setter, 2, CLAMP_LONG);
                 }
@@ -191,6 +194,11 @@
         }
 
         @SuppressWarnings("unused")
+        private static Object rint(final Object rint) {
+            return rint(JSType.toNumber(rint));
+        }
+
+        @SuppressWarnings("unused")
         private static long clampLong(final long l) {
             if(l < 0L) {
                 return 0L;
--- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Wed Aug 06 10:42:46 2014 +0200
@@ -818,9 +818,8 @@
 
     /** ECMA 11.9.6 The Strict Equality Comparison Algorithm */
     private static boolean strictEquals(final Object x, final Object y) {
-        if(x == y) {
-            return true;
-        }
+        // NOTE: you might be tempted to do a quick x == y comparison. Remember, though, that any Double object having
+        // NaN value is not equal to itself by value even though it is referentially.
 
         final JSType xType = JSType.ofNoFunction(x);
         final JSType yType = JSType.ofNoFunction(y);
--- a/nashorn/test/script/basic/JDK-8030182_2.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/test/script/basic/JDK-8030182_2.js	Wed Aug 06 10:42:46 2014 +0200
@@ -41,6 +41,6 @@
 try {
     eval(str);
 } catch (e) {
-    print(e.stack.replace(/\\/g, '/'));
+    print(e.stack.replace(/\\/g, '/').replace(/<eval>@[0-9]+/, '<eval>@<id>'));
 }
 
--- a/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/test/script/basic/JDK-8030182_2.js.EXPECTED	Wed Aug 06 10:42:46 2014 +0200
@@ -1,3 +1,3 @@
 ReferenceError: "g" is not defined
-	at <program> (test/script/basic/JDK-8030182_2.js#42:4<eval>@1:-1)
+	at <program> (test/script/basic/JDK-8030182_2.js#42:4<eval>@<id>:-1)
 	at <program> (test/script/basic/JDK-8030182_2.js:42)
--- a/nashorn/test/script/basic/optimistic_arithmetic_check_type.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/test/script/basic/optimistic_arithmetic_check_type.js	Wed Aug 06 10:42:46 2014 +0200
@@ -25,6 +25,7 @@
  * @test
  * @bug 8036987, 8037572
  * @summary Implement tests that checks static types in the compiled code
+ * @option --optimistic-types=true
  * @run
  */
 
--- a/nashorn/test/script/basic/optimistic_assignment_check_type.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/test/script/basic/optimistic_assignment_check_type.js	Wed Aug 06 10:42:46 2014 +0200
@@ -25,6 +25,7 @@
  * @test
  * @bug 8036987, 8037572
  * @summary Implement tests that checks static types in the compiled code
+ * @option --optimistic-types=true
  * @run
  */
 
--- a/nashorn/test/script/basic/optimistic_check_type.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/test/script/basic/optimistic_check_type.js	Wed Aug 06 10:42:46 2014 +0200
@@ -25,6 +25,7 @@
  * @test
  * @bug 8036987, 8037572
  * @summary Implement tests that checks static types in the compiled code
+ * @option --optimistic-types=true
  * @run
  */
 
--- a/nashorn/test/script/trusted/event_queue.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/test/script/trusted/event_queue.js	Wed Aug 06 10:42:46 2014 +0200
@@ -29,6 +29,7 @@
  * @fork
  * @option -Dnashorn.debug=true
  * @option --log=recompile:quiet
+ * @option --optimistic-types=true
  */
 
 print(Debug);
--- a/nashorn/test/script/trusted/optimistic_recompilation.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/nashorn/test/script/trusted/optimistic_recompilation.js	Wed Aug 06 10:42:46 2014 +0200
@@ -28,6 +28,7 @@
  * @fork
  * @option -Dnashorn.debug=true
  * @option --log=recompile:quiet
+ * @option --optimistic-types=true
  */
 
 var forName       = java.lang.Class["forName(String)"];