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 10656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10667 "for (var i = 0; i < 10; ++i) { pa_load(pixels); }" | 10667 "for (var i = 0; i < 10; ++i) { pa_load(pixels); }" |
10668 "sparse_array = new Object();" | 10668 "sparse_array = new Object();" |
10669 "for (var i = 0; i < 256; ++i) { sparse_array[i] = i; }" | 10669 "for (var i = 0; i < 256; ++i) { sparse_array[i] = i; }" |
10670 "sparse_array[1000000] = 3;" | 10670 "sparse_array[1000000] = 3;" |
10671 "for (var i = 0; i < 10; ++i) {" | 10671 "for (var i = 0; i < 10; ++i) {" |
10672 " result = pa_load(sparse_array);" | 10672 " result = pa_load(sparse_array);" |
10673 "}" | 10673 "}" |
10674 "result"); | 10674 "result"); |
10675 CHECK_EQ(32640, result->Int32Value()); | 10675 CHECK_EQ(32640, result->Int32Value()); |
10676 | 10676 |
| 10677 // Make sure that pixel array loads are optimized by crankshaft. |
| 10678 result = CompileRun("function pa_load(p) {" |
| 10679 " var sum = 0;" |
| 10680 " for (var i=0; i<256; ++i) {" |
| 10681 " sum += p[i];" |
| 10682 " }" |
| 10683 " return sum; " |
| 10684 "}" |
| 10685 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }" |
| 10686 "for (var i = 0; i < 10000; ++i) {" |
| 10687 " result = pa_load(pixels);" |
| 10688 "}" |
| 10689 "result"); |
| 10690 CHECK_EQ(32640, result->Int32Value()); |
| 10691 |
10677 free(pixel_data); | 10692 free(pixel_data); |
10678 } | 10693 } |
10679 | 10694 |
10680 | 10695 |
10681 THREADED_TEST(PixelArrayInfo) { | 10696 THREADED_TEST(PixelArrayInfo) { |
10682 v8::HandleScope scope; | 10697 v8::HandleScope scope; |
10683 LocalContext context; | 10698 LocalContext context; |
10684 for (int size = 0; size < 100; size += 10) { | 10699 for (int size = 0; size < 100; size += 10) { |
10685 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); | 10700 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); |
10686 v8::Handle<v8::Object> obj = v8::Object::New(); | 10701 v8::Handle<v8::Object> obj = v8::Object::New(); |
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12597 v8::Handle<v8::Function> define_property = | 12612 v8::Handle<v8::Function> define_property = |
12598 CompileRun("(function() {" | 12613 CompileRun("(function() {" |
12599 " Object.defineProperty(" | 12614 " Object.defineProperty(" |
12600 " this," | 12615 " this," |
12601 " 1," | 12616 " 1," |
12602 " { configurable: true, enumerable: true, value: 3 });" | 12617 " { configurable: true, enumerable: true, value: 3 });" |
12603 "})").As<Function>(); | 12618 "})").As<Function>(); |
12604 context->DetachGlobal(); | 12619 context->DetachGlobal(); |
12605 define_property->Call(proxy, 0, NULL); | 12620 define_property->Call(proxy, 0, NULL); |
12606 } | 12621 } |
OLD | NEW |