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

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

Issue 294022: Add optimized ICs for new CanvasArray types. This is a follow-on CL to... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 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/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 8179 matching lines...) Expand 10 before | Expand all | Expand 10 after
8190 " sum += tmp_array[i];" 8190 " sum += tmp_array[i];"
8191 " if (i == 4) {" 8191 " if (i == 4) {"
8192 " tmp_array = {};" 8192 " tmp_array = {};"
8193 " }" 8193 " }"
8194 "}" 8194 "}"
8195 "sum;"); 8195 "sum;");
8196 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification. 8196 i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
8197 CHECK_EQ(28, result->Int32Value()); 8197 CHECK_EQ(28, result->Int32Value());
8198 8198
8199 // Check out-of-range loads. 8199 // Check out-of-range loads.
8200 result = CompileRun("var caught_exception = false;"
8201 "try {"
8202 " ext_array[-1];"
8203 "} catch (e) {"
8204 " caught_exception = true;"
8205 "}"
8206 "caught_exception;");
8207 CHECK_EQ(true, result->BooleanValue());
8208
8209 i::OS::SNPrintF(test_buf, 8200 i::OS::SNPrintF(test_buf,
8210 "var caught_exception = false;" 8201 "var caught_exception = false;"
8211 "try {" 8202 "try {"
8212 " ext_array[%d];" 8203 " ext_array[%d];"
8213 "} catch (e) {" 8204 "} catch (e) {"
8214 " caught_exception = true;" 8205 " caught_exception = true;"
8215 "}" 8206 "}"
8216 "caught_exception;", 8207 "caught_exception;",
8217 kElementCount); 8208 kElementCount);
8218 result = CompileRun(test_buf.start()); 8209 result = CompileRun(test_buf.start());
8219 CHECK_EQ(true, result->BooleanValue()); 8210 CHECK_EQ(true, result->BooleanValue());
8220 8211
8221 // Check out-of-range stores. 8212 // Check out-of-range stores.
8222 result = CompileRun("var caught_exception = false;"
8223 "try {"
8224 " ext_array[-1] = 1;"
8225 "} catch (e) {"
8226 " caught_exception = true;"
8227 "}"
8228 "caught_exception;");
8229 CHECK_EQ(true, result->BooleanValue());
8230
8231 i::OS::SNPrintF(test_buf, 8213 i::OS::SNPrintF(test_buf,
8232 "var caught_exception = false;" 8214 "var caught_exception = false;"
8233 "try {" 8215 "try {"
8234 " ext_array[%d] = 1;" 8216 " ext_array[%d] = 1;"
8235 "} catch (e) {" 8217 "} catch (e) {"
8236 " caught_exception = true;" 8218 " caught_exception = true;"
8237 "}" 8219 "}"
8238 "caught_exception;", 8220 "caught_exception;",
8239 kElementCount); 8221 kElementCount);
8240 result = CompileRun(test_buf.start()); 8222 result = CompileRun(test_buf.start());
8241 CHECK_EQ(true, result->BooleanValue()); 8223 CHECK_EQ(true, result->BooleanValue());
8242 8224
8243 // TODO(kbr): check what happens during IC misses on the type of the object.
8244 // Re-assign array object halfway through a loop.
8245
8246 // Check other boundary conditions, values and operations. 8225 // Check other boundary conditions, values and operations.
8247 result = CompileRun("for (var i = 0; i < 8; i++) {" 8226 result = CompileRun("for (var i = 0; i < 8; i++) {"
8248 " ext_array[7] = undefined;" 8227 " ext_array[7] = undefined;"
8249 "}" 8228 "}"
8250 "ext_array[7];"); 8229 "ext_array[7];");
8251 CHECK_EQ(0, result->Int32Value()); 8230 CHECK_EQ(0, result->Int32Value());
8252 CHECK_EQ(0, static_cast<int>(jsobj->GetElement(7)->Number())); 8231 CHECK_EQ(0, static_cast<int>(jsobj->GetElement(7)->Number()));
8253 8232
8254 result = CompileRun("for (var i = 0; i < 8; i++) {" 8233 result = CompileRun("for (var i = 0; i < 8; i++) {"
8255 " ext_array[6] = '2.3';" 8234 " ext_array[6] = '2.3';"
8256 "}" 8235 "}"
8257 "ext_array[6];"); 8236 "ext_array[6];");
8258 CHECK_EQ(2, result->Int32Value()); 8237 CHECK_EQ(2, result->Int32Value());
8259 CHECK_EQ(2, static_cast<int>(jsobj->GetElement(6)->Number())); 8238 CHECK_EQ(2, static_cast<int>(jsobj->GetElement(6)->Number()));
8260 8239
8261 // Result for storing NaNs and +/-Infinity isn't defined for these 8240 if (array_type != v8::kExternalFloatArray) {
8262 // types; they do not have the clamping behavior CanvasPixelArray 8241 // Though the specification doesn't state it, be explicit about
8263 // specifies. 8242 // converting NaNs and +/-Infinity to zero.
8243 result = CompileRun("for (var i = 0; i < 8; i++) {"
8244 " ext_array[i] = 5;"
8245 "}"
8246 "for (var i = 0; i < 8; i++) {"
8247 " ext_array[i] = NaN;"
8248 "}"
8249 "ext_array[5];");
8250 CHECK_EQ(0, result->Int32Value());
8251 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(5))->value());
8252
8253 result = CompileRun("for (var i = 0; i < 8; i++) {"
8254 " ext_array[i] = 5;"
8255 "}"
8256 "for (var i = 0; i < 8; i++) {"
8257 " ext_array[i] = Infinity;"
8258 "}"
8259 "ext_array[5];");
8260 CHECK_EQ(0, result->Int32Value());
8261 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(5))->value());
8262
8263 result = CompileRun("for (var i = 0; i < 8; i++) {"
8264 " ext_array[i] = 5;"
8265 "}"
8266 "for (var i = 0; i < 8; i++) {"
8267 " ext_array[i] = -Infinity;"
8268 "}"
8269 "ext_array[5];");
8270 CHECK_EQ(0, result->Int32Value());
8271 CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(5))->value());
8272 }
8264 8273
8265 result = CompileRun("ext_array[3] = 33;" 8274 result = CompileRun("ext_array[3] = 33;"
8266 "delete ext_array[3];" 8275 "delete ext_array[3];"
8267 "ext_array[3];"); 8276 "ext_array[3];");
8268 CHECK_EQ(33, result->Int32Value()); 8277 CHECK_EQ(33, result->Int32Value());
8269 8278
8270 result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;" 8279 result = CompileRun("ext_array[0] = 10; ext_array[1] = 11;"
8271 "ext_array[2] = 12; ext_array[3] = 13;" 8280 "ext_array[2] = 12; ext_array[3] = 13;"
8272 "ext_array.__defineGetter__('2'," 8281 "ext_array.__defineGetter__('2',"
8273 "function() { return 120; });" 8282 "function() { return 120; });"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
8479 THREADED_TEST(GetHeapStatistics) { 8488 THREADED_TEST(GetHeapStatistics) {
8480 v8::HandleScope scope; 8489 v8::HandleScope scope;
8481 LocalContext c1; 8490 LocalContext c1;
8482 v8::HeapStatistics heap_statistics; 8491 v8::HeapStatistics heap_statistics;
8483 CHECK_EQ(heap_statistics.total_heap_size(), 0); 8492 CHECK_EQ(heap_statistics.total_heap_size(), 0);
8484 CHECK_EQ(heap_statistics.used_heap_size(), 0); 8493 CHECK_EQ(heap_statistics.used_heap_size(), 0);
8485 v8::V8::GetHeapStatistics(&heap_statistics); 8494 v8::V8::GetHeapStatistics(&heap_statistics);
8486 CHECK_NE(heap_statistics.total_heap_size(), 0); 8495 CHECK_NE(heap_statistics.total_heap_size(), 0);
8487 CHECK_NE(heap_statistics.used_heap_size(), 0); 8496 CHECK_NE(heap_statistics.used_heap_size(), 0);
8488 } 8497 }
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