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 | |
44 // Go through all incremental marking steps in one swoop. | 43 // Go through all incremental marking steps in one swoop. |
45 static void SimulateIncrementalMarking() { | 44 static void SimulateIncrementalMarking() { |
46 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); | 45 MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); |
47 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); | 46 IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
48 if (collector->IsConcurrentSweepingInProgress()) { | 47 if (collector->IsConcurrentSweepingInProgress()) { |
49 collector->WaitUntilSweepingCompleted(); | 48 collector->WaitUntilSweepingCompleted(); |
50 } | 49 } |
51 CHECK(marking->IsMarking() || marking->IsStopped()); | 50 CHECK(marking->IsMarking() || marking->IsStopped()); |
52 if (marking->IsStopped()) { | 51 if (marking->IsStopped()) { |
53 marking->Start(); | 52 marking->Start(); |
(...skipping 3838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3892 | 3891 |
3893 // Now make sure that a gc should get rid of the function | 3892 // Now make sure that a gc should get rid of the function |
3894 for (int i = 0; i < 4; i++) { | 3893 for (int i = 0; i < 4; i++) { |
3895 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); | 3894 heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); |
3896 } | 3895 } |
3897 | 3896 |
3898 ASSERT(code->marked_for_deoptimization()); | 3897 ASSERT(code->marked_for_deoptimization()); |
3899 } | 3898 } |
3900 | 3899 |
3901 | 3900 |
| 3901 TEST(NoWeakHashTableLeakWithIncrementalMarking) { |
| 3902 if (i::FLAG_always_opt || !i::FLAG_crankshaft) return; |
| 3903 if (!i::FLAG_incremental_marking) return; |
| 3904 i::FLAG_weak_embedded_objects_in_optimized_code = true; |
| 3905 i::FLAG_allow_natives_syntax = true; |
| 3906 i::FLAG_compilation_cache = false; |
| 3907 CcTest::InitializeVM(); |
| 3908 Isolate* isolate = CcTest::i_isolate(); |
| 3909 v8::internal::Heap* heap = CcTest::heap(); |
| 3910 |
| 3911 if (!isolate->use_crankshaft()) return; |
| 3912 HandleScope outer_scope(heap->isolate()); |
| 3913 for (int i = 0; i < 3; i++) { |
| 3914 SimulateIncrementalMarking(); |
| 3915 { |
| 3916 LocalContext context; |
| 3917 HandleScope scope(heap->isolate()); |
| 3918 EmbeddedVector<char, 256> source; |
| 3919 OS::SNPrintF(source, |
| 3920 "function bar%d() {" |
| 3921 " return foo%d(1);" |
| 3922 "};" |
| 3923 "function foo%d(x) { with (x) { return 1 + x; } };" |
| 3924 "bar%d();" |
| 3925 "bar%d();" |
| 3926 "bar%d();" |
| 3927 "%OptimizeFunctionOnNextCall(bar%d);" |
| 3928 "bar%d();", i, i, i, i, i, i, i, i); |
| 3929 CompileRun(source.start()); |
| 3930 } |
| 3931 heap->CollectAllGarbage(i::Heap::kNoGCFlags); |
| 3932 } |
| 3933 WeakHashTable* table = WeakHashTable::cast(heap->weak_object_to_code_table()); |
| 3934 CHECK_EQ(0, table->NumberOfElements()); |
| 3935 } |
| 3936 |
3902 | 3937 |
3903 static Handle<JSFunction> OptimizeDummyFunction(const char* name) { | 3938 static Handle<JSFunction> OptimizeDummyFunction(const char* name) { |
3904 EmbeddedVector<char, 256> source; | 3939 EmbeddedVector<char, 256> source; |
3905 OS::SNPrintF(source, | 3940 OS::SNPrintF(source, |
3906 "function %s() { return 0; }" | 3941 "function %s() { return 0; }" |
3907 "%s(); %s();" | 3942 "%s(); %s();" |
3908 "%%OptimizeFunctionOnNextCall(%s);" | 3943 "%%OptimizeFunctionOnNextCall(%s);" |
3909 "%s();", name, name, name, name, name); | 3944 "%s();", name, name, name, name, name); |
3910 CompileRun(source.start()); | 3945 CompileRun(source.start()); |
3911 Handle<JSFunction> fun = | 3946 Handle<JSFunction> fun = |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4215 "array;"); | 4250 "array;"); |
4216 | 4251 |
4217 Handle<JSObject> o = | 4252 Handle<JSObject> o = |
4218 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); | 4253 v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(result)); |
4219 CHECK(heap->InOldPointerSpace(o->elements())); | 4254 CHECK(heap->InOldPointerSpace(o->elements())); |
4220 CHECK(heap->InOldPointerSpace(*o)); | 4255 CHECK(heap->InOldPointerSpace(*o)); |
4221 Page* page = Page::FromAddress(o->elements()->address()); | 4256 Page* page = Page::FromAddress(o->elements()->address()); |
4222 CHECK(page->WasSwept() || | 4257 CHECK(page->WasSwept() || |
4223 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); | 4258 Marking::IsBlack(Marking::MarkBitFrom(o->elements()))); |
4224 } | 4259 } |
OLD | NEW |