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 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1909 Map* map = object->map(); | 1909 Map* map = object->map(); |
| 1910 if (map == filler_map) continue; | 1910 if (map == filler_map) continue; |
| 1911 | 1911 |
| 1912 DCHECK(object->IsHeapObject()); | 1912 DCHECK(object->IsHeapObject()); |
| 1913 DCHECK(heap()->Contains(object)); | 1913 DCHECK(heap()->Contains(object)); |
| 1914 DCHECK(!Marking::IsWhite(Marking::MarkBitFrom(object))); | 1914 DCHECK(!Marking::IsWhite(Marking::MarkBitFrom(object))); |
| 1915 | 1915 |
| 1916 MarkBit map_mark = Marking::MarkBitFrom(map); | 1916 MarkBit map_mark = Marking::MarkBitFrom(map); |
| 1917 MarkObject(map, map_mark); | 1917 MarkObject(map, map_mark); |
| 1918 | 1918 |
| 1919 if (UsingEmbedderHeapTracer() && object->IsJSObject()) { | |
| 1920 JSObject* js_object = JSObject::cast(object); | |
| 1921 | |
| 1922 if (js_object->GetInternalFieldCount() >= 2 && | |
| 1923 js_object->WasConstructedFromApiFunction()) { | |
|
jochen (gone - plz use gerrit)
2016/04/01 08:49:12
eventually, we should add a flag to the FunctionTe
Marcel Hlopko
2016/04/01 09:24:31
Noted.
| |
| 1924 wrappers_to_trace().push_back(std::pair<void*, void*>( | |
| 1925 reinterpret_cast<void*>(js_object->GetInternalField(0)), | |
|
jochen (gone - plz use gerrit)
2016/04/01 08:49:12
these can be potentially "undefined_value()", righ
Marcel Hlopko
2016/04/01 09:24:32
Yes, I guarded against that in blink side, here it
| |
| 1926 reinterpret_cast<void*>(js_object->GetInternalField(1)))); | |
| 1927 } | |
| 1928 } | |
| 1929 | |
| 1919 MarkCompactMarkingVisitor::IterateBody(map, object); | 1930 MarkCompactMarkingVisitor::IterateBody(map, object); |
| 1920 } | 1931 } |
| 1921 } | 1932 } |
| 1922 | 1933 |
| 1923 | 1934 |
| 1924 // Sweep the heap for overflowed objects, clear their overflow bits, and | 1935 // Sweep the heap for overflowed objects, clear their overflow bits, and |
| 1925 // push them on the marking stack. Stop early if the marking stack fills | 1936 // push them on the marking stack. Stop early if the marking stack fills |
| 1926 // before sweeping completes. If sweeping completes, there are no remaining | 1937 // before sweeping completes. If sweeping completes, there are no remaining |
| 1927 // overflowed objects in the heap so the overflow flag on the markings stack | 1938 // overflowed objects in the heap so the overflow flag on the markings stack |
| 1928 // is cleared. | 1939 // is cleared. |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 1955 // pointers. After: the marking stack is empty and there are no overflowed | 1966 // pointers. After: the marking stack is empty and there are no overflowed |
| 1956 // objects in the heap. | 1967 // objects in the heap. |
| 1957 void MarkCompactCollector::ProcessMarkingDeque() { | 1968 void MarkCompactCollector::ProcessMarkingDeque() { |
| 1958 EmptyMarkingDeque(); | 1969 EmptyMarkingDeque(); |
| 1959 while (marking_deque_.overflowed()) { | 1970 while (marking_deque_.overflowed()) { |
| 1960 RefillMarkingDeque(); | 1971 RefillMarkingDeque(); |
| 1961 EmptyMarkingDeque(); | 1972 EmptyMarkingDeque(); |
| 1962 } | 1973 } |
| 1963 } | 1974 } |
| 1964 | 1975 |
| 1976 bool MarkCompactCollector::UsingEmbedderHeapTracer() const { | |
| 1977 return FLAG_trace_embedder_heap && heap_->embedder_heap_tracer(); | |
| 1978 } | |
| 1965 | 1979 |
| 1966 // Mark all objects reachable (transitively) from objects on the marking | 1980 // Mark all objects reachable (transitively) from objects on the marking |
| 1967 // stack including references only considered in the atomic marking pause. | 1981 // stack including references only considered in the atomic marking pause. |
| 1968 void MarkCompactCollector::ProcessEphemeralMarking( | 1982 void MarkCompactCollector::ProcessEphemeralMarking( |
| 1969 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { | 1983 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { |
| 1970 bool work_to_do = true; | 1984 bool work_to_do = true; |
| 1971 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); | 1985 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); |
| 1986 v8::Isolate* api_isolate = reinterpret_cast<v8::Isolate*>(isolate()); | |
| 1987 if (!only_process_harmony_weak_collections && UsingEmbedderHeapTracer()) { | |
| 1988 heap()->embedder_heap_tracer()->TraceRoots(api_isolate); | |
| 1989 } | |
| 1972 while (work_to_do) { | 1990 while (work_to_do) { |
| 1973 if (!only_process_harmony_weak_collections) { | 1991 if (!only_process_harmony_weak_collections) { |
| 1974 isolate()->global_handles()->IterateObjectGroups( | 1992 if (UsingEmbedderHeapTracer()) { |
| 1975 visitor, &IsUnmarkedHeapObjectWithHeap); | 1993 heap_->embedder_heap_tracer()->TraceWrappableFrom(api_isolate, |
| 1976 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); | 1994 wrappers_to_trace_); |
| 1995 wrappers_to_trace_.clear(); | |
| 1996 } else { | |
| 1997 isolate()->global_handles()->IterateObjectGroups( | |
| 1998 visitor, &IsUnmarkedHeapObjectWithHeap); | |
| 1999 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); | |
| 2000 } | |
| 1977 } | 2001 } |
| 1978 ProcessWeakCollections(); | 2002 ProcessWeakCollections(); |
| 1979 work_to_do = !marking_deque_.IsEmpty(); | 2003 work_to_do = !marking_deque_.IsEmpty(); |
| 1980 ProcessMarkingDeque(); | 2004 ProcessMarkingDeque(); |
| 1981 } | 2005 } |
| 2006 if (!only_process_harmony_weak_collections && UsingEmbedderHeapTracer()) { | |
| 2007 heap()->embedder_heap_tracer()->ClearTracingMarks(api_isolate); | |
| 2008 } | |
| 1982 } | 2009 } |
| 1983 | 2010 |
| 1984 | 2011 |
| 1985 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { | 2012 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { |
| 1986 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); | 2013 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); |
| 1987 !it.done(); it.Advance()) { | 2014 !it.done(); it.Advance()) { |
| 1988 if (it.frame()->type() == StackFrame::JAVA_SCRIPT) { | 2015 if (it.frame()->type() == StackFrame::JAVA_SCRIPT) { |
| 1989 return; | 2016 return; |
| 1990 } | 2017 } |
| 1991 if (it.frame()->type() == StackFrame::OPTIMIZED) { | 2018 if (it.frame()->type() == StackFrame::OPTIMIZED) { |
| (...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3823 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3850 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 3824 if (Marking::IsBlack(mark_bit)) { | 3851 if (Marking::IsBlack(mark_bit)) { |
| 3825 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3852 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 3826 RecordRelocSlot(host, &rinfo, target); | 3853 RecordRelocSlot(host, &rinfo, target); |
| 3827 } | 3854 } |
| 3828 } | 3855 } |
| 3829 } | 3856 } |
| 3830 | 3857 |
| 3831 } // namespace internal | 3858 } // namespace internal |
| 3832 } // namespace v8 | 3859 } // namespace v8 |
| OLD | NEW |