Revision f230a1cf deps/v8/test/cctest/test-api.cc
deps/v8/test/cctest/test-api.cc | ||
---|---|---|
84 | 84 |
} \ |
85 | 85 |
THREADED_TEST(Name) |
86 | 86 |
|
87 |
|
|
87 | 88 |
void RunWithProfiler(void (*test)()) { |
88 | 89 |
LocalContext env; |
89 | 90 |
v8::HandleScope scope(env->GetIsolate()); |
... | ... | |
185 | 186 |
|
186 | 187 |
|
187 | 188 |
THREADED_TEST(Handles) { |
188 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
189 |
v8::HandleScope scope(CcTest::isolate());
|
|
189 | 190 |
Local<Context> local_env; |
190 | 191 |
{ |
191 | 192 |
LocalContext env; |
... | ... | |
196 | 197 |
CHECK(!local_env.IsEmpty()); |
197 | 198 |
local_env->Enter(); |
198 | 199 |
|
199 |
v8::Handle<v8::Primitive> undef = v8::Undefined(); |
|
200 |
v8::Handle<v8::Primitive> undef = v8::Undefined(CcTest::isolate());
|
|
200 | 201 |
CHECK(!undef.IsEmpty()); |
201 | 202 |
CHECK(undef->IsUndefined()); |
202 | 203 |
|
... | ... | |
210 | 211 |
|
211 | 212 |
|
212 | 213 |
THREADED_TEST(IsolateOfContext) { |
213 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
214 |
v8::Handle<Context> env = Context::New(v8::Isolate::GetCurrent());
|
|
214 |
v8::HandleScope scope(CcTest::isolate());
|
|
215 |
v8::Handle<Context> env = Context::New(CcTest::isolate());
|
|
215 | 216 |
|
216 | 217 |
CHECK(!env->InContext()); |
217 |
CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
|
|
218 |
CHECK(env->GetIsolate() == CcTest::isolate());
|
|
218 | 219 |
env->Enter(); |
219 | 220 |
CHECK(env->InContext()); |
220 |
CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
|
|
221 |
CHECK(env->GetIsolate() == CcTest::isolate());
|
|
221 | 222 |
env->Exit(); |
222 | 223 |
CHECK(!env->InContext()); |
223 |
CHECK(env->GetIsolate() == v8::Isolate::GetCurrent());
|
|
224 |
CHECK(env->GetIsolate() == CcTest::isolate());
|
|
224 | 225 |
} |
225 | 226 |
|
226 | 227 |
|
... | ... | |
383 | 384 |
|
384 | 385 |
THREADED_TEST(HulIgennem) { |
385 | 386 |
LocalContext env; |
386 |
v8::HandleScope scope(env->GetIsolate()); |
|
387 |
v8::Handle<v8::Primitive> undef = v8::Undefined(); |
|
387 |
v8::Isolate* isolate = env->GetIsolate(); |
|
388 |
v8::HandleScope scope(isolate); |
|
389 |
v8::Handle<v8::Primitive> undef = v8::Undefined(isolate); |
|
388 | 390 |
Local<String> undef_str = undef->ToString(); |
389 | 391 |
char* value = i::NewArray<char>(undef_str->Utf8Length() + 1); |
390 | 392 |
undef_str->WriteUtf8(value); |
... | ... | |
395 | 397 |
|
396 | 398 |
THREADED_TEST(Access) { |
397 | 399 |
LocalContext env; |
398 |
v8::HandleScope scope(env->GetIsolate()); |
|
400 |
v8::Isolate* isolate = env->GetIsolate(); |
|
401 |
v8::HandleScope scope(isolate); |
|
399 | 402 |
Local<v8::Object> obj = v8::Object::New(); |
400 | 403 |
Local<Value> foo_before = obj->Get(v8_str("foo")); |
401 | 404 |
CHECK(foo_before->IsUndefined()); |
... | ... | |
515 | 518 |
CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
516 | 519 |
source->GetExternalStringResourceBase(&encoding)); |
517 | 520 |
CHECK_EQ(String::TWO_BYTE_ENCODING, encoding); |
518 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
521 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
519 | 522 |
CHECK_EQ(0, dispose_count); |
520 | 523 |
} |
521 |
v8::internal::Isolate::Current()->compilation_cache()->Clear();
|
|
522 |
HEAP->CollectAllAvailableGarbage();
|
|
524 |
CcTest::i_isolate()->compilation_cache()->Clear();
|
|
525 |
CcTest::heap()->CollectAllAvailableGarbage();
|
|
523 | 526 |
CHECK_EQ(1, dispose_count); |
524 | 527 |
} |
525 | 528 |
|
... | ... | |
544 | 547 |
Local<Value> value = script->Run(); |
545 | 548 |
CHECK(value->IsNumber()); |
546 | 549 |
CHECK_EQ(7, value->Int32Value()); |
547 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
550 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
548 | 551 |
CHECK_EQ(0, dispose_count); |
549 | 552 |
} |
550 |
i::Isolate::Current()->compilation_cache()->Clear();
|
|
551 |
HEAP->CollectAllAvailableGarbage();
|
|
553 |
CcTest::i_isolate()->compilation_cache()->Clear();
|
|
554 |
CcTest::heap()->CollectAllAvailableGarbage();
|
|
552 | 555 |
CHECK_EQ(1, dispose_count); |
553 | 556 |
} |
554 | 557 |
|
... | ... | |
561 | 564 |
v8::HandleScope scope(env->GetIsolate()); |
562 | 565 |
Local<String> source = String::New(two_byte_source); |
563 | 566 |
// Trigger GCs so that the newly allocated string moves to old gen. |
564 |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
565 |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
567 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
568 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
566 | 569 |
CHECK_EQ(source->IsExternal(), false); |
567 | 570 |
CHECK_EQ(source->IsExternalAscii(), false); |
568 | 571 |
String::Encoding encoding = String::UNKNOWN_ENCODING; |
... | ... | |
575 | 578 |
Local<Value> value = script->Run(); |
576 | 579 |
CHECK(value->IsNumber()); |
577 | 580 |
CHECK_EQ(7, value->Int32Value()); |
578 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
581 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
579 | 582 |
CHECK_EQ(0, dispose_count); |
580 | 583 |
} |
581 |
i::Isolate::Current()->compilation_cache()->Clear();
|
|
582 |
HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
|
|
584 |
CcTest::i_isolate()->compilation_cache()->Clear();
|
|
585 |
CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
|
|
583 | 586 |
CHECK_EQ(1, dispose_count); |
584 | 587 |
} |
585 | 588 |
|
... | ... | |
592 | 595 |
v8::HandleScope scope(env->GetIsolate()); |
593 | 596 |
Local<String> source = v8_str(c_source); |
594 | 597 |
// Trigger GCs so that the newly allocated string moves to old gen. |
595 |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
596 |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
598 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
599 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
597 | 600 |
bool success = source->MakeExternal( |
598 | 601 |
new TestAsciiResource(i::StrDup(c_source), &dispose_count)); |
599 | 602 |
CHECK(success); |
... | ... | |
601 | 604 |
Local<Value> value = script->Run(); |
602 | 605 |
CHECK(value->IsNumber()); |
603 | 606 |
CHECK_EQ(7, value->Int32Value()); |
604 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
607 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
605 | 608 |
CHECK_EQ(0, dispose_count); |
606 | 609 |
} |
607 |
i::Isolate::Current()->compilation_cache()->Clear();
|
|
608 |
HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
|
|
610 |
CcTest::i_isolate()->compilation_cache()->Clear();
|
|
611 |
CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
|
|
609 | 612 |
CHECK_EQ(1, dispose_count); |
610 | 613 |
} |
611 | 614 |
|
... | ... | |
615 | 618 |
v8::HandleScope scope(env->GetIsolate()); |
616 | 619 |
|
617 | 620 |
// Free some space in the new space so that we can check freshness. |
618 |
HEAP->CollectGarbage(i::NEW_SPACE);
|
|
619 |
HEAP->CollectGarbage(i::NEW_SPACE);
|
|
621 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
|
|
622 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
|
|
620 | 623 |
|
621 | 624 |
uint16_t* two_byte_string = AsciiToTwoByteString("s1"); |
622 | 625 |
Local<String> small_string = String::New(two_byte_string); |
... | ... | |
625 | 628 |
// We should refuse to externalize newly created small string. |
626 | 629 |
CHECK(!small_string->CanMakeExternal()); |
627 | 630 |
// Trigger GCs so that the newly allocated string moves to old gen. |
628 |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
629 |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
631 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
632 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
630 | 633 |
// Old space strings should be accepted. |
631 | 634 |
CHECK(small_string->CanMakeExternal()); |
632 | 635 |
|
... | ... | |
661 | 664 |
v8::HandleScope scope(env->GetIsolate()); |
662 | 665 |
|
663 | 666 |
// Free some space in the new space so that we can check freshness. |
664 |
HEAP->CollectGarbage(i::NEW_SPACE);
|
|
665 |
HEAP->CollectGarbage(i::NEW_SPACE);
|
|
667 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
|
|
668 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
|
|
666 | 669 |
|
667 | 670 |
Local<String> small_string = String::New("s1"); |
668 | 671 |
// We should refuse to externalize newly created small string. |
669 | 672 |
CHECK(!small_string->CanMakeExternal()); |
670 | 673 |
// Trigger GCs so that the newly allocated string moves to old gen. |
671 |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
672 |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
674 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
675 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
673 | 676 |
// Old space strings should be accepted. |
674 | 677 |
CHECK(small_string->CanMakeExternal()); |
675 | 678 |
|
... | ... | |
707 | 710 |
"slice('abcdefghijklmnopqrstuvwxyz');")); |
708 | 711 |
|
709 | 712 |
// Trigger GCs so that the newly allocated string moves to old gen. |
710 |
SimulateFullSpace(HEAP->old_pointer_space());
|
|
711 |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
712 |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
713 |
SimulateFullSpace(CcTest::heap()->old_pointer_space());
|
|
714 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
715 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
713 | 716 |
|
714 | 717 |
// Turn into external string with unaligned resource data. |
715 | 718 |
int dispose_count = 0; |
... | ... | |
723 | 726 |
CHECK(success); |
724 | 727 |
|
725 | 728 |
// Trigger GCs and force evacuation. |
726 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
727 |
HEAP->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask);
|
|
729 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
730 |
CcTest::heap()->CollectAllGarbage(i::Heap::kReduceMemoryFootprintMask);
|
|
728 | 731 |
} |
729 | 732 |
|
730 | 733 |
|
731 | 734 |
THREADED_TEST(UsingExternalString) { |
732 |
i::Factory* factory = i::Isolate::Current()->factory();
|
|
735 |
i::Factory* factory = CcTest::i_isolate()->factory();
|
|
733 | 736 |
{ |
734 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
737 |
v8::HandleScope scope(CcTest::isolate());
|
|
735 | 738 |
uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
736 | 739 |
Local<String> string = |
737 | 740 |
String::NewExternal(new TestResource(two_byte_string)); |
738 | 741 |
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
739 | 742 |
// Trigger GCs so that the newly allocated string moves to old gen. |
740 |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
741 |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
743 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
744 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
742 | 745 |
i::Handle<i::String> isymbol = |
743 | 746 |
factory->InternalizedStringFromString(istring); |
744 | 747 |
CHECK(isymbol->IsInternalizedString()); |
745 | 748 |
} |
746 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
747 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
749 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
750 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
748 | 751 |
} |
749 | 752 |
|
750 | 753 |
|
751 | 754 |
THREADED_TEST(UsingExternalAsciiString) { |
752 |
i::Factory* factory = i::Isolate::Current()->factory();
|
|
755 |
i::Factory* factory = CcTest::i_isolate()->factory();
|
|
753 | 756 |
{ |
754 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
757 |
v8::HandleScope scope(CcTest::isolate());
|
|
755 | 758 |
const char* one_byte_string = "test string"; |
756 | 759 |
Local<String> string = String::NewExternal( |
757 | 760 |
new TestAsciiResource(i::StrDup(one_byte_string))); |
758 | 761 |
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
759 | 762 |
// Trigger GCs so that the newly allocated string moves to old gen. |
760 |
HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
761 |
HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
763 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in survivor space now
|
|
764 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE); // in old gen now
|
|
762 | 765 |
i::Handle<i::String> isymbol = |
763 | 766 |
factory->InternalizedStringFromString(istring); |
764 | 767 |
CHECK(isymbol->IsInternalizedString()); |
765 | 768 |
} |
766 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
767 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
769 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
770 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
768 | 771 |
} |
769 | 772 |
|
770 | 773 |
|
... | ... | |
774 | 777 |
int dispose_count = 0; |
775 | 778 |
bool in_new_space = false; |
776 | 779 |
{ |
777 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
780 |
v8::HandleScope scope(CcTest::isolate());
|
|
778 | 781 |
uint16_t* two_byte_string = AsciiToTwoByteString("test string"); |
779 | 782 |
Local<String> string = |
780 | 783 |
String::NewExternal(new TestResource(two_byte_string, |
781 | 784 |
&dispose_count)); |
782 | 785 |
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
783 |
HEAP->CollectGarbage(i::NEW_SPACE);
|
|
784 |
in_new_space = HEAP->InNewSpace(*istring);
|
|
785 |
CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring));
|
|
786 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
|
|
787 |
in_new_space = CcTest::heap()->InNewSpace(*istring);
|
|
788 |
CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring));
|
|
786 | 789 |
CHECK_EQ(0, dispose_count); |
787 | 790 |
} |
788 |
HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
|
791 |
CcTest::heap()->CollectGarbage( |
|
792 |
in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
|
789 | 793 |
CHECK_EQ(1, dispose_count); |
790 | 794 |
} |
791 | 795 |
|
... | ... | |
796 | 800 |
int dispose_count = 0; |
797 | 801 |
bool in_new_space = false; |
798 | 802 |
{ |
799 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
803 |
v8::HandleScope scope(CcTest::isolate());
|
|
800 | 804 |
const char* one_byte_string = "test string"; |
801 | 805 |
Local<String> string = String::NewExternal( |
802 | 806 |
new TestAsciiResource(i::StrDup(one_byte_string), &dispose_count)); |
803 | 807 |
i::Handle<i::String> istring = v8::Utils::OpenHandle(*string); |
804 |
HEAP->CollectGarbage(i::NEW_SPACE);
|
|
805 |
in_new_space = HEAP->InNewSpace(*istring);
|
|
806 |
CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring));
|
|
808 |
CcTest::heap()->CollectGarbage(i::NEW_SPACE);
|
|
809 |
in_new_space = CcTest::heap()->InNewSpace(*istring);
|
|
810 |
CHECK(in_new_space || CcTest::heap()->old_data_space()->Contains(*istring));
|
|
807 | 811 |
CHECK_EQ(0, dispose_count); |
808 | 812 |
} |
809 |
HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
|
813 |
CcTest::heap()->CollectGarbage( |
|
814 |
in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE); |
|
810 | 815 |
CHECK_EQ(1, dispose_count); |
811 | 816 |
} |
812 | 817 |
|
... | ... | |
849 | 854 |
Local<Value> value = script->Run(); |
850 | 855 |
CHECK(value->IsNumber()); |
851 | 856 |
CHECK_EQ(7, value->Int32Value()); |
852 |
HEAP->CollectAllAvailableGarbage();
|
|
857 |
CcTest::heap()->CollectAllAvailableGarbage();
|
|
853 | 858 |
CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
854 | 859 |
} |
855 |
i::Isolate::Current()->compilation_cache()->Clear();
|
|
856 |
HEAP->CollectAllAvailableGarbage();
|
|
860 |
CcTest::i_isolate()->compilation_cache()->Clear();
|
|
861 |
CcTest::heap()->CollectAllAvailableGarbage();
|
|
857 | 862 |
CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
858 | 863 |
CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
859 | 864 |
|
... | ... | |
870 | 875 |
Local<Value> value = script->Run(); |
871 | 876 |
CHECK(value->IsNumber()); |
872 | 877 |
CHECK_EQ(7, value->Int32Value()); |
873 |
HEAP->CollectAllAvailableGarbage();
|
|
878 |
CcTest::heap()->CollectAllAvailableGarbage();
|
|
874 | 879 |
CHECK_EQ(0, TestAsciiResourceWithDisposeControl::dispose_count); |
875 | 880 |
} |
876 |
i::Isolate::Current()->compilation_cache()->Clear();
|
|
877 |
HEAP->CollectAllAvailableGarbage();
|
|
881 |
CcTest::i_isolate()->compilation_cache()->Clear();
|
|
882 |
CcTest::heap()->CollectAllAvailableGarbage();
|
|
878 | 883 |
CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls); |
879 | 884 |
CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_count); |
880 | 885 |
} |
... | ... | |
920 | 925 |
CHECK(value->IsNumber()); |
921 | 926 |
CHECK_EQ(68, value->Int32Value()); |
922 | 927 |
} |
923 |
i::Isolate::Current()->compilation_cache()->Clear();
|
|
924 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
925 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
928 |
CcTest::i_isolate()->compilation_cache()->Clear();
|
|
929 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
930 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
926 | 931 |
} |
927 | 932 |
|
928 | 933 |
|
... | ... | |
940 | 945 |
static void CheckReturnValue(const T& t, i::Address callback) { |
941 | 946 |
v8::ReturnValue<v8::Value> rv = t.GetReturnValue(); |
942 | 947 |
i::Object** o = *reinterpret_cast<i::Object***>(&rv); |
943 |
CHECK_EQ(v8::Isolate::GetCurrent(), t.GetIsolate());
|
|
948 |
CHECK_EQ(CcTest::isolate(), t.GetIsolate());
|
|
944 | 949 |
CHECK_EQ(t.GetIsolate(), rv.GetIsolate()); |
945 | 950 |
CHECK((*o)->IsTheHole() || (*o)->IsUndefined()); |
946 | 951 |
// Verify reset |
... | ... | |
1192 | 1197 |
|
1193 | 1198 |
THREADED_PROFILED_TEST(FastReturnValues) { |
1194 | 1199 |
LocalContext env; |
1195 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
1200 |
v8::HandleScope scope(CcTest::isolate());
|
|
1196 | 1201 |
v8::Handle<v8::Value> value; |
1197 | 1202 |
// check int32_t and uint32_t |
1198 | 1203 |
int32_t int_values[] = { |
... | ... | |
1412 | 1417 |
THREADED_TEST(TinyInteger) { |
1413 | 1418 |
LocalContext env; |
1414 | 1419 |
v8::HandleScope scope(env->GetIsolate()); |
1415 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
1420 |
v8::Isolate* isolate = CcTest::isolate();
|
|
1416 | 1421 |
|
1417 | 1422 |
int32_t value = 239; |
1418 | 1423 |
Local<v8::Integer> value_obj = v8::Integer::New(value); |
... | ... | |
1426 | 1431 |
THREADED_TEST(BigSmiInteger) { |
1427 | 1432 |
LocalContext env; |
1428 | 1433 |
v8::HandleScope scope(env->GetIsolate()); |
1429 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
1434 |
v8::Isolate* isolate = CcTest::isolate();
|
|
1430 | 1435 |
|
1431 | 1436 |
int32_t value = i::Smi::kMaxValue; |
1432 | 1437 |
// We cannot add one to a Smi::kMaxValue without wrapping. |
... | ... | |
1446 | 1451 |
THREADED_TEST(BigInteger) { |
1447 | 1452 |
LocalContext env; |
1448 | 1453 |
v8::HandleScope scope(env->GetIsolate()); |
1449 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
1454 |
v8::Isolate* isolate = CcTest::isolate();
|
|
1450 | 1455 |
|
1451 | 1456 |
// We cannot add one to a Smi::kMaxValue without wrapping. |
1452 | 1457 |
if (i::SmiValuesAre31Bits()) { |
... | ... | |
1469 | 1474 |
THREADED_TEST(TinyUnsignedInteger) { |
1470 | 1475 |
LocalContext env; |
1471 | 1476 |
v8::HandleScope scope(env->GetIsolate()); |
1472 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
1477 |
v8::Isolate* isolate = CcTest::isolate();
|
|
1473 | 1478 |
|
1474 | 1479 |
uint32_t value = 239; |
1475 | 1480 |
|
... | ... | |
1484 | 1489 |
THREADED_TEST(BigUnsignedSmiInteger) { |
1485 | 1490 |
LocalContext env; |
1486 | 1491 |
v8::HandleScope scope(env->GetIsolate()); |
1487 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
1492 |
v8::Isolate* isolate = CcTest::isolate();
|
|
1488 | 1493 |
|
1489 | 1494 |
uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue); |
1490 | 1495 |
CHECK(i::Smi::IsValid(value)); |
... | ... | |
1501 | 1506 |
THREADED_TEST(BigUnsignedInteger) { |
1502 | 1507 |
LocalContext env; |
1503 | 1508 |
v8::HandleScope scope(env->GetIsolate()); |
1504 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
1509 |
v8::Isolate* isolate = CcTest::isolate();
|
|
1505 | 1510 |
|
1506 | 1511 |
uint32_t value = static_cast<uint32_t>(i::Smi::kMaxValue) + 1; |
1507 | 1512 |
CHECK(value > static_cast<uint32_t>(i::Smi::kMaxValue)); |
... | ... | |
1518 | 1523 |
THREADED_TEST(OutOfSignedRangeUnsignedInteger) { |
1519 | 1524 |
LocalContext env; |
1520 | 1525 |
v8::HandleScope scope(env->GetIsolate()); |
1521 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
1526 |
v8::Isolate* isolate = CcTest::isolate();
|
|
1522 | 1527 |
|
1523 | 1528 |
uint32_t INT32_MAX_AS_UINT = (1U << 31) - 1; |
1524 | 1529 |
uint32_t value = INT32_MAX_AS_UINT + 1; |
... | ... | |
1679 | 1684 |
|
1680 | 1685 |
THREADED_TEST(ToNumber) { |
1681 | 1686 |
LocalContext env; |
1682 |
v8::HandleScope scope(env->GetIsolate()); |
|
1687 |
v8::Isolate* isolate = CcTest::isolate(); |
|
1688 |
v8::HandleScope scope(isolate); |
|
1683 | 1689 |
Local<String> str = v8_str("3.1415926"); |
1684 | 1690 |
CHECK_EQ(3.1415926, str->NumberValue()); |
1685 |
v8::Handle<v8::Boolean> t = v8::True(); |
|
1691 |
v8::Handle<v8::Boolean> t = v8::True(isolate);
|
|
1686 | 1692 |
CHECK_EQ(1.0, t->NumberValue()); |
1687 |
v8::Handle<v8::Boolean> f = v8::False(); |
|
1693 |
v8::Handle<v8::Boolean> f = v8::False(isolate);
|
|
1688 | 1694 |
CHECK_EQ(0.0, f->NumberValue()); |
1689 | 1695 |
} |
1690 | 1696 |
|
... | ... | |
1703 | 1709 |
THREADED_TEST(Boolean) { |
1704 | 1710 |
LocalContext env; |
1705 | 1711 |
v8::HandleScope scope(env->GetIsolate()); |
1706 |
v8::Handle<v8::Boolean> t = v8::True(); |
|
1712 |
v8::Handle<v8::Boolean> t = v8::True(CcTest::isolate());
|
|
1707 | 1713 |
CHECK(t->Value()); |
1708 |
v8::Handle<v8::Boolean> f = v8::False(); |
|
1714 |
v8::Handle<v8::Boolean> f = v8::False(CcTest::isolate());
|
|
1709 | 1715 |
CHECK(!f->Value()); |
1710 |
v8::Handle<v8::Primitive> u = v8::Undefined(); |
|
1716 |
v8::Handle<v8::Primitive> u = v8::Undefined(CcTest::isolate());
|
|
1711 | 1717 |
CHECK(!u->BooleanValue()); |
1712 |
v8::Handle<v8::Primitive> n = v8::Null(); |
|
1718 |
v8::Handle<v8::Primitive> n = v8::Null(CcTest::isolate());
|
|
1713 | 1719 |
CHECK(!n->BooleanValue()); |
1714 | 1720 |
v8::Handle<String> str1 = v8_str(""); |
1715 | 1721 |
CHECK(!str1->BooleanValue()); |
... | ... | |
1737 | 1743 |
|
1738 | 1744 |
|
1739 | 1745 |
THREADED_TEST(GlobalPrototype) { |
1740 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
1746 |
v8::HandleScope scope(CcTest::isolate());
|
|
1741 | 1747 |
v8::Handle<v8::FunctionTemplate> func_templ = v8::FunctionTemplate::New(); |
1742 | 1748 |
func_templ->PrototypeTemplate()->Set( |
1743 | 1749 |
"dummy", |
... | ... | |
1755 | 1761 |
|
1756 | 1762 |
|
1757 | 1763 |
THREADED_TEST(ObjectTemplate) { |
1758 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
1764 |
v8::HandleScope scope(CcTest::isolate());
|
|
1759 | 1765 |
Local<ObjectTemplate> templ1 = ObjectTemplate::New(); |
1760 | 1766 |
templ1->Set("x", v8_num(10)); |
1761 | 1767 |
templ1->Set("y", v8_num(13)); |
... | ... | |
1792 | 1798 |
|
1793 | 1799 |
|
1794 | 1800 |
THREADED_TEST(DescriptorInheritance) { |
1795 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
1801 |
v8::HandleScope scope(CcTest::isolate());
|
|
1796 | 1802 |
v8::Handle<v8::FunctionTemplate> super = v8::FunctionTemplate::New(); |
1797 | 1803 |
super->PrototypeTemplate()->Set("flabby", |
1798 | 1804 |
v8::FunctionTemplate::New(GetFlabby)); |
... | ... | |
1933 | 1939 |
|
1934 | 1940 |
|
1935 | 1941 |
THREADED_TEST(EmptyInterceptorDoesNotShadowAccessors) { |
1936 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
1942 |
v8::HandleScope scope(CcTest::isolate());
|
|
1937 | 1943 |
Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
1938 | 1944 |
Handle<FunctionTemplate> child = FunctionTemplate::New(); |
1939 | 1945 |
child->Inherit(parent); |
... | ... | |
1951 | 1957 |
|
1952 | 1958 |
|
1953 | 1959 |
THREADED_TEST(EmptyInterceptorDoesNotShadowJSAccessors) { |
1954 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
1960 |
v8::HandleScope scope(CcTest::isolate());
|
|
1955 | 1961 |
Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
1956 | 1962 |
Handle<FunctionTemplate> child = FunctionTemplate::New(); |
1957 | 1963 |
child->Inherit(parent); |
... | ... | |
1972 | 1978 |
|
1973 | 1979 |
|
1974 | 1980 |
THREADED_TEST(EmptyInterceptorDoesNotAffectJSProperties) { |
1975 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
1981 |
v8::HandleScope scope(CcTest::isolate());
|
|
1976 | 1982 |
Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
1977 | 1983 |
Handle<FunctionTemplate> child = FunctionTemplate::New(); |
1978 | 1984 |
child->Inherit(parent); |
... | ... | |
1992 | 1998 |
|
1993 | 1999 |
|
1994 | 2000 |
THREADED_TEST(SwitchFromInterceptorToAccessor) { |
1995 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2001 |
v8::HandleScope scope(CcTest::isolate());
|
|
1996 | 2002 |
Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
1997 | 2003 |
AddAccessor(templ, v8_str("age"), |
1998 | 2004 |
SimpleAccessorGetter, SimpleAccessorSetter); |
... | ... | |
2010 | 2016 |
|
2011 | 2017 |
|
2012 | 2018 |
THREADED_TEST(SwitchFromAccessorToInterceptor) { |
2013 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2019 |
v8::HandleScope scope(CcTest::isolate());
|
|
2014 | 2020 |
Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
2015 | 2021 |
AddAccessor(templ, v8_str("age"), |
2016 | 2022 |
SimpleAccessorGetter, SimpleAccessorSetter); |
... | ... | |
2028 | 2034 |
|
2029 | 2035 |
|
2030 | 2036 |
THREADED_TEST(SwitchFromInterceptorToAccessorWithInheritance) { |
2031 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2037 |
v8::HandleScope scope(CcTest::isolate());
|
|
2032 | 2038 |
Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
2033 | 2039 |
Handle<FunctionTemplate> child = FunctionTemplate::New(); |
2034 | 2040 |
child->Inherit(parent); |
... | ... | |
2048 | 2054 |
|
2049 | 2055 |
|
2050 | 2056 |
THREADED_TEST(SwitchFromAccessorToInterceptorWithInheritance) { |
2051 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2057 |
v8::HandleScope scope(CcTest::isolate());
|
|
2052 | 2058 |
Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
2053 | 2059 |
Handle<FunctionTemplate> child = FunctionTemplate::New(); |
2054 | 2060 |
child->Inherit(parent); |
... | ... | |
2068 | 2074 |
|
2069 | 2075 |
|
2070 | 2076 |
THREADED_TEST(SwitchFromInterceptorToJSAccessor) { |
2071 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2077 |
v8::HandleScope scope(CcTest::isolate());
|
|
2072 | 2078 |
Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
2073 | 2079 |
AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
2074 | 2080 |
LocalContext env; |
... | ... | |
2093 | 2099 |
|
2094 | 2100 |
|
2095 | 2101 |
THREADED_TEST(SwitchFromJSAccessorToInterceptor) { |
2096 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2102 |
v8::HandleScope scope(CcTest::isolate());
|
|
2097 | 2103 |
Handle<FunctionTemplate> templ = FunctionTemplate::New(); |
2098 | 2104 |
AddInterceptor(templ, InterceptorGetter, InterceptorSetter); |
2099 | 2105 |
LocalContext env; |
... | ... | |
2118 | 2124 |
|
2119 | 2125 |
|
2120 | 2126 |
THREADED_TEST(SwitchFromInterceptorToProperty) { |
2121 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2127 |
v8::HandleScope scope(CcTest::isolate());
|
|
2122 | 2128 |
Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
2123 | 2129 |
Handle<FunctionTemplate> child = FunctionTemplate::New(); |
2124 | 2130 |
child->Inherit(parent); |
... | ... | |
2136 | 2142 |
|
2137 | 2143 |
|
2138 | 2144 |
THREADED_TEST(SwitchFromPropertyToInterceptor) { |
2139 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2145 |
v8::HandleScope scope(CcTest::isolate());
|
|
2140 | 2146 |
Handle<FunctionTemplate> parent = FunctionTemplate::New(); |
2141 | 2147 |
Handle<FunctionTemplate> child = FunctionTemplate::New(); |
2142 | 2148 |
child->Inherit(parent); |
... | ... | |
2155 | 2161 |
|
2156 | 2162 |
THREADED_TEST(NamedPropertyHandlerGetter) { |
2157 | 2163 |
echo_named_call_count = 0; |
2158 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2164 |
v8::HandleScope scope(CcTest::isolate());
|
|
2159 | 2165 |
v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
2160 | 2166 |
templ->InstanceTemplate()->SetNamedPropertyHandler(EchoNamedProperty, |
2161 | 2167 |
0, 0, 0, 0, |
... | ... | |
2191 | 2197 |
|
2192 | 2198 |
|
2193 | 2199 |
THREADED_TEST(IndexedPropertyHandlerGetter) { |
2194 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2200 |
v8::HandleScope scope(CcTest::isolate());
|
|
2195 | 2201 |
v8::Handle<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); |
2196 | 2202 |
templ->InstanceTemplate()->SetIndexedPropertyHandler(EchoIndexedProperty, |
2197 | 2203 |
0, 0, 0, 0, |
... | ... | |
2362 | 2368 |
|
2363 | 2369 |
|
2364 | 2370 |
THREADED_TEST(PrePropertyHandler) { |
2365 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2371 |
v8::HandleScope scope(CcTest::isolate());
|
|
2366 | 2372 |
v8::Handle<v8::FunctionTemplate> desc = v8::FunctionTemplate::New(); |
2367 | 2373 |
desc->InstanceTemplate()->SetNamedPropertyHandler(PrePropertyHandlerGet, |
2368 | 2374 |
0, |
... | ... | |
2419 | 2425 |
|
2420 | 2426 |
|
2421 | 2427 |
THREADED_TEST(DeepCrossLanguageRecursion) { |
2422 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2428 |
v8::HandleScope scope(CcTest::isolate());
|
|
2423 | 2429 |
v8::Handle<v8::ObjectTemplate> global = ObjectTemplate::New(); |
2424 | 2430 |
global->Set(v8_str("callScriptRecursively"), |
2425 | 2431 |
v8::FunctionTemplate::New(CallScriptRecursivelyCall)); |
... | ... | |
2441 | 2447 |
Local<String> key, |
2442 | 2448 |
const v8::PropertyCallbackInfo<v8::Value>& info) { |
2443 | 2449 |
ApiTestFuzzer::Fuzz(); |
2444 |
info.GetReturnValue().Set(v8::ThrowException(key));
|
|
2450 |
info.GetReturnValue().Set(info.GetIsolate()->ThrowException(key));
|
|
2445 | 2451 |
} |
2446 | 2452 |
|
2447 | 2453 |
|
... | ... | |
2449 | 2455 |
Local<String> key, |
2450 | 2456 |
Local<Value>, |
2451 | 2457 |
const v8::PropertyCallbackInfo<v8::Value>& info) { |
2452 |
v8::ThrowException(key);
|
|
2458 |
info.GetIsolate()->ThrowException(key);
|
|
2453 | 2459 |
info.GetReturnValue().SetUndefined(); // not the same as empty handle |
2454 | 2460 |
} |
2455 | 2461 |
|
2456 | 2462 |
|
2457 | 2463 |
THREADED_TEST(CallbackExceptionRegression) { |
2458 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2464 |
v8::HandleScope scope(CcTest::isolate());
|
|
2459 | 2465 |
v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New(); |
2460 | 2466 |
obj->SetNamedPropertyHandler(ThrowingPropertyHandlerGet, |
2461 | 2467 |
ThrowingPropertyHandlerSet); |
... | ... | |
2471 | 2477 |
|
2472 | 2478 |
|
2473 | 2479 |
THREADED_TEST(FunctionPrototype) { |
2474 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2480 |
v8::HandleScope scope(CcTest::isolate());
|
|
2475 | 2481 |
Local<v8::FunctionTemplate> Foo = v8::FunctionTemplate::New(); |
2476 | 2482 |
Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); |
2477 | 2483 |
LocalContext env; |
... | ... | |
2497 | 2503 |
|
2498 | 2504 |
|
2499 | 2505 |
THREADED_TEST(GlobalObjectInternalFields) { |
2500 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2506 |
v8::HandleScope scope(CcTest::isolate());
|
|
2501 | 2507 |
Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); |
2502 | 2508 |
global_template->SetInternalFieldCount(1); |
2503 | 2509 |
LocalContext env(NULL, global_template); |
... | ... | |
2512 | 2518 |
|
2513 | 2519 |
THREADED_TEST(GlobalObjectHasRealIndexedProperty) { |
2514 | 2520 |
LocalContext env; |
2515 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
2521 |
v8::HandleScope scope(CcTest::isolate());
|
|
2516 | 2522 |
|
2517 | 2523 |
v8::Local<v8::Object> global = env->Global(); |
2518 | 2524 |
global->Set(0, v8::String::New("value")); |
... | ... | |
2524 | 2530 |
void* value) { |
2525 | 2531 |
CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
2526 | 2532 |
obj->SetAlignedPointerInInternalField(0, value); |
2527 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2533 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2528 | 2534 |
CHECK_EQ(value, obj->GetAlignedPointerFromInternalField(0)); |
2529 | 2535 |
} |
2530 | 2536 |
|
... | ... | |
2558 | 2564 |
void* value) { |
2559 | 2565 |
CHECK_EQ(0, static_cast<int>(reinterpret_cast<uintptr_t>(value) & 0x1)); |
2560 | 2566 |
(*env)->SetAlignedPointerInEmbedderData(index, value); |
2561 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2567 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2562 | 2568 |
CHECK_EQ(value, (*env)->GetAlignedPointerFromEmbedderData(index)); |
2563 | 2569 |
} |
2564 | 2570 |
|
... | ... | |
2588 | 2594 |
for (int i = 0; i < 100; i++) { |
2589 | 2595 |
env->SetAlignedPointerInEmbedderData(i, AlignedTestPointer(i)); |
2590 | 2596 |
} |
2591 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2597 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2592 | 2598 |
for (int i = 0; i < 100; i++) { |
2593 | 2599 |
CHECK_EQ(AlignedTestPointer(i), env->GetAlignedPointerFromEmbedderData(i)); |
2594 | 2600 |
} |
... | ... | |
2620 | 2626 |
|
2621 | 2627 |
// Ensure that the test starts with an fresh heap to test whether the hash |
2622 | 2628 |
// code is based on the address. |
2623 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2629 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2624 | 2630 |
Local<v8::Object> obj = v8::Object::New(); |
2625 | 2631 |
int hash = obj->GetIdentityHash(); |
2626 | 2632 |
int hash1 = obj->GetIdentityHash(); |
... | ... | |
2630 | 2636 |
// objects should not be assigned the same hash code. If the test below fails |
2631 | 2637 |
// the random number generator should be evaluated. |
2632 | 2638 |
CHECK_NE(hash, hash2); |
2633 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2639 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2634 | 2640 |
int hash3 = v8::Object::New()->GetIdentityHash(); |
2635 | 2641 |
// Make sure that the identity hash is not based on the initial address of |
2636 | 2642 |
// the object alone. If the test below fails the random number generator |
... | ... | |
2669 | 2675 |
v8::Local<v8::Symbol> sym1 = v8::Symbol::New(isolate); |
2670 | 2676 |
v8::Local<v8::Symbol> sym2 = v8::Symbol::New(isolate, "my-symbol"); |
2671 | 2677 |
|
2672 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2678 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2673 | 2679 |
|
2674 | 2680 |
// Check basic symbol functionality. |
2675 | 2681 |
CHECK(sym1->IsSymbol()); |
... | ... | |
2720 | 2726 |
CHECK_EQ(1, obj->GetOwnPropertyNames()->Length()); |
2721 | 2727 |
CHECK_EQ(num_props + 1, obj->GetPropertyNames()->Length()); |
2722 | 2728 |
|
2723 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2729 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2724 | 2730 |
|
2725 | 2731 |
// Add another property and delete it afterwards to force the object in |
2726 | 2732 |
// slow case. |
... | ... | |
2770 | 2776 |
CheckInternalFieldsAreZero(ab); |
2771 | 2777 |
CHECK_EQ(1024, static_cast<int>(ab->ByteLength())); |
2772 | 2778 |
CHECK(!ab->IsExternal()); |
2773 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2779 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
2774 | 2780 |
|
2775 | 2781 |
ScopedArrayBufferContents ab_contents(ab->Externalize()); |
2776 | 2782 |
CHECK(ab->IsExternal()); |
... | ... | |
3012 | 3018 |
v8::Local<v8::String> empty = v8_str(""); |
3013 | 3019 |
v8::Local<v8::String> prop_name = v8_str("prop_name"); |
3014 | 3020 |
|
3015 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3021 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3016 | 3022 |
|
3017 | 3023 |
// Make sure delete of a non-existent hidden value works |
3018 | 3024 |
CHECK(obj->DeleteHiddenValue(key)); |
... | ... | |
3022 | 3028 |
CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002))); |
3023 | 3029 |
CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3024 | 3030 |
|
3025 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3031 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3026 | 3032 |
|
3027 | 3033 |
// Make sure we do not find the hidden property. |
3028 | 3034 |
CHECK(!obj->Has(empty)); |
... | ... | |
3033 | 3039 |
CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3034 | 3040 |
CHECK_EQ(2003, obj->Get(empty)->Int32Value()); |
3035 | 3041 |
|
3036 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3042 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3037 | 3043 |
|
3038 | 3044 |
// Add another property and delete it afterwards to force the object in |
3039 | 3045 |
// slow case. |
... | ... | |
3044 | 3050 |
CHECK(obj->Delete(prop_name)); |
3045 | 3051 |
CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value()); |
3046 | 3052 |
|
3047 |
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3053 |
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
|
|
3048 | 3054 |
|
3049 | 3055 |
CHECK(obj->SetHiddenValue(key, Handle<Value>())); |
3050 | 3056 |
CHECK(obj->GetHiddenValue(key).IsEmpty()); |
... | ... | |
3111 | 3117 |
|
3112 | 3118 |
|
3113 | 3119 |
THREADED_TEST(External) { |
3114 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
3120 |
v8::HandleScope scope(CcTest::isolate());
|
|
3115 | 3121 |
int x = 3; |
3116 | 3122 |
Local<v8::External> ext = v8::External::New(&x); |
3117 | 3123 |
LocalContext env; |
... | ... | |
3143 | 3149 |
|
3144 | 3150 |
|
3145 | 3151 |
THREADED_TEST(GlobalHandle) { |
3146 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
3152 |
v8::Isolate* isolate = CcTest::isolate();
|
|
3147 | 3153 |
v8::Persistent<String> global; |
3148 | 3154 |
{ |
3149 | 3155 |
v8::HandleScope scope(isolate); |
... | ... | |
3168 | 3174 |
|
3169 | 3175 |
|
3170 | 3176 |
THREADED_TEST(ResettingGlobalHandle) { |
3171 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
3177 |
v8::Isolate* isolate = CcTest::isolate();
|
|
3172 | 3178 |
v8::Persistent<String> global; |
3173 | 3179 |
{ |
3174 | 3180 |
v8::HandleScope scope(isolate); |
... | ... | |
3196 | 3202 |
|
3197 | 3203 |
|
3198 | 3204 |
THREADED_TEST(ResettingGlobalHandleToEmpty) { |
3199 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
3205 |
v8::Isolate* isolate = CcTest::isolate();
|
|
3200 | 3206 |
v8::Persistent<String> global; |
3201 | 3207 |
{ |
3202 | 3208 |
v8::HandleScope scope(isolate); |
... | ... | |
3220 | 3226 |
|
3221 | 3227 |
|
3222 | 3228 |
THREADED_TEST(ClearAndLeakGlobal) { |
3223 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
3229 |
v8::Isolate* isolate = CcTest::isolate();
|
|
3224 | 3230 |
v8::internal::GlobalHandles* global_handles = NULL; |
3225 | 3231 |
int initial_handle_count = 0; |
3226 | 3232 |
v8::Persistent<String> global; |
... | ... | |
3242 | 3248 |
|
3243 | 3249 |
|
3244 | 3250 |
THREADED_TEST(GlobalHandleUpcast) { |
3245 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
3251 |
v8::Isolate* isolate = CcTest::isolate();
|
|
3246 | 3252 |
v8::HandleScope scope(isolate); |
3247 |
v8::Local<String> local = v8::Local<String>::New(v8_str("str")); |
|
3253 |
v8::Local<String> local = v8::Local<String>::New(isolate, v8_str("str"));
|
|
3248 | 3254 |
v8::Persistent<String> global_string(isolate, local); |
3249 | 3255 |
v8::Persistent<Value>& global_value = |
3250 | 3256 |
v8::Persistent<Value>::Cast(global_string); |
... | ... | |
3255 | 3261 |
|
3256 | 3262 |
|
3257 | 3263 |
THREADED_TEST(HandleEquality) { |
3258 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
3264 |
v8::Isolate* isolate = CcTest::isolate();
|
|
3259 | 3265 |
v8::Persistent<String> global1; |
3260 | 3266 |
v8::Persistent<String> global2; |
3261 | 3267 |
{ |
... | ... | |
3293 | 3299 |
|
3294 | 3300 |
|
3295 | 3301 |
THREADED_TEST(LocalHandle) { |
3296 |
v8::HandleScope scope(v8::Isolate::GetCurrent()); |
|
3297 |
v8::Local<String> local = v8::Local<String>::New(v8_str("str")); |
|
3298 |
CHECK_EQ(local->Length(), 3); |
|
3299 |
|
|
3300 |
local = v8::Local<String>::New(v8::Isolate::GetCurrent(), v8_str("str")); |
|
3302 |
v8::HandleScope scope(CcTest::isolate()); |
|
3303 |
v8::Local<String> local = |
|
3304 |
v8::Local<String>::New(CcTest::isolate(), v8_str("str")); |
|
3301 | 3305 |
CHECK_EQ(local->Length(), 3); |
3302 | 3306 |
} |
3303 | 3307 |
|
... | ... | |
3314 | 3318 |
}; |
3315 | 3319 |
|
3316 | 3320 |
|
3321 |
template<typename T> |
|
3317 | 3322 |
static void WeakPointerCallback(v8::Isolate* isolate, |
3318 |
Persistent<Value>* handle,
|
|
3323 |
Persistent<T>* handle,
|
|
3319 | 3324 |
WeakCallCounter* counter) { |
3320 | 3325 |
CHECK_EQ(1234, counter->id()); |
3321 | 3326 |
counter->increment(); |
... | ... | |
3323 | 3328 |
} |
3324 | 3329 |
|
3325 | 3330 |
|
3326 |
static UniqueId MakeUniqueId(const Persistent<Value>& p) { |
|
3331 |
template<typename T> |
|
3332 |
static UniqueId MakeUniqueId(const Persistent<T>& p) { |
|
3327 | 3333 |
return UniqueId(reinterpret_cast<uintptr_t>(*v8::Utils::OpenPersistent(p))); |
3328 | 3334 |
} |
3329 | 3335 |
|
... | ... | |
3421 | 3427 |
} |
3422 | 3428 |
|
3423 | 3429 |
|
3430 |
THREADED_TEST(ApiObjectGroupsForSubtypes) { |
|
3431 |
LocalContext env; |
|
3432 |
v8::Isolate* iso = env->GetIsolate(); |
|
3433 |
HandleScope scope(iso); |
|
3434 |
|
|
3435 |
Persistent<Object> g1s1; |
|
3436 |
Persistent<String> g1s2; |
|
3437 |
Persistent<String> g1c1; |
|
3438 |
Persistent<Object> g2s1; |
|
3439 |
Persistent<String> g2s2; |
|
3440 |
Persistent<String> g2c1; |
|
3441 |
|
|
3442 |
WeakCallCounter counter(1234); |
|
3443 |
|
|
3444 |
{ |
|
3445 |
HandleScope scope(iso); |
|
3446 |
g1s1.Reset(iso, Object::New()); |
|
3447 |
g1s2.Reset(iso, String::New("foo1")); |
|
3448 |
g1c1.Reset(iso, String::New("foo2")); |
|
3449 |
g1s1.MakeWeak(&counter, &WeakPointerCallback); |
|
3450 |
g1s2.MakeWeak(&counter, &WeakPointerCallback); |
|
3451 |
g1c1.MakeWeak(&counter, &WeakPointerCallback); |
|
3452 |
|
|
3453 |
g2s1.Reset(iso, Object::New()); |
|
3454 |
g2s2.Reset(iso, String::New("foo3")); |
|
3455 |
g2c1.Reset(iso, String::New("foo4")); |
|
3456 |
g2s1.MakeWeak(&counter, &WeakPointerCallback); |
|
3457 |
g2s2.MakeWeak(&counter, &WeakPointerCallback); |
|
3458 |
g2c1.MakeWeak(&counter, &WeakPointerCallback); |
|
3459 |
} |
|
3460 |
|
|
3461 |
Persistent<Value> root(iso, g1s1); // make a root. |
|
3462 |
|
|
3463 |
// Connect group 1 and 2, make a cycle. |
|
3464 |
{ |
|
3465 |
HandleScope scope(iso); |
|
3466 |
CHECK(Local<Object>::New(iso, g1s1)->Set(0, Local<Object>::New(iso, g2s1))); |
|
3467 |
CHECK(Local<Object>::New(iso, g2s1)->Set(0, Local<Object>::New(iso, g1s1))); |
|
3468 |
} |
|
3469 |
|
|
3470 |
{ |
|
3471 |
UniqueId id1 = MakeUniqueId(g1s1); |
|
3472 |
UniqueId id2 = MakeUniqueId(g2s2); |
|
3473 |
iso->SetObjectGroupId(g1s1, id1); |
|
3474 |
iso->SetObjectGroupId(g1s2, id1); |
|
3475 |
iso->SetReference(g1s1, g1c1); |
|
3476 |
iso->SetObjectGroupId(g2s1, id2); |
|
3477 |
iso->SetObjectGroupId(g2s2, id2); |
|
3478 |
iso->SetReferenceFromGroup(id2, g2c1); |
|
3479 |
} |
|
3480 |
// Do a single full GC, ensure incremental marking is stopped. |
|
3481 |
v8::internal::Heap* heap = reinterpret_cast<v8::internal::Isolate*>( |
|
3482 |
iso)->heap(); |
|
3483 |
heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
|
3484 |
|
|
3485 |
// All object should be alive. |
|
3486 |
CHECK_EQ(0, counter.NumberOfWeakCalls()); |
|
3487 |
|
|
3488 |
// Weaken the root. |
|
3489 |
root.MakeWeak(&counter, &WeakPointerCallback); |
|
3490 |
// But make children strong roots---all the objects (except for children) |
|
3491 |
// should be collectable now. |
|
3492 |
g1c1.ClearWeak(); |
|
3493 |
g2c1.ClearWeak(); |
|
3494 |
|
|
3495 |
// Groups are deleted, rebuild groups. |
|
3496 |
{ |
|
3497 |
UniqueId id1 = MakeUniqueId(g1s1); |
|
3498 |
UniqueId id2 = MakeUniqueId(g2s2); |
|
3499 |
iso->SetObjectGroupId(g1s1, id1); |
|
3500 |
iso->SetObjectGroupId(g1s2, id1); |
|
3501 |
iso->SetReference(g1s1, g1c1); |
|
3502 |
iso->SetObjectGroupId(g2s1, id2); |
|
3503 |
iso->SetObjectGroupId(g2s2, id2); |
|
3504 |
iso->SetReferenceFromGroup(id2, g2c1); |
|
3505 |
} |
|
3506 |
|
|
3507 |
heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
|
3508 |
|
|
3509 |
// All objects should be gone. 5 global handles in total. |
|
3510 |
CHECK_EQ(5, counter.NumberOfWeakCalls()); |
|
3511 |
|
|
3512 |
// And now make children weak again and collect them. |
|
3513 |
g1c1.MakeWeak(&counter, &WeakPointerCallback); |
|
3514 |
g2c1.MakeWeak(&counter, &WeakPointerCallback); |
|
3515 |
|
|
3516 |
heap->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
|
3517 |
CHECK_EQ(7, counter.NumberOfWeakCalls()); |
|
3518 |
} |
|
3519 |
|
|
3520 |
|
|
3424 | 3521 |
THREADED_TEST(ApiObjectGroupsCycle) { |
3425 | 3522 |
LocalContext env; |
3426 | 3523 |
v8::Isolate* iso = env->GetIsolate(); |
... | ... | |
3675 | 3772 |
|
3676 | 3773 |
THREADED_TEST(MessageHandler0) { |
3677 | 3774 |
message_received = false; |
3678 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
3775 |
v8::HandleScope scope(CcTest::isolate());
|
|
3679 | 3776 |
CHECK(!message_received); |
3680 | 3777 |
v8::V8::AddMessageListener(check_message_0, v8_num(5.76)); |
3681 | 3778 |
LocalContext context; |
... | ... | |
3702 | 3799 |
|
3703 | 3800 |
TEST(MessageHandler1) { |
3704 | 3801 |
message_received = false; |
3705 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
3802 |
v8::HandleScope scope(CcTest::isolate());
|
|
3706 | 3803 |
CHECK(!message_received); |
3707 | 3804 |
v8::V8::AddMessageListener(check_message_1); |
3708 | 3805 |
LocalContext context; |
... | ... | |
3727 | 3824 |
|
3728 | 3825 |
TEST(MessageHandler2) { |
3729 | 3826 |
message_received = false; |
3730 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
3827 |
v8::HandleScope scope(CcTest::isolate());
|
|
3731 | 3828 |
CHECK(!message_received); |
3732 | 3829 |
v8::V8::AddMessageListener(check_message_2); |
3733 | 3830 |
LocalContext context; |
... | ... | |
3752 | 3849 |
|
3753 | 3850 |
TEST(MessageHandler3) { |
3754 | 3851 |
message_received = false; |
3755 |
v8::HandleScope scope(v8::Isolate::GetCurrent()); |
|
3852 |
v8::Isolate* isolate = CcTest::isolate(); |
|
3853 |
v8::HandleScope scope(isolate); |
|
3756 | 3854 |
CHECK(!message_received); |
3757 | 3855 |
v8::V8::AddMessageListener(check_message_3); |
3758 | 3856 |
LocalContext context; |
3759 | 3857 |
v8::ScriptOrigin origin = |
3760 | 3858 |
v8::ScriptOrigin(v8_str("6.75"), |
3761 |
v8::Integer::New(1), |
|
3762 |
v8::Integer::New(2), |
|
3763 |
v8::True()); |
|
3859 |
v8::Integer::New(1, isolate),
|
|
3860 |
v8::Integer::New(2, isolate),
|
|
3861 |
v8::True(isolate));
|
|
3764 | 3862 |
v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
3765 | 3863 |
&origin); |
3766 | 3864 |
script->Run(); |
... | ... | |
3780 | 3878 |
|
3781 | 3879 |
TEST(MessageHandler4) { |
3782 | 3880 |
message_received = false; |
3783 |
v8::HandleScope scope(v8::Isolate::GetCurrent()); |
|
3881 |
v8::Isolate* isolate = CcTest::isolate(); |
|
3882 |
v8::HandleScope scope(isolate); |
|
3784 | 3883 |
CHECK(!message_received); |
3785 | 3884 |
v8::V8::AddMessageListener(check_message_4); |
3786 | 3885 |
LocalContext context; |
3787 | 3886 |
v8::ScriptOrigin origin = |
3788 | 3887 |
v8::ScriptOrigin(v8_str("6.75"), |
3789 |
v8::Integer::New(1), |
|
3790 |
v8::Integer::New(2), |
|
3791 |
v8::False()); |
|
3888 |
v8::Integer::New(1, isolate),
|
|
3889 |
v8::Integer::New(2, isolate),
|
|
3890 |
v8::False(isolate));
|
|
3792 | 3891 |
v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
3793 | 3892 |
&origin); |
3794 | 3893 |
script->Run(); |
... | ... | |
3816 | 3915 |
|
3817 | 3916 |
TEST(MessageHandler5) { |
3818 | 3917 |
message_received = false; |
3819 |
v8::HandleScope scope(v8::Isolate::GetCurrent()); |
|
3918 |
v8::Isolate* isolate = CcTest::isolate(); |
|
3919 |
v8::HandleScope scope(isolate); |
|
3820 | 3920 |
CHECK(!message_received); |
3821 | 3921 |
v8::V8::AddMessageListener(check_message_5a); |
3822 | 3922 |
LocalContext context; |
3823 | 3923 |
v8::ScriptOrigin origin = |
3824 | 3924 |
v8::ScriptOrigin(v8_str("6.75"), |
3825 |
v8::Integer::New(1), |
|
3826 |
v8::Integer::New(2), |
|
3827 |
v8::True()); |
|
3925 |
v8::Integer::New(1, isolate),
|
|
3926 |
v8::Integer::New(2, isolate),
|
|
3927 |
v8::True(isolate));
|
|
3828 | 3928 |
v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
3829 | 3929 |
&origin); |
3830 | 3930 |
script->Run(); |
... | ... | |
3836 | 3936 |
v8::V8::AddMessageListener(check_message_5b); |
3837 | 3937 |
origin = |
3838 | 3938 |
v8::ScriptOrigin(v8_str("6.75"), |
3839 |
v8::Integer::New(1), |
|
3840 |
v8::Integer::New(2), |
|
3841 |
v8::False()); |
|
3939 |
v8::Integer::New(1, isolate),
|
|
3940 |
v8::Integer::New(2, isolate),
|
|
3941 |
v8::False(isolate));
|
|
3842 | 3942 |
script = Script::Compile(v8_str("throw 'error'"), |
3843 | 3943 |
&origin); |
3844 | 3944 |
script->Run(); |
... | ... | |
3958 | 4058 |
|
3959 | 4059 |
|
3960 | 4060 |
THREADED_TEST(Vector) { |
3961 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4061 |
v8::HandleScope scope(CcTest::isolate());
|
|
3962 | 4062 |
Local<ObjectTemplate> global = ObjectTemplate::New(); |
3963 | 4063 |
global->Set(v8_str("f"), v8::FunctionTemplate::New(HandleF)); |
3964 | 4064 |
LocalContext context(0, global); |
... | ... | |
3997 | 4097 |
|
3998 | 4098 |
THREADED_TEST(FunctionCall) { |
3999 | 4099 |
LocalContext context; |
4000 |
v8::HandleScope scope(context->GetIsolate()); |
|
4100 |
v8::Isolate* isolate = context->GetIsolate(); |
|
4101 |
v8::HandleScope scope(isolate); |
|
4001 | 4102 |
CompileRun( |
4002 | 4103 |
"function Foo() {" |
4003 | 4104 |
" var result = [];" |
... | ... | |
4005 | 4106 |
" result.push(arguments[i]);" |
4006 | 4107 |
" }" |
4007 | 4108 |
" return result;" |
4109 |
"}" |
|
4110 |
"function ReturnThisSloppy() {" |
|
4111 |
" return this;" |
|
4112 |
"}" |
|
4113 |
"function ReturnThisStrict() {" |
|
4114 |
" 'use strict';" |
|
4115 |
" return this;" |
|
4008 | 4116 |
"}"); |
4009 | 4117 |
Local<Function> Foo = |
4010 | 4118 |
Local<Function>::Cast(context->Global()->Get(v8_str("Foo"))); |
4119 |
Local<Function> ReturnThisSloppy = |
|
4120 |
Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisSloppy"))); |
|
4121 |
Local<Function> ReturnThisStrict = |
|
4122 |
Local<Function>::Cast(context->Global()->Get(v8_str("ReturnThisStrict"))); |
|
4011 | 4123 |
|
4012 | 4124 |
v8::Handle<Value>* args0 = NULL; |
4013 | 4125 |
Local<v8::Array> a0 = Local<v8::Array>::Cast(Foo->Call(Foo, 0, args0)); |
... | ... | |
4044 | 4156 |
CHECK_EQ(8.8, a4->Get(v8::Integer::New(1))->NumberValue()); |
4045 | 4157 |
CHECK_EQ(9.9, a4->Get(v8::Integer::New(2))->NumberValue()); |
4046 | 4158 |
CHECK_EQ(10.11, a4->Get(v8::Integer::New(3))->NumberValue()); |
4159 |
|
|
4160 |
Local<v8::Value> r1 = ReturnThisSloppy->Call(v8::Undefined(isolate), 0, NULL); |
|
4161 |
CHECK(r1->StrictEquals(context->Global())); |
|
4162 |
Local<v8::Value> r2 = ReturnThisSloppy->Call(v8::Null(isolate), 0, NULL); |
|
4163 |
CHECK(r2->StrictEquals(context->Global())); |
|
4164 |
Local<v8::Value> r3 = ReturnThisSloppy->Call(v8_num(42), 0, NULL); |
|
4165 |
CHECK(r3->IsNumberObject()); |
|
4166 |
CHECK_EQ(42.0, r3.As<v8::NumberObject>()->ValueOf()); |
|
4167 |
Local<v8::Value> r4 = ReturnThisSloppy->Call(v8_str("hello"), 0, NULL); |
|
4168 |
CHECK(r4->IsStringObject()); |
|
4169 |
CHECK(r4.As<v8::StringObject>()->ValueOf()->StrictEquals(v8_str("hello"))); |
|
4170 |
Local<v8::Value> r5 = ReturnThisSloppy->Call(v8::True(isolate), 0, NULL); |
|
4171 |
CHECK(r5->IsBooleanObject()); |
|
4172 |
CHECK(r5.As<v8::BooleanObject>()->ValueOf()); |
|
4173 |
|
|
4174 |
Local<v8::Value> r6 = ReturnThisStrict->Call(v8::Undefined(isolate), 0, NULL); |
|
4175 |
CHECK(r6->IsUndefined()); |
|
4176 |
Local<v8::Value> r7 = ReturnThisStrict->Call(v8::Null(isolate), 0, NULL); |
|
4177 |
CHECK(r7->IsNull()); |
|
4178 |
Local<v8::Value> r8 = ReturnThisStrict->Call(v8_num(42), 0, NULL); |
|
4179 |
CHECK(r8->StrictEquals(v8_num(42))); |
|
4180 |
Local<v8::Value> r9 = ReturnThisStrict->Call(v8_str("hello"), 0, NULL); |
|
4181 |
CHECK(r9->StrictEquals(v8_str("hello"))); |
|
4182 |
Local<v8::Value> r10 = ReturnThisStrict->Call(v8::True(isolate), 0, NULL); |
|
4183 |
CHECK(r10->StrictEquals(v8::True(isolate))); |
|
4047 | 4184 |
} |
4048 | 4185 |
|
4049 | 4186 |
|
... | ... | |
4104 | 4241 |
constraints.set_max_old_space_size(5 * K * K); |
4105 | 4242 |
v8::SetResourceConstraints(&constraints); |
4106 | 4243 |
|
4107 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4244 |
v8::HandleScope scope(CcTest::isolate());
|
|
4108 | 4245 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4109 | 4246 |
templ->Set(v8_str("ProvokeOutOfMemory"), |
4110 | 4247 |
v8::FunctionTemplate::New(ProvokeOutOfMemory)); |
... | ... | |
4311 | 4448 |
|
4312 | 4449 |
THREADED_TEST(ConversionException) { |
4313 | 4450 |
LocalContext env; |
4314 |
v8::HandleScope scope(env->GetIsolate()); |
|
4451 |
v8::Isolate* isolate = env->GetIsolate(); |
|
4452 |
v8::HandleScope scope(isolate); |
|
4315 | 4453 |
CompileRun( |
4316 | 4454 |
"function TestClass() { };" |
4317 | 4455 |
"TestClass.prototype.toString = function () { throw 'uncle?'; };" |
... | ... | |
4340 | 4478 |
CHECK(to_int32_result.IsEmpty()); |
4341 | 4479 |
CheckUncle(&try_catch); |
4342 | 4480 |
|
4343 |
Local<Value> to_object_result = v8::Undefined()->ToObject(); |
|
4481 |
Local<Value> to_object_result = v8::Undefined(isolate)->ToObject();
|
|
4344 | 4482 |
CHECK(to_object_result.IsEmpty()); |
4345 | 4483 |
CHECK(try_catch.HasCaught()); |
4346 | 4484 |
try_catch.Reset(); |
... | ... | |
4365 | 4503 |
|
4366 | 4504 |
void ThrowFromC(const v8::FunctionCallbackInfo<v8::Value>& args) { |
4367 | 4505 |
ApiTestFuzzer::Fuzz(); |
4368 |
v8::ThrowException(v8_str("konto"));
|
|
4506 |
args.GetIsolate()->ThrowException(v8_str("konto"));
|
|
4369 | 4507 |
} |
4370 | 4508 |
|
4371 | 4509 |
|
... | ... | |
4383 | 4521 |
|
4384 | 4522 |
|
4385 | 4523 |
THREADED_TEST(APICatch) { |
4386 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4524 |
v8::HandleScope scope(CcTest::isolate());
|
|
4387 | 4525 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4388 | 4526 |
templ->Set(v8_str("ThrowFromC"), |
4389 | 4527 |
v8::FunctionTemplate::New(ThrowFromC)); |
... | ... | |
4401 | 4539 |
|
4402 | 4540 |
|
4403 | 4541 |
THREADED_TEST(APIThrowTryCatch) { |
4404 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4542 |
v8::HandleScope scope(CcTest::isolate());
|
|
4405 | 4543 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4406 | 4544 |
templ->Set(v8_str("ThrowFromC"), |
4407 | 4545 |
v8::FunctionTemplate::New(ThrowFromC)); |
... | ... | |
4420 | 4558 |
// JS stack. This test therefore fails on the simulator. The test is |
4421 | 4559 |
// not threaded to allow the threading tests to run on the simulator. |
4422 | 4560 |
TEST(TryCatchInTryFinally) { |
4423 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4561 |
v8::HandleScope scope(CcTest::isolate());
|
|
4424 | 4562 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4425 | 4563 |
templ->Set(v8_str("CCatcher"), |
4426 | 4564 |
v8::FunctionTemplate::New(CCatcher)); |
... | ... | |
4454 | 4592 |
// formatting. However, they are invoked when performing normal error |
4455 | 4593 |
// string conversions. |
4456 | 4594 |
TEST(APIThrowMessageOverwrittenToString) { |
4457 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4595 |
v8::HandleScope scope(CcTest::isolate());
|
|
4458 | 4596 |
v8::V8::AddMessageListener(check_reference_error_message); |
4459 | 4597 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4460 | 4598 |
templ->Set(v8_str("fail"), v8::FunctionTemplate::New(Fail)); |
... | ... | |
4578 | 4716 |
|
4579 | 4717 |
TEST(APIThrowMessage) { |
4580 | 4718 |
message_received = false; |
4581 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4719 |
v8::HandleScope scope(CcTest::isolate());
|
|
4582 | 4720 |
v8::V8::AddMessageListener(receive_message); |
4583 | 4721 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4584 | 4722 |
templ->Set(v8_str("ThrowFromC"), |
... | ... | |
4592 | 4730 |
|
4593 | 4731 |
TEST(APIThrowMessageAndVerboseTryCatch) { |
4594 | 4732 |
message_received = false; |
4595 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4733 |
v8::HandleScope scope(CcTest::isolate());
|
|
4596 | 4734 |
v8::V8::AddMessageListener(receive_message); |
4597 | 4735 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4598 | 4736 |
templ->Set(v8_str("ThrowFromC"), |
... | ... | |
4624 | 4762 |
|
4625 | 4763 |
|
4626 | 4764 |
THREADED_TEST(ExternalScriptException) { |
4627 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4765 |
v8::HandleScope scope(CcTest::isolate());
|
|
4628 | 4766 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4629 | 4767 |
templ->Set(v8_str("ThrowFromC"), |
4630 | 4768 |
v8::FunctionTemplate::New(ThrowFromC)); |
... | ... | |
4648 | 4786 |
int count = args[0]->Int32Value(); |
4649 | 4787 |
int cInterval = args[2]->Int32Value(); |
4650 | 4788 |
if (count == 0) { |
4651 |
v8::ThrowException(v8_str("FromC"));
|
|
4789 |
args.GetIsolate()->ThrowException(v8_str("FromC"));
|
|
4652 | 4790 |
return; |
4653 | 4791 |
} else { |
4654 |
Local<v8::Object> global = Context::GetCurrent()->Global(); |
|
4792 |
Local<v8::Object> global = |
|
4793 |
args.GetIsolate()->GetCurrentContext()->Global(); |
|
4655 | 4794 |
Local<Value> fun = global->Get(v8_str("JSThrowCountDown")); |
4656 | 4795 |
v8::Handle<Value> argv[] = { v8_num(count - 1), |
4657 | 4796 |
args[1], |
... | ... | |
4664 | 4803 |
if (try_catch.HasCaught()) { |
4665 | 4804 |
CHECK_EQ(expected, count); |
4666 | 4805 |
CHECK(result.IsEmpty()); |
4667 |
CHECK(!i::Isolate::Current()->has_scheduled_exception());
|
|
4806 |
CHECK(!CcTest::i_isolate()->has_scheduled_exception());
|
|
4668 | 4807 |
} else { |
4669 | 4808 |
CHECK_NE(expected, count); |
4670 | 4809 |
} |
... | ... | |
4728 | 4867 |
// JS stack. This test therefore fails on the simulator. The test is |
4729 | 4868 |
// not threaded to allow the threading tests to run on the simulator. |
4730 | 4869 |
TEST(ExceptionOrder) { |
4731 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4870 |
v8::HandleScope scope(CcTest::isolate());
|
|
4732 | 4871 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4733 | 4872 |
templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck)); |
4734 | 4873 |
templ->Set(v8_str("CThrowCountDown"), |
... | ... | |
4787 | 4926 |
void ThrowValue(const v8::FunctionCallbackInfo<v8::Value>& args) { |
4788 | 4927 |
ApiTestFuzzer::Fuzz(); |
4789 | 4928 |
CHECK_EQ(1, args.Length()); |
4790 |
v8::ThrowException(args[0]);
|
|
4929 |
args.GetIsolate()->ThrowException(args[0]);
|
|
4791 | 4930 |
} |
4792 | 4931 |
|
4793 | 4932 |
|
4794 | 4933 |
THREADED_TEST(ThrowValues) { |
4795 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
4934 |
v8::HandleScope scope(CcTest::isolate());
|
|
4796 | 4935 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
4797 | 4936 |
templ->Set(v8_str("Throw"), v8::FunctionTemplate::New(ThrowValue)); |
4798 | 4937 |
LocalContext context(0, templ); |
... | ... | |
4885 | 5024 |
CHECK(try_catch.HasCaught()); |
4886 | 5025 |
try_catch.ReThrow(); |
4887 | 5026 |
} else { |
4888 |
v8::ThrowException(v8_str("back"));
|
|
5027 |
CcTest::isolate()->ThrowException(v8_str("back"));
|
|
4889 | 5028 |
} |
4890 | 5029 |
} |
4891 | 5030 |
|
... | ... | |
4930 | 5069 |
// This exercises the ability of TryCatch.ReThrow() to restore the |
4931 | 5070 |
// inner pending Message before throwing the exception again. |
4932 | 5071 |
TEST(TryCatchMixedNesting) { |
4933 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5072 |
v8::HandleScope scope(CcTest::isolate());
|
|
4934 | 5073 |
v8::V8::Initialize(); |
4935 | 5074 |
v8::TryCatch try_catch; |
4936 | 5075 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
... | ... | |
4962 | 5101 |
CHECK(!v8_str("5")->StrictEquals(v8_num(5))); |
4963 | 5102 |
CHECK(v8_num(1)->StrictEquals(v8_num(1))); |
4964 | 5103 |
CHECK(!v8_num(1)->StrictEquals(v8_num(2))); |
4965 |
CHECK(v8_num(0)->StrictEquals(v8_num(-0)));
|
|
5104 |
CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0)));
|
|
4966 | 5105 |
Local<Value> not_a_number = v8_num(i::OS::nan_value()); |
4967 | 5106 |
CHECK(!not_a_number->StrictEquals(not_a_number)); |
4968 |
CHECK(v8::False()->StrictEquals(v8::False()));
|
|
4969 |
CHECK(!v8::False()->StrictEquals(v8::Undefined()));
|
|
5107 |
CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate)));
|
|
5108 |
CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate)));
|
|
4970 | 5109 |
|
4971 | 5110 |
v8::Handle<v8::Object> obj = v8::Object::New(); |
4972 | 5111 |
v8::Persistent<v8::Object> alias(isolate, obj); |
4973 | 5112 |
CHECK(v8::Local<v8::Object>::New(isolate, alias)->StrictEquals(obj)); |
4974 | 5113 |
alias.Dispose(); |
5114 |
|
|
5115 |
CHECK(v8_str("a")->SameValue(v8_str("a"))); |
|
5116 |
CHECK(!v8_str("a")->SameValue(v8_str("b"))); |
|
5117 |
CHECK(!v8_str("5")->SameValue(v8_num(5))); |
|
5118 |
CHECK(v8_num(1)->SameValue(v8_num(1))); |
|
5119 |
CHECK(!v8_num(1)->SameValue(v8_num(2))); |
|
5120 |
CHECK(!v8_num(0.0)->SameValue(v8_num(-0.0))); |
|
5121 |
CHECK(not_a_number->SameValue(not_a_number)); |
|
5122 |
CHECK(v8::False(isolate)->SameValue(v8::False(isolate))); |
|
5123 |
CHECK(!v8::False(isolate)->SameValue(v8::Undefined(isolate))); |
|
4975 | 5124 |
} |
4976 | 5125 |
|
4977 | 5126 |
|
... | ... | |
5056 | 5205 |
|
5057 | 5206 |
|
5058 | 5207 |
THREADED_TEST(DefinePropertyOnDefineGetterSetter) { |
5059 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5208 |
v8::HandleScope scope(CcTest::isolate());
|
|
5060 | 5209 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5061 | 5210 |
templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
5062 | 5211 |
LocalContext context; |
... | ... | |
5108 | 5257 |
|
5109 | 5258 |
|
5110 | 5259 |
THREADED_TEST(DefineAPIAccessorOnObject) { |
5111 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5260 |
v8::HandleScope scope(CcTest::isolate());
|
|
5112 | 5261 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5113 | 5262 |
LocalContext context; |
5114 | 5263 |
|
... | ... | |
5182 | 5331 |
|
5183 | 5332 |
|
5184 | 5333 |
THREADED_TEST(DontDeleteAPIAccessorsCannotBeOverriden) { |
5185 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5334 |
v8::HandleScope scope(CcTest::isolate());
|
|
5186 | 5335 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5187 | 5336 |
LocalContext context; |
5188 | 5337 |
|
... | ... | |
5238 | 5387 |
|
5239 | 5388 |
|
5240 | 5389 |
THREADED_TEST(ElementAPIAccessor) { |
5241 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5390 |
v8::HandleScope scope(CcTest::isolate());
|
|
5242 | 5391 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5243 | 5392 |
LocalContext context; |
5244 | 5393 |
|
... | ... | |
5276 | 5425 |
|
5277 | 5426 |
|
5278 | 5427 |
THREADED_TEST(SimplePropertyWrite) { |
5279 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5428 |
v8::HandleScope scope(CcTest::isolate());
|
|
5280 | 5429 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5281 | 5430 |
templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); |
5282 | 5431 |
LocalContext context; |
... | ... | |
5285 | 5434 |
for (int i = 0; i < 10; i++) { |
5286 | 5435 |
CHECK(xValue.IsEmpty()); |
5287 | 5436 |
script->Run(); |
5288 |
CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
|
|
5437 |
CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue));
|
|
5289 | 5438 |
xValue.Dispose(); |
5290 | 5439 |
xValue.Clear(); |
5291 | 5440 |
} |
... | ... | |
5293 | 5442 |
|
5294 | 5443 |
|
5295 | 5444 |
THREADED_TEST(SetterOnly) { |
5296 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5445 |
v8::HandleScope scope(CcTest::isolate());
|
|
5297 | 5446 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5298 | 5447 |
templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |
5299 | 5448 |
LocalContext context; |
... | ... | |
5302 | 5451 |
for (int i = 0; i < 10; i++) { |
5303 | 5452 |
CHECK(xValue.IsEmpty()); |
5304 | 5453 |
script->Run(); |
5305 |
CHECK_EQ(v8_num(4), Local<Value>::New(v8::Isolate::GetCurrent(), xValue));
|
|
5454 |
CHECK_EQ(v8_num(4), Local<Value>::New(CcTest::isolate(), xValue));
|
|
5306 | 5455 |
xValue.Dispose(); |
5307 | 5456 |
xValue.Clear(); |
5308 | 5457 |
} |
... | ... | |
5310 | 5459 |
|
5311 | 5460 |
|
5312 | 5461 |
THREADED_TEST(NoAccessors) { |
5313 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5462 |
v8::HandleScope scope(CcTest::isolate());
|
|
5314 | 5463 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5315 | 5464 |
templ->SetAccessor(v8_str("x"), |
5316 | 5465 |
static_cast<v8::AccessorGetterCallback>(NULL), |
... | ... | |
5334 | 5483 |
|
5335 | 5484 |
|
5336 | 5485 |
THREADED_TEST(NamedInterceptorPropertyRead) { |
5337 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5486 |
v8::HandleScope scope(CcTest::isolate());
|
|
5338 | 5487 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5339 | 5488 |
templ->SetNamedPropertyHandler(XPropertyGetter); |
5340 | 5489 |
LocalContext context; |
... | ... | |
5348 | 5497 |
|
5349 | 5498 |
|
5350 | 5499 |
THREADED_TEST(NamedInterceptorDictionaryIC) { |
5351 |
v8::HandleScope scope(v8::Isolate::GetCurrent());
|
|
5500 |
v8::HandleScope scope(CcTest::isolate());
|
|
5352 | 5501 |
Local<ObjectTemplate> templ = ObjectTemplate::New(); |
5353 | 5502 |
templ->SetNamedPropertyHandler(XPropertyGetter); |
5354 | 5503 |
LocalContext context; |
... | ... | |
5378 | 5527 |
|
5379 | 5528 |
|
5380 | 5529 |
THREADED_TEST(NamedInterceptorDictionaryICMultipleContext) { |
5381 |
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
5530 |
v8::Isolate* isolate = CcTest::isolate();
|
|
5382 | 5531 |
v8::HandleScope scope(isolate); |
5383 | 5532 |
v8::Local<Context> context1 = Context::New(isolate); |
5384 | 5533 |
|
... | ... | |
5430 | 5579 |
// This is a regression test for http://crbug.com/20104. Map |
5431 | 5580 |
// transitions should not interfere with post interceptor lookup. |
5432 | 5581 |
THREADED_TEST(NamedInterceptorMapTransitionRead) { |
5433 |
v8::HandleScope scope(v8::Isolate::GetCurrent()); |
Also available in: Unified diff