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 2815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2826 | 2826 |
2827 CHECK_EQ(2, cells->CellCount()); | 2827 CHECK_EQ(2, cells->CellCount()); |
2828 CHECK(cells->GetCell(0)->value()->IsTheHole()); | 2828 CHECK(cells->GetCell(0)->value()->IsTheHole()); |
2829 CHECK(cells->GetCell(1)->value()->IsTheHole()); | 2829 CHECK(cells->GetCell(1)->value()->IsTheHole()); |
2830 } | 2830 } |
2831 | 2831 |
2832 | 2832 |
2833 static Code* FindFirstIC(Code* code, Code::Kind kind) { | 2833 static Code* FindFirstIC(Code* code, Code::Kind kind) { |
2834 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | | 2834 int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) | |
2835 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | | 2835 RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) | |
2836 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) | | 2836 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID); |
2837 RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT); | |
2838 for (RelocIterator it(code, mask); !it.done(); it.next()) { | 2837 for (RelocIterator it(code, mask); !it.done(); it.next()) { |
2839 RelocInfo* info = it.rinfo(); | 2838 RelocInfo* info = it.rinfo(); |
2840 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); | 2839 Code* target = Code::GetCodeFromTargetAddress(info->target_address()); |
2841 if (target->is_inline_cache_stub() && target->kind() == kind) { | 2840 if (target->is_inline_cache_stub() && target->kind() == kind) { |
2842 return target; | 2841 return target; |
2843 } | 2842 } |
2844 } | 2843 } |
2845 return NULL; | 2844 return NULL; |
2846 } | 2845 } |
2847 | 2846 |
2848 | 2847 |
2849 TEST(IncrementalMarkingPreservesMonomorhpicIC) { | 2848 TEST(IncrementalMarkingPreservesMonomorphicIC) { |
2850 if (i::FLAG_always_opt) return; | 2849 if (i::FLAG_always_opt) return; |
2851 CcTest::InitializeVM(); | 2850 CcTest::InitializeVM(); |
2852 v8::HandleScope scope(CcTest::isolate()); | 2851 v8::HandleScope scope(CcTest::isolate()); |
2853 | 2852 |
2854 // Prepare function f that contains a monomorphic IC for object | 2853 // Prepare function f that contains a monomorphic IC for object |
2855 // originating from the same native context. | 2854 // originating from the same native context. |
2856 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" | 2855 CompileRun("function fun() { this.x = 1; }; var obj = new fun();" |
2857 "function f(o) { return o.x; } f(obj); f(obj);"); | 2856 "function f(o) { return o.x; } f(obj); f(obj);"); |
2858 Handle<JSFunction> f = | 2857 Handle<JSFunction> f = |
2859 v8::Utils::OpenHandle( | 2858 v8::Utils::OpenHandle( |
2860 *v8::Handle<v8::Function>::Cast( | 2859 *v8::Handle<v8::Function>::Cast( |
2861 CcTest::global()->Get(v8_str("f")))); | 2860 CcTest::global()->Get(v8_str("f")))); |
2862 | 2861 |
2863 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 2862 Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
2864 CHECK(ic_before->ic_state() == MONOMORPHIC); | 2863 CHECK(ic_before->ic_state() == MONOMORPHIC); |
2865 | 2864 |
2866 SimulateIncrementalMarking(); | 2865 SimulateIncrementalMarking(); |
2867 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2866 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
2868 | 2867 |
2869 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 2868 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
2870 CHECK(ic_after->ic_state() == MONOMORPHIC); | 2869 CHECK(ic_after->ic_state() == MONOMORPHIC); |
2871 } | 2870 } |
2872 | 2871 |
2873 | 2872 |
2874 TEST(IncrementalMarkingClearsMonomorhpicIC) { | 2873 TEST(IncrementalMarkingClearsMonomorphicIC) { |
2875 if (i::FLAG_always_opt) return; | 2874 if (i::FLAG_always_opt) return; |
2876 CcTest::InitializeVM(); | 2875 CcTest::InitializeVM(); |
2877 v8::HandleScope scope(CcTest::isolate()); | 2876 v8::HandleScope scope(CcTest::isolate()); |
2878 v8::Local<v8::Value> obj1; | 2877 v8::Local<v8::Value> obj1; |
2879 | 2878 |
2880 { | 2879 { |
2881 LocalContext env; | 2880 LocalContext env; |
2882 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); | 2881 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); |
2883 obj1 = env->Global()->Get(v8_str("obj")); | 2882 obj1 = env->Global()->Get(v8_str("obj")); |
2884 } | 2883 } |
(...skipping 13 matching lines...) Expand all Loading... |
2898 // Fire context dispose notification. | 2897 // Fire context dispose notification. |
2899 v8::V8::ContextDisposedNotification(); | 2898 v8::V8::ContextDisposedNotification(); |
2900 SimulateIncrementalMarking(); | 2899 SimulateIncrementalMarking(); |
2901 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); | 2900 CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); |
2902 | 2901 |
2903 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); | 2902 Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
2904 CHECK(IC::IsCleared(ic_after)); | 2903 CHECK(IC::IsCleared(ic_after)); |
2905 } | 2904 } |
2906 | 2905 |
2907 | 2906 |
2908 TEST(IncrementalMarkingClearsPolymorhpicIC) { | 2907 TEST(IncrementalMarkingClearsPolymorphicIC) { |
2909 if (i::FLAG_always_opt) return; | 2908 if (i::FLAG_always_opt) return; |
2910 CcTest::InitializeVM(); | 2909 CcTest::InitializeVM(); |
2911 v8::HandleScope scope(CcTest::isolate()); | 2910 v8::HandleScope scope(CcTest::isolate()); |
2912 v8::Local<v8::Value> obj1, obj2; | 2911 v8::Local<v8::Value> obj1, obj2; |
2913 | 2912 |
2914 { | 2913 { |
2915 LocalContext env; | 2914 LocalContext env; |
2916 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); | 2915 CompileRun("function fun() { this.x = 1; }; var obj = new fun();"); |
2917 obj1 = env->Global()->Get(v8_str("obj")); | 2916 obj1 = env->Global()->Get(v8_str("obj")); |
2918 } | 2917 } |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3047 Isolate* isolate = CcTest::i_isolate(); | 3046 Isolate* isolate = CcTest::i_isolate(); |
3048 Heap* heap = isolate->heap(); | 3047 Heap* heap = isolate->heap(); |
3049 HandleScope scope(isolate); | 3048 HandleScope scope(isolate); |
3050 | 3049 |
3051 // First make sure that the uninitialized CallIC stub is on a single page | 3050 // First make sure that the uninitialized CallIC stub is on a single page |
3052 // that will later be selected as an evacuation candidate. | 3051 // that will later be selected as an evacuation candidate. |
3053 { | 3052 { |
3054 HandleScope inner_scope(isolate); | 3053 HandleScope inner_scope(isolate); |
3055 AlwaysAllocateScope always_allocate; | 3054 AlwaysAllocateScope always_allocate; |
3056 SimulateFullSpace(heap->code_space()); | 3055 SimulateFullSpace(heap->code_space()); |
3057 isolate->stub_cache()->ComputeCallInitialize(9, RelocInfo::CODE_TARGET); | 3056 isolate->stub_cache()->ComputeCallInitialize(9, NOT_CONTEXTUAL); |
3058 } | 3057 } |
3059 | 3058 |
3060 // Second compile a CallIC and execute it once so that it gets patched to | 3059 // Second compile a CallIC and execute it once so that it gets patched to |
3061 // the pre-monomorphic stub. These code objects are on yet another page. | 3060 // the pre-monomorphic stub. These code objects are on yet another page. |
3062 { | 3061 { |
3063 HandleScope inner_scope(isolate); | 3062 HandleScope inner_scope(isolate); |
3064 AlwaysAllocateScope always_allocate; | 3063 AlwaysAllocateScope always_allocate; |
3065 SimulateFullSpace(heap->code_space()); | 3064 SimulateFullSpace(heap->code_space()); |
3066 CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};" | 3065 CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};" |
3067 "function call() { o.f(1,2,3,4,5,6,7,8,9); };" | 3066 "function call() { o.f(1,2,3,4,5,6,7,8,9); };" |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3621 for (int i = 0; i < 4; i++) { | 3620 for (int i = 0; i < 4; i++) { |
3622 heap->CollectAllGarbage(false); | 3621 heap->CollectAllGarbage(false); |
3623 } | 3622 } |
3624 | 3623 |
3625 // The site still exists because of our global handle, but the code is no | 3624 // The site still exists because of our global handle, but the code is no |
3626 // longer referred to by dependent_code(). | 3625 // longer referred to by dependent_code(). |
3627 DependentCode::GroupStartIndexes starts(site->dependent_code()); | 3626 DependentCode::GroupStartIndexes starts(site->dependent_code()); |
3628 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); | 3627 int index = starts.at(DependentCode::kAllocationSiteTransitionChangedGroup); |
3629 CHECK(!(site->dependent_code()->is_code_at(index))); | 3628 CHECK(!(site->dependent_code()->is_code_at(index))); |
3630 } | 3629 } |
OLD | NEW |