OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 Local<Value> value = script->Run(); | 516 Local<Value> value = script->Run(); |
517 CHECK(value->IsNumber()); | 517 CHECK(value->IsNumber()); |
518 CHECK_EQ(7, value->Int32Value()); | 518 CHECK_EQ(7, value->Int32Value()); |
519 CHECK(source->IsExternal()); | 519 CHECK(source->IsExternal()); |
520 CHECK_EQ(resource, | 520 CHECK_EQ(resource, |
521 static_cast<TestResource*>(source->GetExternalStringResource())); | 521 static_cast<TestResource*>(source->GetExternalStringResource())); |
522 String::Encoding encoding = String::UNKNOWN_ENCODING; | 522 String::Encoding encoding = String::UNKNOWN_ENCODING; |
523 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 523 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
524 source->GetExternalStringResourceBase(&encoding)); | 524 source->GetExternalStringResourceBase(&encoding)); |
525 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); | 525 CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); |
526 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 526 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
527 CHECK_EQ(0, dispose_count); | 527 CHECK_EQ(0, dispose_count); |
528 } | 528 } |
529 CcTest::i_isolate()->compilation_cache()->Clear(); | 529 CcTest::i_isolate()->compilation_cache()->Clear(); |
530 HEAP->CollectAllAvailableGarbage(); | 530 CcTest::heap()->CollectAllAvailableGarbage(); |
531 CHECK_EQ(1, dispose_count); | 531 CHECK_EQ(1, dispose_count); |
532 } | 532 } |
533 | 533 |
534 | 534 |
535 THREADED_TEST(ScriptUsingAsciiStringResource) { | 535 THREADED_TEST(ScriptUsingAsciiStringResource) { |
536 int dispose_count = 0; | 536 int dispose_count = 0; |
537 const char* c_source = "1 + 2 * 3"; | 537 const char* c_source = "1 + 2 * 3"; |
538 { | 538 { |
539 LocalContext env; | 539 LocalContext env; |
540 v8::HandleScope scope(env->GetIsolate()); | 540 v8::HandleScope scope(env->GetIsolate()); |
541 TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source), | 541 TestAsciiResource* resource = new TestAsciiResource(i::StrDup(c_source), |
542 &dispose_count); | 542 &dispose_count); |
543 Local<String> source = String::NewExternal(resource); | 543 Local<String> source = String::NewExternal(resource); |
544 CHECK(source->IsExternalAscii()); | 544 CHECK(source->IsExternalAscii()); |
545 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 545 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
546 source->GetExternalAsciiStringResource()); | 546 source->GetExternalAsciiStringResource()); |
547 String::Encoding encoding = String::UNKNOWN_ENCODING; | 547 String::Encoding encoding = String::UNKNOWN_ENCODING; |
548 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), | 548 CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
549 source->GetExternalStringResourceBase(&encoding)); | 549 source->GetExternalStringResourceBase(&encoding)); |
550 CHECK_EQ(String::ASCII_ENCODING, encoding); | 550 CHECK_EQ(String::ASCII_ENCODING, encoding); |
551 Local<Script> script = Script::Compile(source); | 551 Local<Script> script = Script::Compile(source); |
552 Local<Value> value = script->Run(); | 552 Local<Value> value = script->Run(); |
553 CHECK(value->IsNumber()); | 553 CHECK(value->IsNumber()); |
554 CHECK_EQ(7, value->Int32Value()); | 554 CHECK_EQ(7, value->Int32Value()); |
555 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 555 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
556 CHECK_EQ(0, dispose_count); | 556 CHECK_EQ(0, dispose_count); |
557 } | 557 } |
558 CcTest::i_isolate()->compilation_cache()->Clear(); | 558 CcTest::i_isolate()->compilation_cache()->Clear(); |
559 HEAP->CollectAllAvailableGarbage(); | 559 CcTest::heap()->CollectAllAvailableGarbage(); |
560 CHECK_EQ(1, dispose_count); | 560 CHECK_EQ(1, dispose_count); |
561 } | 561 } |
562 | 562 |
563 | 563 |
564 THREADED_TEST(ScriptMakingExternalString) { | 564 THREADED_TEST(ScriptMakingExternalString) { |
565 int dispose_count = 0; | 565 int dispose_count = 0; |
566 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); | 566 uint16_t* two_byte_source = AsciiToTwoByteString("1 + 2 * 3"); |
567 { | 567 { |
568 LocalContext env; | 568 LocalContext env; |
569 v8::HandleScope scope(env->GetIsolate()); | 569 v8::HandleScope scope(env->GetIsolate()); |
570 Local<String> source = String::New(two_byte_source); | 570 Local<String> source = String::New(two_byte_source); |
571 // Trigger GCs so that the newly allocated string moves to old gen. | 571 // Trigger GCs so that the newly allocated string moves to old gen. |
572 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 572 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
573 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 573 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
574 CHECK_EQ(source->IsExternal(), false); | 574 CHECK_EQ(source->IsExternal(), false); |
575 CHECK_EQ(source->IsExternalAscii(), false); | 575 CHECK_EQ(source->IsExternalAscii(), false); |
576 String::Encoding encoding = String::UNKNOWN_ENCODING; | 576 String::Encoding encoding = String::UNKNOWN_ENCODING; |
577 CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); | 577 CHECK_EQ(NULL, source->GetExternalStringResourceBase(&encoding)); |
578 CHECK_EQ(String::ASCII_ENCODING, encoding); | 578 CHECK_EQ(String::ASCII_ENCODING, encoding); |
579 bool success = source->MakeExternal(new TestResource(two_byte_source, | 579 bool success = source->MakeExternal(new TestResource(two_byte_source, |
580 &dispose_count)); | 580 &dispose_count)); |
581 CHECK(success); | 581 CHECK(success); |
582 Local<Script> script = Script::Compile(source); | 582 Local<Script> script = Script::Compile(source); |
583 Local<Value> value = script->Run(); | 583 Local<Value> value = script->Run(); |
584 CHECK(value->IsNumber()); | 584 CHECK(value->IsNumber()); |
585 CHECK_EQ(7, value->Int32Value()); | 585 CHECK_EQ(7, value->Int32Value()); |
586 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 586 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
587 CHECK_EQ(0, dispose_count); | 587 CHECK_EQ(0, dispose_count); |
588 } | 588 } |
589 CcTest::i_isolate()->compilation_cache()->Clear(); | 589 CcTest::i_isolate()->compilation_cache()->Clear(); |
590 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 590 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
591 CHECK_EQ(1, dispose_count); | 591 CHECK_EQ(1, dispose_count); |
592 } | 592 } |
593 | 593 |
594 | 594 |
595 THREADED_TEST(ScriptMakingExternalAsciiString) { | 595 THREADED_TEST(ScriptMakingExternalAsciiString) { |
596 int dispose_count = 0; | 596 int dispose_count = 0; |
597 const char* c_source = "1 + 2 * 3"; | 597 const char* c_source = "1 + 2 * 3"; |
598 { | 598 { |
599 LocalContext env; | 599 LocalContext env; |
600 v8::HandleScope scope(env->GetIsolate()); | 600 v8::HandleScope scope(env->GetIsolate()); |
601 Local<String> source = v8_str(c_source); | 601 Local<String> source = v8_str(c_source); |
602 // Trigger GCs so that the newly allocated string moves to old gen. | 602 // Trigger GCs so that the newly allocated string moves to old gen. |
603 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 603 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
604 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 604 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
605 bool success = source->MakeExternal( | 605 bool success = source->MakeExternal( |
606 new TestAsciiResource(i::StrDup(c_source), &dispose_count)); | 606 new TestAsciiResource(i::StrDup(c_source), &dispose_count)); |
607 CHECK(success); | 607 CHECK(success); |
608 Local<Script> script = Script::Compile(source); | 608 Local<Script> script = Script::Compile(source); |
609 Local<Value> value = script->Run(); | 609 Local<Value> value = script->Run(); |
610 CHECK(value->IsNumber()); | 610 CHECK(value->IsNumber()); |
611 CHECK_EQ(7, value->Int32Value()); | 611 CHECK_EQ(7, value->Int32Value()); |
612 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 612 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
613 CHECK_EQ(0, dispose_count); | 613 CHECK_EQ(0, dispose_count); |
614 } | 614 } |
615 CcTest::i_isolate()->compilation_cache()->Clear(); | 615 CcTest::i_isolate()->compilation_cache()->Clear(); |
616 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 616 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
617 CHECK_EQ(1, dispose_count); | 617 CHECK_EQ(1, dispose_count); |
618 } | 618 } |
619 | 619 |
620 | 620 |
621 TEST(MakingExternalStringConditions) { | 621 TEST(MakingExternalStringConditions) { |
622 LocalContext env; | 622 LocalContext env; |
623 v8::HandleScope scope(env->GetIsolate()); | 623 v8::HandleScope scope(env->GetIsolate()); |
624 | 624 |
625 // Free some space in the new space so that we can check freshness. | 625 // Free some space in the new space so that we can check freshness. |
626 HEAP->CollectGarbage(i::NEW_SPACE); | 626 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
627 HEAP->CollectGarbage(i::NEW_SPACE); | 627 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
628 | 628 |
629 uint16_t* two_byte_string = AsciiToTwoByteString("s1"); | 629 uint16_t* two_byte_string = AsciiToTwoByteString("s1"); |
630 Local<String> small_string = String::New(two_byte_string); | 630 Local<String> small_string = String::New(two_byte_string); |
631 i::DeleteArray(two_byte_string); | 631 i::DeleteArray(two_byte_string); |
632 | 632 |
633 // We should refuse to externalize newly created small string. | 633 // We should refuse to externalize newly created small string. |
634 CHECK(!small_string->CanMakeExternal()); | 634 CHECK(!small_string->CanMakeExternal()); |
635 // Trigger GCs so that the newly allocated string moves to old gen. | 635 // Trigger GCs so that the newly allocated string moves to old gen. |
636 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 636 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
637 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 637 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
638 // Old space strings should be accepted. | 638 // Old space strings should be accepted. |
639 CHECK(small_string->CanMakeExternal()); | 639 CHECK(small_string->CanMakeExternal()); |
640 | 640 |
641 two_byte_string = AsciiToTwoByteString("small string 2"); | 641 two_byte_string = AsciiToTwoByteString("small string 2"); |
642 small_string = String::New(two_byte_string); | 642 small_string = String::New(two_byte_string); |
643 i::DeleteArray(two_byte_string); | 643 i::DeleteArray(two_byte_string); |
644 | 644 |
645 // We should refuse externalizing newly created small string. | 645 // We should refuse externalizing newly created small string. |
646 CHECK(!small_string->CanMakeExternal()); | 646 CHECK(!small_string->CanMakeExternal()); |
647 for (int i = 0; i < 100; i++) { | 647 for (int i = 0; i < 100; i++) { |
(...skipping 14 matching lines...) Expand all Loading... |
662 // Large strings should be immediately accepted. | 662 // Large strings should be immediately accepted. |
663 CHECK(large_string->CanMakeExternal()); | 663 CHECK(large_string->CanMakeExternal()); |
664 } | 664 } |
665 | 665 |
666 | 666 |
667 TEST(MakingExternalAsciiStringConditions) { | 667 TEST(MakingExternalAsciiStringConditions) { |
668 LocalContext env; | 668 LocalContext env; |
669 v8::HandleScope scope(env->GetIsolate()); | 669 v8::HandleScope scope(env->GetIsolate()); |
670 | 670 |
671 // Free some space in the new space so that we can check freshness. | 671 // Free some space in the new space so that we can check freshness. |
672 HEAP->CollectGarbage(i::NEW_SPACE); | 672 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
673 HEAP->CollectGarbage(i::NEW_SPACE); | 673 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
674 | 674 |
675 Local<String> small_string = String::New("s1"); | 675 Local<String> small_string = String::New("s1"); |
676 // We should refuse to externalize newly created small string. | 676 // We should refuse to externalize newly created small string. |
677 CHECK(!small_string->CanMakeExternal()); | 677 CHECK(!small_string->CanMakeExternal()); |
678 // Trigger GCs so that the newly allocated string moves to old gen. | 678 // Trigger GCs so that the newly allocated string moves to old gen. |
679 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 679 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
680 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 680 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
681 // Old space strings should be accepted. | 681 // Old space strings should be accepted. |
682 CHECK(small_string->CanMakeExternal()); | 682 CHECK(small_string->CanMakeExternal()); |
683 | 683 |
684 small_string = String::New("small string 2"); | 684 small_string = String::New("small string 2"); |
685 // We should refuse externalizing newly created small string. | 685 // We should refuse externalizing newly created small string. |
686 CHECK(!small_string->CanMakeExternal()); | 686 CHECK(!small_string->CanMakeExternal()); |
687 for (int i = 0; i < 100; i++) { | 687 for (int i = 0; i < 100; i++) { |
688 String::Value value(small_string); | 688 String::Value value(small_string); |
689 } | 689 } |
690 // Frequently used strings should be accepted. | 690 // Frequently used strings should be accepted. |
(...skipping 17 matching lines...) Expand all Loading... |
708 CompileRun("function cons(a, b) { return a + b; }" | 708 CompileRun("function cons(a, b) { return a + b; }" |
709 "function slice(a) { return a.substring(1); }"); | 709 "function slice(a) { return a.substring(1); }"); |
710 // Create a cons string that will land in old pointer space. | 710 // Create a cons string that will land in old pointer space. |
711 Local<String> cons = Local<String>::Cast(CompileRun( | 711 Local<String> cons = Local<String>::Cast(CompileRun( |
712 "cons('abcdefghijklm', 'nopqrstuvwxyz');")); | 712 "cons('abcdefghijklm', 'nopqrstuvwxyz');")); |
713 // Create a sliced string that will land in old pointer space. | 713 // Create a sliced string that will land in old pointer space. |
714 Local<String> slice = Local<String>::Cast(CompileRun( | 714 Local<String> slice = Local<String>::Cast(CompileRun( |
715 "slice('abcdefghijklmnopqrstuvwxyz');")); | 715 "slice('abcdefghijklmnopqrstuvwxyz');")); |
716 | 716 |
717 // Trigger GCs so that the newly allocated string moves to old gen. | 717 // Trigger GCs so that the newly allocated string moves to old gen. |
718 SimulateFullSpace(HEAP->old_pointer_space()); | 718 SimulateFullSpace(CcTest::heap()->old_pointer_space()); |
719 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 719 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
720 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 720 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
721 | 721 |
722 // Turn into external string with unaligned resource data. | 722 // Turn into external string with unaligned resource data. |
723 int dispose_count = 0; | 723 int dispose_count = 0; |
724 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; | 724 const char* c_cons = "_abcdefghijklmnopqrstuvwxyz"; |
725 bool success = cons->MakeExternal( | 725 bool success = cons->MakeExternal( |
726 new TestAsciiResource(i::StrDup(c_cons) + 1, &dispose_count)); | 726 new TestAsciiResource(i::StrDup(c_cons) + 1, &dispose_count)); |
727 CHECK(success); | 727 CHECK(success); |
728 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; | 728 const char* c_slice = "_bcdefghijklmnopqrstuvwxyz"; |
729 success = slice->MakeExternal( | 729 success = slice->MakeExternal( |
730 new TestAsciiResource(i::StrDup(c_slice) + 1, &dispose_count)); | 730 new TestAsciiResource(i::StrDup(c_slice) + 1, &dispose_count)); |
731 CHECK(success); | 731 CHECK(success); |
732 | 732 |
733 // Trigger GCs and force evacuation. | 733 // Trigger GCs and force evacuation. |
734 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 734 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
735 HEAP->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); | 735 CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask); |
736 } | 736 } |
737 | 737 |
738 | 738 |
739 THREADED_TEST(UsingExternalString) { | 739 THREADED_TEST(UsingExternalString) { |
740 i::Factory* factory = CcTest::i_isolate()->factory(); | 740 i::Factory* factory = CcTest::i_isolate()->factory(); |
741 { | 741 { |
742 v8::HandleScope scope(CcTest::isolate()); | 742 v8::HandleScope scope(CcTest::isolate()); |
743 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 743 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
744 Local<String> string = | 744 Local<String> string = |
745 String::NewExternal(new TestResource(two_byte_string)); | 745 String::NewExternal(new TestResource(two_byte_string)); |
746 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 746 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
747 // Trigger GCs so that the newly allocated string moves to old gen. | 747 // Trigger GCs so that the newly allocated string moves to old gen. |
748 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 748 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
749 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 749 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
750 i::Handle<i::String> isymbol = | 750 i::Handle<i::String> isymbol = |
751 factory->InternalizedStringFromString(istring); | 751 factory->InternalizedStringFromString(istring); |
752 CHECK(isymbol->IsInternalizedString()); | 752 CHECK(isymbol->IsInternalizedString()); |
753 } | 753 } |
754 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 754 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
755 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 755 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
756 } | 756 } |
757 | 757 |
758 | 758 |
759 THREADED_TEST(UsingExternalAsciiString) { | 759 THREADED_TEST(UsingExternalAsciiString) { |
760 i::Factory* factory = CcTest::i_isolate()->factory(); | 760 i::Factory* factory = CcTest::i_isolate()->factory(); |
761 { | 761 { |
762 v8::HandleScope scope(CcTest::isolate()); | 762 v8::HandleScope scope(CcTest::isolate()); |
763 const char* one_byte_string = "test string"; | 763 const char* one_byte_string = "test string"; |
764 Local<String> string = String::NewExternal( | 764 Local<String> string = String::NewExternal( |
765 new TestAsciiResource(i::StrDup(one_byte_string))); | 765 new TestAsciiResource(i::StrDup(one_byte_string))); |
766 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 766 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
767 // Trigger GCs so that the newly allocated string moves to old gen. | 767 // Trigger GCs so that the newly allocated string moves to old gen. |
768 HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now | 768 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now |
769 HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now | 769 CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now |
770 i::Handle<i::String> isymbol = | 770 i::Handle<i::String> isymbol = |
771 factory->InternalizedStringFromString(istring); | 771 factory->InternalizedStringFromString(istring); |
772 CHECK(isymbol->IsInternalizedString()); | 772 CHECK(isymbol->IsInternalizedString()); |
773 } | 773 } |
774 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 774 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
775 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 775 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
776 } | 776 } |
777 | 777 |
778 | 778 |
779 THREADED_TEST(ScavengeExternalString) { | 779 THREADED_TEST(ScavengeExternalString) { |
780 i::FLAG_stress_compaction = false; | 780 i::FLAG_stress_compaction = false; |
781 i::FLAG_gc_global = false; | 781 i::FLAG_gc_global = false; |
782 int dispose_count = 0; | 782 int dispose_count = 0; |
783 bool in_new_space = false; | 783 bool in_new_space = false; |
784 { | 784 { |
785 v8::HandleScope scope(CcTest::isolate()); | 785 v8::HandleScope scope(CcTest::isolate()); |
786 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); | 786 uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
787 Local<String> string = | 787 Local<String> string = |
788 String::NewExternal(new TestResource(two_byte_string, | 788 String::NewExternal(new TestResource(two_byte_string, |
789 &dispose_count)); | 789 &dispose_count)); |
790 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 790 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
791 HEAP->CollectGarbage(i::NEW_SPACE); | 791 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
792 in_new_space = HEAP->InNewSpace(*istring); | 792 in_new_space = CcTest::heap()->InNewSpace(*istring); |
793 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); | 793 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); |
794 CHECK_EQ(0, dispose_count); | 794 CHECK_EQ(0, dispose_count); |
795 } | 795 } |
796 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 796 CcTest::heap()->CollectGarbage( |
| 797 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
797 CHECK_EQ(1, dispose_count); | 798 CHECK_EQ(1, dispose_count); |
798 } | 799 } |
799 | 800 |
800 | 801 |
801 THREADED_TEST(ScavengeExternalAsciiString) { | 802 THREADED_TEST(ScavengeExternalAsciiString) { |
802 i::FLAG_stress_compaction = false; | 803 i::FLAG_stress_compaction = false; |
803 i::FLAG_gc_global = false; | 804 i::FLAG_gc_global = false; |
804 int dispose_count = 0; | 805 int dispose_count = 0; |
805 bool in_new_space = false; | 806 bool in_new_space = false; |
806 { | 807 { |
807 v8::HandleScope scope(CcTest::isolate()); | 808 v8::HandleScope scope(CcTest::isolate()); |
808 const char* one_byte_string = "test string"; | 809 const char* one_byte_string = "test string"; |
809 Local<String> string = String::NewExternal( | 810 Local<String> string = String::NewExternal( |
810 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); | 811 new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); |
811 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); | 812 i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
812 HEAP->CollectGarbage(i::NEW_SPACE); | 813 CcTest::heap()->CollectGarbage(i::NEW_SPACE); |
813 in_new_space = HEAP->InNewSpace(*istring); | 814 in_new_space = CcTest::heap()->InNewSpace(*istring); |
814 CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring)); | 815 CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring)); |
815 CHECK_EQ(0, dispose_count); | 816 CHECK_EQ(0, dispose_count); |
816 } | 817 } |
817 HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); | 818 CcTest::heap()->CollectGarbage( |
| 819 in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
818 CHECK_EQ(1, dispose_count); | 820 CHECK_EQ(1, dispose_count); |
819 } | 821 } |
820 | 822 |
821 | 823 |
822 class TestAsciiResourceWithDisposeControl: public TestAsciiResource { | 824 class TestAsciiResourceWithDisposeControl: public TestAsciiResource { |
823 public: | 825 public: |
824 // Only used by non-threaded tests, so it can use static fields. | 826 // Only used by non-threaded tests, so it can use static fields. |
825 static int dispose_calls; | 827 static int dispose_calls; |
826 static int dispose_count; | 828 static int dispose_count; |
827 | 829 |
(...skipping 22 matching lines...) Expand all Loading... |
850 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 852 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
851 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); | 853 TestAsciiResourceWithDisposeControl res_stack(i::StrDup(c_source), false); |
852 { | 854 { |
853 LocalContext env; | 855 LocalContext env; |
854 v8::HandleScope scope(env->GetIsolate()); | 856 v8::HandleScope scope(env->GetIsolate()); |
855 Local<String> source = String::NewExternal(&res_stack); | 857 Local<String> source = String::NewExternal(&res_stack); |
856 Local<Script> script = Script::Compile(source); | 858 Local<Script> script = Script::Compile(source); |
857 Local<Value> value = script->Run(); | 859 Local<Value> value = script->Run(); |
858 CHECK(value->IsNumber()); | 860 CHECK(value->IsNumber()); |
859 CHECK_EQ(7, value->Int32Value()); | 861 CHECK_EQ(7, value->Int32Value()); |
860 HEAP->CollectAllAvailableGarbage(); | 862 CcTest::heap()->CollectAllAvailableGarbage(); |
861 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 863 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
862 } | 864 } |
863 CcTest::i_isolate()->compilation_cache()->Clear(); | 865 CcTest::i_isolate()->compilation_cache()->Clear(); |
864 HEAP->CollectAllAvailableGarbage(); | 866 CcTest::heap()->CollectAllAvailableGarbage(); |
865 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 867 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
866 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 868 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
867 | 869 |
868 // Use a heap allocated external string resource allocated object. | 870 // Use a heap allocated external string resource allocated object. |
869 TestAsciiResourceWithDisposeControl::dispose_count = 0; | 871 TestAsciiResourceWithDisposeControl::dispose_count = 0; |
870 TestAsciiResourceWithDisposeControl::dispose_calls = 0; | 872 TestAsciiResourceWithDisposeControl::dispose_calls = 0; |
871 TestAsciiResource* res_heap = | 873 TestAsciiResource* res_heap = |
872 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); | 874 new TestAsciiResourceWithDisposeControl(i::StrDup(c_source), true); |
873 { | 875 { |
874 LocalContext env; | 876 LocalContext env; |
875 v8::HandleScope scope(env->GetIsolate()); | 877 v8::HandleScope scope(env->GetIsolate()); |
876 Local<String> source = String::NewExternal(res_heap); | 878 Local<String> source = String::NewExternal(res_heap); |
877 Local<Script> script = Script::Compile(source); | 879 Local<Script> script = Script::Compile(source); |
878 Local<Value> value = script->Run(); | 880 Local<Value> value = script->Run(); |
879 CHECK(value->IsNumber()); | 881 CHECK(value->IsNumber()); |
880 CHECK_EQ(7, value->Int32Value()); | 882 CHECK_EQ(7, value->Int32Value()); |
881 HEAP->CollectAllAvailableGarbage(); | 883 CcTest::heap()->CollectAllAvailableGarbage(); |
882 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); | 884 CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
883 } | 885 } |
884 CcTest::i_isolate()->compilation_cache()->Clear(); | 886 CcTest::i_isolate()->compilation_cache()->Clear(); |
885 HEAP->CollectAllAvailableGarbage(); | 887 CcTest::heap()->CollectAllAvailableGarbage(); |
886 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); | 888 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
887 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); | 889 CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); |
888 } | 890 } |
889 | 891 |
890 | 892 |
891 THREADED_TEST(StringConcat) { | 893 THREADED_TEST(StringConcat) { |
892 { | 894 { |
893 LocalContext env; | 895 LocalContext env; |
894 v8::HandleScope scope(env->GetIsolate()); | 896 v8::HandleScope scope(env->GetIsolate()); |
895 const char* one_byte_string_1 = "function a_times_t"; | 897 const char* one_byte_string_1 = "function a_times_t"; |
(...skipping 26 matching lines...) Expand all Loading... |
922 source = String::Concat(source, right); | 924 source = String::Concat(source, right); |
923 right = String::NewExternal( | 925 right = String::NewExternal( |
924 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); | 926 new TestResource(AsciiToTwoByteString(two_byte_extern_2))); |
925 source = String::Concat(source, right); | 927 source = String::Concat(source, right); |
926 Local<Script> script = Script::Compile(source); | 928 Local<Script> script = Script::Compile(source); |
927 Local<Value> value = script->Run(); | 929 Local<Value> value = script->Run(); |
928 CHECK(value->IsNumber()); | 930 CHECK(value->IsNumber()); |
929 CHECK_EQ(68, value->Int32Value()); | 931 CHECK_EQ(68, value->Int32Value()); |
930 } | 932 } |
931 CcTest::i_isolate()->compilation_cache()->Clear(); | 933 CcTest::i_isolate()->compilation_cache()->Clear(); |
932 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 934 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
933 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 935 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
934 } | 936 } |
935 | 937 |
936 | 938 |
937 THREADED_TEST(GlobalProperties) { | 939 THREADED_TEST(GlobalProperties) { |
938 LocalContext env; | 940 LocalContext env; |
939 v8::HandleScope scope(env->GetIsolate()); | 941 v8::HandleScope scope(env->GetIsolate()); |
940 v8::Handle<v8::Object> global = env->Global(); | 942 v8::Handle<v8::Object> global = env->Global(); |
941 global->Set(v8_str("pi"), v8_num(3.1415926)); | 943 global->Set(v8_str("pi"), v8_num(3.1415926)); |
942 Local<Value> pi = global->Get(v8_str("pi")); | 944 Local<Value> pi = global->Get(v8_str("pi")); |
943 CHECK_EQ(3.1415926, pi->NumberValue()); | 945 CHECK_EQ(3.1415926, pi->NumberValue()); |
(...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2525 v8::Local<v8::Object> global = env->Global(); | 2527 v8::Local<v8::Object> global = env->Global(); |
2526 global->Set(0, v8::String::New("value")); | 2528 global->Set(0, v8::String::New("value")); |
2527 CHECK(global->HasRealIndexedProperty(0)); | 2529 CHECK(global->HasRealIndexedProperty(0)); |
2528 } | 2530 } |
2529 | 2531 |
2530 | 2532 |
2531 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, | 2533 static void CheckAlignedPointerInInternalField(Handle<v8::Object> obj, |
2532 void* value) { | 2534 void* value) { |
2533 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2535 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
2534 obj->SetAlignedPointerInInternalField(0, value); | 2536 obj->SetAlignedPointerInInternalField(0, value); |
2535 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2537 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2536 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); | 2538 CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); |
2537 } | 2539 } |
2538 | 2540 |
2539 | 2541 |
2540 THREADED_TEST(InternalFieldsAlignedPointers) { | 2542 THREADED_TEST(InternalFieldsAlignedPointers) { |
2541 LocalContext env; | 2543 LocalContext env; |
2542 v8::HandleScope scope(env->GetIsolate()); | 2544 v8::HandleScope scope(env->GetIsolate()); |
2543 | 2545 |
2544 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); | 2546 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
2545 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); | 2547 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); |
(...skipping 13 matching lines...) Expand all Loading... |
2559 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1)); | 2561 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1)); |
2560 CheckAlignedPointerInInternalField(obj, huge); | 2562 CheckAlignedPointerInInternalField(obj, huge); |
2561 } | 2563 } |
2562 | 2564 |
2563 | 2565 |
2564 static void CheckAlignedPointerInEmbedderData(LocalContext* env, | 2566 static void CheckAlignedPointerInEmbedderData(LocalContext* env, |
2565 int index, | 2567 int index, |
2566 void* value) { | 2568 void* value) { |
2567 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); | 2569 CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
2568 (*env)->SetAlignedPointerInEmbedderData(index, value); | 2570 (*env)->SetAlignedPointerInEmbedderData(index, value); |
2569 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2571 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2570 CHECK_EQ(value, (*env)->GetAlignedPointerFromEmbedderData(index)); | 2572 CHECK_EQ(value, (*env)->GetAlignedPointerFromEmbedderData(index)); |
2571 } | 2573 } |
2572 | 2574 |
2573 | 2575 |
2574 static void* AlignedTestPointer(int i) { | 2576 static void* AlignedTestPointer(int i) { |
2575 return reinterpret_cast<void*>(i * 1234); | 2577 return reinterpret_cast<void*>(i * 1234); |
2576 } | 2578 } |
2577 | 2579 |
2578 | 2580 |
2579 THREADED_TEST(EmbedderDataAlignedPointers) { | 2581 THREADED_TEST(EmbedderDataAlignedPointers) { |
2580 LocalContext env; | 2582 LocalContext env; |
2581 v8::HandleScope scope(env->GetIsolate()); | 2583 v8::HandleScope scope(env->GetIsolate()); |
2582 | 2584 |
2583 CheckAlignedPointerInEmbedderData(&env, 0, NULL); | 2585 CheckAlignedPointerInEmbedderData(&env, 0, NULL); |
2584 | 2586 |
2585 int* heap_allocated = new int[100]; | 2587 int* heap_allocated = new int[100]; |
2586 CheckAlignedPointerInEmbedderData(&env, 1, heap_allocated); | 2588 CheckAlignedPointerInEmbedderData(&env, 1, heap_allocated); |
2587 delete[] heap_allocated; | 2589 delete[] heap_allocated; |
2588 | 2590 |
2589 int stack_allocated[100]; | 2591 int stack_allocated[100]; |
2590 CheckAlignedPointerInEmbedderData(&env, 2, stack_allocated); | 2592 CheckAlignedPointerInEmbedderData(&env, 2, stack_allocated); |
2591 | 2593 |
2592 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1)); | 2594 void* huge = reinterpret_cast<void*>(~static_cast<uintptr_t>(1)); |
2593 CheckAlignedPointerInEmbedderData(&env, 3, huge); | 2595 CheckAlignedPointerInEmbedderData(&env, 3, huge); |
2594 | 2596 |
2595 // Test growing of the embedder data's backing store. | 2597 // Test growing of the embedder data's backing store. |
2596 for (int i = 0; i < 100; i++) { | 2598 for (int i = 0; i < 100; i++) { |
2597 env->SetAlignedPointerInEmbedderData(i, AlignedTestPointer(i)); | 2599 env->SetAlignedPointerInEmbedderData(i, AlignedTestPointer(i)); |
2598 } | 2600 } |
2599 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2601 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2600 for (int i = 0; i < 100; i++) { | 2602 for (int i = 0; i < 100; i++) { |
2601 CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i)); | 2603 CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i)); |
2602 } | 2604 } |
2603 } | 2605 } |
2604 | 2606 |
2605 | 2607 |
2606 static void CheckEmbedderData(LocalContext* env, | 2608 static void CheckEmbedderData(LocalContext* env, |
2607 int index, | 2609 int index, |
2608 v8::Handle<Value> data) { | 2610 v8::Handle<Value> data) { |
2609 (*env)->SetEmbedderData(index, data); | 2611 (*env)->SetEmbedderData(index, data); |
(...skipping 11 matching lines...) Expand all Loading... |
2621 CheckEmbedderData(&env, 0, v8::Boolean::New(true)); | 2623 CheckEmbedderData(&env, 0, v8::Boolean::New(true)); |
2622 } | 2624 } |
2623 | 2625 |
2624 | 2626 |
2625 THREADED_TEST(IdentityHash) { | 2627 THREADED_TEST(IdentityHash) { |
2626 LocalContext env; | 2628 LocalContext env; |
2627 v8::HandleScope scope(env->GetIsolate()); | 2629 v8::HandleScope scope(env->GetIsolate()); |
2628 | 2630 |
2629 // Ensure that the test starts with an fresh heap to test whether the hash | 2631 // Ensure that the test starts with an fresh heap to test whether the hash |
2630 // code is based on the address. | 2632 // code is based on the address. |
2631 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2633 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2632 Local<v8::Object> obj = v8::Object::New(); | 2634 Local<v8::Object> obj = v8::Object::New(); |
2633 int hash = obj->GetIdentityHash(); | 2635 int hash = obj->GetIdentityHash(); |
2634 int hash1 = obj->GetIdentityHash(); | 2636 int hash1 = obj->GetIdentityHash(); |
2635 CHECK_EQ(hash, hash1); | 2637 CHECK_EQ(hash, hash1); |
2636 int hash2 = v8::Object::New()->GetIdentityHash(); | 2638 int hash2 = v8::Object::New()->GetIdentityHash(); |
2637 // Since the identity hash is essentially a random number two consecutive | 2639 // Since the identity hash is essentially a random number two consecutive |
2638 // objects should not be assigned the same hash code. If the test below fails | 2640 // objects should not be assigned the same hash code. If the test below fails |
2639 // the random number generator should be evaluated. | 2641 // the random number generator should be evaluated. |
2640 CHECK_NE(hash, hash2); | 2642 CHECK_NE(hash, hash2); |
2641 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2643 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2642 int hash3 = v8::Object::New()->GetIdentityHash(); | 2644 int hash3 = v8::Object::New()->GetIdentityHash(); |
2643 // Make sure that the identity hash is not based on the initial address of | 2645 // Make sure that the identity hash is not based on the initial address of |
2644 // the object alone. If the test below fails the random number generator | 2646 // the object alone. If the test below fails the random number generator |
2645 // should be evaluated. | 2647 // should be evaluated. |
2646 CHECK_NE(hash, hash3); | 2648 CHECK_NE(hash, hash3); |
2647 int hash4 = obj->GetIdentityHash(); | 2649 int hash4 = obj->GetIdentityHash(); |
2648 CHECK_EQ(hash, hash4); | 2650 CHECK_EQ(hash, hash4); |
2649 | 2651 |
2650 // Check identity hashes behaviour in the presence of JS accessors. | 2652 // Check identity hashes behaviour in the presence of JS accessors. |
2651 // Put a getter for 'v8::IdentityHash' on the Object's prototype: | 2653 // Put a getter for 'v8::IdentityHash' on the Object's prototype: |
(...skipping 18 matching lines...) Expand all Loading... |
2670 i::FLAG_harmony_symbols = true; | 2672 i::FLAG_harmony_symbols = true; |
2671 | 2673 |
2672 LocalContext env; | 2674 LocalContext env; |
2673 v8::Isolate* isolate = env->GetIsolate(); | 2675 v8::Isolate* isolate = env->GetIsolate(); |
2674 v8::HandleScope scope(isolate); | 2676 v8::HandleScope scope(isolate); |
2675 | 2677 |
2676 v8::Local<v8::Object> obj = v8::Object::New(); | 2678 v8::Local<v8::Object> obj = v8::Object::New(); |
2677 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); | 2679 v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); |
2678 v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, "my-symbol"); | 2680 v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, "my-symbol"); |
2679 | 2681 |
2680 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2682 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2681 | 2683 |
2682 // Check basic symbol functionality. | 2684 // Check basic symbol functionality. |
2683 CHECK(sym1->IsSymbol()); | 2685 CHECK(sym1->IsSymbol()); |
2684 CHECK(sym2->IsSymbol()); | 2686 CHECK(sym2->IsSymbol()); |
2685 CHECK(!obj->IsSymbol()); | 2687 CHECK(!obj->IsSymbol()); |
2686 | 2688 |
2687 CHECK(sym1->Equals(sym1)); | 2689 CHECK(sym1->Equals(sym1)); |
2688 CHECK(sym2->Equals(sym2)); | 2690 CHECK(sym2->Equals(sym2)); |
2689 CHECK(!sym1->Equals(sym2)); | 2691 CHECK(!sym1->Equals(sym2)); |
2690 CHECK(!sym2->Equals(sym1)); | 2692 CHECK(!sym2->Equals(sym1)); |
(...skipping 30 matching lines...) Expand all Loading... |
2721 CHECK(obj->Has(sym1)); | 2723 CHECK(obj->Has(sym1)); |
2722 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2724 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
2723 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); | 2725 CHECK_EQ(v8::None, obj->GetPropertyAttributes(sym1)); |
2724 | 2726 |
2725 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); | 2727 CHECK_EQ(0, obj->GetOwnPropertyNames()->Length()); |
2726 int num_props = obj->GetPropertyNames()->Length(); | 2728 int num_props = obj->GetPropertyNames()->Length(); |
2727 CHECK(obj->Set(v8::String::New("bla"), v8::Integer::New(20))); | 2729 CHECK(obj->Set(v8::String::New("bla"), v8::Integer::New(20))); |
2728 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2730 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
2729 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); | 2731 CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
2730 | 2732 |
2731 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2733 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2732 | 2734 |
2733 // Add another property and delete it afterwards to force the object in | 2735 // Add another property and delete it afterwards to force the object in |
2734 // slow case. | 2736 // slow case. |
2735 CHECK(obj->Set(sym2, v8::Integer::New(2008))); | 2737 CHECK(obj->Set(sym2, v8::Integer::New(2008))); |
2736 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2738 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
2737 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); | 2739 CHECK_EQ(2008, obj->Get(sym2)->Int32Value()); |
2738 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); | 2740 CHECK_EQ(2002, obj->Get(sym1)->Int32Value()); |
2739 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); | 2741 CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
2740 | 2742 |
2741 CHECK(obj->Has(sym1)); | 2743 CHECK(obj->Has(sym1)); |
(...skipping 29 matching lines...) Expand all Loading... |
2771 | 2773 |
2772 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { | 2774 THREADED_TEST(ArrayBuffer_ApiInternalToExternal) { |
2773 LocalContext env; | 2775 LocalContext env; |
2774 v8::Isolate* isolate = env->GetIsolate(); | 2776 v8::Isolate* isolate = env->GetIsolate(); |
2775 v8::HandleScope handle_scope(isolate); | 2777 v8::HandleScope handle_scope(isolate); |
2776 | 2778 |
2777 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(1024); | 2779 Local<v8::ArrayBuffer> ab = v8::ArrayBuffer::New(1024); |
2778 CheckInternalFieldsAreZero(ab); | 2780 CheckInternalFieldsAreZero(ab); |
2779 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); | 2781 CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); |
2780 CHECK(!ab->IsExternal()); | 2782 CHECK(!ab->IsExternal()); |
2781 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 2783 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
2782 | 2784 |
2783 ScopedArrayBufferContents ab_contents(ab->Externalize()); | 2785 ScopedArrayBufferContents ab_contents(ab->Externalize()); |
2784 CHECK(ab->IsExternal()); | 2786 CHECK(ab->IsExternal()); |
2785 | 2787 |
2786 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); | 2788 CHECK_EQ(1024, static_cast<int>(ab_contents.ByteLength())); |
2787 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); | 2789 uint8_t* data = static_cast<uint8_t*>(ab_contents.Data()); |
2788 ASSERT(data != NULL); | 2790 ASSERT(data != NULL); |
2789 env->Global()->Set(v8_str("ab"), ab); | 2791 env->Global()->Set(v8_str("ab"), ab); |
2790 | 2792 |
2791 v8::Handle<v8::Value> result = CompileRun("ab.byteLength"); | 2793 v8::Handle<v8::Value> result = CompileRun("ab.byteLength"); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3013 | 3015 |
3014 THREADED_TEST(HiddenProperties) { | 3016 THREADED_TEST(HiddenProperties) { |
3015 LocalContext env; | 3017 LocalContext env; |
3016 v8::HandleScope scope(env->GetIsolate()); | 3018 v8::HandleScope scope(env->GetIsolate()); |
3017 | 3019 |
3018 v8::Local<v8::Object> obj = v8::Object::New(); | 3020 v8::Local<v8::Object> obj = v8::Object::New(); |
3019 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); | 3021 v8::Local<v8::String> key = v8_str("api-test::hidden-key"); |
3020 v8::Local<v8::String> empty = v8_str(""); | 3022 v8::Local<v8::String> empty = v8_str(""); |
3021 v8::Local<v8::String> prop_name = v8_str("prop_name"); | 3023 v8::Local<v8::String> prop_name = v8_str("prop_name"); |
3022 | 3024 |
3023 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 3025 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
3024 | 3026 |
3025 // Make sure delete of a non-existent hidden value works | 3027 // Make sure delete of a non-existent hidden value works |
3026 CHECK(obj->DeleteHiddenValue(key)); | 3028 CHECK(obj->DeleteHiddenValue(key)); |
3027 | 3029 |
3028 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); | 3030 CHECK(obj->SetHiddenValue(key, v8::Integer::New(1503))); |
3029 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); | 3031 CHECK_EQ(1503, obj->GetHiddenValue(key)->Int32Value()); |
3030 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); | 3032 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); |
3031 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3033 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3032 | 3034 |
3033 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 3035 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
3034 | 3036 |
3035 // Make sure we do not find the hidden property. | 3037 // Make sure we do not find the hidden property. |
3036 CHECK(!obj->Has(empty)); | 3038 CHECK(!obj->Has(empty)); |
3037 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3039 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3038 CHECK(obj->Get(empty)->IsUndefined()); | 3040 CHECK(obj->Get(empty)->IsUndefined()); |
3039 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3041 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3040 CHECK(obj->Set(empty, v8::Integer::New(2003))); | 3042 CHECK(obj->Set(empty, v8::Integer::New(2003))); |
3041 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3043 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3042 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); | 3044 CHECK_EQ(2003, obj->Get(empty)->Int32Value()); |
3043 | 3045 |
3044 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 3046 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
3045 | 3047 |
3046 // Add another property and delete it afterwards to force the object in | 3048 // Add another property and delete it afterwards to force the object in |
3047 // slow case. | 3049 // slow case. |
3048 CHECK(obj->Set(prop_name, v8::Integer::New(2008))); | 3050 CHECK(obj->Set(prop_name, v8::Integer::New(2008))); |
3049 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3051 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3050 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); | 3052 CHECK_EQ(2008, obj->Get(prop_name)->Int32Value()); |
3051 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3053 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3052 CHECK(obj->Delete(prop_name)); | 3054 CHECK(obj->Delete(prop_name)); |
3053 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); | 3055 CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3054 | 3056 |
3055 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 3057 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
3056 | 3058 |
3057 CHECK(obj->SetHiddenValue(key, Handle<Value>())); | 3059 CHECK(obj->SetHiddenValue(key, Handle<Value>())); |
3058 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 3060 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
3059 | 3061 |
3060 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); | 3062 CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); |
3061 CHECK(obj->DeleteHiddenValue(key)); | 3063 CHECK(obj->DeleteHiddenValue(key)); |
3062 CHECK(obj->GetHiddenValue(key).IsEmpty()); | 3064 CHECK(obj->GetHiddenValue(key).IsEmpty()); |
3063 } | 3065 } |
3064 | 3066 |
3065 | 3067 |
(...skipping 3714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6780 } | 6782 } |
6781 | 6783 |
6782 bool object_a_disposed = false; | 6784 bool object_a_disposed = false; |
6783 bool object_b_disposed = false; | 6785 bool object_b_disposed = false; |
6784 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); | 6786 object_a.MakeWeak(&object_a_disposed, &DisposeAndSetFlag); |
6785 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag); | 6787 object_b.MakeWeak(&object_b_disposed, &DisposeAndSetFlag); |
6786 CHECK(!object_b.IsIndependent()); | 6788 CHECK(!object_b.IsIndependent()); |
6787 object_a.MarkIndependent(); | 6789 object_a.MarkIndependent(); |
6788 object_b.MarkIndependent(); | 6790 object_b.MarkIndependent(); |
6789 CHECK(object_b.IsIndependent()); | 6791 CHECK(object_b.IsIndependent()); |
6790 HEAP->PerformScavenge(); | 6792 CcTest::heap()->PerformScavenge(); |
6791 CHECK(object_a_disposed); | 6793 CHECK(object_a_disposed); |
6792 CHECK(object_b_disposed); | 6794 CHECK(object_b_disposed); |
6793 } | 6795 } |
6794 | 6796 |
6795 | 6797 |
6796 static void InvokeScavenge() { | 6798 static void InvokeScavenge() { |
6797 HEAP->PerformScavenge(); | 6799 CcTest::heap()->PerformScavenge(); |
6798 } | 6800 } |
6799 | 6801 |
6800 | 6802 |
6801 static void InvokeMarkSweep() { | 6803 static void InvokeMarkSweep() { |
6802 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 6804 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
6803 } | 6805 } |
6804 | 6806 |
6805 | 6807 |
6806 static void ForceScavenge(v8::Isolate* isolate, | 6808 static void ForceScavenge(v8::Isolate* isolate, |
6807 v8::Persistent<v8::Object>* obj, | 6809 v8::Persistent<v8::Object>* obj, |
6808 bool* data) { | 6810 bool* data) { |
6809 obj->Dispose(); | 6811 obj->Dispose(); |
6810 *(data) = true; | 6812 *(data) = true; |
6811 InvokeScavenge(); | 6813 InvokeScavenge(); |
6812 } | 6814 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6871 v8::HandleScope handle_scope(isolate); | 6873 v8::HandleScope handle_scope(isolate); |
6872 v8::Local<v8::Object> o = v8::Object::New(); | 6874 v8::Local<v8::Object> o = v8::Object::New(); |
6873 object.Reset(isolate, o); | 6875 object.Reset(isolate, o); |
6874 o->Set(v8_str("x"), v8::Integer::New(1)); | 6876 o->Set(v8_str("x"), v8::Integer::New(1)); |
6875 v8::Local<String> y_str = v8_str("y"); | 6877 v8::Local<String> y_str = v8_str("y"); |
6876 o->Set(y_str, y_str); | 6878 o->Set(y_str, y_str); |
6877 } | 6879 } |
6878 bool revived = false; | 6880 bool revived = false; |
6879 object.MakeWeak(&revived, &RevivingCallback); | 6881 object.MakeWeak(&revived, &RevivingCallback); |
6880 object.MarkIndependent(); | 6882 object.MarkIndependent(); |
6881 HEAP->PerformScavenge(); | 6883 CcTest::heap()->PerformScavenge(); |
6882 CHECK(revived); | 6884 CHECK(revived); |
6883 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 6885 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
6884 { | 6886 { |
6885 v8::HandleScope handle_scope(isolate); | 6887 v8::HandleScope handle_scope(isolate); |
6886 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, object); | 6888 v8::Local<v8::Object> o = v8::Local<v8::Object>::New(isolate, object); |
6887 v8::Local<String> y_str = v8_str("y"); | 6889 v8::Local<String> y_str = v8_str("y"); |
6888 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); | 6890 CHECK_EQ(v8::Integer::New(1), o->Get(v8_str("x"))); |
6889 CHECK(o->Get(y_str)->Equals(y_str)); | 6891 CHECK(o->Get(y_str)->Equals(y_str)); |
6890 } | 6892 } |
6891 } | 6893 } |
6892 | 6894 |
6893 | 6895 |
6894 v8::Handle<Function> args_fun; | 6896 v8::Handle<Function> args_fun; |
6895 | 6897 |
6896 | 6898 |
6897 static void ArgumentsTestCallback( | 6899 static void ArgumentsTestCallback( |
6898 const v8::FunctionCallbackInfo<v8::Value>& args) { | 6900 const v8::FunctionCallbackInfo<v8::Value>& args) { |
6899 ApiTestFuzzer::Fuzz(); | 6901 ApiTestFuzzer::Fuzz(); |
6900 CHECK_EQ(args_fun, args.Callee()); | 6902 CHECK_EQ(args_fun, args.Callee()); |
6901 CHECK_EQ(3, args.Length()); | 6903 CHECK_EQ(3, args.Length()); |
6902 CHECK_EQ(v8::Integer::New(1), args[0]); | 6904 CHECK_EQ(v8::Integer::New(1), args[0]); |
6903 CHECK_EQ(v8::Integer::New(2), args[1]); | 6905 CHECK_EQ(v8::Integer::New(2), args[1]); |
6904 CHECK_EQ(v8::Integer::New(3), args[2]); | 6906 CHECK_EQ(v8::Integer::New(3), args[2]); |
6905 CHECK_EQ(v8::Undefined(), args[3]); | 6907 CHECK_EQ(v8::Undefined(), args[3]); |
6906 v8::HandleScope scope(args.GetIsolate()); | 6908 v8::HandleScope scope(args.GetIsolate()); |
6907 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 6909 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
6908 } | 6910 } |
6909 | 6911 |
6910 | 6912 |
6911 THREADED_TEST(Arguments) { | 6913 THREADED_TEST(Arguments) { |
6912 v8::HandleScope scope(CcTest::isolate()); | 6914 v8::HandleScope scope(CcTest::isolate()); |
6913 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); | 6915 v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
6914 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); | 6916 global->Set(v8_str("f"), v8::FunctionTemplate::New(ArgumentsTestCallback)); |
6915 LocalContext context(NULL, global); | 6917 LocalContext context(NULL, global); |
6916 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); | 6918 args_fun = context->Global()->Get(v8_str("f")).As<Function>(); |
6917 v8_compile("f(1, 2, 3)")->Run(); | 6919 v8_compile("f(1, 2, 3)")->Run(); |
(...skipping 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10380 "var p = new constructor();" | 10382 "var p = new constructor();" |
10381 "p.hasOwnProperty('ostehaps');"); | 10383 "p.hasOwnProperty('ostehaps');"); |
10382 CHECK_EQ(false, value->BooleanValue()); | 10384 CHECK_EQ(false, value->BooleanValue()); |
10383 } | 10385 } |
10384 | 10386 |
10385 | 10387 |
10386 static void InterceptorHasOwnPropertyGetterGC( | 10388 static void InterceptorHasOwnPropertyGetterGC( |
10387 Local<String> name, | 10389 Local<String> name, |
10388 const v8::PropertyCallbackInfo<v8::Value>& info) { | 10390 const v8::PropertyCallbackInfo<v8::Value>& info) { |
10389 ApiTestFuzzer::Fuzz(); | 10391 ApiTestFuzzer::Fuzz(); |
10390 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 10392 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
10391 } | 10393 } |
10392 | 10394 |
10393 | 10395 |
10394 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { | 10396 THREADED_TEST(InterceptorHasOwnPropertyCausingGC) { |
10395 LocalContext context; | 10397 LocalContext context; |
10396 v8::HandleScope scope(context->GetIsolate()); | 10398 v8::HandleScope scope(context->GetIsolate()); |
10397 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); | 10399 Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New(); |
10398 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); | 10400 Local<v8::ObjectTemplate> instance_templ = fun_templ->InstanceTemplate(); |
10399 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); | 10401 instance_templ->SetNamedPropertyHandler(InterceptorHasOwnPropertyGetterGC); |
10400 Local<Function> function = fun_templ->GetFunction(); | 10402 Local<Function> function = fun_templ->GetFunction(); |
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11164 | 11166 |
11165 static void InterceptorCallICFastApi( | 11167 static void InterceptorCallICFastApi( |
11166 Local<String> name, | 11168 Local<String> name, |
11167 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11169 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11168 ApiTestFuzzer::Fuzz(); | 11170 ApiTestFuzzer::Fuzz(); |
11169 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); | 11171 CheckReturnValue(info, FUNCTION_ADDR(InterceptorCallICFastApi)); |
11170 int* call_count = | 11172 int* call_count = |
11171 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); | 11173 reinterpret_cast<int*>(v8::External::Cast(*info.Data())->Value()); |
11172 ++(*call_count); | 11174 ++(*call_count); |
11173 if ((*call_count) % 20 == 0) { | 11175 if ((*call_count) % 20 == 0) { |
11174 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 11176 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
11175 } | 11177 } |
11176 } | 11178 } |
11177 | 11179 |
11178 static void FastApiCallback_TrivialSignature( | 11180 static void FastApiCallback_TrivialSignature( |
11179 const v8::FunctionCallbackInfo<v8::Value>& args) { | 11181 const v8::FunctionCallbackInfo<v8::Value>& args) { |
11180 ApiTestFuzzer::Fuzz(); | 11182 ApiTestFuzzer::Fuzz(); |
11181 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); | 11183 CheckReturnValue(args, FUNCTION_ADDR(FastApiCallback_TrivialSignature)); |
11182 v8::Isolate* isolate = CcTest::isolate(); | 11184 v8::Isolate* isolate = CcTest::isolate(); |
11183 CHECK_EQ(isolate, args.GetIsolate()); | 11185 CHECK_EQ(isolate, args.GetIsolate()); |
11184 CHECK_EQ(args.This(), args.Holder()); | 11186 CHECK_EQ(args.This(), args.Holder()); |
(...skipping 23 matching lines...) Expand all Loading... |
11208 "for (var i = 0; i < 1000; i++) {" | 11210 "for (var i = 0; i < 1000; i++) {" |
11209 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" | 11211 " garbage = [1/i, \"garbage\" + i, garbage, {foo: garbage}];" |
11210 "}" | 11212 "}" |
11211 "garbage = undefined;"); | 11213 "garbage = undefined;"); |
11212 } | 11214 } |
11213 | 11215 |
11214 | 11216 |
11215 void DirectApiCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { | 11217 void DirectApiCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { |
11216 static int count = 0; | 11218 static int count = 0; |
11217 if (count++ % 3 == 0) { | 11219 if (count++ % 3 == 0) { |
11218 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 11220 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
11219 // This should move the stub | 11221 // This should move the stub |
11220 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed | 11222 GenerateSomeGarbage(); // This should ensure the old stub memory is flushed |
11221 } | 11223 } |
11222 } | 11224 } |
11223 | 11225 |
11224 | 11226 |
11225 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { | 11227 THREADED_TEST(CallICFastApi_DirectCall_GCMoveStub) { |
11226 LocalContext context; | 11228 LocalContext context; |
11227 v8::HandleScope scope(context->GetIsolate()); | 11229 v8::HandleScope scope(context->GetIsolate()); |
11228 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); | 11230 v8::Handle<v8::ObjectTemplate> nativeobject_templ = v8::ObjectTemplate::New(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11263 " try { nativeobject.callback(); } catch (e) { result += e; }" | 11265 " try { nativeobject.callback(); } catch (e) { result += e; }" |
11264 " }" | 11266 " }" |
11265 "}" | 11267 "}" |
11266 "f(); result;"); | 11268 "f(); result;"); |
11267 CHECK_EQ(v8_str("ggggg"), result); | 11269 CHECK_EQ(v8_str("ggggg"), result); |
11268 } | 11270 } |
11269 | 11271 |
11270 | 11272 |
11271 static Handle<Value> DoDirectGetter() { | 11273 static Handle<Value> DoDirectGetter() { |
11272 if (++p_getter_count % 3 == 0) { | 11274 if (++p_getter_count % 3 == 0) { |
11273 HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); | 11275 CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
11274 GenerateSomeGarbage(); | 11276 GenerateSomeGarbage(); |
11275 } | 11277 } |
11276 return v8_str("Direct Getter Result"); | 11278 return v8_str("Direct Getter Result"); |
11277 } | 11279 } |
11278 | 11280 |
11279 static void DirectGetterCallback( | 11281 static void DirectGetterCallback( |
11280 Local<String> name, | 11282 Local<String> name, |
11281 const v8::PropertyCallbackInfo<v8::Value>& info) { | 11283 const v8::PropertyCallbackInfo<v8::Value>& info) { |
11282 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)); | 11284 CheckReturnValue(info, FUNCTION_ADDR(DirectGetterCallback)); |
11283 info.GetReturnValue().Set(DoDirectGetter()); | 11285 info.GetReturnValue().Set(DoDirectGetter()); |
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12604 Local<Script> script = v8_compile("(function () {" | 12606 Local<Script> script = v8_compile("(function () {" |
12605 " unlock_for_a_moment();" | 12607 " unlock_for_a_moment();" |
12606 " return 42;" | 12608 " return 42;" |
12607 "})();"); | 12609 "})();"); |
12608 CHECK_EQ(42, script->Run()->Int32Value()); | 12610 CHECK_EQ(42, script->Run()->Int32Value()); |
12609 } | 12611 } |
12610 } | 12612 } |
12611 | 12613 |
12612 | 12614 |
12613 static int GetGlobalObjectsCount() { | 12615 static int GetGlobalObjectsCount() { |
12614 CcTest::i_isolate()->heap()->EnsureHeapIsIterable(); | 12616 CcTest::heap()->EnsureHeapIsIterable(); |
12615 int count = 0; | 12617 int count = 0; |
12616 i::HeapIterator it(HEAP); | 12618 i::HeapIterator it(CcTest::heap()); |
12617 for (i::HeapObject* object = it.next(); object != NULL; object = it.next()) | 12619 for (i::HeapObject* object = it.next(); object != NULL; object = it.next()) |
12618 if (object->IsJSGlobalObject()) count++; | 12620 if (object->IsJSGlobalObject()) count++; |
12619 return count; | 12621 return count; |
12620 } | 12622 } |
12621 | 12623 |
12622 | 12624 |
12623 static void CheckSurvivingGlobalObjectsCount(int expected) { | 12625 static void CheckSurvivingGlobalObjectsCount(int expected) { |
12624 // We need to collect all garbage twice to be sure that everything | 12626 // We need to collect all garbage twice to be sure that everything |
12625 // has been collected. This is because inline caches are cleared in | 12627 // has been collected. This is because inline caches are cleared in |
12626 // the first garbage collection but some of the maps have already | 12628 // the first garbage collection but some of the maps have already |
12627 // been marked at that point. Therefore some of the maps are not | 12629 // been marked at that point. Therefore some of the maps are not |
12628 // collected until the second garbage collection. | 12630 // collected until the second garbage collection. |
12629 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 12631 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
12630 HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); | 12632 CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask); |
12631 int count = GetGlobalObjectsCount(); | 12633 int count = GetGlobalObjectsCount(); |
12632 #ifdef DEBUG | 12634 #ifdef DEBUG |
12633 if (count != expected) HEAP->TracePathToGlobal(); | 12635 if (count != expected) CcTest::heap()->TracePathToGlobal(); |
12634 #endif | 12636 #endif |
12635 CHECK_EQ(expected, count); | 12637 CHECK_EQ(expected, count); |
12636 } | 12638 } |
12637 | 12639 |
12638 | 12640 |
12639 TEST(DontLeakGlobalObjects) { | 12641 TEST(DontLeakGlobalObjects) { |
12640 // Regression test for issues 1139850 and 1174891. | 12642 // Regression test for issues 1139850 and 1174891. |
12641 | 12643 |
12642 v8::V8::Initialize(); | 12644 v8::V8::Initialize(); |
12643 | 12645 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12765 some_object.Reset(isolate, v8::Object::New()); | 12767 some_object.Reset(isolate, v8::Object::New()); |
12766 handle1.Reset(isolate, v8::Object::New()); | 12768 handle1.Reset(isolate, v8::Object::New()); |
12767 handle2.Reset(isolate, v8::Object::New()); | 12769 handle2.Reset(isolate, v8::Object::New()); |
12768 } | 12770 } |
12769 // Note: order is implementation dependent alas: currently | 12771 // Note: order is implementation dependent alas: currently |
12770 // global handle nodes are processed by PostGarbageCollectionProcessing | 12772 // global handle nodes are processed by PostGarbageCollectionProcessing |
12771 // in reverse allocation order, so if second allocated handle is deleted, | 12773 // in reverse allocation order, so if second allocated handle is deleted, |
12772 // weak callback of the first handle would be able to 'reallocate' it. | 12774 // weak callback of the first handle would be able to 'reallocate' it. |
12773 handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback); | 12775 handle1.MakeWeak<v8::Value, void>(NULL, NewPersistentHandleCallback); |
12774 handle2.Dispose(); | 12776 handle2.Dispose(); |
12775 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 12777 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
12776 } | 12778 } |
12777 | 12779 |
12778 | 12780 |
12779 v8::Persistent<v8::Object> to_be_disposed; | 12781 v8::Persistent<v8::Object> to_be_disposed; |
12780 | 12782 |
12781 void DisposeAndForceGcCallback(v8::Isolate* isolate, | 12783 void DisposeAndForceGcCallback(v8::Isolate* isolate, |
12782 v8::Persistent<v8::Value>* handle, | 12784 v8::Persistent<v8::Value>* handle, |
12783 void*) { | 12785 void*) { |
12784 to_be_disposed.Dispose(); | 12786 to_be_disposed.Dispose(); |
12785 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 12787 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
12786 handle->Dispose(); | 12788 handle->Dispose(); |
12787 } | 12789 } |
12788 | 12790 |
12789 | 12791 |
12790 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { | 12792 THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) { |
12791 LocalContext context; | 12793 LocalContext context; |
12792 v8::Isolate* isolate = context->GetIsolate(); | 12794 v8::Isolate* isolate = context->GetIsolate(); |
12793 | 12795 |
12794 v8::Persistent<v8::Object> handle1, handle2; | 12796 v8::Persistent<v8::Object> handle1, handle2; |
12795 { | 12797 { |
12796 v8::HandleScope scope(isolate); | 12798 v8::HandleScope scope(isolate); |
12797 handle1.Reset(isolate, v8::Object::New()); | 12799 handle1.Reset(isolate, v8::Object::New()); |
12798 handle2.Reset(isolate, v8::Object::New()); | 12800 handle2.Reset(isolate, v8::Object::New()); |
12799 } | 12801 } |
12800 handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback); | 12802 handle1.MakeWeak<v8::Value, void>(NULL, DisposeAndForceGcCallback); |
12801 to_be_disposed.Reset(isolate, handle2); | 12803 to_be_disposed.Reset(isolate, handle2); |
12802 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 12804 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
12803 } | 12805 } |
12804 | 12806 |
12805 void DisposingCallback(v8::Isolate* isolate, | 12807 void DisposingCallback(v8::Isolate* isolate, |
12806 v8::Persistent<v8::Value>* handle, | 12808 v8::Persistent<v8::Value>* handle, |
12807 void*) { | 12809 void*) { |
12808 handle->Dispose(); | 12810 handle->Dispose(); |
12809 } | 12811 } |
12810 | 12812 |
12811 void HandleCreatingCallback(v8::Isolate* isolate, | 12813 void HandleCreatingCallback(v8::Isolate* isolate, |
12812 v8::Persistent<v8::Value>* handle, | 12814 v8::Persistent<v8::Value>* handle, |
(...skipping 10 matching lines...) Expand all Loading... |
12823 | 12825 |
12824 v8::Persistent<v8::Object> handle1, handle2, handle3; | 12826 v8::Persistent<v8::Object> handle1, handle2, handle3; |
12825 { | 12827 { |
12826 v8::HandleScope scope(isolate); | 12828 v8::HandleScope scope(isolate); |
12827 handle3.Reset(isolate, v8::Object::New()); | 12829 handle3.Reset(isolate, v8::Object::New()); |
12828 handle2.Reset(isolate, v8::Object::New()); | 12830 handle2.Reset(isolate, v8::Object::New()); |
12829 handle1.Reset(isolate, v8::Object::New()); | 12831 handle1.Reset(isolate, v8::Object::New()); |
12830 } | 12832 } |
12831 handle2.MakeWeak<v8::Value, void>(NULL, DisposingCallback); | 12833 handle2.MakeWeak<v8::Value, void>(NULL, DisposingCallback); |
12832 handle3.MakeWeak<v8::Value, void>(NULL, HandleCreatingCallback); | 12834 handle3.MakeWeak<v8::Value, void>(NULL, HandleCreatingCallback); |
12833 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 12835 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
12834 } | 12836 } |
12835 | 12837 |
12836 | 12838 |
12837 THREADED_TEST(CheckForCrossContextObjectLiterals) { | 12839 THREADED_TEST(CheckForCrossContextObjectLiterals) { |
12838 v8::V8::Initialize(); | 12840 v8::V8::Initialize(); |
12839 | 12841 |
12840 const int nof = 2; | 12842 const int nof = 2; |
12841 const char* sources[nof] = { | 12843 const char* sources[nof] = { |
12842 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", | 12844 "try { [ 2, 3, 4 ].forEach(5); } catch(e) { e.toString(); }", |
12843 "Object()" | 12845 "Object()" |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13372 " sum = foo(i);" | 13374 " sum = foo(i);" |
13373 " return sum;" | 13375 " return sum;" |
13374 "}" | 13376 "}" |
13375 "function foo(i) { return i * i; };" | 13377 "function foo(i) { return i * i; };" |
13376 "bar();"; | 13378 "bar();"; |
13377 | 13379 |
13378 // Run this test in a new isolate to make sure we don't | 13380 // Run this test in a new isolate to make sure we don't |
13379 // have remnants of state from other code. | 13381 // have remnants of state from other code. |
13380 v8::Isolate* isolate = v8::Isolate::New(); | 13382 v8::Isolate* isolate = v8::Isolate::New(); |
13381 isolate->Enter(); | 13383 isolate->Enter(); |
| 13384 i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap(); |
13382 | 13385 |
13383 { | 13386 { |
13384 v8::HandleScope scope(isolate); | 13387 v8::HandleScope scope(isolate); |
13385 i::HashMap code(MatchPointers); | 13388 i::HashMap code(MatchPointers); |
13386 code_map = &code; | 13389 code_map = &code; |
13387 | 13390 |
13388 i::HashMap lineinfo(MatchPointers); | 13391 i::HashMap lineinfo(MatchPointers); |
13389 jitcode_line_info = &lineinfo; | 13392 jitcode_line_info = &lineinfo; |
13390 | 13393 |
13391 saw_bar = 0; | 13394 saw_bar = 0; |
13392 move_events = 0; | 13395 move_events = 0; |
13393 | 13396 |
13394 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); | 13397 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, event_handler); |
13395 | 13398 |
13396 // Generate new code objects sparsely distributed across several | 13399 // Generate new code objects sparsely distributed across several |
13397 // different fragmented code-space pages. | 13400 // different fragmented code-space pages. |
13398 const int kIterations = 10; | 13401 const int kIterations = 10; |
13399 for (int i = 0; i < kIterations; ++i) { | 13402 for (int i = 0; i < kIterations; ++i) { |
13400 LocalContext env; | 13403 LocalContext env; |
13401 i::AlwaysAllocateScope always_allocate; | 13404 i::AlwaysAllocateScope always_allocate; |
13402 SimulateFullSpace(HEAP->code_space()); | 13405 SimulateFullSpace(heap->code_space()); |
13403 CompileRun(script); | 13406 CompileRun(script); |
13404 | 13407 |
13405 // Keep a strong reference to the code object in the handle scope. | 13408 // Keep a strong reference to the code object in the handle scope. |
13406 i::Handle<i::Code> bar_code(i::Handle<i::JSFunction>::cast( | 13409 i::Handle<i::Code> bar_code(i::Handle<i::JSFunction>::cast( |
13407 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar"))))->code()); | 13410 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("bar"))))->code()); |
13408 i::Handle<i::Code> foo_code(i::Handle<i::JSFunction>::cast( | 13411 i::Handle<i::Code> foo_code(i::Handle<i::JSFunction>::cast( |
13409 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo"))))->code()); | 13412 v8::Utils::OpenHandle(*env->Global()->Get(v8_str("foo"))))->code()); |
13410 | 13413 |
13411 // Clear the compilation cache to get more wastage. | 13414 // Clear the compilation cache to get more wastage. |
13412 reinterpret_cast<i::Isolate*>(isolate)->compilation_cache()->Clear(); | 13415 reinterpret_cast<i::Isolate*>(isolate)->compilation_cache()->Clear(); |
13413 } | 13416 } |
13414 | 13417 |
13415 // Force code movement. | 13418 // Force code movement. |
13416 HEAP->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); | 13419 heap->CollectAllAvailableGarbage("TestSetJitCodeEventHandler"); |
13417 | 13420 |
13418 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); | 13421 V8::SetJitCodeEventHandler(v8::kJitCodeEventDefault, NULL); |
13419 | 13422 |
13420 CHECK_LE(kIterations, saw_bar); | 13423 CHECK_LE(kIterations, saw_bar); |
13421 CHECK_LT(0, move_events); | 13424 CHECK_LT(0, move_events); |
13422 | 13425 |
13423 code_map = NULL; | 13426 code_map = NULL; |
13424 jitcode_line_info = NULL; | 13427 jitcode_line_info = NULL; |
13425 } | 13428 } |
13426 | 13429 |
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14248 private: | 14251 private: |
14249 RegExpInterruptTest* test_; | 14252 RegExpInterruptTest* test_; |
14250 }; | 14253 }; |
14251 | 14254 |
14252 void CollectGarbage() { | 14255 void CollectGarbage() { |
14253 block_.Wait(); | 14256 block_.Wait(); |
14254 while (gc_during_regexp_ < kRequiredGCs) { | 14257 while (gc_during_regexp_ < kRequiredGCs) { |
14255 { | 14258 { |
14256 v8::Locker lock(CcTest::default_isolate()); | 14259 v8::Locker lock(CcTest::default_isolate()); |
14257 // TODO(lrn): Perhaps create some garbage before collecting. | 14260 // TODO(lrn): Perhaps create some garbage before collecting. |
14258 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14261 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
14259 gc_count_++; | 14262 gc_count_++; |
14260 } | 14263 } |
14261 i::OS::Sleep(1); | 14264 i::OS::Sleep(1); |
14262 } | 14265 } |
14263 gc_success_ = true; | 14266 gc_success_ = true; |
14264 } | 14267 } |
14265 | 14268 |
14266 void LongRunningRegExp() { | 14269 void LongRunningRegExp() { |
14267 block_.Signal(); // Enable garbage collection thread on next preemption. | 14270 block_.Signal(); // Enable garbage collection thread on next preemption. |
14268 int rounds = 0; | 14271 int rounds = 0; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14369 } | 14372 } |
14370 private: | 14373 private: |
14371 ApplyInterruptTest* test_; | 14374 ApplyInterruptTest* test_; |
14372 }; | 14375 }; |
14373 | 14376 |
14374 void CollectGarbage() { | 14377 void CollectGarbage() { |
14375 block_.Wait(); | 14378 block_.Wait(); |
14376 while (gc_during_apply_ < kRequiredGCs) { | 14379 while (gc_during_apply_ < kRequiredGCs) { |
14377 { | 14380 { |
14378 v8::Locker lock(CcTest::default_isolate()); | 14381 v8::Locker lock(CcTest::default_isolate()); |
14379 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 14382 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
14380 gc_count_++; | 14383 gc_count_++; |
14381 } | 14384 } |
14382 i::OS::Sleep(1); | 14385 i::OS::Sleep(1); |
14383 } | 14386 } |
14384 gc_success_ = true; | 14387 gc_success_ = true; |
14385 } | 14388 } |
14386 | 14389 |
14387 void LongRunningApply() { | 14390 void LongRunningApply() { |
14388 block_.Signal(); | 14391 block_.Signal(); |
14389 int rounds = 0; | 14392 int rounds = 0; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14498 i::Vector<const i::uc16> data_; | 14501 i::Vector<const i::uc16> data_; |
14499 }; | 14502 }; |
14500 | 14503 |
14501 | 14504 |
14502 static void MorphAString(i::String* string, | 14505 static void MorphAString(i::String* string, |
14503 AsciiVectorResource* ascii_resource, | 14506 AsciiVectorResource* ascii_resource, |
14504 UC16VectorResource* uc16_resource) { | 14507 UC16VectorResource* uc16_resource) { |
14505 CHECK(i::StringShape(string).IsExternal()); | 14508 CHECK(i::StringShape(string).IsExternal()); |
14506 if (string->IsOneByteRepresentation()) { | 14509 if (string->IsOneByteRepresentation()) { |
14507 // Check old map is not internalized or long. | 14510 // Check old map is not internalized or long. |
14508 CHECK(string->map() == HEAP->external_ascii_string_map()); | 14511 CHECK(string->map() == CcTest::heap()->external_ascii_string_map()); |
14509 // Morph external string to be TwoByte string. | 14512 // Morph external string to be TwoByte string. |
14510 string->set_map(HEAP->external_string_map()); | 14513 string->set_map(CcTest::heap()->external_string_map()); |
14511 i::ExternalTwoByteString* morphed = | 14514 i::ExternalTwoByteString* morphed = |
14512 i::ExternalTwoByteString::cast(string); | 14515 i::ExternalTwoByteString::cast(string); |
14513 morphed->set_resource(uc16_resource); | 14516 morphed->set_resource(uc16_resource); |
14514 } else { | 14517 } else { |
14515 // Check old map is not internalized or long. | 14518 // Check old map is not internalized or long. |
14516 CHECK(string->map() == HEAP->external_string_map()); | 14519 CHECK(string->map() == CcTest::heap()->external_string_map()); |
14517 // Morph external string to be ASCII string. | 14520 // Morph external string to be ASCII string. |
14518 string->set_map(HEAP->external_ascii_string_map()); | 14521 string->set_map(CcTest::heap()->external_ascii_string_map()); |
14519 i::ExternalAsciiString* morphed = | 14522 i::ExternalAsciiString* morphed = |
14520 i::ExternalAsciiString::cast(string); | 14523 i::ExternalAsciiString::cast(string); |
14521 morphed->set_resource(ascii_resource); | 14524 morphed->set_resource(ascii_resource); |
14522 } | 14525 } |
14523 } | 14526 } |
14524 | 14527 |
14525 | 14528 |
14526 // Test that we can still flatten a string if the components it is built up | 14529 // Test that we can still flatten a string if the components it is built up |
14527 // from have been turned into 16 bit strings in the mean time. | 14530 // from have been turned into 16 bit strings in the mean time. |
14528 THREADED_TEST(MorphCompositeStringTest) { | 14531 THREADED_TEST(MorphCompositeStringTest) { |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15166 i::Factory* factory = isolate->factory(); | 15169 i::Factory* factory = isolate->factory(); |
15167 v8::HandleScope scope(context->GetIsolate()); | 15170 v8::HandleScope scope(context->GetIsolate()); |
15168 const int kElementCount = 260; | 15171 const int kElementCount = 260; |
15169 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); | 15172 uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount)); |
15170 i::Handle<i::ExternalPixelArray> pixels = | 15173 i::Handle<i::ExternalPixelArray> pixels = |
15171 i::Handle<i::ExternalPixelArray>::cast( | 15174 i::Handle<i::ExternalPixelArray>::cast( |
15172 factory->NewExternalArray(kElementCount, | 15175 factory->NewExternalArray(kElementCount, |
15173 v8::kExternalPixelArray, | 15176 v8::kExternalPixelArray, |
15174 pixel_data)); | 15177 pixel_data)); |
15175 // Force GC to trigger verification. | 15178 // Force GC to trigger verification. |
15176 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15179 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
15177 for (int i = 0; i < kElementCount; i++) { | 15180 for (int i = 0; i < kElementCount; i++) { |
15178 pixels->set(i, i % 256); | 15181 pixels->set(i, i % 256); |
15179 } | 15182 } |
15180 // Force GC to trigger verification. | 15183 // Force GC to trigger verification. |
15181 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15184 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
15182 for (int i = 0; i < kElementCount; i++) { | 15185 for (int i = 0; i < kElementCount; i++) { |
15183 CHECK_EQ(i % 256, pixels->get_scalar(i)); | 15186 CHECK_EQ(i % 256, pixels->get_scalar(i)); |
15184 CHECK_EQ(i % 256, pixel_data[i]); | 15187 CHECK_EQ(i % 256, pixel_data[i]); |
15185 } | 15188 } |
15186 | 15189 |
15187 v8::Handle<v8::Object> obj = v8::Object::New(); | 15190 v8::Handle<v8::Object> obj = v8::Object::New(); |
15188 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 15191 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
15189 // Set the elements to be the pixels. | 15192 // Set the elements to be the pixels. |
15190 // jsobj->set_elements(*pixels); | 15193 // jsobj->set_elements(*pixels); |
15191 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); | 15194 obj->SetIndexedPropertiesToPixelData(pixel_data, kElementCount); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15742 "var sum = 0;" | 15745 "var sum = 0;" |
15743 "for (var i = 0; i < 8; i++) {" | 15746 "for (var i = 0; i < 8; i++) {" |
15744 " tmp_array[i] = i;" | 15747 " tmp_array[i] = i;" |
15745 " sum += tmp_array[i];" | 15748 " sum += tmp_array[i];" |
15746 " if (i == 4) {" | 15749 " if (i == 4) {" |
15747 " tmp_array = {};" | 15750 " tmp_array = {};" |
15748 " }" | 15751 " }" |
15749 "}" | 15752 "}" |
15750 "sum;"); | 15753 "sum;"); |
15751 // Force GC to trigger verification. | 15754 // Force GC to trigger verification. |
15752 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15755 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
15753 CHECK_EQ(28, result->Int32Value()); | 15756 CHECK_EQ(28, result->Int32Value()); |
15754 | 15757 |
15755 // Make sure out-of-range loads do not throw. | 15758 // Make sure out-of-range loads do not throw. |
15756 i::OS::SNPrintF(test_buf, | 15759 i::OS::SNPrintF(test_buf, |
15757 "var caught_exception = false;" | 15760 "var caught_exception = false;" |
15758 "try {" | 15761 "try {" |
15759 " ext_array[%d];" | 15762 " ext_array[%d];" |
15760 "} catch (e) {" | 15763 "} catch (e) {" |
15761 " caught_exception = true;" | 15764 " caught_exception = true;" |
15762 "}" | 15765 "}" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15946 i::Factory* factory = isolate->factory(); | 15949 i::Factory* factory = isolate->factory(); |
15947 v8::HandleScope scope(context->GetIsolate()); | 15950 v8::HandleScope scope(context->GetIsolate()); |
15948 const int kElementCount = 40; | 15951 const int kElementCount = 40; |
15949 int element_size = ExternalArrayElementSize(array_type); | 15952 int element_size = ExternalArrayElementSize(array_type); |
15950 ElementType* array_data = | 15953 ElementType* array_data = |
15951 static_cast<ElementType*>(malloc(kElementCount * element_size)); | 15954 static_cast<ElementType*>(malloc(kElementCount * element_size)); |
15952 i::Handle<ExternalArrayClass> array = | 15955 i::Handle<ExternalArrayClass> array = |
15953 i::Handle<ExternalArrayClass>::cast( | 15956 i::Handle<ExternalArrayClass>::cast( |
15954 factory->NewExternalArray(kElementCount, array_type, array_data)); | 15957 factory->NewExternalArray(kElementCount, array_type, array_data)); |
15955 // Force GC to trigger verification. | 15958 // Force GC to trigger verification. |
15956 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15959 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
15957 for (int i = 0; i < kElementCount; i++) { | 15960 for (int i = 0; i < kElementCount; i++) { |
15958 array->set(i, static_cast<ElementType>(i)); | 15961 array->set(i, static_cast<ElementType>(i)); |
15959 } | 15962 } |
15960 // Force GC to trigger verification. | 15963 // Force GC to trigger verification. |
15961 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 15964 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
15962 for (int i = 0; i < kElementCount; i++) { | 15965 for (int i = 0; i < kElementCount; i++) { |
15963 CHECK_EQ(static_cast<int64_t>(i), | 15966 CHECK_EQ(static_cast<int64_t>(i), |
15964 static_cast<int64_t>(array->get_scalar(i))); | 15967 static_cast<int64_t>(array->get_scalar(i))); |
15965 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); | 15968 CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i])); |
15966 } | 15969 } |
15967 | 15970 |
15968 v8::Handle<v8::Object> obj = v8::Object::New(); | 15971 v8::Handle<v8::Object> obj = v8::Object::New(); |
15969 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); | 15972 i::Handle<i::JSObject> jsobj = v8::Utils::OpenHandle(*obj); |
15970 // Set the elements to be the external array. | 15973 // Set the elements to be the external array. |
15971 obj->SetIndexedPropertiesToExternalArrayData(array_data, | 15974 obj->SetIndexedPropertiesToExternalArrayData(array_data, |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16951 factory->NewFixedArray(1000, i::TENURED); | 16954 factory->NewFixedArray(1000, i::TENURED); |
16952 } | 16955 } |
16953 } | 16956 } |
16954 | 16957 |
16955 | 16958 |
16956 // Test that idle notification can be handled and eventually returns true. | 16959 // Test that idle notification can be handled and eventually returns true. |
16957 TEST(IdleNotification) { | 16960 TEST(IdleNotification) { |
16958 const intptr_t MB = 1024 * 1024; | 16961 const intptr_t MB = 1024 * 1024; |
16959 LocalContext env; | 16962 LocalContext env; |
16960 v8::HandleScope scope(env->GetIsolate()); | 16963 v8::HandleScope scope(env->GetIsolate()); |
16961 intptr_t initial_size = HEAP->SizeOfObjects(); | 16964 intptr_t initial_size = CcTest::heap()->SizeOfObjects(); |
16962 CreateGarbageInOldSpace(); | 16965 CreateGarbageInOldSpace(); |
16963 intptr_t size_with_garbage = HEAP->SizeOfObjects(); | 16966 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); |
16964 CHECK_GT(size_with_garbage, initial_size + MB); | 16967 CHECK_GT(size_with_garbage, initial_size + MB); |
16965 bool finished = false; | 16968 bool finished = false; |
16966 for (int i = 0; i < 200 && !finished; i++) { | 16969 for (int i = 0; i < 200 && !finished; i++) { |
16967 finished = v8::V8::IdleNotification(); | 16970 finished = v8::V8::IdleNotification(); |
16968 } | 16971 } |
16969 intptr_t final_size = HEAP->SizeOfObjects(); | 16972 intptr_t final_size = CcTest::heap()->SizeOfObjects(); |
16970 CHECK(finished); | 16973 CHECK(finished); |
16971 CHECK_LT(final_size, initial_size + 1); | 16974 CHECK_LT(final_size, initial_size + 1); |
16972 } | 16975 } |
16973 | 16976 |
16974 | 16977 |
16975 // Test that idle notification can be handled and eventually collects garbage. | 16978 // Test that idle notification can be handled and eventually collects garbage. |
16976 TEST(IdleNotificationWithSmallHint) { | 16979 TEST(IdleNotificationWithSmallHint) { |
16977 const intptr_t MB = 1024 * 1024; | 16980 const intptr_t MB = 1024 * 1024; |
16978 const int IdlePauseInMs = 900; | 16981 const int IdlePauseInMs = 900; |
16979 LocalContext env; | 16982 LocalContext env; |
16980 v8::HandleScope scope(env->GetIsolate()); | 16983 v8::HandleScope scope(env->GetIsolate()); |
16981 intptr_t initial_size = HEAP->SizeOfObjects(); | 16984 intptr_t initial_size = CcTest::heap()->SizeOfObjects(); |
16982 CreateGarbageInOldSpace(); | 16985 CreateGarbageInOldSpace(); |
16983 intptr_t size_with_garbage = HEAP->SizeOfObjects(); | 16986 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); |
16984 CHECK_GT(size_with_garbage, initial_size + MB); | 16987 CHECK_GT(size_with_garbage, initial_size + MB); |
16985 bool finished = false; | 16988 bool finished = false; |
16986 for (int i = 0; i < 200 && !finished; i++) { | 16989 for (int i = 0; i < 200 && !finished; i++) { |
16987 finished = v8::V8::IdleNotification(IdlePauseInMs); | 16990 finished = v8::V8::IdleNotification(IdlePauseInMs); |
16988 } | 16991 } |
16989 intptr_t final_size = HEAP->SizeOfObjects(); | 16992 intptr_t final_size = CcTest::heap()->SizeOfObjects(); |
16990 CHECK(finished); | 16993 CHECK(finished); |
16991 CHECK_LT(final_size, initial_size + 1); | 16994 CHECK_LT(final_size, initial_size + 1); |
16992 } | 16995 } |
16993 | 16996 |
16994 | 16997 |
16995 // Test that idle notification can be handled and eventually collects garbage. | 16998 // Test that idle notification can be handled and eventually collects garbage. |
16996 TEST(IdleNotificationWithLargeHint) { | 16999 TEST(IdleNotificationWithLargeHint) { |
16997 const intptr_t MB = 1024 * 1024; | 17000 const intptr_t MB = 1024 * 1024; |
16998 const int IdlePauseInMs = 900; | 17001 const int IdlePauseInMs = 900; |
16999 LocalContext env; | 17002 LocalContext env; |
17000 v8::HandleScope scope(env->GetIsolate()); | 17003 v8::HandleScope scope(env->GetIsolate()); |
17001 intptr_t initial_size = HEAP->SizeOfObjects(); | 17004 intptr_t initial_size = CcTest::heap()->SizeOfObjects(); |
17002 CreateGarbageInOldSpace(); | 17005 CreateGarbageInOldSpace(); |
17003 intptr_t size_with_garbage = HEAP->SizeOfObjects(); | 17006 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); |
17004 CHECK_GT(size_with_garbage, initial_size + MB); | 17007 CHECK_GT(size_with_garbage, initial_size + MB); |
17005 bool finished = false; | 17008 bool finished = false; |
17006 for (int i = 0; i < 200 && !finished; i++) { | 17009 for (int i = 0; i < 200 && !finished; i++) { |
17007 finished = v8::V8::IdleNotification(IdlePauseInMs); | 17010 finished = v8::V8::IdleNotification(IdlePauseInMs); |
17008 } | 17011 } |
17009 intptr_t final_size = HEAP->SizeOfObjects(); | 17012 intptr_t final_size = CcTest::heap()->SizeOfObjects(); |
17010 CHECK(finished); | 17013 CHECK(finished); |
17011 CHECK_LT(final_size, initial_size + 1); | 17014 CHECK_LT(final_size, initial_size + 1); |
17012 } | 17015 } |
17013 | 17016 |
17014 | 17017 |
17015 TEST(Regress2107) { | 17018 TEST(Regress2107) { |
17016 const intptr_t MB = 1024 * 1024; | 17019 const intptr_t MB = 1024 * 1024; |
17017 const int kShortIdlePauseInMs = 100; | 17020 const int kShortIdlePauseInMs = 100; |
17018 const int kLongIdlePauseInMs = 1000; | 17021 const int kLongIdlePauseInMs = 1000; |
17019 LocalContext env; | 17022 LocalContext env; |
17020 v8::Isolate* isolate = env->GetIsolate(); | 17023 v8::Isolate* isolate = env->GetIsolate(); |
17021 v8::HandleScope scope(env->GetIsolate()); | 17024 v8::HandleScope scope(env->GetIsolate()); |
17022 intptr_t initial_size = HEAP->SizeOfObjects(); | 17025 intptr_t initial_size = CcTest::heap()->SizeOfObjects(); |
17023 // Send idle notification to start a round of incremental GCs. | 17026 // Send idle notification to start a round of incremental GCs. |
17024 v8::V8::IdleNotification(kShortIdlePauseInMs); | 17027 v8::V8::IdleNotification(kShortIdlePauseInMs); |
17025 // Emulate 7 page reloads. | 17028 // Emulate 7 page reloads. |
17026 for (int i = 0; i < 7; i++) { | 17029 for (int i = 0; i < 7; i++) { |
17027 { | 17030 { |
17028 v8::HandleScope inner_scope(env->GetIsolate()); | 17031 v8::HandleScope inner_scope(env->GetIsolate()); |
17029 v8::Local<v8::Context> ctx = v8::Context::New(isolate); | 17032 v8::Local<v8::Context> ctx = v8::Context::New(isolate); |
17030 ctx->Enter(); | 17033 ctx->Enter(); |
17031 CreateGarbageInOldSpace(); | 17034 CreateGarbageInOldSpace(); |
17032 ctx->Exit(); | 17035 ctx->Exit(); |
17033 } | 17036 } |
17034 v8::V8::ContextDisposedNotification(); | 17037 v8::V8::ContextDisposedNotification(); |
17035 v8::V8::IdleNotification(kLongIdlePauseInMs); | 17038 v8::V8::IdleNotification(kLongIdlePauseInMs); |
17036 } | 17039 } |
17037 // Create garbage and check that idle notification still collects it. | 17040 // Create garbage and check that idle notification still collects it. |
17038 CreateGarbageInOldSpace(); | 17041 CreateGarbageInOldSpace(); |
17039 intptr_t size_with_garbage = HEAP->SizeOfObjects(); | 17042 intptr_t size_with_garbage = CcTest::heap()->SizeOfObjects(); |
17040 CHECK_GT(size_with_garbage, initial_size + MB); | 17043 CHECK_GT(size_with_garbage, initial_size + MB); |
17041 bool finished = false; | 17044 bool finished = false; |
17042 for (int i = 0; i < 200 && !finished; i++) { | 17045 for (int i = 0; i < 200 && !finished; i++) { |
17043 finished = v8::V8::IdleNotification(kShortIdlePauseInMs); | 17046 finished = v8::V8::IdleNotification(kShortIdlePauseInMs); |
17044 } | 17047 } |
17045 intptr_t final_size = HEAP->SizeOfObjects(); | 17048 intptr_t final_size = CcTest::heap()->SizeOfObjects(); |
17046 CHECK_LT(final_size, initial_size + 1); | 17049 CHECK_LT(final_size, initial_size + 1); |
17047 } | 17050 } |
17048 | 17051 |
17049 static uint32_t* stack_limit; | 17052 static uint32_t* stack_limit; |
17050 | 17053 |
17051 static void GetStackLimitCallback( | 17054 static void GetStackLimitCallback( |
17052 const v8::FunctionCallbackInfo<v8::Value>& args) { | 17055 const v8::FunctionCallbackInfo<v8::Value>& args) { |
17053 stack_limit = reinterpret_cast<uint32_t*>( | 17056 stack_limit = reinterpret_cast<uint32_t*>( |
17054 CcTest::i_isolate()->stack_guard()->real_climit()); | 17057 CcTest::i_isolate()->stack_guard()->real_climit()); |
17055 } | 17058 } |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17183 v8::Local<v8::String> string1 = v8::String::NewExternal(resource[1]); | 17186 v8::Local<v8::String> string1 = v8::String::NewExternal(resource[1]); |
17184 | 17187 |
17185 // Externalized symbol. | 17188 // Externalized symbol. |
17186 resource[2] = new TestResource(two_byte_string); | 17189 resource[2] = new TestResource(two_byte_string); |
17187 v8::Local<v8::String> string2 = v8::String::NewSymbol(string); | 17190 v8::Local<v8::String> string2 = v8::String::NewSymbol(string); |
17188 CHECK(string2->MakeExternal(resource[2])); | 17191 CHECK(string2->MakeExternal(resource[2])); |
17189 | 17192 |
17190 // Symbolized External. | 17193 // Symbolized External. |
17191 resource[3] = new TestResource(AsciiToTwoByteString("Some other string")); | 17194 resource[3] = new TestResource(AsciiToTwoByteString("Some other string")); |
17192 v8::Local<v8::String> string3 = v8::String::NewExternal(resource[3]); | 17195 v8::Local<v8::String> string3 = v8::String::NewExternal(resource[3]); |
17193 HEAP->CollectAllAvailableGarbage(); // Tenure string. | 17196 CcTest::heap()->CollectAllAvailableGarbage(); // Tenure string. |
17194 // Turn into a symbol. | 17197 // Turn into a symbol. |
17195 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3); | 17198 i::Handle<i::String> string3_i = v8::Utils::OpenHandle(*string3); |
17196 CHECK(!HEAP->InternalizeString(*string3_i)->IsFailure()); | 17199 CHECK(!CcTest::heap()->InternalizeString(*string3_i)->IsFailure()); |
17197 CHECK(string3_i->IsInternalizedString()); | 17200 CHECK(string3_i->IsInternalizedString()); |
17198 | 17201 |
17199 // We need to add usages for string* to avoid warnings in GCC 4.7 | 17202 // We need to add usages for string* to avoid warnings in GCC 4.7 |
17200 CHECK(string0->IsExternal()); | 17203 CHECK(string0->IsExternal()); |
17201 CHECK(string1->IsExternal()); | 17204 CHECK(string1->IsExternal()); |
17202 CHECK(string2->IsExternal()); | 17205 CHECK(string2->IsExternal()); |
17203 CHECK(string3->IsExternal()); | 17206 CHECK(string3->IsExternal()); |
17204 | 17207 |
17205 VisitorImpl visitor(resource); | 17208 VisitorImpl visitor(resource); |
17206 v8::V8::VisitExternalResources(&visitor); | 17209 v8::V8::VisitExternalResources(&visitor); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17383 Local<v8::String> obj = v8::String::New(""); | 17386 Local<v8::String> obj = v8::String::New(""); |
17384 context->SetEmbedderData(0, obj); | 17387 context->SetEmbedderData(0, obj); |
17385 CompileRun(source_simple); | 17388 CompileRun(source_simple); |
17386 context->Exit(); | 17389 context->Exit(); |
17387 } | 17390 } |
17388 v8::V8::ContextDisposedNotification(); | 17391 v8::V8::ContextDisposedNotification(); |
17389 for (gc_count = 1; gc_count < 10; gc_count++) { | 17392 for (gc_count = 1; gc_count < 10; gc_count++) { |
17390 other_context->Enter(); | 17393 other_context->Enter(); |
17391 CompileRun(source_simple); | 17394 CompileRun(source_simple); |
17392 other_context->Exit(); | 17395 other_context->Exit(); |
17393 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17396 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17394 if (GetGlobalObjectsCount() == 1) break; | 17397 if (GetGlobalObjectsCount() == 1) break; |
17395 } | 17398 } |
17396 CHECK_GE(2, gc_count); | 17399 CHECK_GE(2, gc_count); |
17397 CHECK_EQ(1, GetGlobalObjectsCount()); | 17400 CHECK_EQ(1, GetGlobalObjectsCount()); |
17398 | 17401 |
17399 // Eval in a function creates reference from the compilation cache to the | 17402 // Eval in a function creates reference from the compilation cache to the |
17400 // global object. | 17403 // global object. |
17401 const char* source_eval = "function f(){eval('1')}; f()"; | 17404 const char* source_eval = "function f(){eval('1')}; f()"; |
17402 { | 17405 { |
17403 v8::HandleScope scope(isolate); | 17406 v8::HandleScope scope(isolate); |
17404 v8::Local<Context> context = Context::New(isolate); | 17407 v8::Local<Context> context = Context::New(isolate); |
17405 | 17408 |
17406 context->Enter(); | 17409 context->Enter(); |
17407 CompileRun(source_eval); | 17410 CompileRun(source_eval); |
17408 context->Exit(); | 17411 context->Exit(); |
17409 } | 17412 } |
17410 v8::V8::ContextDisposedNotification(); | 17413 v8::V8::ContextDisposedNotification(); |
17411 for (gc_count = 1; gc_count < 10; gc_count++) { | 17414 for (gc_count = 1; gc_count < 10; gc_count++) { |
17412 other_context->Enter(); | 17415 other_context->Enter(); |
17413 CompileRun(source_eval); | 17416 CompileRun(source_eval); |
17414 other_context->Exit(); | 17417 other_context->Exit(); |
17415 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17418 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17416 if (GetGlobalObjectsCount() == 1) break; | 17419 if (GetGlobalObjectsCount() == 1) break; |
17417 } | 17420 } |
17418 CHECK_GE(2, gc_count); | 17421 CHECK_GE(2, gc_count); |
17419 CHECK_EQ(1, GetGlobalObjectsCount()); | 17422 CHECK_EQ(1, GetGlobalObjectsCount()); |
17420 | 17423 |
17421 // Looking up the line number for an exception creates reference from the | 17424 // Looking up the line number for an exception creates reference from the |
17422 // compilation cache to the global object. | 17425 // compilation cache to the global object. |
17423 const char* source_exception = "function f(){throw 1;} f()"; | 17426 const char* source_exception = "function f(){throw 1;} f()"; |
17424 { | 17427 { |
17425 v8::HandleScope scope(isolate); | 17428 v8::HandleScope scope(isolate); |
17426 v8::Local<Context> context = Context::New(isolate); | 17429 v8::Local<Context> context = Context::New(isolate); |
17427 | 17430 |
17428 context->Enter(); | 17431 context->Enter(); |
17429 v8::TryCatch try_catch; | 17432 v8::TryCatch try_catch; |
17430 CompileRun(source_exception); | 17433 CompileRun(source_exception); |
17431 CHECK(try_catch.HasCaught()); | 17434 CHECK(try_catch.HasCaught()); |
17432 v8::Handle<v8::Message> message = try_catch.Message(); | 17435 v8::Handle<v8::Message> message = try_catch.Message(); |
17433 CHECK(!message.IsEmpty()); | 17436 CHECK(!message.IsEmpty()); |
17434 CHECK_EQ(1, message->GetLineNumber()); | 17437 CHECK_EQ(1, message->GetLineNumber()); |
17435 context->Exit(); | 17438 context->Exit(); |
17436 } | 17439 } |
17437 v8::V8::ContextDisposedNotification(); | 17440 v8::V8::ContextDisposedNotification(); |
17438 for (gc_count = 1; gc_count < 10; gc_count++) { | 17441 for (gc_count = 1; gc_count < 10; gc_count++) { |
17439 other_context->Enter(); | 17442 other_context->Enter(); |
17440 CompileRun(source_exception); | 17443 CompileRun(source_exception); |
17441 other_context->Exit(); | 17444 other_context->Exit(); |
17442 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17445 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17443 if (GetGlobalObjectsCount() == 1) break; | 17446 if (GetGlobalObjectsCount() == 1) break; |
17444 } | 17447 } |
17445 CHECK_GE(2, gc_count); | 17448 CHECK_GE(2, gc_count); |
17446 CHECK_EQ(1, GetGlobalObjectsCount()); | 17449 CHECK_EQ(1, GetGlobalObjectsCount()); |
17447 | 17450 |
17448 v8::V8::ContextDisposedNotification(); | 17451 v8::V8::ContextDisposedNotification(); |
17449 } | 17452 } |
17450 | 17453 |
17451 | 17454 |
17452 THREADED_TEST(ScriptOrigin) { | 17455 THREADED_TEST(ScriptOrigin) { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17771 } | 17774 } |
17772 | 17775 |
17773 | 17776 |
17774 TEST(GCCallbacksOld) { | 17777 TEST(GCCallbacksOld) { |
17775 LocalContext context; | 17778 LocalContext context; |
17776 | 17779 |
17777 v8::V8::AddGCPrologueCallback(PrologueCallback); | 17780 v8::V8::AddGCPrologueCallback(PrologueCallback); |
17778 v8::V8::AddGCEpilogueCallback(EpilogueCallback); | 17781 v8::V8::AddGCEpilogueCallback(EpilogueCallback); |
17779 CHECK_EQ(0, prologue_call_count); | 17782 CHECK_EQ(0, prologue_call_count); |
17780 CHECK_EQ(0, epilogue_call_count); | 17783 CHECK_EQ(0, epilogue_call_count); |
17781 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17784 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17782 CHECK_EQ(1, prologue_call_count); | 17785 CHECK_EQ(1, prologue_call_count); |
17783 CHECK_EQ(1, epilogue_call_count); | 17786 CHECK_EQ(1, epilogue_call_count); |
17784 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); | 17787 v8::V8::AddGCPrologueCallback(PrologueCallbackSecond); |
17785 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); | 17788 v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond); |
17786 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17789 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17787 CHECK_EQ(2, prologue_call_count); | 17790 CHECK_EQ(2, prologue_call_count); |
17788 CHECK_EQ(2, epilogue_call_count); | 17791 CHECK_EQ(2, epilogue_call_count); |
17789 CHECK_EQ(1, prologue_call_count_second); | 17792 CHECK_EQ(1, prologue_call_count_second); |
17790 CHECK_EQ(1, epilogue_call_count_second); | 17793 CHECK_EQ(1, epilogue_call_count_second); |
17791 v8::V8::RemoveGCPrologueCallback(PrologueCallback); | 17794 v8::V8::RemoveGCPrologueCallback(PrologueCallback); |
17792 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); | 17795 v8::V8::RemoveGCEpilogueCallback(EpilogueCallback); |
17793 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17796 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17794 CHECK_EQ(2, prologue_call_count); | 17797 CHECK_EQ(2, prologue_call_count); |
17795 CHECK_EQ(2, epilogue_call_count); | 17798 CHECK_EQ(2, epilogue_call_count); |
17796 CHECK_EQ(2, prologue_call_count_second); | 17799 CHECK_EQ(2, prologue_call_count_second); |
17797 CHECK_EQ(2, epilogue_call_count_second); | 17800 CHECK_EQ(2, epilogue_call_count_second); |
17798 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); | 17801 v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond); |
17799 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); | 17802 v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond); |
17800 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17803 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17801 CHECK_EQ(2, prologue_call_count); | 17804 CHECK_EQ(2, prologue_call_count); |
17802 CHECK_EQ(2, epilogue_call_count); | 17805 CHECK_EQ(2, epilogue_call_count); |
17803 CHECK_EQ(2, prologue_call_count_second); | 17806 CHECK_EQ(2, prologue_call_count_second); |
17804 CHECK_EQ(2, epilogue_call_count_second); | 17807 CHECK_EQ(2, epilogue_call_count_second); |
17805 } | 17808 } |
17806 | 17809 |
17807 | 17810 |
17808 TEST(GCCallbacks) { | 17811 TEST(GCCallbacks) { |
17809 LocalContext context; | 17812 LocalContext context; |
17810 v8::Isolate* isolate = context->GetIsolate(); | 17813 v8::Isolate* isolate = context->GetIsolate(); |
17811 gc_callbacks_isolate = isolate; | 17814 gc_callbacks_isolate = isolate; |
17812 isolate->AddGCPrologueCallback(PrologueCallback); | 17815 isolate->AddGCPrologueCallback(PrologueCallback); |
17813 isolate->AddGCEpilogueCallback(EpilogueCallback); | 17816 isolate->AddGCEpilogueCallback(EpilogueCallback); |
17814 CHECK_EQ(0, prologue_call_count); | 17817 CHECK_EQ(0, prologue_call_count); |
17815 CHECK_EQ(0, epilogue_call_count); | 17818 CHECK_EQ(0, epilogue_call_count); |
17816 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17819 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17817 CHECK_EQ(1, prologue_call_count); | 17820 CHECK_EQ(1, prologue_call_count); |
17818 CHECK_EQ(1, epilogue_call_count); | 17821 CHECK_EQ(1, epilogue_call_count); |
17819 isolate->AddGCPrologueCallback(PrologueCallbackSecond); | 17822 isolate->AddGCPrologueCallback(PrologueCallbackSecond); |
17820 isolate->AddGCEpilogueCallback(EpilogueCallbackSecond); | 17823 isolate->AddGCEpilogueCallback(EpilogueCallbackSecond); |
17821 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17824 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17822 CHECK_EQ(2, prologue_call_count); | 17825 CHECK_EQ(2, prologue_call_count); |
17823 CHECK_EQ(2, epilogue_call_count); | 17826 CHECK_EQ(2, epilogue_call_count); |
17824 CHECK_EQ(1, prologue_call_count_second); | 17827 CHECK_EQ(1, prologue_call_count_second); |
17825 CHECK_EQ(1, epilogue_call_count_second); | 17828 CHECK_EQ(1, epilogue_call_count_second); |
17826 isolate->RemoveGCPrologueCallback(PrologueCallback); | 17829 isolate->RemoveGCPrologueCallback(PrologueCallback); |
17827 isolate->RemoveGCEpilogueCallback(EpilogueCallback); | 17830 isolate->RemoveGCEpilogueCallback(EpilogueCallback); |
17828 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17831 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17829 CHECK_EQ(2, prologue_call_count); | 17832 CHECK_EQ(2, prologue_call_count); |
17830 CHECK_EQ(2, epilogue_call_count); | 17833 CHECK_EQ(2, epilogue_call_count); |
17831 CHECK_EQ(2, prologue_call_count_second); | 17834 CHECK_EQ(2, prologue_call_count_second); |
17832 CHECK_EQ(2, epilogue_call_count_second); | 17835 CHECK_EQ(2, epilogue_call_count_second); |
17833 isolate->RemoveGCPrologueCallback(PrologueCallbackSecond); | 17836 isolate->RemoveGCPrologueCallback(PrologueCallbackSecond); |
17834 isolate->RemoveGCEpilogueCallback(EpilogueCallbackSecond); | 17837 isolate->RemoveGCEpilogueCallback(EpilogueCallbackSecond); |
17835 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 17838 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
17836 CHECK_EQ(2, prologue_call_count); | 17839 CHECK_EQ(2, prologue_call_count); |
17837 CHECK_EQ(2, epilogue_call_count); | 17840 CHECK_EQ(2, epilogue_call_count); |
17838 CHECK_EQ(2, prologue_call_count_second); | 17841 CHECK_EQ(2, prologue_call_count_second); |
17839 CHECK_EQ(2, epilogue_call_count_second); | 17842 CHECK_EQ(2, epilogue_call_count_second); |
17840 } | 17843 } |
17841 | 17844 |
17842 | 17845 |
17843 THREADED_TEST(AddToJSFunctionResultCache) { | 17846 THREADED_TEST(AddToJSFunctionResultCache) { |
17844 i::FLAG_stress_compaction = false; | 17847 i::FLAG_stress_compaction = false; |
17845 i::FLAG_allow_natives_syntax = true; | 17848 i::FLAG_allow_natives_syntax = true; |
17846 v8::HandleScope scope(CcTest::isolate()); | 17849 v8::HandleScope scope(CcTest::isolate()); |
17847 | 17850 |
17848 LocalContext context; | 17851 LocalContext context; |
17849 | 17852 |
17850 const char* code = | 17853 const char* code = |
17851 "(function() {" | 17854 "(function() {" |
17852 " var key0 = 'a';" | 17855 " var key0 = 'a';" |
17853 " var key1 = 'b';" | 17856 " var key1 = 'b';" |
17854 " var r0 = %_GetFromCache(0, key0);" | 17857 " var r0 = %_GetFromCache(0, key0);" |
17855 " var r1 = %_GetFromCache(0, key1);" | 17858 " var r1 = %_GetFromCache(0, key1);" |
17856 " var r0_ = %_GetFromCache(0, key0);" | 17859 " var r0_ = %_GetFromCache(0, key0);" |
17857 " if (r0 !== r0_)" | 17860 " if (r0 !== r0_)" |
17858 " return 'Different results for ' + key0 + ': ' + r0 + ' vs. ' + r0_;" | 17861 " return 'Different results for ' + key0 + ': ' + r0 + ' vs. ' + r0_;" |
17859 " var r1_ = %_GetFromCache(0, key1);" | 17862 " var r1_ = %_GetFromCache(0, key1);" |
17860 " if (r1 !== r1_)" | 17863 " if (r1 !== r1_)" |
17861 " return 'Different results for ' + key1 + ': ' + r1 + ' vs. ' + r1_;" | 17864 " return 'Different results for ' + key1 + ': ' + r1 + ' vs. ' + r1_;" |
17862 " return 'PASSED';" | 17865 " return 'PASSED';" |
17863 "})()"; | 17866 "})()"; |
17864 HEAP->ClearJSFunctionResultCaches(); | 17867 CcTest::heap()->ClearJSFunctionResultCaches(); |
17865 ExpectString(code, "PASSED"); | 17868 ExpectString(code, "PASSED"); |
17866 } | 17869 } |
17867 | 17870 |
17868 | 17871 |
17869 static const int k0CacheSize = 16; | 17872 static const int k0CacheSize = 16; |
17870 | 17873 |
17871 THREADED_TEST(FillJSFunctionResultCache) { | 17874 THREADED_TEST(FillJSFunctionResultCache) { |
17872 i::FLAG_allow_natives_syntax = true; | 17875 i::FLAG_allow_natives_syntax = true; |
17873 LocalContext context; | 17876 LocalContext context; |
17874 v8::HandleScope scope(context->GetIsolate()); | 17877 v8::HandleScope scope(context->GetIsolate()); |
17875 | 17878 |
17876 const char* code = | 17879 const char* code = |
17877 "(function() {" | 17880 "(function() {" |
17878 " var k = 'a';" | 17881 " var k = 'a';" |
17879 " var r = %_GetFromCache(0, k);" | 17882 " var r = %_GetFromCache(0, k);" |
17880 " for (var i = 0; i < 16; i++) {" | 17883 " for (var i = 0; i < 16; i++) {" |
17881 " %_GetFromCache(0, 'a' + i);" | 17884 " %_GetFromCache(0, 'a' + i);" |
17882 " };" | 17885 " };" |
17883 " if (r === %_GetFromCache(0, k))" | 17886 " if (r === %_GetFromCache(0, k))" |
17884 " return 'FAILED: k0CacheSize is too small';" | 17887 " return 'FAILED: k0CacheSize is too small';" |
17885 " return 'PASSED';" | 17888 " return 'PASSED';" |
17886 "})()"; | 17889 "})()"; |
17887 HEAP->ClearJSFunctionResultCaches(); | 17890 CcTest::heap()->ClearJSFunctionResultCaches(); |
17888 ExpectString(code, "PASSED"); | 17891 ExpectString(code, "PASSED"); |
17889 } | 17892 } |
17890 | 17893 |
17891 | 17894 |
17892 THREADED_TEST(RoundRobinGetFromCache) { | 17895 THREADED_TEST(RoundRobinGetFromCache) { |
17893 i::FLAG_allow_natives_syntax = true; | 17896 i::FLAG_allow_natives_syntax = true; |
17894 LocalContext context; | 17897 LocalContext context; |
17895 v8::HandleScope scope(context->GetIsolate()); | 17898 v8::HandleScope scope(context->GetIsolate()); |
17896 | 17899 |
17897 const char* code = | 17900 const char* code = |
17898 "(function() {" | 17901 "(function() {" |
17899 " var keys = [];" | 17902 " var keys = [];" |
17900 " for (var i = 0; i < 16; i++) keys.push(i);" | 17903 " for (var i = 0; i < 16; i++) keys.push(i);" |
17901 " var values = [];" | 17904 " var values = [];" |
17902 " for (var i = 0; i < 16; i++) values[i] = %_GetFromCache(0, keys[i]);" | 17905 " for (var i = 0; i < 16; i++) values[i] = %_GetFromCache(0, keys[i]);" |
17903 " for (var i = 0; i < 16; i++) {" | 17906 " for (var i = 0; i < 16; i++) {" |
17904 " var v = %_GetFromCache(0, keys[i]);" | 17907 " var v = %_GetFromCache(0, keys[i]);" |
17905 " if (v.toString() !== values[i].toString())" | 17908 " if (v.toString() !== values[i].toString())" |
17906 " return 'Wrong value for ' + " | 17909 " return 'Wrong value for ' + " |
17907 " keys[i] + ': ' + v + ' vs. ' + values[i];" | 17910 " keys[i] + ': ' + v + ' vs. ' + values[i];" |
17908 " };" | 17911 " };" |
17909 " return 'PASSED';" | 17912 " return 'PASSED';" |
17910 "})()"; | 17913 "})()"; |
17911 HEAP->ClearJSFunctionResultCaches(); | 17914 CcTest::heap()->ClearJSFunctionResultCaches(); |
17912 ExpectString(code, "PASSED"); | 17915 ExpectString(code, "PASSED"); |
17913 } | 17916 } |
17914 | 17917 |
17915 | 17918 |
17916 THREADED_TEST(ReverseGetFromCache) { | 17919 THREADED_TEST(ReverseGetFromCache) { |
17917 i::FLAG_allow_natives_syntax = true; | 17920 i::FLAG_allow_natives_syntax = true; |
17918 LocalContext context; | 17921 LocalContext context; |
17919 v8::HandleScope scope(context->GetIsolate()); | 17922 v8::HandleScope scope(context->GetIsolate()); |
17920 | 17923 |
17921 const char* code = | 17924 const char* code = |
17922 "(function() {" | 17925 "(function() {" |
17923 " var keys = [];" | 17926 " var keys = [];" |
17924 " for (var i = 0; i < 16; i++) keys.push(i);" | 17927 " for (var i = 0; i < 16; i++) keys.push(i);" |
17925 " var values = [];" | 17928 " var values = [];" |
17926 " for (var i = 0; i < 16; i++) values[i] = %_GetFromCache(0, keys[i]);" | 17929 " for (var i = 0; i < 16; i++) values[i] = %_GetFromCache(0, keys[i]);" |
17927 " for (var i = 15; i >= 16; i--) {" | 17930 " for (var i = 15; i >= 16; i--) {" |
17928 " var v = %_GetFromCache(0, keys[i]);" | 17931 " var v = %_GetFromCache(0, keys[i]);" |
17929 " if (v !== values[i])" | 17932 " if (v !== values[i])" |
17930 " return 'Wrong value for ' + " | 17933 " return 'Wrong value for ' + " |
17931 " keys[i] + ': ' + v + ' vs. ' + values[i];" | 17934 " keys[i] + ': ' + v + ' vs. ' + values[i];" |
17932 " };" | 17935 " };" |
17933 " return 'PASSED';" | 17936 " return 'PASSED';" |
17934 "})()"; | 17937 "})()"; |
17935 HEAP->ClearJSFunctionResultCaches(); | 17938 CcTest::heap()->ClearJSFunctionResultCaches(); |
17936 ExpectString(code, "PASSED"); | 17939 ExpectString(code, "PASSED"); |
17937 } | 17940 } |
17938 | 17941 |
17939 | 17942 |
17940 THREADED_TEST(TestEviction) { | 17943 THREADED_TEST(TestEviction) { |
17941 i::FLAG_allow_natives_syntax = true; | 17944 i::FLAG_allow_natives_syntax = true; |
17942 LocalContext context; | 17945 LocalContext context; |
17943 v8::HandleScope scope(context->GetIsolate()); | 17946 v8::HandleScope scope(context->GetIsolate()); |
17944 | 17947 |
17945 const char* code = | 17948 const char* code = |
17946 "(function() {" | 17949 "(function() {" |
17947 " for (var i = 0; i < 2*16; i++) {" | 17950 " for (var i = 0; i < 2*16; i++) {" |
17948 " %_GetFromCache(0, 'a' + i);" | 17951 " %_GetFromCache(0, 'a' + i);" |
17949 " };" | 17952 " };" |
17950 " return 'PASSED';" | 17953 " return 'PASSED';" |
17951 "})()"; | 17954 "})()"; |
17952 HEAP->ClearJSFunctionResultCaches(); | 17955 CcTest::heap()->ClearJSFunctionResultCaches(); |
17953 ExpectString(code, "PASSED"); | 17956 ExpectString(code, "PASSED"); |
17954 } | 17957 } |
17955 | 17958 |
17956 | 17959 |
17957 THREADED_TEST(TwoByteStringInAsciiCons) { | 17960 THREADED_TEST(TwoByteStringInAsciiCons) { |
17958 // See Chromium issue 47824. | 17961 // See Chromium issue 47824. |
17959 LocalContext context; | 17962 LocalContext context; |
17960 v8::HandleScope scope(context->GetIsolate()); | 17963 v8::HandleScope scope(context->GetIsolate()); |
17961 | 17964 |
17962 const char* init_code = | 17965 const char* init_code = |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18108 string_contents[zero_offset] = 0x41; | 18111 string_contents[zero_offset] = 0x41; |
18109 } | 18112 } |
18110 } | 18113 } |
18111 } | 18114 } |
18112 | 18115 |
18113 | 18116 |
18114 // Failed access check callback that performs a GC on each invocation. | 18117 // Failed access check callback that performs a GC on each invocation. |
18115 void FailedAccessCheckCallbackGC(Local<v8::Object> target, | 18118 void FailedAccessCheckCallbackGC(Local<v8::Object> target, |
18116 v8::AccessType type, | 18119 v8::AccessType type, |
18117 Local<v8::Value> data) { | 18120 Local<v8::Value> data) { |
18118 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 18121 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
18119 } | 18122 } |
18120 | 18123 |
18121 | 18124 |
18122 TEST(GCInFailedAccessCheckCallback) { | 18125 TEST(GCInFailedAccessCheckCallback) { |
18123 // Install a failed access check callback that performs a GC on each | 18126 // Install a failed access check callback that performs a GC on each |
18124 // invocation. Then force the callback to be called from va | 18127 // invocation. Then force the callback to be called from va |
18125 | 18128 |
18126 v8::V8::Initialize(); | 18129 v8::V8::Initialize(); |
18127 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); | 18130 v8::V8::SetFailedAccessCheckCallbackFunction(&FailedAccessCheckCallbackGC); |
18128 | 18131 |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18638 ExpectBoolean("delete cell", true); | 18641 ExpectBoolean("delete cell", true); |
18639 ExpectString("(function() {" | 18642 ExpectString("(function() {" |
18640 " try {" | 18643 " try {" |
18641 " return readCell();" | 18644 " return readCell();" |
18642 " } catch(e) {" | 18645 " } catch(e) {" |
18643 " return e.toString();" | 18646 " return e.toString();" |
18644 " }" | 18647 " }" |
18645 "})()", | 18648 "})()", |
18646 "ReferenceError: cell is not defined"); | 18649 "ReferenceError: cell is not defined"); |
18647 CompileRun("cell = \"new_second\";"); | 18650 CompileRun("cell = \"new_second\";"); |
18648 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 18651 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
18649 ExpectString("readCell()", "new_second"); | 18652 ExpectString("readCell()", "new_second"); |
18650 ExpectString("readCell()", "new_second"); | 18653 ExpectString("readCell()", "new_second"); |
18651 } | 18654 } |
18652 } | 18655 } |
18653 | 18656 |
18654 | 18657 |
18655 TEST(DontDeleteCellLoadICForceDelete) { | 18658 TEST(DontDeleteCellLoadICForceDelete) { |
18656 const char* function_code = | 18659 const char* function_code = |
18657 "function readCell() { while (true) { return cell; } }"; | 18660 "function readCell() { while (true) { return cell; } }"; |
18658 | 18661 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18763 | 18766 |
18764 TEST(PersistentHandleInNewSpaceVisitor) { | 18767 TEST(PersistentHandleInNewSpaceVisitor) { |
18765 LocalContext context; | 18768 LocalContext context; |
18766 v8::Isolate* isolate = context->GetIsolate(); | 18769 v8::Isolate* isolate = context->GetIsolate(); |
18767 v8::HandleScope scope(isolate); | 18770 v8::HandleScope scope(isolate); |
18768 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); | 18771 v8::Persistent<v8::Object> object1(isolate, v8::Object::New()); |
18769 CHECK_EQ(0, object1.WrapperClassId()); | 18772 CHECK_EQ(0, object1.WrapperClassId()); |
18770 object1.SetWrapperClassId(42); | 18773 object1.SetWrapperClassId(42); |
18771 CHECK_EQ(42, object1.WrapperClassId()); | 18774 CHECK_EQ(42, object1.WrapperClassId()); |
18772 | 18775 |
18773 HEAP->CollectAllGarbage(i::Heap::kNoGCFlags); | 18776 CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags); |
18774 | 18777 |
18775 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); | 18778 v8::Persistent<v8::Object> object2(isolate, v8::Object::New()); |
18776 CHECK_EQ(0, object2.WrapperClassId()); | 18779 CHECK_EQ(0, object2.WrapperClassId()); |
18777 object2.SetWrapperClassId(42); | 18780 object2.SetWrapperClassId(42); |
18778 CHECK_EQ(42, object2.WrapperClassId()); | 18781 CHECK_EQ(42, object2.WrapperClassId()); |
18779 | 18782 |
18780 Visitor42 visitor(&object2); | 18783 Visitor42 visitor(&object2); |
18781 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); | 18784 v8::V8::VisitHandlesForPartialDependence(isolate, &visitor); |
18782 CHECK_EQ(1, visitor.counter_); | 18785 CHECK_EQ(1, visitor.counter_); |
18783 | 18786 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19299 CompileRun("({'a': 0})"); | 19302 CompileRun("({'a': 0})"); |
19300 } | 19303 } |
19301 | 19304 |
19302 int elements; | 19305 int elements; |
19303 { i::MapCache* map_cache = | 19306 { i::MapCache* map_cache = |
19304 i::MapCache::cast(CcTest::i_isolate()->context()->map_cache()); | 19307 i::MapCache::cast(CcTest::i_isolate()->context()->map_cache()); |
19305 elements = map_cache->NumberOfElements(); | 19308 elements = map_cache->NumberOfElements(); |
19306 CHECK_LE(1, elements); | 19309 CHECK_LE(1, elements); |
19307 } | 19310 } |
19308 | 19311 |
19309 CcTest::i_isolate()->heap()->CollectAllGarbage( | 19312 CcTest::heap()->CollectAllGarbage( |
19310 i::Heap::kAbortIncrementalMarkingMask); | 19313 i::Heap::kAbortIncrementalMarkingMask); |
19311 { i::Object* raw_map_cache = CcTest::i_isolate()->context()->map_cache(); | 19314 { i::Object* raw_map_cache = CcTest::i_isolate()->context()->map_cache(); |
19312 if (raw_map_cache != CcTest::i_isolate()->heap()->undefined_value()) { | 19315 if (raw_map_cache != CcTest::heap()->undefined_value()) { |
19313 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); | 19316 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); |
19314 CHECK_GT(elements, map_cache->NumberOfElements()); | 19317 CHECK_GT(elements, map_cache->NumberOfElements()); |
19315 } | 19318 } |
19316 } | 19319 } |
19317 } | 19320 } |
19318 | 19321 |
19319 | 19322 |
19320 static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global, | 19323 static bool BlockProtoNamedSecurityTestCallback(Local<v8::Object> global, |
19321 Local<Value> name, | 19324 Local<Value> name, |
19322 v8::AccessType type, | 19325 v8::AccessType type, |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20590 Local<Object> data2 = v8::Object::New(); | 20593 Local<Object> data2 = v8::Object::New(); |
20591 function_new_expected_env = data2; | 20594 function_new_expected_env = data2; |
20592 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); | 20595 Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2); |
20593 CHECK(!func2->IsNull()); | 20596 CHECK(!func2->IsNull()); |
20594 CHECK_NE(func, func2); | 20597 CHECK_NE(func, func2); |
20595 env->Global()->Set(v8_str("func2"), func2); | 20598 env->Global()->Set(v8_str("func2"), func2); |
20596 Local<Value> result2 = CompileRun("func2();"); | 20599 Local<Value> result2 = CompileRun("func2();"); |
20597 CHECK_EQ(v8::Integer::New(17, isolate), result2); | 20600 CHECK_EQ(v8::Integer::New(17, isolate), result2); |
20598 } | 20601 } |
20599 | 20602 |
OLD | NEW |