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

Side by Side Diff: src/heap/mark-compact.cc

Issue 1844413002: Use EmbedderHeapTracer instead of object grouping when trace_embedder_heap flag is set (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporated Jochen's wonderful comments Created 4 years, 8 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 | « src/heap/mark-compact.h ('k') | src/objects.h » ('j') | 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 // 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
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()) {
Hannes Payer (out of office) 2016/04/01 11:13:36 As discussed offline, move this code to the proper
Marcel Hlopko 2016/04/01 12:47:20 Gave it a try, my tests still pass, so I hope I fo
1920 JSObject* js_object = JSObject::cast(object);
1921
1922 if (js_object->GetInternalFieldCount() >= 2 &&
1923 js_object->WasConstructedFromApiFunction() &&
1924 js_object->GetInternalField(0) != heap()->undefined_value() &&
1925 js_object->GetInternalField(1) != heap()->undefined_value()) {
1926 wrappers_to_trace().push_back(std::pair<void*, void*>(
Hannes Payer (out of office) 2016/04/01 11:13:36 Could these be Object*?
Marcel Hlopko 2016/04/01 12:47:20 I'm afraid they cannot, from the v8 side they are
1927 reinterpret_cast<void*>(js_object->GetInternalField(0)),
1928 reinterpret_cast<void*>(js_object->GetInternalField(1))));
1929 }
1930 }
1931
1919 MarkCompactMarkingVisitor::IterateBody(map, object); 1932 MarkCompactMarkingVisitor::IterateBody(map, object);
1920 } 1933 }
1921 } 1934 }
1922 1935
1923 1936
1924 // Sweep the heap for overflowed objects, clear their overflow bits, and 1937 // 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 1938 // push them on the marking stack. Stop early if the marking stack fills
1926 // before sweeping completes. If sweeping completes, there are no remaining 1939 // before sweeping completes. If sweeping completes, there are no remaining
1927 // overflowed objects in the heap so the overflow flag on the markings stack 1940 // overflowed objects in the heap so the overflow flag on the markings stack
1928 // is cleared. 1941 // is cleared.
(...skipping 26 matching lines...) Expand all
1955 // pointers. After: the marking stack is empty and there are no overflowed 1968 // pointers. After: the marking stack is empty and there are no overflowed
1956 // objects in the heap. 1969 // objects in the heap.
1957 void MarkCompactCollector::ProcessMarkingDeque() { 1970 void MarkCompactCollector::ProcessMarkingDeque() {
1958 EmptyMarkingDeque(); 1971 EmptyMarkingDeque();
1959 while (marking_deque_.overflowed()) { 1972 while (marking_deque_.overflowed()) {
1960 RefillMarkingDeque(); 1973 RefillMarkingDeque();
1961 EmptyMarkingDeque(); 1974 EmptyMarkingDeque();
1962 } 1975 }
1963 } 1976 }
1964 1977
1978 bool MarkCompactCollector::UsingEmbedderHeapTracer() const {
1979 return FLAG_trace_embedder_heap && heap_->embedder_heap_tracer();
1980 }
1965 1981
1966 // Mark all objects reachable (transitively) from objects on the marking 1982 // Mark all objects reachable (transitively) from objects on the marking
1967 // stack including references only considered in the atomic marking pause. 1983 // stack including references only considered in the atomic marking pause.
1968 void MarkCompactCollector::ProcessEphemeralMarking( 1984 void MarkCompactCollector::ProcessEphemeralMarking(
1969 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { 1985 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) {
1970 bool work_to_do = true; 1986 bool work_to_do = true;
1971 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); 1987 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed());
1988 v8::Isolate* api_isolate = reinterpret_cast<v8::Isolate*>(isolate());
Hannes Payer (out of office) 2016/04/01 11:13:36 This method now looks really complicated. Can we d
Marcel Hlopko 2016/04/01 12:47:20 I was not happy with the split into 2 methods, so
1989 if (!only_process_harmony_weak_collections && UsingEmbedderHeapTracer()) {
1990 heap()->embedder_heap_tracer()->TraceRoots(api_isolate);
1991 }
1972 while (work_to_do) { 1992 while (work_to_do) {
1973 if (!only_process_harmony_weak_collections) { 1993 if (!only_process_harmony_weak_collections) {
1974 isolate()->global_handles()->IterateObjectGroups( 1994 if (UsingEmbedderHeapTracer()) {
1975 visitor, &IsUnmarkedHeapObjectWithHeap); 1995 heap_->embedder_heap_tracer()->TraceWrappableFrom(api_isolate,
1976 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); 1996 wrappers_to_trace_);
1997 wrappers_to_trace_.clear();
1998 } else {
1999 isolate()->global_handles()->IterateObjectGroups(
2000 visitor, &IsUnmarkedHeapObjectWithHeap);
2001 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject);
2002 }
1977 } 2003 }
1978 ProcessWeakCollections(); 2004 ProcessWeakCollections();
1979 work_to_do = !marking_deque_.IsEmpty(); 2005 work_to_do = !marking_deque_.IsEmpty();
1980 ProcessMarkingDeque(); 2006 ProcessMarkingDeque();
1981 } 2007 }
2008 if (!only_process_harmony_weak_collections && UsingEmbedderHeapTracer()) {
2009 heap()->embedder_heap_tracer()->ClearTracingMarks(api_isolate);
2010 }
1982 } 2011 }
1983 2012
1984 2013
1985 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { 2014 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) {
1986 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); 2015 for (StackFrameIterator it(isolate(), isolate()->thread_local_top());
1987 !it.done(); it.Advance()) { 2016 !it.done(); it.Advance()) {
1988 if (it.frame()->type() == StackFrame::JAVA_SCRIPT) { 2017 if (it.frame()->type() == StackFrame::JAVA_SCRIPT) {
1989 return; 2018 return;
1990 } 2019 }
1991 if (it.frame()->type() == StackFrame::OPTIMIZED) { 2020 if (it.frame()->type() == StackFrame::OPTIMIZED) {
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after
3823 MarkBit mark_bit = Marking::MarkBitFrom(host); 3852 MarkBit mark_bit = Marking::MarkBitFrom(host);
3824 if (Marking::IsBlack(mark_bit)) { 3853 if (Marking::IsBlack(mark_bit)) {
3825 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); 3854 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host);
3826 RecordRelocSlot(host, &rinfo, target); 3855 RecordRelocSlot(host, &rinfo, target);
3827 } 3856 }
3828 } 3857 }
3829 } 3858 }
3830 3859
3831 } // namespace internal 3860 } // namespace internal
3832 } // namespace v8 3861 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698