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

Side by Side Diff: test/cctest/test-api.cc

Issue 405016: Push pixel array fix in bleeding_edge revision 3328 to 1.3 branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/1.3/
Patch Set: Created 11 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/ic-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 7866 matching lines...) Expand 10 before | Expand all | Expand 10 after
7877 // global object (not the proxy), and make sure that the dictionary 7877 // global object (not the proxy), and make sure that the dictionary
7878 // load IC doesn't mess up loading directly from the global object. 7878 // load IC doesn't mess up loading directly from the global object.
7879 context->DetachGlobal(); 7879 context->DetachGlobal();
7880 CHECK_EQ(42, CompileRun("f(this).foo")->Int32Value()); 7880 CHECK_EQ(42, CompileRun("f(this).foo")->Int32Value());
7881 } 7881 }
7882 7882
7883 7883
7884 THREADED_TEST(PixelArray) { 7884 THREADED_TEST(PixelArray) {
7885 v8::HandleScope scope; 7885 v8::HandleScope scope;
7886 LocalContext context; 7886 LocalContext context;
7887 const int kElementCount = 40; 7887 const int kElementCount = 260;
7888 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); 7888 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
7889 i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount, 7889 i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount,
7890 pixel_data); 7890 pixel_data);
7891 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. 7891 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
7892 for (int i = 0; i < kElementCount; i++) { 7892 for (int i = 0; i < kElementCount; i++) {
7893 pixels->set(i, i); 7893 pixels->set(i, i % 256);
7894 } 7894 }
7895 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. 7895 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
7896 for (int i = 0; i < kElementCount; i++) { 7896 for (int i = 0; i < kElementCount; i++) {
7897 CHECK_EQ(i, pixels->get(i)); 7897 CHECK_EQ(i % 256, pixels->get(i));
7898 CHECK_EQ(i, pixel_data[i]); 7898 CHECK_EQ(i % 256, pixel_data[i]);
7899 } 7899 }
7900 7900
7901 v8::Handle<v8::Object> obj = v8::Object::New(); 7901 v8::Handle<v8::Object> obj = v8::Object::New();
7902 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); 7902 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj);
7903 // Set the elements to be the pixels. 7903 // Set the elements to be the pixels.
7904 // jsobj->set_elements(*pixels); 7904 // jsobj->set_elements(*pixels);
7905 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); 7905 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount);
7906 CHECK_EQ(1, i::Smi::cast(jsobj->GetElement(1))->value()); 7906 CHECK_EQ(1, i::Smi::cast(jsobj->GetElement(1))->value());
7907 obj->Set(v8_str("field"), v8::Int32::New(1503)); 7907 obj->Set(v8_str("field"), v8::Int32::New(1503));
7908 context->Global()->Set(v8_str("pixels"), obj); 7908 context->Global()->Set(v8_str("pixels"), obj);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
8052 result = CompileRun("pixels[1] = 23;" 8052 result = CompileRun("pixels[1] = 23;"
8053 "pixels.__proto__ = [];" 8053 "pixels.__proto__ = [];"
8054 "js_array.__proto__ = pixels;" 8054 "js_array.__proto__ = pixels;"
8055 "js_array.concat(pixels);"); 8055 "js_array.concat(pixels);");
8056 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value()); 8056 CHECK_EQ(77, v8::Object::Cast(*result)->Get(v8_str("0"))->Int32Value());
8057 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value()); 8057 CHECK_EQ(23, v8::Object::Cast(*result)->Get(v8_str("1"))->Int32Value());
8058 8058
8059 result = CompileRun("pixels[1] = 23;"); 8059 result = CompileRun("pixels[1] = 23;");
8060 CHECK_EQ(23, result->Int32Value()); 8060 CHECK_EQ(23, result->Int32Value());
8061 8061
8062 // Test for index greater than 255. Regression test for:
8063 // http://code.google.com/p/chromium/issues/detail?id=26337.
8064 result = CompileRun("pixels[256] = 255;");
8065 CHECK_EQ(255, result->Int32Value());
8066 result = CompileRun("var i = 0;"
8067 "for (var j = 0; j < 8; j++) { i = pixels[256]; }"
8068 "i");
8069 CHECK_EQ(255, result->Int32Value());
8070
8062 free(pixel_data); 8071 free(pixel_data);
8063 } 8072 }
8064 8073
8065 8074
8066 template <class ExternalArrayClass, class ElementType> 8075 template <class ExternalArrayClass, class ElementType>
8067 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type, 8076 static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
8068 int64_t low, 8077 int64_t low,
8069 int64_t high) { 8078 int64_t high) {
8070 v8::HandleScope scope; 8079 v8::HandleScope scope;
8071 LocalContext context; 8080 LocalContext context;
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
8662 " i++;" 8671 " i++;"
8663 " return s(o);" 8672 " return s(o);"
8664 " }" 8673 " }"
8665 " }" 8674 " }"
8666 "};" 8675 "};"
8667 "s(o);"); 8676 "s(o);");
8668 CHECK(try_catch.HasCaught()); 8677 CHECK(try_catch.HasCaught());
8669 v8::String::Utf8Value value(try_catch.Exception()); 8678 v8::String::Utf8Value value(try_catch.Exception());
8670 CHECK_EQ(0, strcmp(*value, "Hey!")); 8679 CHECK_EQ(0, strcmp(*value, "Hey!"));
8671 } 8680 }
OLDNEW
« no previous file with comments | « src/x64/ic-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698