Changeset 39366 in webkit


Ignore:
Timestamp:
Dec 17, 2008 1:25:40 PM (15 years ago)
Author:
weinig@apple.com
Message:

2008-12-17 Sam Weinig <sam@webkit.org>

Reviewed by Darin Adler.

Fix for https://bugs.webkit.org/show_bug.cgi?id=22897
<rdar://problem/6428342>
Look into feasibility of discarding bytecode after native codegen

Clear the bytecode Instruction vector at the end JIT generation.

Saves 4.8 MB on Membuster head.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): Add logging for the case that someone tries to dump the instructions of a CodeBlock that has had its bytecode vector cleared. (JSC::CodeBlock::CodeBlock): Initialize the instructionCount (JSC::CodeBlock::handlerForBytecodeOffset): Use instructionCount instead of the size of the instruction vector in the assertion. (JSC::CodeBlock::lineNumberForBytecodeOffset): Ditto. (JSC::CodeBlock::expressionRangeForBytecodeOffset): Ditto. (JSC::CodeBlock::getByIdExceptionInfoForBytecodeOffset): Ditto. (JSC::CodeBlock::functionRegisterForBytecodeOffset): Ditto.
  • bytecode/CodeBlock.h: (JSC::CodeBlock::setInstructionCount): Store the instruction vector size in debug builds for assertions.
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate):
  • jit/JIT.cpp: (JSC::JIT::privateCompile): Clear the bytecode vector unless we have compiled with Opcode sampling where we will continue to require it
Location:
trunk/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r39362 r39366  
     12008-12-17  Sam Weinig  <sam@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=22897
     6        <rdar://problem/6428342>
     7        Look into feasibility of discarding bytecode after native codegen
     8
     9        Clear the bytecode Instruction vector at the end JIT generation.
     10
     11        Saves 4.8 MB on Membuster head.
     12
     13        * bytecode/CodeBlock.cpp:
     14        (JSC::CodeBlock::dump): Add logging for the case that someone tries
     15        to dump the instructions of a CodeBlock that has had its bytecode
     16        vector cleared.
     17        (JSC::CodeBlock::CodeBlock): Initialize the instructionCount
     18        (JSC::CodeBlock::handlerForBytecodeOffset): Use instructionCount instead
     19        of the size of the instruction vector in the assertion.
     20        (JSC::CodeBlock::lineNumberForBytecodeOffset): Ditto.
     21        (JSC::CodeBlock::expressionRangeForBytecodeOffset): Ditto.
     22        (JSC::CodeBlock::getByIdExceptionInfoForBytecodeOffset): Ditto.
     23        (JSC::CodeBlock::functionRegisterForBytecodeOffset): Ditto.
     24        * bytecode/CodeBlock.h:
     25        (JSC::CodeBlock::setInstructionCount): Store the instruction vector size
     26        in debug builds for assertions.
     27        * bytecompiler/BytecodeGenerator.cpp:
     28        (JSC::BytecodeGenerator::generate):
     29        * jit/JIT.cpp:
     30        (JSC::JIT::privateCompile): Clear the bytecode vector unless we
     31        have compiled with Opcode sampling where we will continue to require it
     32
    1332008-12-17  Cary Clark  <caryclark@google.com>
    234
  • trunk/JavaScriptCore/bytecode/CodeBlock.cpp

    r39354 r39366  
    3535#include "Interpreter.h"
    3636#include "Debugger.h"
     37#include "BytecodeGenerator.h"
    3738#include <stdio.h>
    3839#include <wtf/StringExtras.h>
     
    323324void CodeBlock::dump(ExecState* exec) const
    324325{
     326    if (m_instructions.isEmpty()) {
     327        printf("No instructions available.\n");
     328        return;
     329    }
     330
    325331    size_t instructionCount = 0;
    326332
     
    11731179    , m_ownerNode(ownerNode)
    11741180    , m_globalData(0)
     1181#ifndef NDEBUG
     1182    , m_instructionCount(0)
     1183#endif
    11751184    , m_needsFullScopeChain(ownerNode->needsActivation())
    11761185    , m_usesEval(ownerNode->usesEval())
     
    13301339HandlerInfo* CodeBlock::handlerForBytecodeOffset(unsigned bytecodeOffset)
    13311340{
     1341    ASSERT(bytecodeOffset < m_instructionCount);
     1342
    13321343    if (!m_rareData)
    13331344        return 0;
    1334 
    1335     ASSERT(bytecodeOffset < m_instructions.size());
    13361345   
    13371346    Vector<HandlerInfo>& exceptionHandlers = m_rareData->m_exceptionHandlers;
     
    13481357int CodeBlock::lineNumberForBytecodeOffset(unsigned bytecodeOffset)
    13491358{
    1350     ASSERT(bytecodeOffset < m_instructions.size());
     1359    ASSERT(bytecodeOffset < m_instructionCount);
    13511360
    13521361    if (!m_lineInfo.size())
     
    13701379int CodeBlock::expressionRangeForBytecodeOffset(unsigned bytecodeOffset, int& divot, int& startOffset, int& endOffset)
    13711380{
    1372     ASSERT(bytecodeOffset < m_instructions.size());
     1381    ASSERT(bytecodeOffset < m_instructionCount);
    13731382
    13741383    if (!m_expressionInfo.size()) {
     
    14061415bool CodeBlock::getByIdExceptionInfoForBytecodeOffset(unsigned bytecodeOffset, OpcodeID& opcodeID)
    14071416{
    1408     ASSERT(bytecodeOffset < m_instructions.size());
     1417    ASSERT(bytecodeOffset < m_instructionCount);
    14091418
    14101419    if (!m_getByIdExceptionInfo.size())
     
    14311440bool CodeBlock::functionRegisterForBytecodeOffset(unsigned bytecodeOffset, int& functionRegisterIndex)
    14321441{
    1433     ASSERT(bytecodeOffset < m_instructions.size());
     1442    ASSERT(bytecodeOffset < m_instructionCount);
    14341443
    14351444    if (!m_rareData || !m_rareData->m_functionRegisterInfos.size())
     
    14511460    functionRegisterIndex = m_rareData->m_functionRegisterInfos[low - 1].functionRegisterIndex;
    14521461    return true;
     1462}
     1463
     1464void CodeBlock::setJITCode(JITCodeRef& jitCode)
     1465{
     1466    m_jitCode = jitCode;
     1467#if !ENABLE(OPCODE_SAMPLING)
     1468    if (!BytecodeGenerator::dumpsGeneratedCode())
     1469        m_instructions.clear();
     1470#endif
    14531471}
    14541472#endif
  • trunk/JavaScriptCore/bytecode/CodeBlock.h

    r39354 r39366  
    307307
    308308        Vector<Instruction>& instructions() { return m_instructions; }
    309 
    310 #if ENABLE(JIT)
    311         void setJITCode(JITCodeRef& jitCode) { m_jitCode = jitCode; }
     309#ifndef NDEBUG
     310        void setInstructionCount(unsigned instructionCount) { m_instructionCount = instructionCount; }
     311#endif
     312
     313#if ENABLE(JIT)
     314        void setJITCode(JITCodeRef& jitCode);
    312315        void* jitCode() { return m_jitCode.code; }
    313316        ExecutablePool* executablePool() { return m_jitCode.executablePool.get(); }
     
    440443
    441444        Vector<Instruction> m_instructions;
     445#ifndef NDEBUG
     446        unsigned m_instructionCount;
     447#endif
    442448#if ENABLE(JIT)
    443449        JITCodeRef m_jitCode;
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r39354 r39366  
    128128}
    129129
     130bool BytecodeGenerator::dumpsGeneratedCode()
     131{
     132#ifndef NDEBUG
     133    return s_dumpsGeneratedCode;
     134#else
     135    return false;
     136#endif
     137}
     138
    130139void BytecodeGenerator::generate()
    131140{
     
    135144
    136145#ifndef NDEBUG
     146    m_codeBlock->setInstructionCount(m_codeBlock->instructions().size());
     147
    137148    if (s_dumpsGeneratedCode) {
    138149        JSGlobalObject* globalObject = m_scopeChain->globalObject();
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r39255 r39366  
    6767
    6868        static void setDumpsGeneratedCode(bool dumpsGeneratedCode);
     69        static bool dumpsGeneratedCode();
    6970
    7071        BytecodeGenerator(ProgramNode*, const Debugger*, const ScopeChain&, SymbolTable*, ProgramCodeBlock*);
Note: See TracChangeset for help on using the changeset viewer.