8049407: Endianness problem with TypedArrays
authorlagergren
Mon, 17 Nov 2014 14:36:15 +0100
changeset 27812 c2d0feb951e3
parent 27811 e415087c78aa
child 27813 469b7c927aec
8049407: Endianness problem with TypedArrays Reviewed-by: hannesw, sundar
nashorn/test/script/basic/JDK-8049407-big-endian.js
nashorn/test/script/basic/JDK-8049407-big-endian.js.EXPECTED
nashorn/test/script/basic/JDK-8049407-payload.js
nashorn/test/script/basic/JDK-8049407.js
nashorn/test/script/basic/JDK-8049407.js.EXPECTED
nashorn/test/script/basic/NASHORN-377-big-endian.js
nashorn/test/script/basic/NASHORN-377-big-endian.js.EXPECTED
nashorn/test/script/basic/NASHORN-377-payload.js
nashorn/test/script/basic/NASHORN-377.js
nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8049407-big-endian.js	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Verify DataView behavior with little/big endian
+ *
+ * @test
+ * @run
+ * @bigendian
+ */
+
+var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__;
+load(dir + "JDK-8049407-payload.js");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8049407-big-endian.js.EXPECTED	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,1 @@
+false
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8049407-payload.js	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Verify DataView behavior with little/big endian
+ *
+ * @subtest
+ * @run
+ */
+
+var littleEndian = (function() {
+	var buffer = new ArrayBuffer(2);
+	new DataView(buffer).setInt16(0, 256, true);
+	return new Int16Array(buffer)[0] === 256;
+    })();
+
+print(littleEndian);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8049407.js	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Verify DataView behavior with little/big endian
+ *
+ * @test
+ * @run
+ * @littleendian
+ */
+
+var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__;
+load(dir + "JDK-8049407-payload.js");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8049407.js.EXPECTED	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,1 @@
+true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/NASHORN-377-big-endian.js	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * NASHORN-377: Typed arrays.
+ *
+ * @test
+ * @run
+ * @bigendian
+ */
+
+var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__;
+load(dir + "NASHORN-377-payload.js");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/NASHORN-377-big-endian.js.EXPECTED	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,34 @@
+8 8 true undefined
+[object ArrayBuffer] [object ArrayBuffer] [object Int8Array]
+0 8 8 1
+0 8 8 1
+0 8 8 1
+0 8 4 2
+0 8 4 2
+0 8 2 4
+0 8 2 4
+0 8 2 4
+0 8 1 8
+7071727374-807677 7071727374807677
+727374-807677 2 6
+72737480 2 4
+71727374 1 4
+717273748076
+7071727374807677 1886483059 1954575991
+70717273-1020305 1886483059 -16909061
+70717273fefdfcfb 1886483059 4278058235
+40490fdafefdfcfb 2
+400921fb4d12d84a 1
+400921fb4d12d84a 1074340347 1293080650
+00000000400921fb4d12d84a
+400921fb4d12-27b6 400921fb4d12d84a
+00-100804d12-27b6 ffff00804d12d84a
+0 1 2 3 4 5 6 7
+0102030405060708
+subarray(2,4)=0304 subarray(-6,-4)=0304
+010203040506
+03040506 0405
+0102030405060708090a0b0c0d0e0f10
+slice(4,8)=05060708 slice(-8,-4)=090a0b0c
+0102030405060708090a0b0c
+060708090a0b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/NASHORN-377-payload.js	Mon Nov 17 14:36:15 2014 +0100
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * NASHORN-377: Typed arrays. Payload for litte and big endian platforms.
+ *
+ * @subtest
+ * @run
+ */
+
+var types = [Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];
+
+//---------------------------------------------------------------------------
+// utility functions
+//---------------------------------------------------------------------------
+function tohex(d, w) {
+  var hex = Number(d).toString(16);
+  var pad = (w ? w : 8) - hex.length;
+  hex = "00000000".substr(0, pad) + hex;
+  return hex;
+}
+
+function arrstr(a, n, w) {
+  var s = "";
+  if (typeof n == "undefined") n = a.length;
+  if (typeof w == "undefined") w = a.constructor.BYTES_PER_ELEMENT * 2;
+  for (var i = 0; i < n; i++) {
+    s += tohex(a[i], w);
+  }
+  return s;
+}
+function bufstr(b) {
+  if (b.buffer !== undefined) {
+    b = b.buffer;
+  }
+  return arrstr(new Uint8Array(b));
+}
+
+function assertFail(f) {
+  try {
+    f();
+  } catch (e) {
+    //print(e);
+    return;
+  }
+  throw "assertion failed: expected exception";
+}
+
+function assertTrue(f) {
+  if (f() !== true) throw "assertion failed: " + f;
+}
+
+function isUndefined(x) {
+  return typeof x === "undefined";
+}
+
+function fillArray(a, start) {
+  if (typeof start == "undefined") start = 1;
+  for (var i = 0; i < a.length; i++) {
+    a[i] = i + start;
+  }
+  return a;
+}
+
+//---------------------------------------------------------------------------
+// tests
+//---------------------------------------------------------------------------
+(function() {
+  var b = new ArrayBuffer(8);
+  var i8 = new Int8Array(b);
+  print(i8.buffer.byteLength, b.byteLength, i8.buffer === b, b.length);
+  print(b, i8.buffer, i8);
+})();
+
+(function test_attributes() {
+  var b = new ArrayBuffer(8);
+  for (var i in types) {
+    var x = new types[i](b);
+    print(x.byteOffset, x.byteLength, x.length, x.constructor.BYTES_PER_ELEMENT);
+    assertTrue(function(){ return x.constructor === types[i] });
+  }
+})();
+
+(function() {
+  var b = new ArrayBuffer(8);
+  var i8 = new Int8Array(b);
+  fillArray(i8, 0x70);
+
+  var i8_2 = new Int8Array(b, 2);
+  var i8_2_4 = new Uint8Array(b, 2, 4);
+
+  i8_2_4[3] = 0x80;
+
+  print(arrstr(i8, 8, 2)  + " " + bufstr(i8));
+  print(arrstr(i8_2, 6)   + " " + i8_2.byteOffset   + " " + i8_2.byteLength);
+  print(arrstr(i8_2_4, 4) + " " + i8_2_4.byteOffset + " " + i8_2_4.byteLength);
+
+  var i8_1_5 = i8.subarray(1, 5);
+  i8_2_4.subarray(1, 5);
+  print(arrstr(i8_1_5, 4) + " " + i8_1_5.byteOffset + " " + i8_1_5.byteLength);
+
+  print(bufstr(b.slice(1,7)));
+})();
+
+(function() {
+  var b = new ArrayBuffer(8);
+  fillArray(new Int8Array(b), 0x70);
+  new Int8Array(b)[5] = 0x80;
+
+  var i32 = new Int32Array(b);
+  var u32 = new Uint32Array(b);
+  print(arrstr(i32), i32[0], i32[1]);
+  i32[1] = 0xfefdfcfb;
+  print(arrstr(i32), i32[0], i32[1]);
+  print(arrstr(u32), u32[0], u32[1]);
+
+  var pi = 3.1415926;
+  var f32 = new Float32Array(b);
+  var f64 = new Float64Array(b);
+  f32[0] = pi;
+  print(bufstr(b), f32.length);
+  f64[0] = pi;
+  print(bufstr(b), f64.length);
+  print(arrstr(u32), u32[0], u32[1]);
+
+  var d = new Int32Array(3);
+  d.set(i32,1);
+  print(bufstr(d));
+
+  var s = new Int16Array(b);
+  var t = new Uint16Array(b);
+  print(arrstr(s), arrstr(t));
+  s[0] = -1; s[1] = 0x80;
+  print(arrstr(s), arrstr(t));
+})();
+
+(function enumerate_properties() {
+  var i8 = new Int8Array(new ArrayBuffer(8));
+  var s = ""; for (var i in i8) { s += i + " "; } print(s.trim());
+})();
+
+// check that ScriptObject fallback is still working
+// DISABLED because correct behavior is unclear
+(function() {
+  // NB: firefox will never set any out-of-bounds or non-array values although it does get both from prototype.
+  var z = new Uint8Array(4);
+  z["asdf"] = "asdf"; print(z["asdf"]);
+  z[0x100000000] = "asdf"; print(z[0x100000000]);
+  z[-1] = "asdf"; print(z[-1]);
+
+  // v8 and nashorn disagree on out-of-bounds uint32 indices: v8 won't go to the prototype.
+  z[0xf0000000] = "asdf"; print(z[0xf0000000]);
+  z[0xffffffff] = "asdf"; print(z[0xffffffff]);
+  z[0x70000000] = "asdf"; print(z[0x70000000]);
+
+  // this will work in firefox and nashorn (not in v8).
+  Uint8Array.prototype[4] = "asdf"; print(z[4]);
+});
+
+(function test_exceptions() {
+  assertFail(function() { new Int32Array(new ArrayBuffer(7)); });
+  assertFail(function() { new Int32Array(new ArrayBuffer(8), 0, 4); });
+  assertFail(function() { new Int32Array(new ArrayBuffer(8),-1, 2); });
+  assertFail(function() { new Int32Array(new ArrayBuffer(8), 0,-1); });
+})();
+
+(function test_subarray() {
+  var x = fillArray(new Int8Array(8));
+  print(arrstr(x));
+  print("subarray(2,4)=" + arrstr(x.subarray(2, 4)), "subarray(-6,-4)=" + arrstr(x.subarray(-6, -4))); // negative index refers from the end of the array
+  print(arrstr(x.subarray(-10, -2))); // negative index clamped to 0
+  assertTrue(function(){ return arrstr(x.subarray(6, 4)) === ""; }); // negative length clamped to 0
+  print(arrstr(x.subarray(1,-1).subarray(1,-1)), arrstr(x.subarray(1,-1).subarray(1,-1).subarray(1,-1))); // subarray of subarray
+})();
+
+(function test_slice() {
+  var b = new ArrayBuffer(16);
+  fillArray(new Int8Array(b));
+  print(bufstr(b));
+  print("slice(4,8)=" + bufstr(b.slice(4, 8)), "slice(-8,-4)=" + bufstr(b.slice(-8, -4))); // negative index refers from the end of the array
+  print(bufstr(b.slice(-20, -4))); // negative index clamped to 0
+  assertTrue(function(){ return bufstr(b.slice(8, 4)) === ""; }); // negative length clamped to 0
+  print(arrstr(new Int16Array(b.slice(1,-1).slice(2,-1).slice(1,-2).slice(1,-1)))); // slice of slice
+})();
+
+(function test_clamped() {
+  var a = new Uint8ClampedArray(10);
+  a[0] = -17;       // clamped to 0
+  a[1] = 4711;      // clamped to 255
+  a[2] = 17.5;      // clamped to 18
+  a[3] = 16.5;      // clamped to 16
+  a[4] = 255.9;     // clamped to 255
+  a[5] = Infinity;  // clamped to 255
+  a[6] = -Infinity; // clamped to 0
+  a[7] = NaN;       // 0
+  assertTrue(function(){ return a[0] === 0 && a[1] === 255 && a[2] === 18 && a[3] === 16 && a[4] === 255 && a[5] === 255 && a[6] === 0 && a[7] === 0; });
+})();
+
+(function test_out_of_bounds() {
+  var a = new Int32Array(10);
+  a[10] = 10;
+  a[100] = 100;
+  a[1000] = 1000;
+  assertTrue(function(){ return isUndefined(a[10]) && isUndefined(a[11]) && isUndefined(a[100]) && isUndefined(a[123]) && isUndefined(a[1000]); });
+})();
+
--- a/nashorn/test/script/basic/NASHORN-377.js	Mon Nov 17 14:57:28 2014 +0300
+++ b/nashorn/test/script/basic/NASHORN-377.js	Mon Nov 17 14:36:15 2014 +0100
@@ -26,201 +26,8 @@
  *
  * @test
  * @run
+ * @littleendian
  */
 
-var types = [Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];
-
-//---------------------------------------------------------------------------
-// utility functions
-//---------------------------------------------------------------------------
-function tohex(d, w) {
-  var hex = Number(d).toString(16);
-  var pad = (w ? w : 8) - hex.length;
-  hex = "00000000".substr(0, pad) + hex;
-  return hex;
-}
-
-function arrstr(a, n, w) {
-  var s = "";
-  if (typeof n == "undefined") n = a.length;
-  if (typeof w == "undefined") w = a.constructor.BYTES_PER_ELEMENT * 2;
-  for (var i = 0; i < n; i++) {
-    s += tohex(a[i], w);
-  }
-  return s;
-}
-function bufstr(b) {
-  if (b.buffer !== undefined) {
-    b = b.buffer;
-  }
-  return arrstr(new Uint8Array(b));
-}
-
-function assertFail(f) {
-  try {
-    f();
-  } catch (e) {
-    //print(e);
-    return;
-  }
-  throw "assertion failed: expected exception";
-}
-
-function assertTrue(f) {
-  if (f() !== true) throw "assertion failed: " + f;
-}
-
-function isUndefined(x) {
-  return typeof x === "undefined";
-}
-
-function fillArray(a, start) {
-  if (typeof start == "undefined") start = 1;
-  for (var i = 0; i < a.length; i++) {
-    a[i] = i + start;
-  }
-  return a;
-}
-
-//---------------------------------------------------------------------------
-// tests
-//---------------------------------------------------------------------------
-(function() {
-  var b = new ArrayBuffer(8);
-  var i8 = new Int8Array(b);
-  print(i8.buffer.byteLength, b.byteLength, i8.buffer === b, b.length);
-  print(b, i8.buffer, i8);
-})();
-
-(function test_attributes() {
-  var b = new ArrayBuffer(8);
-  for (var i in types) {
-    var x = new types[i](b);
-    print(x.byteOffset, x.byteLength, x.length, x.constructor.BYTES_PER_ELEMENT);
-    assertTrue(function(){ return x.constructor === types[i] });
-  }
-})();
-
-(function() {
-  var b = new ArrayBuffer(8);
-  var i8 = new Int8Array(b);
-  fillArray(i8, 0x70);
-
-  var i8_2 = new Int8Array(b, 2);
-  var i8_2_4 = new Uint8Array(b, 2, 4);
-
-  i8_2_4[3] = 0x80;
-
-  print(arrstr(i8, 8, 2)  + " " + bufstr(i8));
-  print(arrstr(i8_2, 6)   + " " + i8_2.byteOffset   + " " + i8_2.byteLength);
-  print(arrstr(i8_2_4, 4) + " " + i8_2_4.byteOffset + " " + i8_2_4.byteLength);
-
-  var i8_1_5 = i8.subarray(1, 5);
-  i8_2_4.subarray(1, 5);
-  print(arrstr(i8_1_5, 4) + " " + i8_1_5.byteOffset + " " + i8_1_5.byteLength);
-
-  print(bufstr(b.slice(1,7)));
-})();
-
-(function() {
-  var b = new ArrayBuffer(8);
-  fillArray(new Int8Array(b), 0x70);
-  new Int8Array(b)[5] = 0x80;
-
-  var i32 = new Int32Array(b);
-  var u32 = new Uint32Array(b);
-  print(arrstr(i32), i32[0], i32[1]);
-  i32[1] = 0xfefdfcfb;
-  print(arrstr(i32), i32[0], i32[1]);
-  print(arrstr(u32), u32[0], u32[1]);
-
-  var pi = 3.1415926;
-  var f32 = new Float32Array(b);
-  var f64 = new Float64Array(b);
-  f32[0] = pi;
-  print(bufstr(b), f32.length);
-  f64[0] = pi;
-  print(bufstr(b), f64.length);
-  print(arrstr(u32), u32[0], u32[1]);
-
-  var d = new Int32Array(3);
-  d.set(i32,1);
-  print(bufstr(d));
-
-  var s = new Int16Array(b);
-  var t = new Uint16Array(b);
-  print(arrstr(s), arrstr(t));
-  s[0] = -1; s[1] = 0x80;
-  print(arrstr(s), arrstr(t));
-})();
-
-(function enumerate_properties() {
-  var i8 = new Int8Array(new ArrayBuffer(8));
-  var s = ""; for (var i in i8) { s += i + " "; } print(s.trim());
-})();
-
-// check that ScriptObject fallback is still working
-// DISABLED because correct behavior is unclear
-(function() {
-  // NB: firefox will never set any out-of-bounds or non-array values although it does get both from prototype.
-  var z = new Uint8Array(4);
-  z["asdf"] = "asdf"; print(z["asdf"]);
-  z[0x100000000] = "asdf"; print(z[0x100000000]);
-  z[-1] = "asdf"; print(z[-1]);
-
-  // v8 and nashorn disagree on out-of-bounds uint32 indices: v8 won't go to the prototype.
-  z[0xf0000000] = "asdf"; print(z[0xf0000000]);
-  z[0xffffffff] = "asdf"; print(z[0xffffffff]);
-  z[0x70000000] = "asdf"; print(z[0x70000000]);
-
-  // this will work in firefox and nashorn (not in v8).
-  Uint8Array.prototype[4] = "asdf"; print(z[4]);
-});
-
-(function test_exceptions() {
-  assertFail(function() { new Int32Array(new ArrayBuffer(7)); });
-  assertFail(function() { new Int32Array(new ArrayBuffer(8), 0, 4); });
-  assertFail(function() { new Int32Array(new ArrayBuffer(8),-1, 2); });
-  assertFail(function() { new Int32Array(new ArrayBuffer(8), 0,-1); });
-})();
-
-(function test_subarray() {
-  var x = fillArray(new Int8Array(8));
-  print(arrstr(x));
-  print("subarray(2,4)=" + arrstr(x.subarray(2, 4)), "subarray(-6,-4)=" + arrstr(x.subarray(-6, -4))); // negative index refers from the end of the array
-  print(arrstr(x.subarray(-10, -2))); // negative index clamped to 0
-  assertTrue(function(){ return arrstr(x.subarray(6, 4)) === ""; }); // negative length clamped to 0
-  print(arrstr(x.subarray(1,-1).subarray(1,-1)), arrstr(x.subarray(1,-1).subarray(1,-1).subarray(1,-1))); // subarray of subarray
-})();
-
-(function test_slice() {
-  var b = new ArrayBuffer(16);
-  fillArray(new Int8Array(b));
-  print(bufstr(b));
-  print("slice(4,8)=" + bufstr(b.slice(4, 8)), "slice(-8,-4)=" + bufstr(b.slice(-8, -4))); // negative index refers from the end of the array
-  print(bufstr(b.slice(-20, -4))); // negative index clamped to 0
-  assertTrue(function(){ return bufstr(b.slice(8, 4)) === ""; }); // negative length clamped to 0
-  print(arrstr(new Int16Array(b.slice(1,-1).slice(2,-1).slice(1,-2).slice(1,-1)))); // slice of slice
-})();
-
-(function test_clamped() {
-  var a = new Uint8ClampedArray(10);
-  a[0] = -17;       // clamped to 0
-  a[1] = 4711;      // clamped to 255
-  a[2] = 17.5;      // clamped to 18
-  a[3] = 16.5;      // clamped to 16
-  a[4] = 255.9;     // clamped to 255
-  a[5] = Infinity;  // clamped to 255
-  a[6] = -Infinity; // clamped to 0
-  a[7] = NaN;       // 0
-  assertTrue(function(){ return a[0] === 0 && a[1] === 255 && a[2] === 18 && a[3] === 16 && a[4] === 255 && a[5] === 255 && a[6] === 0 && a[7] === 0; });
-})();
-
-(function test_out_of_bounds() {
-  var a = new Int32Array(10);
-  a[10] = 10;
-  a[100] = 100;
-  a[1000] = 1000;
-  assertTrue(function(){ return isUndefined(a[10]) && isUndefined(a[11]) && isUndefined(a[100]) && isUndefined(a[123]) && isUndefined(a[1000]); });
-})();
-
+var dir = typeof(__DIR__) == 'undefined' ? "test/script/basic/" : __DIR__;
+load(dir + "NASHORN-377-payload.js");
--- a/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Mon Nov 17 14:57:28 2014 +0300
+++ b/nashorn/test/src/jdk/nashorn/internal/test/framework/TestFinder.java	Mon Nov 17 14:36:15 2014 +0100
@@ -46,6 +46,7 @@
 import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
+import java.nio.ByteOrder;
 import java.nio.file.FileSystem;
 import java.nio.file.FileSystems;
 import java.nio.file.FileVisitOption;
@@ -264,6 +265,12 @@
                     isTest = false;
                     isNotTest = true;
                     break;
+                case "@bigendian":
+                    shouldRun = ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
+                    break;
+                case "@littleendian":
+                    shouldRun = ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN;
+                    break;
                 case "@runif": {
                     final String prop = scanner.next();
                     if (System.getProperty(prop) != null) {