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

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

Issue 552089: A follow-up to fix 553: really report function object moves. (Closed)
Patch Set: Add an assertion to test Created 10 years, 11 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 | « no previous file | test/cctest/test-log-stack-tracer.cc » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1188
1189 void MarkCompactCollector::EncodeForwardingAddresses() { 1189 void MarkCompactCollector::EncodeForwardingAddresses() {
1190 ASSERT(state_ == ENCODE_FORWARDING_ADDRESSES); 1190 ASSERT(state_ == ENCODE_FORWARDING_ADDRESSES);
1191 // Objects in the active semispace of the young generation may be 1191 // Objects in the active semispace of the young generation may be
1192 // relocated to the inactive semispace (if not promoted). Set the 1192 // relocated to the inactive semispace (if not promoted). Set the
1193 // relocation info to the beginning of the inactive semispace. 1193 // relocation info to the beginning of the inactive semispace.
1194 Heap::new_space()->MCResetRelocationInfo(); 1194 Heap::new_space()->MCResetRelocationInfo();
1195 1195
1196 // Compute the forwarding pointers in each space. 1196 // Compute the forwarding pointers in each space.
1197 EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldPointerSpace, 1197 EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldPointerSpace,
1198 IgnoreNonLiveObject>( 1198 ReportDeleteIfNeeded>(
1199 Heap::old_pointer_space()); 1199 Heap::old_pointer_space());
1200 1200
1201 EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldDataSpace, 1201 EncodeForwardingAddressesInPagedSpace<MCAllocateFromOldDataSpace,
1202 IgnoreNonLiveObject>( 1202 IgnoreNonLiveObject>(
1203 Heap::old_data_space()); 1203 Heap::old_data_space());
1204 1204
1205 EncodeForwardingAddressesInPagedSpace<MCAllocateFromCodeSpace, 1205 EncodeForwardingAddressesInPagedSpace<MCAllocateFromCodeSpace,
1206 ReportDeleteIfNeeded>( 1206 ReportDeleteIfNeeded>(
1207 Heap::code_space()); 1207 Heap::code_space());
1208 1208
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 int obj_size = RestoreMap(obj, space, new_addr, map_addr); 1893 int obj_size = RestoreMap(obj, space, new_addr, map_addr);
1894 1894
1895 Address old_addr = obj->address(); 1895 Address old_addr = obj->address();
1896 1896
1897 if (new_addr != old_addr) { 1897 if (new_addr != old_addr) {
1898 memmove(new_addr, old_addr, obj_size); // Copy contents 1898 memmove(new_addr, old_addr, obj_size); // Copy contents
1899 } 1899 }
1900 1900
1901 ASSERT(!HeapObject::FromAddress(new_addr)->IsCode()); 1901 ASSERT(!HeapObject::FromAddress(new_addr)->IsCode());
1902 1902
1903 HeapObject* copied_to = HeapObject::FromAddress(new_addr);
1904 if (copied_to->IsJSFunction()) {
1905 LOG(FunctionMoveEvent(old_addr, new_addr));
1906 }
1907
1903 return obj_size; 1908 return obj_size;
1904 } 1909 }
1905 1910
1906 1911
1907 int MarkCompactCollector::RelocateOldPointerObject(HeapObject* obj) { 1912 int MarkCompactCollector::RelocateOldPointerObject(HeapObject* obj) {
1908 return RelocateOldNonCodeObject(obj, Heap::old_pointer_space()); 1913 return RelocateOldNonCodeObject(obj, Heap::old_pointer_space());
1909 } 1914 }
1910 1915
1911 1916
1912 int MarkCompactCollector::RelocateOldDataObject(HeapObject* obj) { 1917 int MarkCompactCollector::RelocateOldDataObject(HeapObject* obj) {
(...skipping 23 matching lines...) Expand all
1936 if (new_addr != old_addr) { 1941 if (new_addr != old_addr) {
1937 memmove(new_addr, old_addr, obj_size); // Copy contents. 1942 memmove(new_addr, old_addr, obj_size); // Copy contents.
1938 } 1943 }
1939 1944
1940 HeapObject* copied_to = HeapObject::FromAddress(new_addr); 1945 HeapObject* copied_to = HeapObject::FromAddress(new_addr);
1941 if (copied_to->IsCode()) { 1946 if (copied_to->IsCode()) {
1942 // May also update inline cache target. 1947 // May also update inline cache target.
1943 Code::cast(copied_to)->Relocate(new_addr - old_addr); 1948 Code::cast(copied_to)->Relocate(new_addr - old_addr);
1944 // Notify the logger that compiled code has moved. 1949 // Notify the logger that compiled code has moved.
1945 LOG(CodeMoveEvent(old_addr, new_addr)); 1950 LOG(CodeMoveEvent(old_addr, new_addr));
1946 } else if (copied_to->IsJSFunction()) {
1947 LOG(FunctionMoveEvent(old_addr, new_addr));
1948 } 1951 }
1949 1952
1950 return obj_size; 1953 return obj_size;
1951 } 1954 }
1952 1955
1953 1956
1954 int MarkCompactCollector::RelocateNewObject(HeapObject* obj) { 1957 int MarkCompactCollector::RelocateNewObject(HeapObject* obj) {
1955 int obj_size = obj->Size(); 1958 int obj_size = obj->Size();
1956 1959
1957 // Get forwarding address 1960 // Get forwarding address
(...skipping 17 matching lines...) Expand all
1975 memcpy(reinterpret_cast<void*>(new_addr), 1978 memcpy(reinterpret_cast<void*>(new_addr),
1976 reinterpret_cast<void*>(old_addr), 1979 reinterpret_cast<void*>(old_addr),
1977 obj_size); 1980 obj_size);
1978 1981
1979 #ifdef DEBUG 1982 #ifdef DEBUG
1980 if (FLAG_gc_verbose) { 1983 if (FLAG_gc_verbose) {
1981 PrintF("relocate %p -> %p\n", old_addr, new_addr); 1984 PrintF("relocate %p -> %p\n", old_addr, new_addr);
1982 } 1985 }
1983 #endif 1986 #endif
1984 1987
1988 HeapObject* copied_to = HeapObject::FromAddress(new_addr);
1989 if (copied_to->IsJSFunction()) {
1990 LOG(FunctionMoveEvent(old_addr, new_addr));
1991 }
1992
1985 return obj_size; 1993 return obj_size;
1986 } 1994 }
1987 1995
1988 1996
1989 // ------------------------------------------------------------------------- 1997 // -------------------------------------------------------------------------
1990 // Phase 5: rebuild remembered sets 1998 // Phase 5: rebuild remembered sets
1991 1999
1992 void MarkCompactCollector::RebuildRSets() { 2000 void MarkCompactCollector::RebuildRSets() {
1993 #ifdef DEBUG 2001 #ifdef DEBUG
1994 ASSERT(state_ == RELOCATE_OBJECTS); 2002 ASSERT(state_ == RELOCATE_OBJECTS);
1995 state_ = REBUILD_RSETS; 2003 state_ = REBUILD_RSETS;
1996 #endif 2004 #endif
1997 Heap::RebuildRSets(); 2005 Heap::RebuildRSets();
1998 } 2006 }
1999 2007
2000 2008
2001 void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj) { 2009 void MarkCompactCollector::ReportDeleteIfNeeded(HeapObject* obj) {
2002 #ifdef ENABLE_LOGGING_AND_PROFILING 2010 #ifdef ENABLE_LOGGING_AND_PROFILING
2003 if (obj->IsCode()) { 2011 if (obj->IsCode()) {
2004 LOG(CodeDeleteEvent(obj->address())); 2012 LOG(CodeDeleteEvent(obj->address()));
2005 } else if (obj->IsJSFunction()) { 2013 } else if (obj->IsJSFunction()) {
2006 LOG(FunctionDeleteEvent(obj->address())); 2014 LOG(FunctionDeleteEvent(obj->address()));
2007 } 2015 }
2008 #endif 2016 #endif
2009 } 2017 }
2010 2018
2011 } } // namespace v8::internal 2019 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-log-stack-tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698