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 10772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10783 " }" | 10783 " }" |
10784 " return sum; " | 10784 " return sum; " |
10785 "}" | 10785 "}" |
10786 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }" | 10786 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }" |
10787 "for (var i = 0; i < 10000; ++i) {" | 10787 "for (var i = 0; i < 10000; ++i) {" |
10788 " result = pa_load(pixels);" | 10788 " result = pa_load(pixels);" |
10789 "}" | 10789 "}" |
10790 "result"); | 10790 "result"); |
10791 CHECK_EQ(32640, result->Int32Value()); | 10791 CHECK_EQ(32640, result->Int32Value()); |
10792 | 10792 |
| 10793 // Make sure that pixel array stores are optimized by crankshaft. |
| 10794 result = CompileRun("function pa_init(p) {" |
| 10795 "for (var i = 0; i < 256; ++i) { p[i] = i; }" |
| 10796 "}" |
| 10797 "function pa_load(p) {" |
| 10798 " var sum = 0;" |
| 10799 " for (var i=0; i<256; ++i) {" |
| 10800 " sum += p[i];" |
| 10801 " }" |
| 10802 " return sum; " |
| 10803 "}" |
| 10804 "for (var i = 0; i < 100000; ++i) {" |
| 10805 " pa_init(pixels);" |
| 10806 "}" |
| 10807 "result = pa_load(pixels);" |
| 10808 "result"); |
| 10809 CHECK_EQ(32640, result->Int32Value()); |
| 10810 |
10793 free(pixel_data); | 10811 free(pixel_data); |
10794 } | 10812 } |
10795 | 10813 |
10796 | 10814 |
10797 THREADED_TEST(PixelArrayInfo) { | 10815 THREADED_TEST(PixelArrayInfo) { |
10798 v8::HandleScope scope; | 10816 v8::HandleScope scope; |
10799 LocalContext context; | 10817 LocalContext context; |
10800 for (int size = 0; size < 100; size += 10) { | 10818 for (int size = 0; size < 100; size += 10) { |
10801 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); | 10819 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); |
10802 v8::Handle<v8::Object> obj = v8::Object::New(); | 10820 v8::Handle<v8::Object> obj = v8::Object::New(); |
(...skipping 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12713 v8::Handle<v8::Function> define_property = | 12731 v8::Handle<v8::Function> define_property = |
12714 CompileRun("(function() {" | 12732 CompileRun("(function() {" |
12715 " Object.defineProperty(" | 12733 " Object.defineProperty(" |
12716 " this," | 12734 " this," |
12717 " 1," | 12735 " 1," |
12718 " { configurable: true, enumerable: true, value: 3 });" | 12736 " { configurable: true, enumerable: true, value: 3 });" |
12719 "})").As<Function>(); | 12737 "})").As<Function>(); |
12720 context->DetachGlobal(); | 12738 context->DetachGlobal(); |
12721 define_property->Call(proxy, 0, NULL); | 12739 define_property->Call(proxy, 0, NULL); |
12722 } | 12740 } |
OLD | NEW |