Changeset 48662 in webkit


Ignore:
Timestamp:
Sep 22, 2009 5:40:58 PM (15 years ago)
Author:
oliver@apple.com
Message:

Code sampling builds are broken.
https://bugs.webkit.org/show_bug.cgi?id=29662

Reviewed by Geoff Garen

Fix build.

Location:
trunk/JavaScriptCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r48650 r48662  
     12009-09-22  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Geoff Garen.
     4
     5        Code sampling builds are broken.
     6        https://bugs.webkit.org/show_bug.cgi?id=29662
     7
     8        Fix build.
     9
     10        * bytecode/EvalCodeCache.h:
     11        (JSC::EvalCodeCache::get):
     12        * bytecode/SamplingTool.cpp:
     13        (JSC::ScriptSampleRecord::sample):
     14        (JSC::SamplingTool::doRun):
     15        (JSC::SamplingTool::notifyOfScope):
     16        (JSC::compareScriptSampleRecords):
     17        (JSC::SamplingTool::dump):
     18        * bytecode/SamplingTool.h:
     19        (JSC::ScriptSampleRecord::ScriptSampleRecord):
     20        (JSC::ScriptSampleRecord::~ScriptSampleRecord):
     21        (JSC::SamplingTool::SamplingTool):
     22        * bytecompiler/BytecodeGenerator.cpp:
     23        (JSC::BytecodeGenerator::BytecodeGenerator):
     24        (JSC::BytecodeGenerator::emitNewFunction):
     25        (JSC::BytecodeGenerator::emitNewFunctionExpression):
     26        * bytecompiler/BytecodeGenerator.h:
     27        (JSC::BytecodeGenerator::makeFunction):
     28        * debugger/Debugger.cpp:
     29        (JSC::evaluateInGlobalCallFrame):
     30        * debugger/DebuggerCallFrame.cpp:
     31        (JSC::DebuggerCallFrame::evaluate):
     32        * parser/Nodes.cpp:
     33        (JSC::ScopeNode::ScopeNode):
     34        * runtime/Completion.cpp:
     35        (JSC::checkSyntax):
     36        (JSC::evaluate):
     37        * runtime/Executable.cpp:
     38        (JSC::FunctionExecutable::fromGlobalCode):
     39        * runtime/Executable.h:
     40        (JSC::ScriptExecutable::ScriptExecutable):
     41        (JSC::EvalExecutable::EvalExecutable):
     42        (JSC::EvalExecutable::create):
     43        (JSC::ProgramExecutable::ProgramExecutable):
     44        (JSC::FunctionExecutable::create):
     45        (JSC::FunctionExecutable::FunctionExecutable):
     46        * runtime/JSGlobalObjectFunctions.cpp:
     47        (JSC::globalFuncEval):
     48
    1492009-09-22  Darin Adler  <darin@apple.com>
    250
  • trunk/JavaScriptCore/bytecode/EvalCodeCache.h

    r47738 r48662  
    5151
    5252            if (!evalExecutable) {
    53                 evalExecutable = EvalExecutable::create(makeSource(evalSource));
     53                evalExecutable = EvalExecutable::create(exec, makeSource(evalSource));
    5454                exceptionValue = evalExecutable->compile(exec, scopeChain);
    5555                if (exceptionValue)
  • trunk/JavaScriptCore/bytecode/SamplingTool.cpp

    r47412 r48662  
    158158
    159159
    160 void ScopeSampleRecord::sample(CodeBlock* codeBlock, Instruction* vPC)
     160void ScriptSampleRecord::sample(CodeBlock* codeBlock, Instruction* vPC)
    161161{
    162162    if (!m_samples) {
     
    197197#if ENABLE(CODEBLOCK_SAMPLING)
    198198    if (CodeBlock* codeBlock = sample.codeBlock()) {
    199         MutexLocker locker(m_scopeSampleMapMutex);
    200         ScopeSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable());
     199        MutexLocker locker(m_scriptSampleMapMutex);
     200        ScriptSampleRecord* record = m_scopeSampleMap->get(codeBlock->ownerExecutable());
    201201        ASSERT(record);
    202202        record->sample(codeBlock, sample.vPC());
     
    210210}
    211211
    212 void SamplingTool::notifyOfScope(ScopeNode* scope)
     212void SamplingTool::notifyOfScope(ScriptExecutable* script)
    213213{
    214214#if ENABLE(CODEBLOCK_SAMPLING)
    215     MutexLocker locker(m_scopeSampleMapMutex);
    216     m_scopeSampleMap->set(scope, new ScopeSampleRecord(scope));
     215    MutexLocker locker(m_scriptSampleMapMutex);
     216    m_scopeSampleMap->set(script, new ScriptSampleRecord(script));
    217217#else
    218     UNUSED_PARAM(scope);
     218    UNUSED_PARAM(script);
    219219#endif
    220220}
     
    255255}
    256256
    257 static int compareScopeSampleRecords(const void* left, const void* right)
    258 {
    259     const ScopeSampleRecord* const leftValue = *static_cast<const ScopeSampleRecord* const *>(left);
    260     const ScopeSampleRecord* const rightValue = *static_cast<const ScopeSampleRecord* const *>(right);
     257static int compareScriptSampleRecords(const void* left, const void* right)
     258{
     259    const ScriptSampleRecord* const leftValue = *static_cast<const ScriptSampleRecord* const *>(left);
     260    const ScriptSampleRecord* const rightValue = *static_cast<const ScriptSampleRecord* const *>(right);
    261261
    262262    return (leftValue->m_sampleCount < rightValue->m_sampleCount) ? 1 : (leftValue->m_sampleCount > rightValue->m_sampleCount) ? -1 : 0;
     
    319319
    320320    int scopeCount = m_scopeSampleMap->size();
    321     Vector<ScopeSampleRecord*> codeBlockSamples(scopeCount);
    322     ScopeSampleRecordMap::iterator iter = m_scopeSampleMap->begin();
     321    Vector<ScriptSampleRecord*> codeBlockSamples(scopeCount);
     322    ScriptSampleRecordMap::iterator iter = m_scopeSampleMap->begin();
    323323    for (int i = 0; i < scopeCount; ++i, ++iter)
    324324        codeBlockSamples[i] = iter->second;
    325325
    326     qsort(codeBlockSamples.begin(), scopeCount, sizeof(ScopeSampleRecord*), compareScopeSampleRecords);
     326    qsort(codeBlockSamples.begin(), scopeCount, sizeof(ScriptSampleRecord*), compareScriptSampleRecords);
    327327
    328328    // (4) Print data from 'codeBlockSamples' array.
     
    331331
    332332    for (int i = 0; i < scopeCount; ++i) {
    333         ScopeSampleRecord* record = codeBlockSamples[i];
     333        ScriptSampleRecord* record = codeBlockSamples[i];
    334334        CodeBlock* codeBlock = record->m_codeBlock;
    335335
     
    338338        if (blockPercent >= 1) {
    339339            //Instruction* code = codeBlock->instructions().begin();
    340             printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_scope->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent);
     340            printf("#%d: %s:%d: %d / %lld (%.3f%%)\n", i + 1, record->m_executable->sourceURL().UTF8String().c_str(), codeBlock->lineNumberForBytecodeOffset(exec, 0), record->m_sampleCount, m_sampleCount, blockPercent);
    341341            if (i < 10) {
    342342                HashMap<unsigned,unsigned> lineCounts;
  • trunk/JavaScriptCore/bytecode/SamplingTool.h

    r46528 r48662  
    3939namespace JSC {
    4040
     41    class ScriptExecutable;
     42
    4143    class SamplingFlags {
    4244        friend class JIT;
     
    9395    struct Instruction;
    9496
    95     struct ScopeSampleRecord {
    96         ScopeSampleRecord(ScopeNode* scope)
    97             : m_scope(scope)
     97    struct ScriptSampleRecord {
     98        ScriptSampleRecord(ScriptExecutable* executable)
     99            : m_executable(executable)
    98100            , m_codeBlock(0)
    99101            , m_sampleCount(0)
     
    104106        }
    105107       
    106         ~ScopeSampleRecord()
     108        ~ScriptSampleRecord()
    107109        {
    108110            if (m_samples)
     
    112114        void sample(CodeBlock*, Instruction*);
    113115
    114         RefPtr<ScopeNode> m_scope;
     116        ScriptExecutable* m_executable;
    115117        CodeBlock* m_codeBlock;
    116118        int m_sampleCount;
     
    120122    };
    121123
    122     typedef WTF::HashMap<ScopeNode*, ScopeSampleRecord*> ScopeSampleRecordMap;
     124    typedef WTF::HashMap<ScriptExecutable*, ScriptSampleRecord*> ScriptSampleRecordMap;
    123125
    124126    class SamplingThread {
     
    194196            , m_opcodeSampleCount(0)
    195197#if ENABLE(CODEBLOCK_SAMPLING)
    196             , m_scopeSampleMap(new ScopeSampleRecordMap())
     198            , m_scopeSampleMap(new ScriptSampleRecordMap())
    197199#endif
    198200        {
     
    211213        void dump(ExecState*);
    212214
    213         void notifyOfScope(ScopeNode* scope);
     215        void notifyOfScope(ScriptExecutable* scope);
    214216
    215217        void sample(CodeBlock* codeBlock, Instruction* vPC)
     
    267269       
    268270#if ENABLE(CODEBLOCK_SAMPLING)
    269         Mutex m_scopeSampleMapMutex;
    270         OwnPtr<ScopeSampleRecordMap> m_scopeSampleMap;
     271        Mutex m_scriptSampleMapMutex;
     272        OwnPtr<ScriptSampleRecordMap> m_scopeSampleMap;
    271273#endif
    272274    };
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r47775 r48662  
    274274        for (size_t i = 0; i < functionStack.size(); ++i) {
    275275            FunctionBodyNode* function = functionStack[i];
    276             globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction(function), scopeChain.node()), DontDelete);
     276            globalObject->putWithAttributes(exec, function->ident(), new (exec) JSFunction(exec, makeFunction(exec, function), scopeChain.node()), DontDelete);
    277277        }
    278278        for (size_t i = 0; i < varStack.size(); ++i) {
     
    400400    const DeclarationStacks::FunctionStack& functionStack = evalNode->functionStack();
    401401    for (size_t i = 0; i < functionStack.size(); ++i)
    402         m_codeBlock->addFunctionDecl(makeFunction(functionStack[i]));
     402        m_codeBlock->addFunctionDecl(makeFunction(m_globalData, functionStack[i]));
    403403
    404404    const DeclarationStacks::VarStack& varStack = evalNode->varStack();
     
    13171317RegisterID* BytecodeGenerator::emitNewFunction(RegisterID* dst, FunctionBodyNode* function)
    13181318{
    1319     unsigned index = m_codeBlock->addFunctionDecl(makeFunction(function));
     1319    unsigned index = m_codeBlock->addFunctionDecl(makeFunction(m_globalData, function));
    13201320
    13211321    emitOpcode(op_new_func);
     
    13371337{
    13381338    FunctionBodyNode* function = n->body();
    1339     unsigned index = m_codeBlock->addFunctionExpr(makeFunction(function));
     1339    unsigned index = m_codeBlock->addFunctionExpr(makeFunction(m_globalData, function));
    13401340
    13411341    emitOpcode(op_new_func_exp);
  • trunk/JavaScriptCore/bytecompiler/BytecodeGenerator.h

    r47775 r48662  
    418418        unsigned addRegExp(RegExp*);
    419419
    420         PassRefPtr<FunctionExecutable> makeFunction(FunctionBodyNode* body)
    421         {
    422             return FunctionExecutable::create(body->ident(), body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());
     420        PassRefPtr<FunctionExecutable> makeFunction(ExecState* exec, FunctionBodyNode* body)
     421        {
     422            return FunctionExecutable::create(exec, body->ident(), body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());
     423        }
     424
     425        PassRefPtr<FunctionExecutable> makeFunction(JSGlobalData* globalData, FunctionBodyNode* body)
     426        {
     427            return FunctionExecutable::create(globalData, body->ident(), body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());
    423428        }
    424429
  • trunk/JavaScriptCore/debugger/Debugger.cpp

    r47738 r48662  
    101101    CallFrame* globalCallFrame = globalObject->globalExec();
    102102
    103     EvalExecutable eval(makeSource(script));
     103    EvalExecutable eval(globalCallFrame, makeSource(script));
    104104    JSObject* error = eval.compile(globalCallFrame, globalCallFrame->scopeChain());
    105105    if (error)
  • trunk/JavaScriptCore/debugger/DebuggerCallFrame.cpp

    r47738 r48662  
    8080        return JSValue();
    8181
    82     EvalExecutable eval(makeSource(script));
     82    EvalExecutable eval(m_callFrame, makeSource(script));
    8383    JSObject* error = eval.compile(m_callFrame, m_callFrame->scopeChain());
    8484    if (error)
  • trunk/JavaScriptCore/parser/Nodes.cpp

    r47775 r48662  
    18871887    , m_features(NoFeatures)
    18881888{
    1889 #if ENABLE(CODEBLOCK_SAMPLING)
    1890     if (SamplingTool* sampler = globalData->interpreter->sampler())
    1891         sampler->notifyOfScope(this);
    1892 #endif
    18931889}
    18941890
     
    19001896    , m_source(source)
    19011897{
    1902 #if ENABLE(CODEBLOCK_SAMPLING)
    1903     if (SamplingTool* sampler = globalData->interpreter->sampler())
    1904         sampler->notifyOfScope(this);
    1905 #endif
    19061898}
    19071899
  • trunk/JavaScriptCore/runtime/Completion.cpp

    r48048 r48662  
    3838    JSLock lock(exec);
    3939
    40     ProgramExecutable program(source);
     40    ProgramExecutable program(exec, source);
    4141    JSObject* error = program.checkSyntax(exec);
    4242    if (error)
     
    5050    JSLock lock(exec);
    5151
    52     ProgramExecutable program(source);
     52    ProgramExecutable program(exec, source);
    5353    JSObject* error = program.compile(exec, scopeChain.node());
    5454    if (error)
  • trunk/JavaScriptCore/runtime/Executable.cpp

    r47775 r48662  
    260260    FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
    261261    ASSERT(body);
    262     return FunctionExecutable::create(functionName, body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());
     262    return FunctionExecutable::create(&exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());
    263263}
    264264
  • trunk/JavaScriptCore/runtime/Executable.h

    r47775 r48662  
    2828
    2929#include "JSFunction.h"
     30#include "Interpreter.h"
    3031#include "Nodes.h"
     32#include "SamplingTool.h"
    3133
    3234namespace JSC {
     
    103105    class ScriptExecutable : public ExecutableBase {
    104106    public:
    105         ScriptExecutable(const SourceCode& source)
     107        ScriptExecutable(JSGlobalData* globalData, const SourceCode& source)
    106108            : ExecutableBase(NUM_PARAMETERS_NOT_COMPILED)
    107109            , m_source(source)
    108110            , m_features(0)
    109111        {
     112#if ENABLE(CODEBLOCK_SAMPLING)
     113            if (SamplingTool* sampler = globalData->interpreter->sampler())
     114                sampler->notifyOfScope(this);
     115#else
     116            UNUSED_PARAM(globalData);
     117#endif
     118        }
     119
     120        ScriptExecutable(ExecState* exec, const SourceCode& source)
     121            : ExecutableBase(NUM_PARAMETERS_NOT_COMPILED)
     122            , m_source(source)
     123            , m_features(0)
     124        {
     125#if ENABLE(CODEBLOCK_SAMPLING)
     126            if (SamplingTool* sampler = exec->globalData().interpreter->sampler())
     127                sampler->notifyOfScope(this);
     128#else
     129            UNUSED_PARAM(exec);
     130#endif
    110131        }
    111132
     
    138159    class EvalExecutable : public ScriptExecutable {
    139160    public:
    140         EvalExecutable(const SourceCode& source)
    141             : ScriptExecutable(source)
     161        EvalExecutable(ExecState* exec, const SourceCode& source)
     162            : ScriptExecutable(exec, source)
    142163            , m_evalCodeBlock(0)
    143164        {
     
    158179
    159180        ExceptionInfo* reparseExceptionInfo(JSGlobalData*, ScopeChainNode*, CodeBlock*);
    160         static PassRefPtr<EvalExecutable> create(const SourceCode& source) { return adoptRef(new EvalExecutable(source)); }
     181        static PassRefPtr<EvalExecutable> create(ExecState* exec, const SourceCode& source) { return adoptRef(new EvalExecutable(exec, source)); }
    161182
    162183    private:
     
    179200    class ProgramExecutable : public ScriptExecutable {
    180201    public:
    181         ProgramExecutable(const SourceCode& source)
    182             : ScriptExecutable(source)
     202        ProgramExecutable(ExecState* exec, const SourceCode& source)
     203            : ScriptExecutable(exec, source)
    183204            , m_programCodeBlock(0)
    184205        {
     
    222243        friend class JIT;
    223244    public:
    224         static PassRefPtr<FunctionExecutable> create(const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
    225         {
    226             return adoptRef(new FunctionExecutable(name, source, forceUsesArguments, parameters, firstLine, lastLine));
     245        static PassRefPtr<FunctionExecutable> create(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
     246        {
     247            return adoptRef(new FunctionExecutable(exec, name, source, forceUsesArguments, parameters, firstLine, lastLine));
     248        }
     249
     250        static PassRefPtr<FunctionExecutable> create(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
     251        {
     252            return adoptRef(new FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, firstLine, lastLine));
    227253        }
    228254
     
    264290
    265291    private:
    266         FunctionExecutable(const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
    267             : ScriptExecutable(source)
     292        FunctionExecutable(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
     293            : ScriptExecutable(globalData, source)
    268294            , m_forceUsesArguments(forceUsesArguments)
    269295            , m_parameters(parameters)
     
    276302        }
    277303
     304        FunctionExecutable(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, int firstLine, int lastLine)
     305            : ScriptExecutable(exec, source)
     306            , m_forceUsesArguments(forceUsesArguments)
     307            , m_parameters(parameters)
     308            , m_codeBlock(0)
     309            , m_name(name)
     310            , m_numVariables(0)
     311        {
     312            m_firstLine = firstLine;
     313            m_lastLine = lastLine;
     314        }
     315
    278316        void compile(ExecState*, ScopeChainNode*);
    279317
  • trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r47738 r48662  
    287287        return parsedObject;
    288288
    289     EvalExecutable eval(makeSource(s));
     289    EvalExecutable eval(exec, makeSource(s));
    290290    JSObject* error = eval.compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node());
    291291    if (error)
Note: See TracChangeset for help on using the changeset viewer.