Changeset 202650 in webkit
- Timestamp:
- Jun 29, 2016 3:00:02 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r202648 r202650 1 2016-06-29 Mark Lam <mark.lam@apple.com> 2 3 Add support for collecting cumulative LLINT stats via a JSC_llintStatsFile option. 4 https://bugs.webkit.org/show_bug.cgi?id=159274 5 6 Reviewed by Keith Miller. 7 8 * jsc.cpp: 9 (main): 10 * llint/LLIntData.cpp: 11 (JSC::LLInt::initialize): 12 (JSC::LLInt::Data::finalizeStats): 13 (JSC::LLInt::compareStats): 14 (JSC::LLInt::Data::dumpStats): 15 (JSC::LLInt::Data::ensureStats): 16 (JSC::LLInt::Data::loadStats): 17 (JSC::LLInt::Data::resetStats): 18 (JSC::LLInt::Data::saveStats): 19 * llint/LLIntData.h: 20 (JSC::LLInt::Data::opcodeStats): 21 * runtime/Options.cpp: 22 (JSC::Options::isAvailable): 23 (JSC::recomputeDependentOptions): 24 (JSC::Options::initialize): 25 * runtime/Options.h: 26 1 27 2016-06-29 Saam barati <sbarati@apple.com> 2 28 -
trunk/Source/JavaScriptCore/jsc.cpp
r202588 r202650 1986 1986 HeapStatistics::reportSuccess(); 1987 1987 if (Options::reportLLIntStats()) 1988 LLInt::Data:: dumpStats();1988 LLInt::Data::finalizeStats(); 1989 1989 1990 1990 #if PLATFORM(EFL) -
trunk/Source/JavaScriptCore/llint/LLIntData.cpp
r202131 r202650 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 #include "CodeBlock.h" 31 31 #include "CodeType.h" 32 #include "InitializeThreading.h" 32 33 #include "Instruction.h" 33 34 #include "JSScope.h" … … 39 40 #include "ShadowChicken.h" 40 41 #include "WriteBarrier.h" 42 #include <string> 43 #include <wtf/NeverDestroyed.h> 41 44 42 45 #define STATIC_ASSERT(cond) static_assert(cond, "LLInt assumes " #cond) … … 68 71 69 72 #if ENABLE(LLINT_STATS) 70 Data::s_opcodeStatsArray = new OpcodeStatsArray(); 71 unsigned i = 0; 72 for (auto& stats : *Data::s_opcodeStatsArray) 73 stats.id = static_cast<OpcodeID>(i++); 73 Data::ensureStats(); 74 74 #endif 75 75 } … … 229 229 #endif 230 230 231 void Data:: dumpStats()231 void Data::finalizeStats() 232 232 { 233 233 #if ENABLE(LLINT_STATS) 234 234 if (!Options::reportLLIntStats()) 235 235 return; 236 236 237 if (Options::llintStatsFile()) 238 saveStats(); 239 240 dumpStats(); 241 #endif 242 } 243 244 #if ENABLE(LLINT_STATS) 245 static const bool verboseStats = false; 246 247 static bool compareStats(const OpcodeStats& a, const OpcodeStats& b) 248 { 249 if (a.count > b.count) 250 return true; 251 if (a.count < b.count) 252 return false; 253 return a.slowPathCount > b.slowPathCount; 254 } 255 256 void Data::dumpStats() 257 { 258 ASSERT(Options::reportLLIntStats()); 237 259 auto statsCopy = *s_opcodeStatsArray; 238 std::sort(statsCopy.begin(), statsCopy.end(), [] (OpcodeStats& a, OpcodeStats& b) -> bool { 239 if (a.count > b.count) 240 return true; 241 if (a.count < b.count) 242 return false; 243 return a.slowPathCount > b.slowPathCount; 244 }); 245 260 std::sort(statsCopy.begin(), statsCopy.end(), compareStats); 261 246 262 dataLog("Opcode stats:\n"); 247 263 unsigned i = 0; 248 264 for (auto& stats : statsCopy) { 249 if (stats.count )265 if (stats.count || stats.slowPathCount) 250 266 dataLog(" [", i++, "]: fast:", stats.count, " slow:", stats.slowPathCount, " ", opcodeNames[stats.id], "\n"); 251 267 } 252 #endif 253 } 254 268 } 269 270 void Data::ensureStats() 271 { 272 static std::once_flag initializeOptionsOnceFlag; 273 std::call_once(initializeOptionsOnceFlag, [] { 274 s_opcodeStatsArray = new OpcodeStatsArray(); 275 resetStats(); 276 }); 277 } 278 279 void Data::loadStats() 280 { 281 static NeverDestroyed<std::string> installedStatsFile; 282 if (!Options::llintStatsFile() || !installedStatsFile.get().compare(Options::llintStatsFile())) 283 return; 284 285 Options::reportLLIntStats() = true; // Force stats collection. 286 installedStatsFile.get() = Options::llintStatsFile(); 287 288 ensureStats(); 289 290 const char* filename = Options::llintStatsFile(); 291 FILE* file = fopen(filename, "r"); 292 if (!file) { 293 dataLogF("Failed to open file %s. Did you add the file-read-write-data entitlement to WebProcess.sb?\n", filename); 294 return; 295 } 296 297 resetStats(); 298 299 OpcodeStats loaded; 300 unsigned index; 301 char opcodeName[100]; 302 while (fscanf(file, "[%u]: fast:%zu slow:%zu id:%u %s\n", &index, &loaded.count, &loaded.slowPathCount, &loaded.id, opcodeName) != EOF) { 303 if (verboseStats) 304 dataLogF("loaded [%u]: fast %zu slow %zu id:%u %s\n", index, loaded.count, loaded.slowPathCount, loaded.id, opcodeName); 305 306 OpcodeStats& stats = opcodeStats(loaded.id); 307 stats.count = loaded.count; 308 stats.slowPathCount = loaded.slowPathCount; 309 } 310 311 if (verboseStats) { 312 dataLogF("After loading from %s, ", filename); 313 dumpStats(); 314 } 315 316 int result = fclose(file); 317 if (result) 318 dataLogF("Failed to close file %s: %s\n", filename, strerror(errno)); 319 } 320 321 void Data::resetStats() 322 { 323 unsigned i = 0; 324 for (auto& stats : *s_opcodeStatsArray) { 325 stats.id = static_cast<OpcodeID>(i++); 326 stats.count = 0; 327 stats.slowPathCount = 0; 328 } 329 } 330 331 void Data::saveStats() 332 { 333 ASSERT(Options::reportLLIntStats() && Options::llintStatsFile()); 334 const char* filename = Options::llintStatsFile(); 335 336 FILE* file = fopen(filename, "w"); 337 if (!file) { 338 dataLogF("Failed to open file %s. Did you add the file-read-write-data entitlement to WebProcess.sb?\n", filename); 339 return; 340 } 341 342 auto statsCopy = *s_opcodeStatsArray; 343 std::sort(statsCopy.begin(), statsCopy.end(), compareStats); 344 345 int index = 0; 346 for (auto& stats : statsCopy) { 347 if (!stats.count && !stats.slowPathCount) 348 break; // stats are sorted. If we encountered 0 counts, then there are no more non-zero counts. 349 350 if (verboseStats) 351 dataLogF("saved [%u]: fast:%zu slow:%zu id:%u %s\n", index, stats.count, stats.slowPathCount, stats.id, opcodeNames[stats.id]); 352 353 fprintf(file, "[%u]: fast:%zu slow:%zu id:%u %s\n", index, stats.count, stats.slowPathCount, stats.id, opcodeNames[stats.id]); 354 index++; 355 } 356 357 int result = fclose(file); 358 if (result) 359 dataLogF("Failed to close file %s: %s\n", filename, strerror(errno)); 360 } 361 #endif 255 362 256 363 } } // namespace JSC::LLInt -
trunk/Source/JavaScriptCore/llint/LLIntData.h
r202131 r202650 1 1 /* 2 * Copyright (C) 2011 Apple Inc. All rights reserved.2 * Copyright (C) 2011, 2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 57 57 static OpcodeStats& opcodeStats(OpcodeID id) { return (*s_opcodeStatsArray)[id]; } 58 58 59 JS_EXPORT_PRIVATE static void dumpStats(); 59 JS_EXPORT_PRIVATE static void finalizeStats(); 60 61 static void dumpStats(); 62 static void loadStats(); 60 63 61 64 private: 65 static void ensureStats(); 66 static void resetStats(); 67 static void saveStats(); 68 62 69 static Instruction* s_exceptionInstructions; 63 70 static Opcode s_opcodeMap[numOpcodeIDs]; -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r202402 r202650 1 1 /* 2 * Copyright (C) 2011-2012, 2014-201 5Apple Inc. All rights reserved.2 * Copyright (C) 2011-2012, 2014-2016 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #include "LLIntCommon.h" 30 #include "LLIntData.h" 30 31 #include <algorithm> 31 32 #include <limits> … … 133 134 UNUSED_PARAM(id); 134 135 #if ENABLE(LLINT_STATS) 135 if (id == reportLLIntStatsID )136 if (id == reportLLIntStatsID || id == llintStatsFileID) 136 137 return true; 137 138 #endif … … 390 391 ASSERT((static_cast<int64_t>(Options::thresholdForOptimizeAfterLongWarmUp()) << Options::reoptimizationRetryCounterMax()) <= static_cast<int64_t>(std::numeric_limits<int32_t>::max())); 391 392 ASSERT(Options::deferGCProbability() >= 0.0 && Options::deferGCProbability() <= 1.0); 393 394 #if ENABLE(LLINT_STATS) 395 LLInt::Data::loadStats(); 396 #endif 392 397 } 393 398 … … 438 443 #endif 439 444 440 recomputeDependentOptions();441 442 445 #if USE(OPTIONS_FILE) 443 446 { … … 464 467 } 465 468 #endif 469 470 recomputeDependentOptions(); 466 471 467 472 // Do range checks where needed and make corrections to the options: -
trunk/Source/JavaScriptCore/runtime/Options.h
r202402 r202650 376 376 v(bool, useSuperSampler, false, Normal, nullptr) \ 377 377 \ 378 v(bool, reportLLIntStats, false, Configurable, "Reports LLInt statistics") 378 v(bool, reportLLIntStats, false, Configurable, "Reports LLInt statistics") \ 379 v(optionString, llintStatsFile, nullptr, Configurable, "File to collect LLInt statistics in") \ 379 380 380 381 enum OptionEquivalence { -
trunk/Tools/ChangeLog
r202640 r202650 1 2016-06-29 Mark Lam <mark.lam@apple.com> 2 3 Add support for collecting cumulative LLINT stats via a JSC_llintStatsFile option. 4 https://bugs.webkit.org/show_bug.cgi?id=159274 5 6 Reviewed by Keith Miller. 7 8 * DumpRenderTree/mac/DumpRenderTree.mm: 9 (DumpRenderTreeMain): 10 1 11 2016-06-29 Alex Christensen <achristensen@webkit.org> 2 12 -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r202020 r202650 1445 1445 JSC::HeapStatistics::reportSuccess(); 1446 1446 if (JSC::Options::reportLLIntStats()) 1447 JSC::LLInt::Data:: dumpStats();1447 JSC::LLInt::Data::finalizeStats(); 1448 1448 [pool release]; 1449 1449 returningFromMain = true;
Note: See TracChangeset
for help on using the changeset viewer.