Upgrade to V8 3.3
Merge V8 at 3.3.10.39
Simple merge required updates to makefiles only.
Bug: 5688872
Change-Id: I14703f418235f5ce6013b9b3e2e502407a9f6dfd
diff --git a/test/mjsunit/external-array.js b/test/mjsunit/external-array.js
index 45d8be5..32b2c0c 100644
--- a/test/mjsunit/external-array.js
+++ b/test/mjsunit/external-array.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax
+// Flags: --allow-natives-syntax --expose-gc
// This is a regression test for overlapping key and value registers.
function f(a) {
@@ -43,15 +43,6 @@
assertEquals(0, a[0]);
assertEquals(0, a[1]);
-// Test the correct behavior of the |length| property (which is read-only).
-a = new Int32Array(42);
-assertEquals(42, a.length);
-a.length = 2;
-assertEquals(42, a.length);
-assertTrue(delete a.length);
-a.length = 2
-assertEquals(2, a.length);
-
// Test the correct behavior of the |BYTES_PER_ELEMENT| property (which is
// "constant", but not read-only).
a = new Int32Array(2);
@@ -63,3 +54,161 @@
a = new Int16Array(2);
assertEquals(2, a.BYTES_PER_ELEMENT);
+// Test Float64Arrays.
+function get(a, index) {
+ return a[index];
+}
+function set(a, index, value) {
+ a[index] = value;
+}
+function temp() {
+var array = new Float64Array(2);
+for (var i = 0; i < 5; i++) {
+ set(array, 0, 2.5);
+ assertEquals(2.5, array[0]);
+}
+%OptimizeFunctionOnNextCall(set);
+set(array, 0, 2.5);
+assertEquals(2.5, array[0]);
+set(array, 1, 3.5);
+assertEquals(3.5, array[1]);
+for (var i = 0; i < 5; i++) {
+ assertEquals(2.5, get(array, 0));
+ assertEquals(3.5, array[1]);
+}
+%OptimizeFunctionOnNextCall(get);
+assertEquals(2.5, get(array, 0));
+assertEquals(3.5, get(array, 1));
+}
+
+// Test loads and stores.
+types = [Array, Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array,
+ Uint32Array, PixelArray, Float32Array, Float64Array];
+
+test_result_nan = [NaN, 0, 0, 0, 0, 0, 0, 0, NaN, NaN];
+test_result_low_int = [-1, -1, 255, -1, 65535, -1, 0xFFFFFFFF, 0, -1, -1];
+test_result_middle = [253.75, -3, 253, 253, 253, 253, 253, 254, 253.75, 253.75];
+test_result_high_int = [256, 0, 0, 256, 256, 256, 256, 255, 256, 256];
+
+const kElementCount = 40;
+
+function test_load(array, sum) {
+ for (var i = 0; i < kElementCount; i++) {
+ sum += array[i];
+ }
+ return sum;
+}
+
+function test_load_const_key(array, sum) {
+ sum += array[0];
+ sum += array[1];
+ sum += array[2];
+ return sum;
+}
+
+function test_store(array, sum) {
+ for (var i = 0; i < kElementCount; i++) {
+ sum += array[i] = i+1;
+ }
+ return sum;
+}
+
+function test_store_const_key(array, sum) {
+ sum += array[0] = 1;
+ sum += array[1] = 2;
+ sum += array[2] = 3;
+ return sum;
+}
+
+
+function test_store_middle_double(array, sum) {
+ array[0] = 253.75;
+ return array[0];
+}
+
+
+function test_store_high_double(array, sum) {
+ array[0] = 256.25;
+ return array[0];
+}
+
+function test_store_high_double(array, sum) {
+ array[0] = 256.25;
+ return array[0];
+}
+
+function test_store_low_int(array, sum) {
+ array[0] = -1;
+ return array[0];
+}
+
+function test_store_high_int(array, sum) {
+ array[0] = 256;
+ return array[0];
+}
+
+function test_store_nan(array, sum) {
+ array[0] = NaN;
+ return array[0];
+}
+
+const kRuns = 10;
+
+function run_test(test_func, array, expected_result) {
+ for (var i = 0; i < 5; i++) test_func(array, 0);
+ %OptimizeFunctionOnNextCall(test_func);
+ var sum = 0;
+ for (var i = 0; i < kRuns; i++) {
+ sum = test_func(array, sum);
+ }
+ assertEquals(expected_result, sum);
+ %DeoptimizeFunction(test_func);
+ gc(); // Makes V8 forget about type information for test_func.
+}
+
+for (var t = 0; t < types.length; t++) {
+ var type = types[t];
+ print ("type = " + t);
+ var a = new type(kElementCount);
+ for (var i = 0; i < kElementCount; i++) {
+ a[i] = i;
+ }
+
+ // Run test functions defined above.
+ run_test(test_load, a, 780 * kRuns);
+ run_test(test_load_const_key, a, 3 * kRuns);
+ run_test(test_store, a, 820 * kRuns);
+ run_test(test_store_const_key, a, 6 * kRuns);
+ run_test(test_store_low_int, a, test_result_low_int[t]);
+ run_test(test_store_high_int, a, test_result_high_int[t]);
+ run_test(test_store_nan, a, test_result_nan[t]);
+ run_test(test_store_middle_double, a, test_result_middle[t]);
+
+ // Test the correct behavior of the |length| property (which is read-only).
+ if (t != 0) {
+ assertEquals(kElementCount, a.length);
+ a.length = 2;
+ assertEquals(kElementCount, a.length);
+ assertTrue(delete a.length);
+ a.length = 2;
+ assertEquals(2, a.length);
+ }
+
+ function array_load_set_smi_check(a) {
+ return a[0] = a[0] = 1;
+ }
+
+ array_load_set_smi_check(a);
+ array_load_set_smi_check(0);
+
+ function array_load_set_smi_check2(a) {
+ return a[0] = a[0] = 1;
+ }
+
+ array_load_set_smi_check2(a);
+ %OptimizeFunctionOnNextCall(array_load_set_smi_check2);
+ array_load_set_smi_check2(a);
+ array_load_set_smi_check2(0);
+ %DeoptimizeFunction(array_load_set_smi_check2);
+ gc(); // Makes V8 forget about type information for array_load_set_smi_check.
+}