Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 49 #include <windows.h> | 49 #include <windows.h> |
| 50 #include <winnt.h> | 50 #include <winnt.h> |
| 51 #elif defined(__GLIBC__) | 51 #elif defined(__GLIBC__) |
| 52 extern "C" void* __libc_stack_end; // NOLINT | 52 extern "C" void* __libc_stack_end; // NOLINT |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 #if defined(MEMORY_SANITIZER) | 55 #if defined(MEMORY_SANITIZER) |
| 56 #include <sanitizer/msan_interface.h> | 56 #include <sanitizer/msan_interface.h> |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 #if ENABLE(GC_PROFILING) | |
| 60 #include <limits> | |
| 61 #endif | |
| 62 | |
| 59 #if OS(FREEBSD) | 63 #if OS(FREEBSD) |
| 60 #include <pthread_np.h> | 64 #include <pthread_np.h> |
| 61 #endif | 65 #endif |
| 62 | 66 |
| 63 namespace blink { | 67 namespace blink { |
| 64 | 68 |
| 65 static void* getStackStart() | 69 static void* getStackStart() |
| 66 { | 70 { |
| 67 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) | 71 #if defined(__GLIBC__) || OS(ANDROID) || OS(FREEBSD) |
| 68 pthread_attr_t attr; | 72 pthread_attr_t attr; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 , m_sweepForbidden(false) | 309 , m_sweepForbidden(false) |
| 306 , m_noAllocationCount(0) | 310 , m_noAllocationCount(0) |
| 307 , m_isTerminating(false) | 311 , m_isTerminating(false) |
| 308 , m_shouldFlushHeapDoesNotContainCache(false) | 312 , m_shouldFlushHeapDoesNotContainCache(false) |
| 309 , m_collectionRate(1.0) | 313 , m_collectionRate(1.0) |
| 310 , m_gcState(NoGCScheduled) | 314 , m_gcState(NoGCScheduled) |
| 311 , m_traceDOMWrappers(nullptr) | 315 , m_traceDOMWrappers(nullptr) |
| 312 #if defined(ADDRESS_SANITIZER) | 316 #if defined(ADDRESS_SANITIZER) |
| 313 , m_asanFakeStack(__asan_get_current_fake_stack()) | 317 , m_asanFakeStack(__asan_get_current_fake_stack()) |
| 314 #endif | 318 #endif |
| 319 #if ENABLE(GC_PROFILING) | |
| 320 , m_nextFreeListSnapshotTime(-std::numeric_limits<double>::infinity()) | |
| 321 #endif | |
| 315 { | 322 { |
| 316 checkThread(); | 323 checkThread(); |
| 317 ASSERT(!**s_threadSpecific); | 324 ASSERT(!**s_threadSpecific); |
| 318 **s_threadSpecific = this; | 325 **s_threadSpecific = this; |
| 319 | 326 |
| 320 if (isMainThread()) { | 327 if (isMainThread()) { |
| 321 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*); | 328 s_mainThreadStackStart = reinterpret_cast<uintptr_t>(m_startOfStack) - s izeof(void*); |
| 322 s_mainThreadUnderestimatedStackSize = getUnderestimatedStackSize() - siz eof(void*); | 329 s_mainThreadUnderestimatedStackSize = getUnderestimatedStackSize() - siz eof(void*); |
| 323 } | 330 } |
| 324 | 331 |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1081 } else { | 1088 } else { |
| 1082 // The default behavior is lazy sweeping. | 1089 // The default behavior is lazy sweeping. |
| 1083 setGCState(Sweeping); | 1090 setGCState(Sweeping); |
| 1084 } | 1091 } |
| 1085 #else | 1092 #else |
| 1086 // FIXME: For now, we disable lazy sweeping in non-oilpan builds | 1093 // FIXME: For now, we disable lazy sweeping in non-oilpan builds |
| 1087 // to avoid unacceptable behavior regressions on trunk. | 1094 // to avoid unacceptable behavior regressions on trunk. |
| 1088 setGCState(Sweeping); | 1095 setGCState(Sweeping); |
| 1089 completeSweep(); | 1096 completeSweep(); |
| 1090 #endif | 1097 #endif |
| 1098 | |
| 1099 #if ENABLE(GC_PROFILING) | |
| 1100 snapshotFreeListIfNecessary(); | |
| 1101 #endif | |
| 1091 } | 1102 } |
| 1092 | 1103 |
| 1093 void ThreadState::addInterruptor(Interruptor* interruptor) | 1104 void ThreadState::addInterruptor(Interruptor* interruptor) |
| 1094 { | 1105 { |
| 1095 checkThread(); | 1106 checkThread(); |
| 1096 SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting); | 1107 SafePointScope scope(HeapPointersOnStack, SafePointScope::AllowNesting); |
| 1097 { | 1108 { |
| 1098 MutexLocker locker(threadAttachMutex()); | 1109 MutexLocker locker(threadAttachMutex()); |
| 1099 m_interruptors.append(interruptor); | 1110 m_interruptors.append(interruptor); |
| 1100 } | 1111 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1159 if (const GCInfo* gcInfo = state->findGCInfo(address)) { | 1170 if (const GCInfo* gcInfo = state->findGCInfo(address)) { |
| 1160 if (needLockForIteration) | 1171 if (needLockForIteration) |
| 1161 threadAttachMutex().unlock(); | 1172 threadAttachMutex().unlock(); |
| 1162 return gcInfo; | 1173 return gcInfo; |
| 1163 } | 1174 } |
| 1164 } | 1175 } |
| 1165 if (needLockForIteration) | 1176 if (needLockForIteration) |
| 1166 threadAttachMutex().unlock(); | 1177 threadAttachMutex().unlock(); |
| 1167 return nullptr; | 1178 return nullptr; |
| 1168 } | 1179 } |
| 1180 | |
| 1181 void ThreadState::snapshotFreeListIfNecessary() | |
| 1182 { | |
| 1183 bool enabled; | |
| 1184 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("blink_gc"), &e nabled); | |
| 1185 if (!enabled) | |
| 1186 return; | |
| 1187 | |
| 1188 static const double recordIntervalSeconds = 0.010; | |
| 1189 double now = monotonicallyIncreasingTime(); | |
| 1190 if (now > m_nextFreeListSnapshotTime) { | |
| 1191 snapshotFreeList(); | |
| 1192 m_nextFreeListSnapshotTime = now + recordIntervalSeconds; | |
| 1193 } | |
| 1194 } | |
| 1195 | |
| 1196 void ThreadState::snapshotFreeList() | |
| 1197 { | |
| 1198 RefPtr<TracedValue> json = TracedValue::create(); | |
| 1199 | |
| 1200 #define SNAPSHOT_FREE_LIST(HeapType) \ | |
| 1201 { \ | |
| 1202 json->beginDictionary(); \ | |
| 1203 json->setString("name", #HeapType); \ | |
| 1204 m_heaps[HeapType##Heap]->snapshotFreeList(*json); \ | |
| 1205 json->endDictionary(); \ | |
| 1206 } | |
| 1207 | |
| 1208 json->beginArray("heaps"); | |
| 1209 SNAPSHOT_FREE_LIST(General); | |
| 1210 SNAPSHOT_FREE_LIST(VectorBacking); | |
|
haraken
2015/02/04 07:30:01
Add SNAPSHOT_FREE_LIST(InlineVectorBacking).
Yuta Kitamura
2015/02/04 09:45:42
Done.
| |
| 1211 SNAPSHOT_FREE_LIST(HashTableBacking); | |
| 1212 FOR_EACH_TYPED_HEAP(SNAPSHOT_FREE_LIST); | |
| 1213 json->endArray(); | |
| 1214 | |
| 1215 #undef SNAPSHOT_FREE_LIST | |
| 1216 | |
| 1217 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(TRACE_DISABLED_BY_DEFAULT("blink_gc"), " FreeList", this, json.release()); | |
| 1218 } | |
| 1169 #endif | 1219 #endif |
| 1170 | 1220 |
| 1171 } // namespace blink | 1221 } // namespace blink |
| OLD | NEW |