Changeset 34182 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
May 28, 2008, 1:47:13 PM (17 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2008-05-27 Geoffrey Garen <[email protected]>

Reviewed by Tim Hatcher.

Fixed https://bugs.webkit.org/show_bug.cgi?id=19183
REGRESSION (r33979): Crash in DebuggerCallFrame::functionName when
clicking button in returnEvent-crash.html

Added two new debugger hooks, willExecuteProgram and didExecuteProgram,
along with code to generate them, code to invoke them when unwinding
due to an exception, and code to dump them.


SunSpider reports no change.

  • VM/CodeBlock.cpp: (KJS::debugHookName): I had to mark this function NEVER_INLINE to avoid a .4% performance regression. The mind boggles.

WebCore:

2008-05-27 Geoffrey Garen <[email protected]>

Reviewed by Tim Hatcher.

Fixed https://bugs.webkit.org/show_bug.cgi?id=19183
REGRESSION (r33979): Crash in DebuggerCallFrame::functionName when
clicking button in returnEvent-crash.html


Added implementations for willExecuteProgram and didExecuteProgram. They
take care to update our call frame when entering and exiting programs,
preventing us from keeping around a stale global frame after executing
a program.


eval programs now show up as "anonymous function" in a new scope. This
is slightly better than what they used to do -- overwriting the current
scope -- but obviously we can do better.

WebKit/mac:

2008-05-27 Geoffrey Garen <[email protected]>

Reviewed by Tim Hatcher.


Fixed https://bugs.webkit.org/show_bug.cgi?id=19183
REGRESSION (r33979): Crash in DebuggerCallFrame::functionName when
clicking button in returnEvent-crash.html


Added implementations for willExecuteProgram and didExecuteProgram, which
take care of making sure we're not hanging on to stale data.

Location:
trunk/JavaScriptCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r34180 r34182  
     12008-05-27  Geoffrey Garen  <[email protected]>
     2
     3        Reviewed by Tim Hatcher.
     4
     5        Fixed https://bugs.webkit.org/show_bug.cgi?id=19183
     6        REGRESSION (r33979): Crash in DebuggerCallFrame::functionName when
     7        clicking button in returnEvent-crash.html
     8
     9        Added two new debugger hooks, willExecuteProgram and didExecuteProgram,
     10        along with code to generate them, code to invoke them when unwinding
     11        due to an exception, and code to dump them.
     12       
     13        SunSpider reports no change.
     14
     15        * VM/CodeBlock.cpp:
     16        (KJS::debugHookName): I had to mark this function NEVER_INLINE to avoid
     17        a .4% performance regression. The mind boggles.
     18
    1192008-05-28  Adam Roben  <[email protected]>
    220
  • trunk/JavaScriptCore/VM/CodeBlock.cpp

    r34157 r34182  
    9696}
    9797
    98 static const char* debugHookName(int debugHookID)
    99 {
    100     if (debugHookID == DidEnterCallFrame)
     98NEVER_INLINE static const char* debugHookName(int debugHookID)
     99{
     100    switch((DebugHookID)debugHookID) {
     101    case DidEnterCallFrame:
    101102        return "didEnterCallFrame";
    102     else if (debugHookID == WillLeaveCallFrame)
     103    case WillLeaveCallFrame:
    103104        return "willLeaveCallFrame";
    104     else {
    105         ASSERT(debugHookID == WillExecuteStatement);
     105    case WillExecuteStatement:
    106106        return "willExecuteStatement";
    107     }
     107    case WillExecuteProgram:
     108        return "willExecuteProgram";
     109    case DidExecuteProgram:
     110        return "didExecuteProgram";
     111    }
     112   
     113    ASSERT_NOT_REACHED();
     114    return "";
    108115}
    109116
  • trunk/JavaScriptCore/VM/Machine.cpp

    r34172 r34182  
    565565{
    566566    CodeBlock* oldCodeBlock = codeBlock;
    567 
     567    Register* callFrame = r - oldCodeBlock->numLocals - CallFrameHeaderSize;
     568   
    568569    if (Debugger* debugger = exec->dynamicGlobalObject()->debugger()) {
    569         if (!isGlobalCallFrame(registerBase, r)) {
    570             DebuggerCallFrame debuggerCallFrame(this, exec->dynamicGlobalObject(), codeBlock, scopeChain, exceptionValue, registerBase, r - *registerBase);
     570        DebuggerCallFrame debuggerCallFrame(this, exec->dynamicGlobalObject(), codeBlock, scopeChain, exceptionValue, registerBase, r - *registerBase);
     571        if (!isGlobalCallFrame(registerBase, r) && callFrame[Callee].u.jsObject) // Check for global and eval code
    571572            debugger->returnEvent(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->ownerNode->lastLine());
    572         }
    573     }
    574 
    575     Register* callFrame = r - oldCodeBlock->numLocals - CallFrameHeaderSize;
    576    
     573        else
     574            debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerNode->sourceId(), codeBlock->ownerNode->lastLine());
     575    }
     576
    577577    if (Profiler* profiler = *Profiler::enabledProfilerReference()) {
    578578        if (!isGlobalCallFrame(registerBase, r) && callFrame[Callee].u.jsObject) // Check for global and eval code
     
    850850    case WillExecuteStatement: {
    851851        debugger->atStatement(debuggerCallFrame, codeBlock->ownerNode->sourceId(), firstLine);
     852        return;
     853    }
     854    case WillExecuteProgram: {
     855        debugger->willExecuteProgram(debuggerCallFrame, codeBlock->ownerNode->sourceId(), lastLine);
     856        return;
     857    }
     858    case DidExecuteProgram: {
     859        debugger->didExecuteProgram(debuggerCallFrame, codeBlock->ownerNode->sourceId(), firstLine);
    852860        return;
    853861    }
     
    23522360        /* debug debugHookID(n) firstLine(n) lastLine(n)
    23532361         
    2354          Notifies the debugger of the current state of execution:
    2355          didEnterCallFrame; willLeaveCallFrame; or willExecuteStatement.
    2356          
    2357          This opcode is only generated while the debugger is attached.
     2362         Notifies the debugger of the current state of execution. This opcode
     2363         is only generated while the debugger is attached.
    23582364        */
    23592365
  • trunk/JavaScriptCore/VM/Machine.h

    r33979 r34182  
    4848   
    4949    enum DebugHookID {
    50         WillExecuteStatement,
     50        WillExecuteProgram,
     51        DidExecuteProgram,
    5152        DidEnterCallFrame,
    52         WillLeaveCallFrame
     53        WillLeaveCallFrame,
     54        WillExecuteStatement
    5355    };
    5456
  • trunk/JavaScriptCore/kjs/debugger.h

    r33979 r34182  
    165165    virtual void returnEvent(const DebuggerCallFrame&, int sourceId, int lineno) = 0;
    166166
     167    virtual void willExecuteProgram(const DebuggerCallFrame&, int sourceId, int lineno) = 0;
     168    virtual void didExecuteProgram(const DebuggerCallFrame&, int sourceId, int lineno) = 0;
     169
    167170  private:
    168171    HashSet<JSGlobalObject*> m_globalObjects;
  • trunk/JavaScriptCore/kjs/nodes.cpp

    r34177 r34182  
    58265826RegisterID* EvalNode::emitCode(CodeGenerator& generator, RegisterID*)
    58275827{
     5828    generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine());
     5829
    58285830    RefPtr<RegisterID> dstRegister = generator.newTemporary();
    58295831    generator.emitLoad(dstRegister.get(), jsUndefined());
    58305832    statementListEmitCode(m_children, generator, dstRegister.get());
     5833
     5834    generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine());
    58315835    generator.emitEnd(dstRegister.get());
    58325836    return 0;
     
    59025906RegisterID* ProgramNode::emitCode(CodeGenerator& generator, RegisterID*)
    59035907{
     5908    generator.emitDebugHook(WillExecuteProgram, firstLine(), lastLine());
     5909
    59045910    RefPtr<RegisterID> dstRegister = generator.newTemporary();
    59055911    generator.emitLoad(dstRegister.get(), jsUndefined());
    59065912    statementListEmitCode(m_children, generator, dstRegister.get());
     5913
     5914    generator.emitDebugHook(DidExecuteProgram, firstLine(), lastLine());
    59075915    generator.emitEnd(dstRegister.get());
    59085916    return 0;
Note: See TracChangeset for help on using the changeset viewer.