Changeset 89058 in webkit


Ignore:
Timestamp:
Jun 16, 2011 12:30:57 PM (13 years ago)
Author:
oliver@apple.com
Message:

2011-06-15 Oliver Hunt <oliver@apple.com>

Reviewed by Geoffrey Garen.

Reduce memory usage of resolve_global
https://bugs.webkit.org/show_bug.cgi?id=62765

If we have a large number of resolve_globals in a single
block start planting plain resolve instructions instead
whenever we aren't in a loop. This allows us to reduce
the code size for extremely large functions without
losing the performance benefits of op_resolve_global.

  • bytecode/CodeBlock.h: (JSC::CodeBlock::globalResolveInfoCount):
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::shouldAvoidResolveGlobal): (JSC::BytecodeGenerator::emitResolve): (JSC::BytecodeGenerator::emitResolveWithBase):
  • bytecompiler/BytecodeGenerator.h:
Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r89037 r89058  
     12011-06-15  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoffrey Garen.
     4
     5        Reduce memory usage of resolve_global
     6        https://bugs.webkit.org/show_bug.cgi?id=62765
     7
     8        If we have a large number of resolve_globals in a single
     9        block start planting plain resolve instructions instead
     10        whenever we aren't in a loop.  This allows us to reduce
     11        the code size for extremely large functions without
     12        losing the performance benefits of op_resolve_global.
     13
     14        * bytecode/CodeBlock.h:
     15        (JSC::CodeBlock::globalResolveInfoCount):
     16        * bytecompiler/BytecodeGenerator.cpp:
     17        (JSC::BytecodeGenerator::shouldAvoidResolveGlobal):
     18        (JSC::BytecodeGenerator::emitResolve):
     19        (JSC::BytecodeGenerator::emitResolveWithBase):
     20        * bytecompiler/BytecodeGenerator.h:
     21
    1222011-06-16  Qi Zhang  <qi.2.zhang@nokia.com>
    223
  • trunk/Source/JavaScriptCore/bytecode/CodeBlock.h

    r88873 r89058  
    373373        MethodCallLinkInfo& methodCallLinkInfo(int index) { return m_methodCallLinkInfos[index]; }
    374374#endif
     375        unsigned globalResolveInfoCount() const
     376        {
     377#if ENABLE(JIT)   
     378            if (m_globalData->canUseJIT())
     379                return m_globalResolveInfos.size();
     380#endif
     381            return 0;
     382        }
    375383
    376384        // Exception handling support
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r88873 r89058  
    12021202}
    12031203
     1204static const unsigned maxGlobalResolves = 128;
     1205
     1206bool BytecodeGenerator::shouldAvoidResolveGlobal()
     1207{
     1208    return m_codeBlock->globalResolveInfoCount() > maxGlobalResolves && !m_labelScopes.size();
     1209}
     1210
    12041211RegisterID* BytecodeGenerator::emitResolve(RegisterID* dst, const Identifier& property)
    12051212{
     
    12151222        return dst;
    12161223    }
    1217 
     1224    if (shouldAvoidResolveGlobal()) {
     1225        globalObject = 0;
     1226        requiresDynamicChecks = true;
     1227    }
     1228       
    12181229    if (globalObject) {
    12191230        bool forceGlobalResolve = false;
     
    13641375        return baseDst;
    13651376    }
    1366 
     1377    if (shouldAvoidResolveGlobal()) {
     1378        emitOpcode(op_resolve);
     1379        instructions().append(propDst->index());
     1380        instructions().append(addConstant(property));
     1381        return baseDst;
     1382    }
    13671383#if ENABLE(JIT)
    13681384    m_codeBlock->addGlobalResolveInfo(instructions().size());
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r88873 r89058  
    460460       
    461461        void preserveLastVar();
     462        bool shouldAvoidResolveGlobal();
    462463
    463464        RegisterID& registerFor(int index)
Note: See TracChangeset for help on using the changeset viewer.