OLD | NEW |
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 } | 189 } |
190 virtual int Position() { | 190 virtual int Position() { |
191 return ftell(fp_); | 191 return ftell(fp_); |
192 } | 192 } |
193 void WriteSpaceUsed( | 193 void WriteSpaceUsed( |
194 int new_space_used, | 194 int new_space_used, |
195 int pointer_space_used, | 195 int pointer_space_used, |
196 int data_space_used, | 196 int data_space_used, |
197 int code_space_used, | 197 int code_space_used, |
198 int map_space_used, | 198 int map_space_used, |
199 int cell_space_used); | 199 int cell_space_used, |
| 200 int large_space_used); |
200 | 201 |
201 private: | 202 private: |
202 FILE* fp_; | 203 FILE* fp_; |
203 const char* file_name_; | 204 const char* file_name_; |
204 }; | 205 }; |
205 | 206 |
206 | 207 |
207 void FileByteSink::WriteSpaceUsed( | 208 void FileByteSink::WriteSpaceUsed( |
208 int new_space_used, | 209 int new_space_used, |
209 int pointer_space_used, | 210 int pointer_space_used, |
210 int data_space_used, | 211 int data_space_used, |
211 int code_space_used, | 212 int code_space_used, |
212 int map_space_used, | 213 int map_space_used, |
213 int cell_space_used) { | 214 int cell_space_used, |
| 215 int large_space_used) { |
214 int file_name_length = StrLength(file_name_) + 10; | 216 int file_name_length = StrLength(file_name_) + 10; |
215 Vector<char> name = Vector<char>::New(file_name_length + 1); | 217 Vector<char> name = Vector<char>::New(file_name_length + 1); |
216 OS::SNPrintF(name, "%s.size", file_name_); | 218 OS::SNPrintF(name, "%s.size", file_name_); |
217 FILE* fp = OS::FOpen(name.start(), "w"); | 219 FILE* fp = OS::FOpen(name.start(), "w"); |
218 name.Dispose(); | 220 name.Dispose(); |
219 fprintf(fp, "new %d\n", new_space_used); | 221 fprintf(fp, "new %d\n", new_space_used); |
220 fprintf(fp, "pointer %d\n", pointer_space_used); | 222 fprintf(fp, "pointer %d\n", pointer_space_used); |
221 fprintf(fp, "data %d\n", data_space_used); | 223 fprintf(fp, "data %d\n", data_space_used); |
222 fprintf(fp, "code %d\n", code_space_used); | 224 fprintf(fp, "code %d\n", code_space_used); |
223 fprintf(fp, "map %d\n", map_space_used); | 225 fprintf(fp, "map %d\n", map_space_used); |
224 fprintf(fp, "cell %d\n", cell_space_used); | 226 fprintf(fp, "cell %d\n", cell_space_used); |
| 227 fprintf(fp, "large %d\n", large_space_used); |
225 fclose(fp); | 228 fclose(fp); |
226 } | 229 } |
227 | 230 |
228 | 231 |
229 static bool WriteToFile(const char* snapshot_file) { | 232 static bool WriteToFile(const char* snapshot_file) { |
230 FileByteSink file(snapshot_file); | 233 FileByteSink file(snapshot_file); |
231 StartupSerializer ser(&file); | 234 StartupSerializer ser(&file); |
232 ser.Serialize(); | 235 ser.Serialize(); |
233 | |
234 file.WriteSpaceUsed( | |
235 ser.CurrentAllocationAddress(NEW_SPACE), | |
236 ser.CurrentAllocationAddress(OLD_POINTER_SPACE), | |
237 ser.CurrentAllocationAddress(OLD_DATA_SPACE), | |
238 ser.CurrentAllocationAddress(CODE_SPACE), | |
239 ser.CurrentAllocationAddress(MAP_SPACE), | |
240 ser.CurrentAllocationAddress(CELL_SPACE)); | |
241 | |
242 return true; | 236 return true; |
243 } | 237 } |
244 | 238 |
245 | 239 |
246 static void Serialize() { | 240 static void Serialize() { |
247 // We have to create one context. One reason for this is so that the builtins | 241 // We have to create one context. One reason for this is so that the builtins |
248 // can be loaded from v8natives.js and their addresses can be processed. This | 242 // can be loaded from v8natives.js and their addresses can be processed. This |
249 // will clear the pending fixups array, which would otherwise contain GC roots | 243 // will clear the pending fixups array, which would otherwise contain GC roots |
250 // that would confuse the serialization/deserialization process. | 244 // that would confuse the serialization/deserialization process. |
251 v8::Persistent<v8::Context> env = v8::Context::New(); | 245 v8::Persistent<v8::Context> env = v8::Context::New(); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 } | 377 } |
384 | 378 |
385 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 379 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
386 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 380 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
387 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 381 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
388 | 382 |
389 env->Exit(); | 383 env->Exit(); |
390 env.Dispose(); | 384 env.Dispose(); |
391 | 385 |
392 FileByteSink startup_sink(startup_name.start()); | 386 FileByteSink startup_sink(startup_name.start()); |
| 387 startup_name.Dispose(); |
393 StartupSerializer startup_serializer(&startup_sink); | 388 StartupSerializer startup_serializer(&startup_sink); |
394 startup_serializer.SerializeStrongReferences(); | 389 startup_serializer.SerializeStrongReferences(); |
395 | 390 |
396 FileByteSink partial_sink(FLAG_testing_serialization_file); | 391 FileByteSink partial_sink(FLAG_testing_serialization_file); |
397 PartialSerializer p_ser(&startup_serializer, &partial_sink); | 392 PartialSerializer p_ser(&startup_serializer, &partial_sink); |
398 p_ser.Serialize(&raw_foo); | 393 p_ser.Serialize(&raw_foo); |
399 startup_serializer.SerializeWeakReferences(); | 394 startup_serializer.SerializeWeakReferences(); |
400 | |
401 partial_sink.WriteSpaceUsed( | 395 partial_sink.WriteSpaceUsed( |
402 p_ser.CurrentAllocationAddress(NEW_SPACE), | 396 p_ser.CurrentAllocationAddress(NEW_SPACE), |
403 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), | 397 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), |
404 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), | 398 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), |
405 p_ser.CurrentAllocationAddress(CODE_SPACE), | 399 p_ser.CurrentAllocationAddress(CODE_SPACE), |
406 p_ser.CurrentAllocationAddress(MAP_SPACE), | 400 p_ser.CurrentAllocationAddress(MAP_SPACE), |
407 p_ser.CurrentAllocationAddress(CELL_SPACE)); | 401 p_ser.CurrentAllocationAddress(CELL_SPACE), |
408 | 402 p_ser.CurrentAllocationAddress(LO_SPACE)); |
409 startup_sink.WriteSpaceUsed( | |
410 startup_serializer.CurrentAllocationAddress(NEW_SPACE), | |
411 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), | |
412 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), | |
413 startup_serializer.CurrentAllocationAddress(CODE_SPACE), | |
414 startup_serializer.CurrentAllocationAddress(MAP_SPACE), | |
415 startup_serializer.CurrentAllocationAddress(CELL_SPACE)); | |
416 startup_name.Dispose(); | |
417 } | 403 } |
418 } | 404 } |
419 | 405 |
420 | 406 |
421 static void ReserveSpaceForSnapshot(Deserializer* deserializer, | 407 static void ReserveSpaceForPartialSnapshot(const char* file_name) { |
422 const char* file_name) { | |
423 int file_name_length = StrLength(file_name) + 10; | 408 int file_name_length = StrLength(file_name) + 10; |
424 Vector<char> name = Vector<char>::New(file_name_length + 1); | 409 Vector<char> name = Vector<char>::New(file_name_length + 1); |
425 OS::SNPrintF(name, "%s.size", file_name); | 410 OS::SNPrintF(name, "%s.size", file_name); |
426 FILE* fp = OS::FOpen(name.start(), "r"); | 411 FILE* fp = OS::FOpen(name.start(), "r"); |
427 name.Dispose(); | 412 name.Dispose(); |
428 int new_size, pointer_size, data_size, code_size, map_size, cell_size; | 413 int new_size, pointer_size, data_size, code_size, map_size, cell_size; |
| 414 int large_size; |
429 #ifdef _MSC_VER | 415 #ifdef _MSC_VER |
430 // Avoid warning about unsafe fscanf from MSVC. | 416 // Avoid warning about unsafe fscanf from MSVC. |
431 // Please note that this is only fine if %c and %s are not being used. | 417 // Please note that this is only fine if %c and %s are not being used. |
432 #define fscanf fscanf_s | 418 #define fscanf fscanf_s |
433 #endif | 419 #endif |
434 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size)); | 420 CHECK_EQ(1, fscanf(fp, "new %d\n", &new_size)); |
435 CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size)); | 421 CHECK_EQ(1, fscanf(fp, "pointer %d\n", &pointer_size)); |
436 CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size)); | 422 CHECK_EQ(1, fscanf(fp, "data %d\n", &data_size)); |
437 CHECK_EQ(1, fscanf(fp, "code %d\n", &code_size)); | 423 CHECK_EQ(1, fscanf(fp, "code %d\n", &code_size)); |
438 CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size)); | 424 CHECK_EQ(1, fscanf(fp, "map %d\n", &map_size)); |
439 CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size)); | 425 CHECK_EQ(1, fscanf(fp, "cell %d\n", &cell_size)); |
| 426 CHECK_EQ(1, fscanf(fp, "large %d\n", &large_size)); |
440 #ifdef _MSC_VER | 427 #ifdef _MSC_VER |
441 #undef fscanf | 428 #undef fscanf |
442 #endif | 429 #endif |
443 fclose(fp); | 430 fclose(fp); |
444 deserializer->set_reservation(NEW_SPACE, new_size); | 431 HEAP->ReserveSpace(new_size, |
445 deserializer->set_reservation(OLD_POINTER_SPACE, pointer_size); | 432 pointer_size, |
446 deserializer->set_reservation(OLD_DATA_SPACE, data_size); | 433 data_size, |
447 deserializer->set_reservation(CODE_SPACE, code_size); | 434 code_size, |
448 deserializer->set_reservation(MAP_SPACE, map_size); | 435 map_size, |
449 deserializer->set_reservation(CELL_SPACE, cell_size); | 436 cell_size, |
| 437 large_size); |
450 } | 438 } |
451 | 439 |
452 | 440 |
453 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { | 441 DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { |
454 if (!Snapshot::IsEnabled()) { | 442 if (!Snapshot::IsEnabled()) { |
455 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 443 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
456 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 444 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
457 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 445 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
458 | 446 |
459 CHECK(Snapshot::Initialize(startup_name.start())); | 447 CHECK(Snapshot::Initialize(startup_name.start())); |
460 startup_name.Dispose(); | 448 startup_name.Dispose(); |
461 | 449 |
462 const char* file_name = FLAG_testing_serialization_file; | 450 const char* file_name = FLAG_testing_serialization_file; |
| 451 ReserveSpaceForPartialSnapshot(file_name); |
463 | 452 |
464 int snapshot_size = 0; | 453 int snapshot_size = 0; |
465 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 454 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
466 | 455 |
467 Object* root; | 456 Object* root; |
468 { | 457 { |
469 SnapshotByteSource source(snapshot, snapshot_size); | 458 SnapshotByteSource source(snapshot, snapshot_size); |
470 Deserializer deserializer(&source); | 459 Deserializer deserializer(&source); |
471 ReserveSpaceForSnapshot(&deserializer, file_name); | |
472 deserializer.DeserializePartial(&root); | 460 deserializer.DeserializePartial(&root); |
473 CHECK(root->IsString()); | 461 CHECK(root->IsString()); |
474 } | 462 } |
475 v8::HandleScope handle_scope; | 463 v8::HandleScope handle_scope; |
476 Handle<Object> root_handle(root); | 464 Handle<Object> root_handle(root); |
477 | 465 |
| 466 ReserveSpaceForPartialSnapshot(file_name); |
478 | 467 |
479 Object* root2; | 468 Object* root2; |
480 { | 469 { |
481 SnapshotByteSource source(snapshot, snapshot_size); | 470 SnapshotByteSource source(snapshot, snapshot_size); |
482 Deserializer deserializer(&source); | 471 Deserializer deserializer(&source); |
483 ReserveSpaceForSnapshot(&deserializer, file_name); | |
484 deserializer.DeserializePartial(&root2); | 472 deserializer.DeserializePartial(&root2); |
485 CHECK(root2->IsString()); | 473 CHECK(root2->IsString()); |
486 CHECK(*root_handle == root2); | 474 CHECK(*root_handle == root2); |
487 } | 475 } |
488 } | 476 } |
489 } | 477 } |
490 | 478 |
491 | 479 |
492 TEST(ContextSerialization) { | 480 TEST(ContextSerialization) { |
493 if (!Snapshot::HaveASnapshotToStartFrom()) { | 481 if (!Snapshot::HaveASnapshotToStartFrom()) { |
(...skipping 17 matching lines...) Expand all Loading... |
511 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 499 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
512 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 500 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
513 | 501 |
514 env->Exit(); | 502 env->Exit(); |
515 | 503 |
516 Object* raw_context = *(v8::Utils::OpenHandle(*env)); | 504 Object* raw_context = *(v8::Utils::OpenHandle(*env)); |
517 | 505 |
518 env.Dispose(); | 506 env.Dispose(); |
519 | 507 |
520 FileByteSink startup_sink(startup_name.start()); | 508 FileByteSink startup_sink(startup_name.start()); |
| 509 startup_name.Dispose(); |
521 StartupSerializer startup_serializer(&startup_sink); | 510 StartupSerializer startup_serializer(&startup_sink); |
522 startup_serializer.SerializeStrongReferences(); | 511 startup_serializer.SerializeStrongReferences(); |
523 | 512 |
524 FileByteSink partial_sink(FLAG_testing_serialization_file); | 513 FileByteSink partial_sink(FLAG_testing_serialization_file); |
525 PartialSerializer p_ser(&startup_serializer, &partial_sink); | 514 PartialSerializer p_ser(&startup_serializer, &partial_sink); |
526 p_ser.Serialize(&raw_context); | 515 p_ser.Serialize(&raw_context); |
527 startup_serializer.SerializeWeakReferences(); | 516 startup_serializer.SerializeWeakReferences(); |
528 | |
529 partial_sink.WriteSpaceUsed( | 517 partial_sink.WriteSpaceUsed( |
530 p_ser.CurrentAllocationAddress(NEW_SPACE), | 518 p_ser.CurrentAllocationAddress(NEW_SPACE), |
531 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), | 519 p_ser.CurrentAllocationAddress(OLD_POINTER_SPACE), |
532 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), | 520 p_ser.CurrentAllocationAddress(OLD_DATA_SPACE), |
533 p_ser.CurrentAllocationAddress(CODE_SPACE), | 521 p_ser.CurrentAllocationAddress(CODE_SPACE), |
534 p_ser.CurrentAllocationAddress(MAP_SPACE), | 522 p_ser.CurrentAllocationAddress(MAP_SPACE), |
535 p_ser.CurrentAllocationAddress(CELL_SPACE)); | 523 p_ser.CurrentAllocationAddress(CELL_SPACE), |
536 | 524 p_ser.CurrentAllocationAddress(LO_SPACE)); |
537 startup_sink.WriteSpaceUsed( | |
538 startup_serializer.CurrentAllocationAddress(NEW_SPACE), | |
539 startup_serializer.CurrentAllocationAddress(OLD_POINTER_SPACE), | |
540 startup_serializer.CurrentAllocationAddress(OLD_DATA_SPACE), | |
541 startup_serializer.CurrentAllocationAddress(CODE_SPACE), | |
542 startup_serializer.CurrentAllocationAddress(MAP_SPACE), | |
543 startup_serializer.CurrentAllocationAddress(CELL_SPACE)); | |
544 startup_name.Dispose(); | |
545 } | 525 } |
546 } | 526 } |
547 | 527 |
548 | 528 |
549 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { | 529 DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { |
550 if (!Snapshot::HaveASnapshotToStartFrom()) { | 530 if (!Snapshot::HaveASnapshotToStartFrom()) { |
551 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; | 531 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; |
552 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); | 532 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); |
553 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); | 533 OS::SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); |
554 | 534 |
555 CHECK(Snapshot::Initialize(startup_name.start())); | 535 CHECK(Snapshot::Initialize(startup_name.start())); |
556 startup_name.Dispose(); | 536 startup_name.Dispose(); |
557 | 537 |
558 const char* file_name = FLAG_testing_serialization_file; | 538 const char* file_name = FLAG_testing_serialization_file; |
| 539 ReserveSpaceForPartialSnapshot(file_name); |
559 | 540 |
560 int snapshot_size = 0; | 541 int snapshot_size = 0; |
561 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 542 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
562 | 543 |
563 Object* root; | 544 Object* root; |
564 { | 545 { |
565 SnapshotByteSource source(snapshot, snapshot_size); | 546 SnapshotByteSource source(snapshot, snapshot_size); |
566 Deserializer deserializer(&source); | 547 Deserializer deserializer(&source); |
567 ReserveSpaceForSnapshot(&deserializer, file_name); | |
568 deserializer.DeserializePartial(&root); | 548 deserializer.DeserializePartial(&root); |
569 CHECK(root->IsContext()); | 549 CHECK(root->IsContext()); |
570 } | 550 } |
571 v8::HandleScope handle_scope; | 551 v8::HandleScope handle_scope; |
572 Handle<Object> root_handle(root); | 552 Handle<Object> root_handle(root); |
573 | 553 |
| 554 ReserveSpaceForPartialSnapshot(file_name); |
574 | 555 |
575 Object* root2; | 556 Object* root2; |
576 { | 557 { |
577 SnapshotByteSource source(snapshot, snapshot_size); | 558 SnapshotByteSource source(snapshot, snapshot_size); |
578 Deserializer deserializer(&source); | 559 Deserializer deserializer(&source); |
579 ReserveSpaceForSnapshot(&deserializer, file_name); | |
580 deserializer.DeserializePartial(&root2); | 560 deserializer.DeserializePartial(&root2); |
581 CHECK(root2->IsContext()); | 561 CHECK(root2->IsContext()); |
582 CHECK(*root_handle != root2); | 562 CHECK(*root_handle != root2); |
583 } | 563 } |
584 } | 564 } |
585 } | 565 } |
586 | 566 |
587 | 567 |
| 568 TEST(LinearAllocation) { |
| 569 v8::V8::Initialize(); |
| 570 int new_space_max = 512 * KB; |
| 571 int paged_space_max = Page::kMaxNonCodeHeapObjectSize; |
| 572 int code_space_max = HEAP->code_space()->AreaSize(); |
| 573 |
| 574 for (int size = 1000; size < 5 * MB; size += size >> 1) { |
| 575 size &= ~8; // Round. |
| 576 int new_space_size = (size < new_space_max) ? size : new_space_max; |
| 577 int paged_space_size = (size < paged_space_max) ? size : paged_space_max; |
| 578 HEAP->ReserveSpace( |
| 579 new_space_size, |
| 580 paged_space_size, // Old pointer space. |
| 581 paged_space_size, // Old data space. |
| 582 HEAP->code_space()->RoundSizeDownToObjectAlignment(code_space_max), |
| 583 HEAP->map_space()->RoundSizeDownToObjectAlignment(paged_space_size), |
| 584 HEAP->cell_space()->RoundSizeDownToObjectAlignment(paged_space_size), |
| 585 size); // Large object space. |
| 586 LinearAllocationScope linear_allocation_scope; |
| 587 DisallowAllocationFailure disallow_allocation_failure; |
| 588 const int kSmallFixedArrayLength = 4; |
| 589 const int kSmallFixedArraySize = |
| 590 FixedArray::kHeaderSize + kSmallFixedArrayLength * kPointerSize; |
| 591 const int kSmallStringLength = 16; |
| 592 const int kSmallStringSize = |
| 593 (SeqAsciiString::kHeaderSize + kSmallStringLength + |
| 594 kObjectAlignmentMask) & ~kObjectAlignmentMask; |
| 595 const int kMapSize = Map::kSize; |
| 596 |
| 597 Object* new_last = NULL; |
| 598 for (int i = 0; |
| 599 i + kSmallFixedArraySize <= new_space_size; |
| 600 i += kSmallFixedArraySize) { |
| 601 Object* obj = |
| 602 HEAP->AllocateFixedArray(kSmallFixedArrayLength)->ToObjectChecked(); |
| 603 if (new_last != NULL) { |
| 604 CHECK(reinterpret_cast<char*>(obj) == |
| 605 reinterpret_cast<char*>(new_last) + kSmallFixedArraySize); |
| 606 } |
| 607 new_last = obj; |
| 608 } |
| 609 |
| 610 Object* pointer_last = NULL; |
| 611 for (int i = 0; |
| 612 i + kSmallFixedArraySize <= paged_space_size; |
| 613 i += kSmallFixedArraySize) { |
| 614 Object* obj = HEAP->AllocateFixedArray(kSmallFixedArrayLength, |
| 615 TENURED)->ToObjectChecked(); |
| 616 int old_page_fullness = i % Page::kPageSize; |
| 617 int page_fullness = (i + kSmallFixedArraySize) % Page::kPageSize; |
| 618 if (page_fullness < old_page_fullness || |
| 619 page_fullness > HEAP->old_pointer_space()->AreaSize()) { |
| 620 i = RoundUp(i, Page::kPageSize); |
| 621 pointer_last = NULL; |
| 622 } |
| 623 if (pointer_last != NULL) { |
| 624 CHECK(reinterpret_cast<char*>(obj) == |
| 625 reinterpret_cast<char*>(pointer_last) + kSmallFixedArraySize); |
| 626 } |
| 627 pointer_last = obj; |
| 628 } |
| 629 |
| 630 Object* data_last = NULL; |
| 631 for (int i = 0; |
| 632 i + kSmallStringSize <= paged_space_size; |
| 633 i += kSmallStringSize) { |
| 634 Object* obj = HEAP->AllocateRawAsciiString(kSmallStringLength, |
| 635 TENURED)->ToObjectChecked(); |
| 636 int old_page_fullness = i % Page::kPageSize; |
| 637 int page_fullness = (i + kSmallStringSize) % Page::kPageSize; |
| 638 if (page_fullness < old_page_fullness || |
| 639 page_fullness > HEAP->old_data_space()->AreaSize()) { |
| 640 i = RoundUp(i, Page::kPageSize); |
| 641 data_last = NULL; |
| 642 } |
| 643 if (data_last != NULL) { |
| 644 CHECK(reinterpret_cast<char*>(obj) == |
| 645 reinterpret_cast<char*>(data_last) + kSmallStringSize); |
| 646 } |
| 647 data_last = obj; |
| 648 } |
| 649 |
| 650 Object* map_last = NULL; |
| 651 for (int i = 0; i + kMapSize <= paged_space_size; i += kMapSize) { |
| 652 Object* obj = HEAP->AllocateMap(JS_OBJECT_TYPE, |
| 653 42 * kPointerSize)->ToObjectChecked(); |
| 654 int old_page_fullness = i % Page::kPageSize; |
| 655 int page_fullness = (i + kMapSize) % Page::kPageSize; |
| 656 if (page_fullness < old_page_fullness || |
| 657 page_fullness > HEAP->map_space()->AreaSize()) { |
| 658 i = RoundUp(i, Page::kPageSize); |
| 659 map_last = NULL; |
| 660 } |
| 661 if (map_last != NULL) { |
| 662 CHECK(reinterpret_cast<char*>(obj) == |
| 663 reinterpret_cast<char*>(map_last) + kMapSize); |
| 664 } |
| 665 map_last = obj; |
| 666 } |
| 667 |
| 668 if (size > Page::kMaxNonCodeHeapObjectSize) { |
| 669 // Support for reserving space in large object space is not there yet, |
| 670 // but using an always-allocate scope is fine for now. |
| 671 AlwaysAllocateScope always; |
| 672 int large_object_array_length = |
| 673 (size - FixedArray::kHeaderSize) / kPointerSize; |
| 674 Object* obj = HEAP->AllocateFixedArray(large_object_array_length, |
| 675 TENURED)->ToObjectChecked(); |
| 676 CHECK(!obj->IsFailure()); |
| 677 } |
| 678 } |
| 679 } |
| 680 |
| 681 |
588 TEST(TestThatAlwaysSucceeds) { | 682 TEST(TestThatAlwaysSucceeds) { |
589 } | 683 } |
590 | 684 |
591 | 685 |
592 TEST(TestThatAlwaysFails) { | 686 TEST(TestThatAlwaysFails) { |
593 bool ArtificialFailure = false; | 687 bool ArtificialFailure = false; |
594 CHECK(ArtificialFailure); | 688 CHECK(ArtificialFailure); |
595 } | 689 } |
596 | 690 |
597 | 691 |
598 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { | 692 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) { |
599 bool ArtificialFailure2 = false; | 693 bool ArtificialFailure2 = false; |
600 CHECK(ArtificialFailure2); | 694 CHECK(ArtificialFailure2); |
601 } | 695 } |
OLD | NEW |