| OLD | NEW |
| 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 10460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10471 context->DetachGlobal(); | 10471 context->DetachGlobal(); |
| 10472 CHECK_EQ(42, CompileRun("f(this).foo")->Int32Value()); | 10472 CHECK_EQ(42, CompileRun("f(this).foo")->Int32Value()); |
| 10473 } | 10473 } |
| 10474 | 10474 |
| 10475 | 10475 |
| 10476 THREADED_TEST(PixelArray) { | 10476 THREADED_TEST(PixelArray) { |
| 10477 v8::HandleScope scope; | 10477 v8::HandleScope scope; |
| 10478 LocalContext context; | 10478 LocalContext context; |
| 10479 const int kElementCount = 260; | 10479 const int kElementCount = 260; |
| 10480 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); | 10480 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); |
| 10481 i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount, | 10481 i::Handle<i::ExternalPixelArray> pixels = |
| 10482 pixel_data); | 10482 i::Factory::NewExternalPixelArray(kElementCount, pixel_data); |
| 10483 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. | 10483 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. |
| 10484 for (int i = 0; i < kElementCount; i++) { | 10484 for (int i = 0; i < kElementCount; i++) { |
| 10485 pixels->set(i, i % 256); | 10485 pixels->set(i, i % 256); |
| 10486 } | 10486 } |
| 10487 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. | 10487 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. |
| 10488 for (int i = 0; i < kElementCount; i++) { | 10488 for (int i = 0; i < kElementCount; i++) { |
| 10489 CHECK_EQ(i % 256, pixels->get(i)); | 10489 CHECK_EQ(i % 256, pixels->get(i)); |
| 10490 CHECK_EQ(i % 256, pixel_data[i]); | 10490 CHECK_EQ(i % 256, pixel_data[i]); |
| 10491 } | 10491 } |
| 10492 | 10492 |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10812 | 10812 |
| 10813 // Make sure that pixel array loads are optimized by crankshaft. | 10813 // Make sure that pixel array loads are optimized by crankshaft. |
| 10814 result = CompileRun("function pa_load(p) {" | 10814 result = CompileRun("function pa_load(p) {" |
| 10815 " var sum = 0;" | 10815 " var sum = 0;" |
| 10816 " for (var i=0; i<256; ++i) {" | 10816 " for (var i=0; i<256; ++i) {" |
| 10817 " sum += p[i];" | 10817 " sum += p[i];" |
| 10818 " }" | 10818 " }" |
| 10819 " return sum; " | 10819 " return sum; " |
| 10820 "}" | 10820 "}" |
| 10821 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }" | 10821 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }" |
| 10822 "for (var i = 0; i < 10000; ++i) {" | 10822 "for (var i = 0; i < 5000; ++i) {" |
| 10823 " result = pa_load(pixels);" | 10823 " result = pa_load(pixels);" |
| 10824 "}" | 10824 "}" |
| 10825 "result"); | 10825 "result"); |
| 10826 CHECK_EQ(32640, result->Int32Value()); | 10826 CHECK_EQ(32640, result->Int32Value()); |
| 10827 | 10827 |
| 10828 // Make sure that pixel array stores are optimized by crankshaft. | 10828 // Make sure that pixel array stores are optimized by crankshaft. |
| 10829 result = CompileRun("function pa_init(p) {" | 10829 result = CompileRun("function pa_init(p) {" |
| 10830 "for (var i = 0; i < 256; ++i) { p[i] = i; }" | 10830 "for (var i = 0; i < 256; ++i) { p[i] = i; }" |
| 10831 "}" | 10831 "}" |
| 10832 "function pa_load(p) {" | 10832 "function pa_load(p) {" |
| 10833 " var sum = 0;" | 10833 " var sum = 0;" |
| 10834 " for (var i=0; i<256; ++i) {" | 10834 " for (var i=0; i<256; ++i) {" |
| 10835 " sum += p[i];" | 10835 " sum += p[i];" |
| 10836 " }" | 10836 " }" |
| 10837 " return sum; " | 10837 " return sum; " |
| 10838 "}" | 10838 "}" |
| 10839 "for (var i = 0; i < 100000; ++i) {" | 10839 "for (var i = 0; i < 5000; ++i) {" |
| 10840 " pa_init(pixels);" | 10840 " pa_init(pixels);" |
| 10841 "}" | 10841 "}" |
| 10842 "result = pa_load(pixels);" | 10842 "result = pa_load(pixels);" |
| 10843 "result"); | 10843 "result"); |
| 10844 CHECK_EQ(32640, result->Int32Value()); | 10844 CHECK_EQ(32640, result->Int32Value()); |
| 10845 | 10845 |
| 10846 free(pixel_data); | 10846 free(pixel_data); |
| 10847 } | 10847 } |
| 10848 | 10848 |
| 10849 | 10849 |
| 10850 THREADED_TEST(PixelArrayInfo) { | 10850 THREADED_TEST(PixelArrayInfo) { |
| 10851 v8::HandleScope scope; | 10851 v8::HandleScope scope; |
| 10852 LocalContext context; | 10852 LocalContext context; |
| 10853 for (int size = 0; size < 100; size += 10) { | 10853 for (int size = 0; size < 100; size += 10) { |
| 10854 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); | 10854 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); |
| 10855 v8::Handle<v8::Object> obj = v8::Object::New(); | 10855 v8::Handle<v8::Object> obj = v8::Object::New(); |
| 10856 obj->SetIndexedPropertiesToPixelData(pixel_data, size); | 10856 obj->SetIndexedPropertiesToPixelData(pixel_data, size); |
| 10857 CHECK(obj->HasIndexedPropertiesInPixelData()); | 10857 CHECK(obj->HasIndexedPropertiesInPixelData()); |
| 10858 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); | 10858 CHECK_EQ(pixel_data, obj->GetIndexedPropertiesPixelData()); |
| 10859 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); | 10859 CHECK_EQ(size, obj->GetIndexedPropertiesPixelDataLength()); |
| 10860 free(pixel_data); | 10860 free(pixel_data); |
| 10861 } | 10861 } |
| 10862 } | 10862 } |
| 10863 | 10863 |
| 10864 | 10864 |
| 10865 static int ExternalArrayElementSize(v8::ExternalArrayType array_type) { | 10865 static int ExternalArrayElementSize(v8::ExternalArrayType array_type) { |
| 10866 switch (array_type) { | 10866 switch (array_type) { |
| 10867 case v8::kExternalByteArray: | 10867 case v8::kExternalByteArray: |
| 10868 case v8::kExternalUnsignedByteArray: | 10868 case v8::kExternalUnsignedByteArray: |
| 10869 case v8::kExternalPixelArray: |
| 10869 return 1; | 10870 return 1; |
| 10870 break; | 10871 break; |
| 10871 case v8::kExternalShortArray: | 10872 case v8::kExternalShortArray: |
| 10872 case v8::kExternalUnsignedShortArray: | 10873 case v8::kExternalUnsignedShortArray: |
| 10873 return 2; | 10874 return 2; |
| 10874 break; | 10875 break; |
| 10875 case v8::kExternalIntArray: | 10876 case v8::kExternalIntArray: |
| 10876 case v8::kExternalUnsignedIntArray: | 10877 case v8::kExternalUnsignedIntArray: |
| 10877 case v8::kExternalFloatArray: | 10878 case v8::kExternalFloatArray: |
| 10878 return 4; | 10879 return 4; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11249 | 11250 |
| 11250 | 11251 |
| 11251 THREADED_TEST(ExternalUnsignedByteArray) { | 11252 THREADED_TEST(ExternalUnsignedByteArray) { |
| 11252 ExternalArrayTestHelper<i::ExternalUnsignedByteArray, uint8_t>( | 11253 ExternalArrayTestHelper<i::ExternalUnsignedByteArray, uint8_t>( |
| 11253 v8::kExternalUnsignedByteArray, | 11254 v8::kExternalUnsignedByteArray, |
| 11254 0, | 11255 0, |
| 11255 255); | 11256 255); |
| 11256 } | 11257 } |
| 11257 | 11258 |
| 11258 | 11259 |
| 11260 THREADED_TEST(ExternalPixelArray) { |
| 11261 ExternalArrayTestHelper<i::ExternalPixelArray, uint8_t>( |
| 11262 v8::kExternalPixelArray, |
| 11263 0, |
| 11264 255); |
| 11265 } |
| 11266 |
| 11267 |
| 11259 THREADED_TEST(ExternalShortArray) { | 11268 THREADED_TEST(ExternalShortArray) { |
| 11260 ExternalArrayTestHelper<i::ExternalShortArray, int16_t>( | 11269 ExternalArrayTestHelper<i::ExternalShortArray, int16_t>( |
| 11261 v8::kExternalShortArray, | 11270 v8::kExternalShortArray, |
| 11262 -32768, | 11271 -32768, |
| 11263 32767); | 11272 32767); |
| 11264 } | 11273 } |
| 11265 | 11274 |
| 11266 | 11275 |
| 11267 THREADED_TEST(ExternalUnsignedShortArray) { | 11276 THREADED_TEST(ExternalUnsignedShortArray) { |
| 11268 ExternalArrayTestHelper<i::ExternalUnsignedShortArray, uint16_t>( | 11277 ExternalArrayTestHelper<i::ExternalUnsignedShortArray, uint16_t>( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11326 | 11335 |
| 11327 | 11336 |
| 11328 THREADED_TEST(ExternalArrayInfo) { | 11337 THREADED_TEST(ExternalArrayInfo) { |
| 11329 ExternalArrayInfoTestHelper(v8::kExternalByteArray); | 11338 ExternalArrayInfoTestHelper(v8::kExternalByteArray); |
| 11330 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); | 11339 ExternalArrayInfoTestHelper(v8::kExternalUnsignedByteArray); |
| 11331 ExternalArrayInfoTestHelper(v8::kExternalShortArray); | 11340 ExternalArrayInfoTestHelper(v8::kExternalShortArray); |
| 11332 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); | 11341 ExternalArrayInfoTestHelper(v8::kExternalUnsignedShortArray); |
| 11333 ExternalArrayInfoTestHelper(v8::kExternalIntArray); | 11342 ExternalArrayInfoTestHelper(v8::kExternalIntArray); |
| 11334 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); | 11343 ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray); |
| 11335 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); | 11344 ExternalArrayInfoTestHelper(v8::kExternalFloatArray); |
| 11345 ExternalArrayInfoTestHelper(v8::kExternalPixelArray); |
| 11336 } | 11346 } |
| 11337 | 11347 |
| 11338 | 11348 |
| 11339 THREADED_TEST(ScriptContextDependence) { | 11349 THREADED_TEST(ScriptContextDependence) { |
| 11340 v8::HandleScope scope; | 11350 v8::HandleScope scope; |
| 11341 LocalContext c1; | 11351 LocalContext c1; |
| 11342 const char *source = "foo"; | 11352 const char *source = "foo"; |
| 11343 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); | 11353 v8::Handle<v8::Script> dep = v8::Script::Compile(v8::String::New(source)); |
| 11344 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); | 11354 v8::Handle<v8::Script> indep = v8::Script::New(v8::String::New(source)); |
| 11345 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100)); | 11355 c1->Global()->Set(v8::String::New("foo"), v8::Integer::New(100)); |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12766 v8::Handle<v8::Function> define_property = | 12776 v8::Handle<v8::Function> define_property = |
| 12767 CompileRun("(function() {" | 12777 CompileRun("(function() {" |
| 12768 " Object.defineProperty(" | 12778 " Object.defineProperty(" |
| 12769 " this," | 12779 " this," |
| 12770 " 1," | 12780 " 1," |
| 12771 " { configurable: true, enumerable: true, value: 3 });" | 12781 " { configurable: true, enumerable: true, value: 3 });" |
| 12772 "})").As<Function>(); | 12782 "})").As<Function>(); |
| 12773 context->DetachGlobal(); | 12783 context->DetachGlobal(); |
| 12774 define_property->Call(proxy, 0, NULL); | 12784 define_property->Call(proxy, 0, NULL); |
| 12775 } | 12785 } |
| OLD | NEW |