changeset 949:fca4db1360f7

8044786: Some tests fail with non-optimistic compilation Reviewed-by: hannesw, jlaskey
author attila
date Wed, 06 Aug 2014 10:42:46 +0200
parents 6f579dd103da
children ba38d4cea99e
files src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java src/jdk/nashorn/internal/runtime/ScriptRuntime.java test/script/basic/JDK-8030182_2.js test/script/basic/JDK-8030182_2.js.EXPECTED test/script/basic/optimistic_arithmetic_check_type.js test/script/basic/optimistic_assignment_check_type.js test/script/basic/optimistic_check_type.js test/script/trusted/event_queue.js test/script/trusted/optimistic_recompilation.js
diffstat 9 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/src/jdk/nashorn/internal/runtime/ScriptRuntime.java	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/test/script/basic/JDK-8030182_2.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/test/script/basic/JDK-8030182_2.js.EXPECTED	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/test/script/basic/optimistic_arithmetic_check_type.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/test/script/basic/optimistic_assignment_check_type.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/test/script/basic/optimistic_check_type.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/test/script/trusted/event_queue.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/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/test/script/trusted/optimistic_recompilation.js	Mon Aug 04 15:34:57 2014 -0700
+++ b/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)"];