From 4af7bf510c01d256ff44d77a975a98644f79d292 Mon Sep 17 00:00:00 2001 From: "kbr@chromium.org" Date: Mon, 30 Nov 2009 22:21:16 +0000 Subject: [PATCH] Reduced workload in external array test and added it back in. BUG=http://code.google.com/p/v8/issues/detail?id=534 Review URL: http://codereview.chromium.org/449022 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3386 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- test/cctest/test-api.cc | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index e0113c3..9eb135d 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -8083,6 +8083,85 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, result = CompileRun("ext_array[1] = 23;"); CHECK_EQ(23, result->Int32Value()); + // Test more complex manipulations which cause eax to contain values + // that won't be completely overwritten by loads from the arrays. + // This catches bugs in the instructions used for the KeyedLoadIC + // for byte and word types. + { + const int kXSize = 300; + const int kYSize = 300; + const int kLargeElementCount = kXSize * kYSize * 4; + ElementType* large_array_data = + static_cast(malloc(kLargeElementCount * element_size)); + i::Handle large_array = + i::Handle::cast( + i::Factory::NewExternalArray(kLargeElementCount, + array_type, + array_data)); + v8::Handle large_obj = v8::Object::New(); + // Set the elements to be the external array. + large_obj->SetIndexedPropertiesToExternalArrayData(large_array_data, + array_type, + kLargeElementCount); + context->Global()->Set(v8_str("large_array"), large_obj); + // Initialize contents of a few rows. + for (int x = 0; x < 300; x++) { + int row = 0; + int offset = row * 300 * 4; + large_array_data[offset + 4 * x + 0] = (ElementType) 127; + large_array_data[offset + 4 * x + 1] = (ElementType) 0; + large_array_data[offset + 4 * x + 2] = (ElementType) 0; + large_array_data[offset + 4 * x + 3] = (ElementType) 127; + row = 150; + offset = row * 300 * 4; + large_array_data[offset + 4 * x + 0] = (ElementType) 127; + large_array_data[offset + 4 * x + 1] = (ElementType) 0; + large_array_data[offset + 4 * x + 2] = (ElementType) 0; + large_array_data[offset + 4 * x + 3] = (ElementType) 127; + row = 298; + offset = row * 300 * 4; + large_array_data[offset + 4 * x + 0] = (ElementType) 127; + large_array_data[offset + 4 * x + 1] = (ElementType) 0; + large_array_data[offset + 4 * x + 2] = (ElementType) 0; + large_array_data[offset + 4 * x + 3] = (ElementType) 127; + } + // The goal of the code below is to make "offset" large enough + // that the computation of the index (which goes into eax) has + // high bits set which will not be overwritten by a byte or short + // load. + result = CompileRun("var failed = false;" + "var offset = 0;" + "for (var i = 0; i < 300; i++) {" + " if (large_array[4 * i] != 127 ||" + " large_array[4 * i + 1] != 0 ||" + " large_array[4 * i + 2] != 0 ||" + " large_array[4 * i + 3] != 127) {" + " failed = true;" + " }" + "}" + "offset = 150 * 300 * 4;" + "for (var i = 0; i < 300; i++) {" + " if (large_array[offset + 4 * i] != 127 ||" + " large_array[offset + 4 * i + 1] != 0 ||" + " large_array[offset + 4 * i + 2] != 0 ||" + " large_array[offset + 4 * i + 3] != 127) {" + " failed = true;" + " }" + "}" + "offset = 298 * 300 * 4;" + "for (var i = 0; i < 300; i++) {" + " if (large_array[offset + 4 * i] != 127 ||" + " large_array[offset + 4 * i + 1] != 0 ||" + " large_array[offset + 4 * i + 2] != 0 ||" + " large_array[offset + 4 * i + 3] != 127) {" + " failed = true;" + " }" + "}" + "!failed;"); + CHECK_EQ(true, result->BooleanValue()); + free(large_array_data); + } + free(array_data); } -- 2.7.4