Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: test/mjsunit/external-array.js

Issue 7014033: Support conversion of clamped double values for pixel arrays in Crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/external-array.js
diff --git a/test/mjsunit/external-array.js b/test/mjsunit/external-array.js
index f03f5799fa4d6c2ccd18a1fa6dec62b48b6d8a21..3847d595fcc4d3a98bdf745eead0d393877d95de 100644
--- a/test/mjsunit/external-array.js
+++ b/test/mjsunit/external-array.js
@@ -61,7 +61,7 @@ function get(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);
@@ -79,11 +79,17 @@ for (var i = 0; i < 5; i++) {
%OptimizeFunctionOnNextCall(get);
assertEquals(2.5, get(array, 0));
assertEquals(3.5, get(array, 1));
+}
// Test loads and stores.
-types = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array,
+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) {
@@ -114,37 +120,77 @@ function test_store_const_key(array, sum) {
return sum;
}
-function run_test(test_func, array, expected_sum_per_run) {
+
+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);
- const kRuns = 10;
var sum = 0;
for (var i = 0; i < kRuns; i++) {
sum = test_func(array, sum);
}
- assertEquals(sum, expected_sum_per_run * kRuns);
+ 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);
- run_test(test_load_const_key, a, 3);
- run_test(test_store, a, 820);
- run_test(test_store_const_key, a, 6);
-
+ 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).
- assertEquals(kElementCount, a.length);
- a.length = 2;
- assertEquals(kElementCount, a.length);
- assertTrue(delete a.length);
- a.length = 2
- assertEquals(2, a.length);
+ 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);
+ }
}
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698