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

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

Issue 1154103005: Refactor lexical home object binding (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: git rebase Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 3624 matching lines...) Expand 10 before | Expand all | Expand 10 after
3635 CcTest::global()->Set(v8_str("fun2"), fun2); 3635 CcTest::global()->Set(v8_str("fun2"), fun2);
3636 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); 3636 CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);");
3637 3637
3638 Handle<JSFunction> f = 3638 Handle<JSFunction> f =
3639 v8::Utils::OpenHandle( 3639 v8::Utils::OpenHandle(
3640 *v8::Handle<v8::Function>::Cast( 3640 *v8::Handle<v8::Function>::Cast(
3641 CcTest::global()->Get(v8_str("f")))); 3641 CcTest::global()->Get(v8_str("f"))));
3642 3642
3643 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector()); 3643 Handle<TypeFeedbackVector> feedback_vector(f->shared()->feedback_vector());
3644 3644
3645 int expected_slots = 3; 3645 int expected_slots = 2;
3646 CHECK_EQ(expected_slots, feedback_vector->ICSlots()); 3646 CHECK_EQ(expected_slots, feedback_vector->ICSlots());
3647 int slot1 = 1; 3647 int slot1 = 0;
3648 int slot2 = 2; 3648 int slot2 = 1;
3649 CHECK(feedback_vector->Get(FeedbackVectorICSlot(slot1))->IsWeakCell()); 3649 CHECK(feedback_vector->Get(FeedbackVectorICSlot(slot1))->IsWeakCell());
3650 CHECK(feedback_vector->Get(FeedbackVectorICSlot(slot2))->IsWeakCell()); 3650 CHECK(feedback_vector->Get(FeedbackVectorICSlot(slot2))->IsWeakCell());
3651 3651
3652 SimulateIncrementalMarking(CcTest::heap()); 3652 SimulateIncrementalMarking(CcTest::heap());
3653 CcTest::heap()->CollectAllGarbage(); 3653 CcTest::heap()->CollectAllGarbage();
3654 3654
3655 CHECK(!WeakCell::cast(feedback_vector->Get(FeedbackVectorICSlot(slot1))) 3655 CHECK(!WeakCell::cast(feedback_vector->Get(FeedbackVectorICSlot(slot1)))
3656 ->cleared()); 3656 ->cleared());
3657 CHECK(!WeakCell::cast(feedback_vector->Get(FeedbackVectorICSlot(slot2))) 3657 CHECK(!WeakCell::cast(feedback_vector->Get(FeedbackVectorICSlot(slot2)))
3658 ->cleared()); 3658 ->cleared());
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
3761 // Prepare function f that contains a monomorphic IC for object 3761 // Prepare function f that contains a monomorphic IC for object
3762 // originating from the same native context. 3762 // originating from the same native context.
3763 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" 3763 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
3764 "function f(o) { return o.x; } f(obj); f(obj);"); 3764 "function f(o) { return o.x; } f(obj); f(obj);");
3765 Handle<JSFunction> f = 3765 Handle<JSFunction> f =
3766 v8::Utils::OpenHandle( 3766 v8::Utils::OpenHandle(
3767 *v8::Handle<v8::Function>::Cast( 3767 *v8::Handle<v8::Function>::Cast(
3768 CcTest::global()->Get(v8_str("f")))); 3768 CcTest::global()->Get(v8_str("f"))));
3769 3769
3770 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3770 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3771 CheckVectorIC(f, 1, MONOMORPHIC); 3771 CheckVectorIC(f, 0, MONOMORPHIC);
3772 CHECK(ic_before->ic_state() == DEFAULT); 3772 CHECK(ic_before->ic_state() == DEFAULT);
3773 3773
3774 SimulateIncrementalMarking(CcTest::heap()); 3774 SimulateIncrementalMarking(CcTest::heap());
3775 CcTest::heap()->CollectAllGarbage(); 3775 CcTest::heap()->CollectAllGarbage();
3776 3776
3777 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3777 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3778 CheckVectorIC(f, 1, MONOMORPHIC); 3778 CheckVectorIC(f, 0, MONOMORPHIC);
3779 CHECK(ic_after->ic_state() == DEFAULT); 3779 CHECK(ic_after->ic_state() == DEFAULT);
3780 } 3780 }
3781 3781
3782 3782
3783 TEST(IncrementalMarkingClearsMonomorphicIC) { 3783 TEST(IncrementalMarkingClearsMonomorphicIC) {
3784 if (i::FLAG_always_opt) return; 3784 if (i::FLAG_always_opt) return;
3785 CcTest::InitializeVM(); 3785 CcTest::InitializeVM();
3786 v8::HandleScope scope(CcTest::isolate()); 3786 v8::HandleScope scope(CcTest::isolate());
3787 v8::Local<v8::Value> obj1; 3787 v8::Local<v8::Value> obj1;
3788 3788
3789 { 3789 {
3790 LocalContext env; 3790 LocalContext env;
3791 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); 3791 CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
3792 obj1 = env->Global()->Get(v8_str("obj")); 3792 obj1 = env->Global()->Get(v8_str("obj"));
3793 } 3793 }
3794 3794
3795 // Prepare function f that contains a monomorphic IC for object 3795 // Prepare function f that contains a monomorphic IC for object
3796 // originating from a different native context. 3796 // originating from a different native context.
3797 CcTest::global()->Set(v8_str("obj1"), obj1); 3797 CcTest::global()->Set(v8_str("obj1"), obj1);
3798 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); 3798 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
3799 Handle<JSFunction> f = v8::Utils::OpenHandle( 3799 Handle<JSFunction> f = v8::Utils::OpenHandle(
3800 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 3800 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3801 3801
3802 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3802 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3803 CheckVectorIC(f, 1, MONOMORPHIC); 3803 CheckVectorIC(f, 0, MONOMORPHIC);
3804 CHECK(ic_before->ic_state() == DEFAULT); 3804 CHECK(ic_before->ic_state() == DEFAULT);
3805 3805
3806 // Fire context dispose notification. 3806 // Fire context dispose notification.
3807 CcTest::isolate()->ContextDisposedNotification(); 3807 CcTest::isolate()->ContextDisposedNotification();
3808 SimulateIncrementalMarking(CcTest::heap()); 3808 SimulateIncrementalMarking(CcTest::heap());
3809 CcTest::heap()->CollectAllGarbage(); 3809 CcTest::heap()->CollectAllGarbage();
3810 3810
3811 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3811 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3812 CheckVectorICCleared(f, 1); 3812 CheckVectorICCleared(f, 0);
3813 CHECK(ic_after->ic_state() == DEFAULT); 3813 CHECK(ic_after->ic_state() == DEFAULT);
3814 } 3814 }
3815 3815
3816 3816
3817 TEST(IncrementalMarkingPreservesPolymorphicIC) { 3817 TEST(IncrementalMarkingPreservesPolymorphicIC) {
3818 if (i::FLAG_always_opt) return; 3818 if (i::FLAG_always_opt) return;
3819 CcTest::InitializeVM(); 3819 CcTest::InitializeVM();
3820 v8::HandleScope scope(CcTest::isolate()); 3820 v8::HandleScope scope(CcTest::isolate());
3821 v8::Local<v8::Value> obj1, obj2; 3821 v8::Local<v8::Value> obj1, obj2;
3822 3822
(...skipping 11 matching lines...) Expand all
3834 3834
3835 // Prepare function f that contains a polymorphic IC for objects 3835 // Prepare function f that contains a polymorphic IC for objects
3836 // originating from two different native contexts. 3836 // originating from two different native contexts.
3837 CcTest::global()->Set(v8_str("obj1"), obj1); 3837 CcTest::global()->Set(v8_str("obj1"), obj1);
3838 CcTest::global()->Set(v8_str("obj2"), obj2); 3838 CcTest::global()->Set(v8_str("obj2"), obj2);
3839 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); 3839 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
3840 Handle<JSFunction> f = v8::Utils::OpenHandle( 3840 Handle<JSFunction> f = v8::Utils::OpenHandle(
3841 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 3841 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3842 3842
3843 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3843 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3844 CheckVectorIC(f, 1, POLYMORPHIC); 3844 CheckVectorIC(f, 0, POLYMORPHIC);
3845 CHECK(ic_before->ic_state() == DEFAULT); 3845 CHECK(ic_before->ic_state() == DEFAULT);
3846 3846
3847 // Fire context dispose notification. 3847 // Fire context dispose notification.
3848 SimulateIncrementalMarking(CcTest::heap()); 3848 SimulateIncrementalMarking(CcTest::heap());
3849 CcTest::heap()->CollectAllGarbage(); 3849 CcTest::heap()->CollectAllGarbage();
3850 3850
3851 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3851 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3852 CheckVectorIC(f, 1, POLYMORPHIC); 3852 CheckVectorIC(f, 0, POLYMORPHIC);
3853 CHECK(ic_after->ic_state() == DEFAULT); 3853 CHECK(ic_after->ic_state() == DEFAULT);
3854 } 3854 }
3855 3855
3856 3856
3857 TEST(IncrementalMarkingClearsPolymorphicIC) { 3857 TEST(IncrementalMarkingClearsPolymorphicIC) {
3858 if (i::FLAG_always_opt) return; 3858 if (i::FLAG_always_opt) return;
3859 CcTest::InitializeVM(); 3859 CcTest::InitializeVM();
3860 v8::HandleScope scope(CcTest::isolate()); 3860 v8::HandleScope scope(CcTest::isolate());
3861 v8::Local<v8::Value> obj1, obj2; 3861 v8::Local<v8::Value> obj1, obj2;
3862 3862
(...skipping 11 matching lines...) Expand all
3874 3874
3875 // Prepare function f that contains a polymorphic IC for objects 3875 // Prepare function f that contains a polymorphic IC for objects
3876 // originating from two different native contexts. 3876 // originating from two different native contexts.
3877 CcTest::global()->Set(v8_str("obj1"), obj1); 3877 CcTest::global()->Set(v8_str("obj1"), obj1);
3878 CcTest::global()->Set(v8_str("obj2"), obj2); 3878 CcTest::global()->Set(v8_str("obj2"), obj2);
3879 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); 3879 CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
3880 Handle<JSFunction> f = v8::Utils::OpenHandle( 3880 Handle<JSFunction> f = v8::Utils::OpenHandle(
3881 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f")))); 3881 *v8::Handle<v8::Function>::Cast(CcTest::global()->Get(v8_str("f"))));
3882 3882
3883 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); 3883 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
3884 CheckVectorIC(f, 1, POLYMORPHIC); 3884 CheckVectorIC(f, 0, POLYMORPHIC);
3885 CHECK(ic_before->ic_state() == DEFAULT); 3885 CHECK(ic_before->ic_state() == DEFAULT);
3886 3886
3887 // Fire context dispose notification. 3887 // Fire context dispose notification.
3888 CcTest::isolate()->ContextDisposedNotification(); 3888 CcTest::isolate()->ContextDisposedNotification();
3889 SimulateIncrementalMarking(CcTest::heap()); 3889 SimulateIncrementalMarking(CcTest::heap());
3890 CcTest::heap()->CollectAllGarbage(); 3890 CcTest::heap()->CollectAllGarbage();
3891 3891
3892 CheckVectorICCleared(f, 1); 3892 CheckVectorICCleared(f, 0);
3893 CHECK(ic_before->ic_state() == DEFAULT); 3893 CHECK(ic_before->ic_state() == DEFAULT);
3894 } 3894 }
3895 3895
3896 3896
3897 class SourceResource : public v8::String::ExternalOneByteStringResource { 3897 class SourceResource : public v8::String::ExternalOneByteStringResource {
3898 public: 3898 public:
3899 explicit SourceResource(const char* data) 3899 explicit SourceResource(const char* data)
3900 : data_(data), length_(strlen(data)) { } 3900 : data_(data), length_(strlen(data)) { }
3901 3901
3902 virtual void Dispose() { 3902 virtual void Dispose() {
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
5031 " loadIC(obj);" 5031 " loadIC(obj);"
5032 " loadIC(obj);" 5032 " loadIC(obj);"
5033 " return proto;" 5033 " return proto;"
5034 "};"); 5034 "};");
5035 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC"); 5035 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
5036 { 5036 {
5037 v8::HandleScope scope(CcTest::isolate()); 5037 v8::HandleScope scope(CcTest::isolate());
5038 CompileRun("(testIC())"); 5038 CompileRun("(testIC())");
5039 } 5039 }
5040 heap->CollectAllGarbage(); 5040 heap->CollectAllGarbage();
5041 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 1, MONOMORPHIC); 5041 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, MONOMORPHIC);
5042 { 5042 {
5043 v8::HandleScope scope(CcTest::isolate()); 5043 v8::HandleScope scope(CcTest::isolate());
5044 CompileRun("(testIC())"); 5044 CompileRun("(testIC())");
5045 } 5045 }
5046 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 1, MONOMORPHIC); 5046 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, MONOMORPHIC);
5047 } 5047 }
5048 5048
5049 5049
5050 TEST(PolymorphicStaysPolymorphicAfterGC) { 5050 TEST(PolymorphicStaysPolymorphicAfterGC) {
5051 if (FLAG_always_opt) return; 5051 if (FLAG_always_opt) return;
5052 CcTest::InitializeVM(); 5052 CcTest::InitializeVM();
5053 Isolate* isolate = CcTest::i_isolate(); 5053 Isolate* isolate = CcTest::i_isolate();
5054 Heap* heap = isolate->heap(); 5054 Heap* heap = isolate->heap();
5055 v8::HandleScope scope(CcTest::isolate()); 5055 v8::HandleScope scope(CcTest::isolate());
5056 CompileRun( 5056 CompileRun(
(...skipping 10 matching lines...) Expand all
5067 " poly.x = true;" 5067 " poly.x = true;"
5068 " loadIC(poly);" 5068 " loadIC(poly);"
5069 " return proto;" 5069 " return proto;"
5070 "};"); 5070 "};");
5071 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC"); 5071 Handle<JSFunction> loadIC = GetFunctionByName(isolate, "loadIC");
5072 { 5072 {
5073 v8::HandleScope scope(CcTest::isolate()); 5073 v8::HandleScope scope(CcTest::isolate());
5074 CompileRun("(testIC())"); 5074 CompileRun("(testIC())");
5075 } 5075 }
5076 heap->CollectAllGarbage(); 5076 heap->CollectAllGarbage();
5077 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 1, POLYMORPHIC); 5077 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, POLYMORPHIC);
5078 { 5078 {
5079 v8::HandleScope scope(CcTest::isolate()); 5079 v8::HandleScope scope(CcTest::isolate());
5080 CompileRun("(testIC())"); 5080 CompileRun("(testIC())");
5081 } 5081 }
5082 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 1, POLYMORPHIC); 5082 CheckIC(loadIC->code(), Code::LOAD_IC, loadIC->shared(), 0, POLYMORPHIC);
5083 } 5083 }
5084 5084
5085 5085
5086 TEST(WeakCell) { 5086 TEST(WeakCell) {
5087 CcTest::InitializeVM(); 5087 CcTest::InitializeVM();
5088 Isolate* isolate = CcTest::i_isolate(); 5088 Isolate* isolate = CcTest::i_isolate();
5089 v8::internal::Heap* heap = CcTest::heap(); 5089 v8::internal::Heap* heap = CcTest::heap();
5090 v8::internal::Factory* factory = isolate->factory(); 5090 v8::internal::Factory* factory = isolate->factory();
5091 5091
5092 HandleScope outer_scope(isolate); 5092 HandleScope outer_scope(isolate);
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
5953 size_t counter2 = 2000; 5953 size_t counter2 = 2000;
5954 tracer->SampleAllocation(time2, counter2, counter2); 5954 tracer->SampleAllocation(time2, counter2, counter2);
5955 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 5955 size_t throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5956 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput); 5956 CHECK_EQ(2 * (counter2 - counter1) / (time2 - time1), throughput);
5957 int time3 = 1000; 5957 int time3 = 1000;
5958 size_t counter3 = 30000; 5958 size_t counter3 = 30000;
5959 tracer->SampleAllocation(time3, counter3, counter3); 5959 tracer->SampleAllocation(time3, counter3, counter3);
5960 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100); 5960 throughput = tracer->AllocationThroughputInBytesPerMillisecond(100);
5961 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput); 5961 CHECK_EQ(2 * (counter3 - counter1) / (time3 - time1), throughput);
5962 } 5962 }
OLDNEW
« no previous file with comments | « test/cctest/test-feedback-vector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698