Changeset 95676 in webkit
- Timestamp:
- Sep 21, 2011 3:43:11 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r95672 r95676 1 2011-09-21 Gavin Barraclough <barraclough@apple.com> 2 3 Should support value profiling on CPU(X86) 4 https://bugs.webkit.org/show_bug.cgi?id=68575 5 6 Reviewed by Sam Weinig. 7 8 Fix verbose profiling in ToT (SlowCaseProfile had been 9 partially renamed to RareCaseProfile), add in-memory 10 bucket counter for CPU(X86), move JIT::m_canBeOptimized 11 out of the DFG_JIT ifdef. 12 13 * bytecode/CodeBlock.cpp: 14 (JSC::CodeBlock::resetRareCaseProfiles): 15 (JSC::CodeBlock::dumpValueProfiles): 16 * bytecode/CodeBlock.h: 17 * dfg/DFGByteCodeParser.cpp: 18 (JSC::DFG::ByteCodeParser::makeSafe): 19 * jit/JIT.cpp: 20 (JSC::JIT::privateCompileSlowCases): 21 (JSC::JIT::privateCompile): 22 * jit/JIT.h: 23 * jit/JITInlineMethods.h: 24 (JSC::JIT::emitValueProfilingSite): 25 1 26 2011-09-21 Filip Pizlo <fpizlo@apple.com> 2 27 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r95484 r95676 1988 1988 void CodeBlock::resetRareCaseProfiles() 1989 1989 { 1990 for (unsigned i = 0; i < numberOf SlowCaseProfiles(); ++i)1991 slowCaseProfile(i)->m_counter = 0;1990 for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i) 1991 rareCaseProfile(i)->m_counter = 0; 1992 1992 for (unsigned i = 0; i < numberOfSpecialFastCaseProfiles(); ++i) 1993 1993 specialFastCaseProfile(i)->m_counter = 0; … … 2013 2013 fprintf(stderr, "\n"); 2014 2014 } 2015 fprintf(stderr, " SlowCaseProfile for %p:\n", this);2016 for (unsigned i = 0; i < numberOf SlowCaseProfiles(); ++i) {2017 SlowCaseProfile* profile = slowCaseProfile(i);2015 fprintf(stderr, "RareCaseProfile for %p:\n", this); 2016 for (unsigned i = 0; i < numberOfRareCaseProfiles(); ++i) { 2017 RareCaseProfile* profile = rareCaseProfile(i); 2018 2018 fprintf(stderr, " bc = %d: %u\n", profile->m_bytecodeOffset, profile->m_counter); 2019 2019 } -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r95484 r95676 490 490 } 491 491 492 RareCaseProfile* add SlowCaseProfile(int bytecodeOffset)493 { 494 m_ slowCaseProfiles.append(RareCaseProfile(bytecodeOffset));495 return &m_ slowCaseProfiles.last();496 } 497 unsigned numberOf SlowCaseProfiles() { return m_slowCaseProfiles.size(); }498 RareCaseProfile* slowCaseProfile(int index) { return &m_slowCaseProfiles[index]; }499 RareCaseProfile* slowCaseProfileForBytecodeOffset(int bytecodeOffset)500 { 501 return WTF::genericBinarySearch<RareCaseProfile, int, getRareCaseProfileBytecodeOffset>(m_ slowCaseProfiles, m_slowCaseProfiles.size(), bytecodeOffset);492 RareCaseProfile* addRareCaseProfile(int bytecodeOffset) 493 { 494 m_rareCaseProfiles.append(RareCaseProfile(bytecodeOffset)); 495 return &m_rareCaseProfiles.last(); 496 } 497 unsigned numberOfRareCaseProfiles() { return m_rareCaseProfiles.size(); } 498 RareCaseProfile* rareCaseProfile(int index) { return &m_rareCaseProfiles[index]; } 499 RareCaseProfile* rareCaseProfileForBytecodeOffset(int bytecodeOffset) 500 { 501 return WTF::genericBinarySearch<RareCaseProfile, int, getRareCaseProfileBytecodeOffset>(m_rareCaseProfiles, m_rareCaseProfiles.size(), bytecodeOffset); 502 502 } 503 503 … … 505 505 bool likelyToTakeSlowCase(int bytecodeOffset) 506 506 { 507 return slowCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter >= slowCaseThreshold();507 return rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter >= slowCaseThreshold(); 508 508 } 509 509 … … 522 522 bool likelyToTakeDeepestSlowCase(int bytecodeOffset) 523 523 { 524 unsigned slowCaseCount = slowCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter;524 unsigned slowCaseCount = rareCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter; 525 525 unsigned specialFastCaseCount = specialFastCaseProfileForBytecodeOffset(bytecodeOffset)->m_counter; 526 526 return (slowCaseCount - specialFastCaseCount) >= slowCaseThreshold(); … … 831 831 #if ENABLE(VALUE_PROFILER) 832 832 SegmentedVector<ValueProfile, 8> m_valueProfiles; 833 SegmentedVector<RareCaseProfile, 8> m_ slowCaseProfiles;833 SegmentedVector<RareCaseProfile, 8> m_rareCaseProfiles; 834 834 SegmentedVector<RareCaseProfile, 8> m_specialFastCaseProfiles; 835 835 #endif -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r95672 r95676 514 514 515 515 #if ENABLE(DFG_DEBUG_VERBOSE) 516 printf("Making %s @%u safe at bc#%u because slow-case counter is at %u\n", Graph::opName(m_graph[nodeIndex].op), nodeIndex, m_currentIndex, m_profiledBlock-> slowCaseProfileForBytecodeOffset(m_currentIndex)->m_counter);516 printf("Making %s @%u safe at bc#%u because slow-case counter is at %u\n", Graph::opName(m_graph[nodeIndex].op), nodeIndex, m_currentIndex, m_profiledBlock->rareCaseProfileForBytecodeOffset(m_currentIndex)->m_counter); 517 517 #endif 518 518 -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r95484 r95676 416 416 417 417 #if ENABLE(VALUE_PROFILER) 418 RareCaseProfile* slowCaseProfile = 0;418 RareCaseProfile* rareCaseProfile = 0; 419 419 if (m_canBeOptimized) 420 slowCaseProfile = m_codeBlock->addSlowCaseProfile(m_bytecodeOffset);420 rareCaseProfile = m_codeBlock->addRareCaseProfile(m_bytecodeOffset); 421 421 #endif 422 422 … … 495 495 #if ENABLE(VALUE_PROFILER) 496 496 if (m_canBeOptimized) 497 add32(Imm32(1), AbsoluteAddress(& slowCaseProfile->m_counter));497 add32(Imm32(1), AbsoluteAddress(&rareCaseProfile->m_counter)); 498 498 #endif 499 499 … … 515 515 JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck) 516 516 { 517 #if ENABLE(VALUE_PROFILER) 518 m_canBeOptimized = m_codeBlock->canCompileWithDFG(); 519 #endif 517 520 #if ENABLE(DFG_JIT) 518 m_canBeOptimized = m_codeBlock->canCompileWithDFG();519 521 if (m_canBeOptimized) 520 522 m_startOfCode = label(); -
trunk/Source/JavaScriptCore/jit/JIT.h
r95666 r95676 1075 1075 WeakRandom m_randomGenerator; 1076 1076 static CodeRef stringGetByValStubGenerator(JSGlobalData*); 1077 1077 1078 #if ENABLE(VALUE_PROFILER) 1079 bool m_canBeOptimized; 1080 #endif 1078 1081 #if ENABLE(DFG_JIT) 1079 bool m_canBeOptimized;1080 1082 Label m_startOfCode; 1081 1083 CompactJITCodeMap::Encoder m_jitCodeMapEncoder; -
trunk/Source/JavaScriptCore/jit/JITInlineMethods.h
r95666 r95676 447 447 } 448 448 449 #if CPU(X86) 450 static int bucketCounter; 451 #endif 452 449 453 #if ENABLE(VALUE_PROFILER) 450 454 inline void JIT::emitValueProfilingSite(ValueProfilingSiteKind siteKind) … … 466 470 ASSERT(valueProfile); 467 471 472 #if CPU(X86) 473 if (m_randomGenerator.getUint32() & 1) 474 add32(Imm32(1), AbsoluteAddress(&bucketCounter)); 475 else 476 add32(Imm32(3), AbsoluteAddress(&bucketCounter)); 477 and32(Imm32(ValueProfile::bucketIndexMask), AbsoluteAddress(&bucketCounter)); 478 load32(&bucketCounter, scratch); 479 lshift32(TrustedImm32(3), scratch); 480 addPtr(ImmPtr(valueProfile->m_buckets), scratch); 481 storePtr(value, scratch); 482 #else 468 483 if (m_randomGenerator.getUint32() & 1) 469 484 add32(Imm32(1), bucketCounterRegister); … … 473 488 move(ImmPtr(valueProfile->m_buckets), scratch); 474 489 storePtr(value, BaseIndex(scratch, bucketCounterRegister, TimesEight)); 490 #endif 475 491 } 476 492 #endif
Note: See TracChangeset
for help on using the changeset viewer.