Ignore:
Timestamp:
Aug 19, 2011, 7:17:49 PM (14 years ago)
Author:
[email protected]
Message:

The JSC JIT currently has no facility to profile and report
the types of values
https://bugs.webkit.org/show_bug.cgi?id=65901

Reviewed by Gavin Barraclough.

Added the ability to profile the values seen at function calls (both
arguments and results) and heap loads. This is done with emphasis
on performance. A value profiling site consists of: add, and,
move, and store; no branching is necessary. Each value profiling
site (called a ValueProfile) has a ring buffer of 8 recently-seen
values. ValueProfiles are stored in the CodeBlock; there will be
one for each argument (excluding this) and each heap load or callsite.
Each time a value profiling site executes, it stores the value into
a pseudo-random element in the ValueProfile buffer. The point is
that for frequently executed code, we will have 8 somewhat recent
values in the buffer and will be able to not only figure out what
type it is, but also to be able to reason about the actual values
if we wish to do so.

This feature is currently disabled by default. When enabled, it
results in a 3.7% slow-down on SunSpider.

(JSC::CodeBlock::~CodeBlock):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addValueProfile):
(JSC::CodeBlock::numberOfValueProfiles):
(JSC::CodeBlock::valueProfile):
(JSC::CodeBlock::valueProfileForBytecodeOffset):

  • bytecode/ValueProfile.h: Added.

(JSC::ValueProfile::ValueProfile):
(JSC::ValueProfile::numberOfSamples):
(JSC::ValueProfile::computeProbability):
(JSC::ValueProfile::numberOfInt32s):
(JSC::ValueProfile::numberOfDoubles):
(JSC::ValueProfile::numberOfCells):
(JSC::ValueProfile::probabilityOfInt32):
(JSC::ValueProfile::probabilityOfDouble):
(JSC::ValueProfile::probabilityOfCell):
(JSC::getValueProfileBytecodeOffset):

  • jit/JIT.cpp:

(JSC::JIT::privateCompileSlowCases):
(JSC::JIT::privateCompile):

  • jit/JIT.h:

(JSC::JIT::emitValueProfilingSite):

  • jit/JITCall.cpp:

(JSC::JIT::emit_op_call_put_result):

  • jit/JITInlineMethods.h:

(JSC::JIT::emitValueProfilingSite):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emitSlow_op_get_by_val):
(JSC::JIT::emit_op_method_check):
(JSC::JIT::emit_op_get_by_id):
(JSC::JIT::emitSlow_op_get_by_id):

  • jit/JSInterfaceJIT.h:
  • wtf/Platform.h:
  • wtf/StdLibExtras.h:

(WTF::binarySearch):
(WTF::genericBinarySearch):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r93238 r93466  
    4040#include "RegExpObject.h"
    4141#include "UString.h"
     42#include "ValueProfile.h"
    4243#include <wtf/FastAllocBase.h>
    4344#include <wtf/PassOwnPtr.h>
    4445#include <wtf/RefPtr.h>
     46#include <wtf/SegmentedVector.h>
    4547#include <wtf/Vector.h>
    4648
     
    382384        MethodCallLinkInfo& methodCallLinkInfo(int index) { return m_methodCallLinkInfos[index]; }
    383385#endif
     386       
     387#if ENABLE(VALUE_PROFILER)
     388        ValueProfile* addValueProfile(int bytecodeOffset)
     389        {
     390            m_valueProfiles.append(ValueProfile(bytecodeOffset));
     391            return &m_valueProfiles.last();
     392        }
     393        unsigned numberOfValueProfiles() { return m_valueProfiles.size(); }
     394        ValueProfile* valueProfile(int index) { return &m_valueProfiles[index]; }
     395        ValueProfile* valueProfileForBytecodeOffset(int bytecodeOffset)
     396        {
     397            return WTF::genericBinarySearch<ValueProfile, int, getValueProfileBytecodeOffset>(m_valueProfiles, m_valueProfiles.size(), bytecodeOffset);
     398        }
     399#endif
     400
    384401        unsigned globalResolveInfoCount() const
    385402        {
     
    576593        Vector<CallLinkInfo> m_callLinkInfos;
    577594        Vector<MethodCallLinkInfo> m_methodCallLinkInfos;
     595#endif
     596#if ENABLE(VALUE_PROFILER)
     597        SegmentedVector<ValueProfile, 8> m_valueProfiles;
    578598#endif
    579599
Note: See TracChangeset for help on using the changeset viewer.