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

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

Issue 7060010: Merge bleeding edge into the GC branch up to 7948. The asserts (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: 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 | « test/mjsunit/execScript-case-insensitive.js ('k') | test/mjsunit/function-names.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/external-array.js
===================================================================
--- test/mjsunit/external-array.js (revision 7948)
+++ test/mjsunit/external-array.js (working copy)
@@ -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);
@@ -70,7 +61,7 @@
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);
@@ -88,3 +79,118 @@
%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);
+ }
+}
« no previous file with comments | « test/mjsunit/execScript-case-insensitive.js ('k') | test/mjsunit/function-names.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698