Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 #include "compilation-cache.h" | 33 #include "compilation-cache.h" |
| 34 #include "execution.h" | 34 #include "execution.h" |
| 35 #include "factory.h" | 35 #include "factory.h" |
| 36 #include "macro-assembler.h" | 36 #include "macro-assembler.h" |
| 37 #include "global-handles.h" | 37 #include "global-handles.h" |
| 38 #include "stub-cache.h" | 38 #include "stub-cache.h" |
| 39 #include "cctest.h" | 39 #include "cctest.h" |
| 40 | 40 |
| 41 using namespace v8::internal; | 41 using namespace v8::internal; |
| 42 | 42 |
| 43 | 43 static void StartIncrementalMarking() { |
| 44 // Go through all incremental marking steps in one swoop. | |
| 45 static void SimulateIncrementalMarking() { | |
| 46 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); | 44 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); |
| 47 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 45 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
| 48 if (collector->IsConcurrentSweepingInProgress()) { | 46 if (collector->IsConcurrentSweepingInProgress()) { |
| 49 collector->WaitUntilSweepingCompleted(); | 47 collector->WaitUntilSweepingCompleted(); |
| 50 } | 48 } |
| 51 CHECK(marking->IsMarking() || marking->IsStopped()); | 49 CHECK(marking->IsMarking() || marking->IsStopped()); |
| 52 if (marking->IsStopped()) { | 50 if (marking->IsStopped()) { |
| 53 marking->Start(); | 51 marking->Start(); |
| 54 } | 52 } |
| 55 CHECK(marking->IsMarking()); | 53 CHECK(marking->IsMarking()); |
| 54 } | |
| 55 | |
| 56 | |
| 57 static void CompleteIncrementalMarking() { | |
| 58 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | |
| 59 CHECK(marking->IsMarking()); | |
| 56 while (!marking->IsComplete()) { | 60 while (!marking->IsComplete()) { |
| 57 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); | 61 marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |
| 58 } | 62 } |
| 59 CHECK(marking->IsComplete()); | 63 CHECK(marking->IsComplete()); |
| 60 } | 64 } |
| 61 | 65 |
| 62 | 66 |
| 67 // Go through all incremental marking steps in one swoop. | |
| 68 static void SimulateIncrementalMarking() { | |
| 69 StartIncrementalMarking(); | |
| 70 CompleteIncrementalMarking(); | |
| 71 } | |
| 72 | |
| 73 | |
| 63 static void CheckMap(Map* map, int type, int instance_size) { | 74 static void CheckMap(Map* map, int type, int instance_size) { |
| 64 CHECK(map->IsHeapObject()); | 75 CHECK(map->IsHeapObject()); |
| 65 #ifdef DEBUG | 76 #ifdef DEBUG |
| 66 CHECK(CcTest::heap()->Contains(map)); | 77 CHECK(CcTest::heap()->Contains(map)); |
| 67 #endif | 78 #endif |
| 68 CHECK_EQ(CcTest::heap()->meta_map(), map->map()); | 79 CHECK_EQ(CcTest::heap()->meta_map(), map->map()); |
| 69 CHECK_EQ(type, map->instance_type()); | 80 CHECK_EQ(type, map->instance_type()); |
| 70 CHECK_EQ(instance_size, map->instance_size()); | 81 CHECK_EQ(instance_size, map->instance_size()); |
| 71 } | 82 } |
| 72 | 83 |
| (...skipping 3808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3881 | 3892 |
| 3882 // Now make sure that a gc should get rid of the function | 3893 // Now make sure that a gc should get rid of the function |
| 3883 for (int i = 0; i < 4; i++) { | 3894 for (int i = 0; i < 4; i++) { |
| 3884 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3895 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
| 3885 } | 3896 } |
| 3886 | 3897 |
| 3887 ASSERT(code->marked_for_deoptimization()); | 3898 ASSERT(code->marked_for_deoptimization()); |
| 3888 } | 3899 } |
| 3889 | 3900 |
| 3890 | 3901 |
| 3902 TEST(NoWeakHashTableLeakWithIncrementalMarking) { | |
| 3903 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; | |
| 3904 if (!i::FLAG_incremental_marking) return; | |
| 3905 i::FLAG_weak_embedded_objects_in_optimized_code = true; | |
| 3906 i::FLAG_allow_natives_syntax = true; | |
| 3907 i::FLAG_compilation_cache = false; | |
|
Hannes Payer (out of office)
2014/05/14 06:47:45
why i::FLAG_compilation_cache = false; ?
ulan
2014/05/14 07:27:10
To avoid caching the generated code below. So that
| |
| 3908 CcTest::InitializeVM(); | |
| 3909 Isolate* isolate = CcTest::i_isolate(); | |
| 3910 v8::internal::Heap* heap = CcTest::heap(); | |
| 3911 | |
| 3912 if (!isolate->use_crankshaft()) return; | |
| 3913 HandleScope outer_scope(heap->isolate()); | |
| 3914 for (int i = 0; i < 3; i++) { | |
| 3915 StartIncrementalMarking(); | |
|
Michael Starzinger
2014/05/14 08:38:30
I don't fully understand the reason for splitting
ulan
2014/05/14 08:54:04
You're right! Calling SimulateIncrementalMarking a
| |
| 3916 { | |
| 3917 LocalContext context; | |
| 3918 HandleScope scope(heap->isolate()); | |
| 3919 EmbeddedVector<char, 256> source; | |
| 3920 OS::SNPrintF(source, | |
| 3921 "function bar%d() {" | |
| 3922 " return foo%d(1);" | |
| 3923 "};" | |
| 3924 "function foo%d(x) { with (x) { return 1 + x; } };" | |
| 3925 "bar%d();" | |
| 3926 "bar%d();" | |
| 3927 "bar%d();" | |
| 3928 "%OptimizeFunctionOnNextCall(bar%d);" | |
| 3929 "bar%d();", i, i, i, i, i, i, i, i); | |
| 3930 CompileRun(source.start()); | |
| 3931 } | |
| 3932 StartIncrementalMarking(); | |
|
Hannes Payer (out of office)
2014/05/14 06:47:45
Why do we start incremental marking again here? We
ulan
2014/05/14 07:27:10
This functions starts incremental marking if it is
| |
| 3933 CompleteIncrementalMarking(); | |
| 3934 heap->CollectAllGarbage(i::Heap::kNoGCFlags); | |
| 3935 } | |
| 3936 WeakHashTable* table = WeakHashTable::cast(heap->weak_object_to_code_table()); | |
| 3937 CHECK_EQ(0, table->NumberOfElements()); | |
| 3938 } | |
| 3939 | |
| 3891 | 3940 |
| 3892 static Handle<JSFunction> OptimizeDummyFunction(const char* name) { | 3941 static Handle<JSFunction> OptimizeDummyFunction(const char* name) { |
| 3893 EmbeddedVector<char, 256> source; | 3942 EmbeddedVector<char, 256> source; |
| 3894 OS::SNPrintF(source, | 3943 OS::SNPrintF(source, |
| 3895 "function %s() { return 0; }" | 3944 "function %s() { return 0; }" |
| 3896 "%s(); %s();" | 3945 "%s(); %s();" |
| 3897 "%%OptimizeFunctionOnNextCall(%s);" | 3946 "%%OptimizeFunctionOnNextCall(%s);" |
| 3898 "%s();", name, name, name, name, name); | 3947 "%s();", name, name, name, name, name); |
| 3899 CompileRun(source.start()); | 3948 CompileRun(source.start()); |
| 3900 Handle<JSFunction> fun = | 3949 Handle<JSFunction> fun = |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4205 "array;"); | 4254 "array;"); |
| 4206 | 4255 |
| 4207 Handle<JSObject> o = | 4256 Handle<JSObject> o = |
| 4208 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 4257 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
| 4209 CHECK(heap->InOldPointerSpace(o->elements())); | 4258 CHECK(heap->InOldPointerSpace(o->elements())); |
| 4210 CHECK(heap->InOldPointerSpace(*o)); | 4259 CHECK(heap->InOldPointerSpace(*o)); |
| 4211 Page* page = Page::FromAddress(o->elements()->address()); | 4260 Page* page = Page::FromAddress(o->elements()->address()); |
| 4212 CHECK(page->WasSwept() || | 4261 CHECK(page->WasSwept() || |
| 4213 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 4262 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
| 4214 } | 4263 } |
| OLD | NEW |