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

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

Issue 6287030: Create specialized code stubs for PixelArray loads. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: review feedback Created 9 years, 10 months 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/stub-cache-x64.cc ('k') | test/mjsunit/regress/regress-900966.js » ('j') | 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 10346 matching lines...) Expand 10 before | Expand all | Expand 10 after
10357 10357
10358 // Test for index greater than 255. Regression test for: 10358 // Test for index greater than 255. Regression test for:
10359 // http://code.google.com/p/chromium/issues/detail?id=26337. 10359 // http://code.google.com/p/chromium/issues/detail?id=26337.
10360 result = CompileRun("pixels[256] = 255;"); 10360 result = CompileRun("pixels[256] = 255;");
10361 CHECK_EQ(255, result->Int32Value()); 10361 CHECK_EQ(255, result->Int32Value());
10362 result = CompileRun("var i = 0;" 10362 result = CompileRun("var i = 0;"
10363 "for (var j = 0; j < 8; j++) { i = pixels[256]; }" 10363 "for (var j = 0; j < 8; j++) { i = pixels[256]; }"
10364 "i"); 10364 "i");
10365 CHECK_EQ(255, result->Int32Value()); 10365 CHECK_EQ(255, result->Int32Value());
10366 10366
10367 // Make sure that pixel array ICs recognize when a non-pixel array
10368 // is passed to it.
10369 result = CompileRun("function pa_load(p) {"
10370 " var sum = 0;"
10371 " for (var j = 0; j < 256; j++) { sum += p[j]; }"
10372 " return sum;"
10373 "}"
10374 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }"
10375 "for (var i = 0; i < 10; ++i) { pa_load(pixels); }"
10376 "just_ints = new Object();"
10377 "for (var i = 0; i < 256; ++i) { just_ints[i] = i; }"
10378 "for (var i = 0; i < 10; ++i) {"
10379 " result = pa_load(just_ints);"
10380 "}"
10381 "result");
10382 CHECK_EQ(32640, result->Int32Value());
10383
10384 // Make sure that pixel array ICs recognize out-of-bound accesses.
10385 result = CompileRun("function pa_load(p, start) {"
10386 " var sum = 0;"
10387 " for (var j = start; j < 256; j++) { sum += p[j]; }"
10388 " return sum;"
10389 "}"
10390 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }"
10391 "for (var i = 0; i < 10; ++i) { pa_load(pixels,0); }"
10392 "for (var i = 0; i < 10; ++i) {"
10393 " result = pa_load(pixels,-10);"
10394 "}"
10395 "result");
10396 CHECK_EQ(0, result->Int32Value());
10397
10398 // Make sure that generic ICs properly handles a pixel array.
10399 result = CompileRun("function pa_load(p) {"
10400 " var sum = 0;"
10401 " for (var j = 0; j < 256; j++) { sum += p[j]; }"
10402 " return sum;"
10403 "}"
10404 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }"
10405 "just_ints = new Object();"
10406 "for (var i = 0; i < 256; ++i) { just_ints[i] = i; }"
10407 "for (var i = 0; i < 10; ++i) { pa_load(just_ints); }"
10408 "for (var i = 0; i < 10; ++i) {"
10409 " result = pa_load(pixels);"
10410 "}"
10411 "result");
10412 CHECK_EQ(32640, result->Int32Value());
10413
10414 // Make sure that generic load ICs recognize out-of-bound accesses in
10415 // pixel arrays.
10416 result = CompileRun("function pa_load(p, start) {"
10417 " var sum = 0;"
10418 " for (var j = start; j < 256; j++) { sum += p[j]; }"
10419 " return sum;"
10420 "}"
10421 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }"
10422 "just_ints = new Object();"
10423 "for (var i = 0; i < 256; ++i) { just_ints[i] = i; }"
10424 "for (var i = 0; i < 10; ++i) { pa_load(just_ints,0); }"
10425 "for (var i = 0; i < 10; ++i) { pa_load(pixels,0); }"
10426 "for (var i = 0; i < 10; ++i) {"
10427 " result = pa_load(pixels,-10);"
10428 "}"
10429 "result");
10430 CHECK_EQ(0, result->Int32Value());
10431
10432 // Make sure that generic ICs properly handles other types than pixel
10433 // arrays (that the inlined fast pixel array test leaves the right information
10434 // in the right registers).
10435 result = CompileRun("function pa_load(p) {"
10436 " var sum = 0;"
10437 " for (var j = 0; j < 256; j++) { sum += p[j]; }"
10438 " return sum;"
10439 "}"
10440 "for (var i = 0; i < 256; ++i) { pixels[i] = i; }"
10441 "just_ints = new Object();"
10442 "for (var i = 0; i < 256; ++i) { just_ints[i] = i; }"
10443 "for (var i = 0; i < 10; ++i) { pa_load(just_ints); }"
10444 "for (var i = 0; i < 10; ++i) { pa_load(pixels); }"
10445 "sparse_array = new Object();"
10446 "for (var i = 0; i < 256; ++i) { sparse_array[i] = i; }"
10447 "sparse_array[1000000] = 3;"
10448 "for (var i = 0; i < 10; ++i) {"
10449 " result = pa_load(sparse_array);"
10450 "}"
10451 "result");
10452 CHECK_EQ(32640, result->Int32Value());
10453
10367 free(pixel_data); 10454 free(pixel_data);
10368 } 10455 }
10369 10456
10370 10457
10371 THREADED_TEST(PixelArrayInfo) { 10458 THREADED_TEST(PixelArrayInfo) {
10372 v8::HandleScope scope; 10459 v8::HandleScope scope;
10373 LocalContext context; 10460 LocalContext context;
10374 for (int size = 0; size < 100; size += 10) { 10461 for (int size = 0; size < 100; size += 10) {
10375 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size)); 10462 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(size));
10376 v8::Handle<v8::Object> obj = v8::Object::New(); 10463 v8::Handle<v8::Object> obj = v8::Object::New();
(...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after
12232 v8::Context::Scope context_scope(context.local()); 12319 v8::Context::Scope context_scope(context.local());
12233 12320
12234 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New(); 12321 v8::Handle<v8::ObjectTemplate> tmpl = v8::ObjectTemplate::New();
12235 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator); 12322 tmpl->SetNamedPropertyHandler(Getter, NULL, NULL, NULL, Enumerator);
12236 context->Global()->Set(v8_str("o"), tmpl->NewInstance()); 12323 context->Global()->Set(v8_str("o"), tmpl->NewInstance());
12237 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun( 12324 v8::Handle<v8::Array> result = v8::Handle<v8::Array>::Cast(CompileRun(
12238 "var result = []; for (var k in o) result.push(k); result")); 12325 "var result = []; for (var k in o) result.push(k); result"));
12239 CHECK_EQ(1, result->Length()); 12326 CHECK_EQ(1, result->Length());
12240 CHECK_EQ(v8_str("universalAnswer"), result->Get(0)); 12327 CHECK_EQ(v8_str("universalAnswer"), result->Get(0));
12241 } 12328 }
OLDNEW
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | test/mjsunit/regress/regress-900966.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698