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

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

Issue 668060: Don't use strcmp to test heap object pointer equality. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 9 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 | « no previous file | 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-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 const int kSmallStringSize = 474 const int kSmallStringSize =
475 SeqAsciiString::kHeaderSize + kSmallStringLength; 475 SeqAsciiString::kHeaderSize + kSmallStringLength;
476 const int kMapSize = Map::kSize; 476 const int kMapSize = Map::kSize;
477 477
478 Object* new_last = NULL; 478 Object* new_last = NULL;
479 for (int i = 0; 479 for (int i = 0;
480 i + kSmallFixedArraySize <= new_space_size; 480 i + kSmallFixedArraySize <= new_space_size;
481 i += kSmallFixedArraySize) { 481 i += kSmallFixedArraySize) {
482 Object* obj = Heap::AllocateFixedArray(kSmallFixedArrayLength); 482 Object* obj = Heap::AllocateFixedArray(kSmallFixedArrayLength);
483 if (new_last != NULL) { 483 if (new_last != NULL) {
484 CHECK_EQ(reinterpret_cast<char*>(obj), 484 CHECK(reinterpret_cast<char*>(obj) ==
485 reinterpret_cast<char*>(new_last) + kSmallFixedArraySize); 485 reinterpret_cast<char*>(new_last) + kSmallFixedArraySize);
486 } 486 }
487 new_last = obj; 487 new_last = obj;
488 } 488 }
489 489
490 Object* pointer_last = NULL; 490 Object* pointer_last = NULL;
491 for (int i = 0; 491 for (int i = 0;
492 i + kSmallFixedArraySize <= size; 492 i + kSmallFixedArraySize <= size;
493 i += kSmallFixedArraySize) { 493 i += kSmallFixedArraySize) {
494 Object* obj = Heap::AllocateFixedArray(kSmallFixedArrayLength, TENURED); 494 Object* obj = Heap::AllocateFixedArray(kSmallFixedArrayLength, TENURED);
495 int old_page_fullness = i % Page::kPageSize; 495 int old_page_fullness = i % Page::kPageSize;
496 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; 496 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize;
497 if (page_fullness < old_page_fullness || 497 if (page_fullness < old_page_fullness ||
498 page_fullness > Page::kObjectAreaSize) { 498 page_fullness > Page::kObjectAreaSize) {
499 i = RoundUp(i, Page::kPageSize); 499 i = RoundUp(i, Page::kPageSize);
500 pointer_last = NULL; 500 pointer_last = NULL;
501 } 501 }
502 if (pointer_last != NULL) { 502 if (pointer_last != NULL) {
503 CHECK_EQ(reinterpret_cast<char*>(obj), 503 CHECK(reinterpret_cast<char*>(obj) ==
504 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize); 504 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize);
505 } 505 }
506 pointer_last = obj; 506 pointer_last = obj;
507 } 507 }
508 508
509 Object* data_last = NULL; 509 Object* data_last = NULL;
510 for (int i = 0; i + kSmallStringSize <= size; i += kSmallStringSize) { 510 for (int i = 0; i + kSmallStringSize <= size; i += kSmallStringSize) {
511 Object* obj = Heap::AllocateRawAsciiString(kSmallStringLength, TENURED); 511 Object* obj = Heap::AllocateRawAsciiString(kSmallStringLength, TENURED);
512 int old_page_fullness = i % Page::kPageSize; 512 int old_page_fullness = i % Page::kPageSize;
513 int page_fullness = (i + kSmallStringSize) % Page::kPageSize; 513 int page_fullness = (i + kSmallStringSize) % Page::kPageSize;
514 if (page_fullness < old_page_fullness || 514 if (page_fullness < old_page_fullness ||
515 page_fullness > Page::kObjectAreaSize) { 515 page_fullness > Page::kObjectAreaSize) {
516 i = RoundUp(i, Page::kPageSize); 516 i = RoundUp(i, Page::kPageSize);
517 data_last = NULL; 517 data_last = NULL;
518 } 518 }
519 if (data_last != NULL) { 519 if (data_last != NULL) {
520 CHECK_EQ(reinterpret_cast<char*>(obj), 520 CHECK(reinterpret_cast<char*>(obj) ==
521 reinterpret_cast<char*>(data_last) + kSmallStringSize); 521 reinterpret_cast<char*>(data_last) + kSmallStringSize);
522 } 522 }
523 data_last = obj; 523 data_last = obj;
524 } 524 }
525 525
526 Object* map_last = NULL; 526 Object* map_last = NULL;
527 for (int i = 0; i + kMapSize <= size; i += kMapSize) { 527 for (int i = 0; i + kMapSize <= size; i += kMapSize) {
528 Object* obj = Heap::AllocateMap(JS_OBJECT_TYPE, 42 * kPointerSize); 528 Object* obj = Heap::AllocateMap(JS_OBJECT_TYPE, 42 * kPointerSize);
529 int old_page_fullness = i % Page::kPageSize; 529 int old_page_fullness = i % Page::kPageSize;
530 int page_fullness = (i + kMapSize) % Page::kPageSize; 530 int page_fullness = (i + kMapSize) % Page::kPageSize;
531 if (page_fullness < old_page_fullness || 531 if (page_fullness < old_page_fullness ||
532 page_fullness > Page::kObjectAreaSize) { 532 page_fullness > Page::kObjectAreaSize) {
533 i = RoundUp(i, Page::kPageSize); 533 i = RoundUp(i, Page::kPageSize);
534 map_last = NULL; 534 map_last = NULL;
535 } 535 }
536 if (map_last != NULL) { 536 if (map_last != NULL) {
537 CHECK_EQ(reinterpret_cast<char*>(obj), 537 CHECK(reinterpret_cast<char*>(obj) ==
538 reinterpret_cast<char*>(map_last) + kMapSize); 538 reinterpret_cast<char*>(map_last) + kMapSize);
539 } 539 }
540 map_last = obj; 540 map_last = obj;
541 } 541 }
542 542
543 if (size > Page::kObjectAreaSize) { 543 if (size > Page::kObjectAreaSize) {
544 // Support for reserving space in large object space is not there yet, 544 // Support for reserving space in large object space is not there yet,
545 // but using an always-allocate scope is fine for now. 545 // but using an always-allocate scope is fine for now.
546 AlwaysAllocateScope always; 546 AlwaysAllocateScope always;
547 int large_object_array_length = 547 int large_object_array_length =
548 (size - FixedArray::kHeaderSize) / kPointerSize; 548 (size - FixedArray::kHeaderSize) / kPointerSize;
(...skipping 12 matching lines...) Expand all
561 TEST(TestThatAlwaysFails) { 561 TEST(TestThatAlwaysFails) {
562 bool ArtificialFailure = false; 562 bool ArtificialFailure = false;
563 CHECK(ArtificialFailure); 563 CHECK(ArtificialFailure);
564 } 564 }
565 565
566 566
567 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { 567 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
568 bool ArtificialFailure2 = false; 568 bool ArtificialFailure2 = false;
569 CHECK(ArtificialFailure2); 569 CHECK(ArtificialFailure2);
570 } 570 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698