Changeset 151500 in webkit


Ignore:
Timestamp:
Jun 12, 2013 8:03:37 AM (11 years ago)
Author:
mark.lam@apple.com
Message:

Unreviewed, rolled out r151456, r151420:

<http://trac.webkit.org/changeset/151420>

Source/JavaScriptCore:

It causes layout test failures.

Source/WebCore:

It causes layout test failures.

Location:
branches/dfgFourthTier/Source
Files:
4 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • branches/dfgFourthTier/Source/JavaScriptCore/API/JSContextRef.cpp

    r151420 r151500  
    3131#include "InitializeThreading.h"
    3232#include <interpreter/CallFrame.h>
     33#include <interpreter/Interpreter.h>
    3334#include "JSCallbackObject.h"
    3435#include "JSClassRef.h"
     
    3738#include "Operations.h"
    3839#include "SourceProvider.h"
    39 #include "StackIterator.h"
    4040#include <wtf/text/StringBuilder.h>
    4141#include <wtf/text/StringHash.h>
     
    206206    JSLockHolder lock(exec);
    207207    StringBuilder builder;
    208     size_t i = 0;
    209     ASSERT(maxStackSize);
    210     for (StackIterator iter = exec->begin(); iter != exec->end() && maxStackSize--; ++iter, ++i) {
    211         JSObject* callee = iter->callee();
    212         // If callee is unknown, but we've not added any frame yet, we should
    213         // still add the frame, because something called us, and gave us arguments.
    214         if (!callee && i)
    215             break;
    216 
     208    Vector<StackFrame> stackTrace;
     209    exec->interpreter()->getStackTrace(stackTrace, maxStackSize);
     210
     211    for (size_t i = 0; i < stackTrace.size(); i++) {
     212        String urlString;
     213        String functionName;
     214        StackFrame& frame = stackTrace[i];
     215        JSValue function = frame.callee.get();
     216        if (frame.callee)
     217            functionName = frame.friendlyFunctionName(exec);
     218        else {
     219            // Caller is unknown, but if frame is empty we should still add the frame, because
     220            // something called us, and gave us arguments.
     221            if (i)
     222                break;
     223        }
     224        unsigned lineNumber = frame.line();
    217225        if (!builder.isEmpty())
    218226            builder.append('\n');
     
    220228        builder.appendNumber(i);
    221229        builder.append(' ');
    222         builder.append(iter->functionName());
     230        builder.append(stackTrace[i].friendlyFunctionName(exec));
    223231        builder.appendLiteral("() at ");
    224         builder.append(iter->sourceURL());
    225         if (iter->isJSFrame()) {
     232        builder.append(stackTrace[i].friendlySourceURL());
     233        if (frame.codeType != StackFrameNativeCode) {
    226234            builder.append(':');
    227             builder.appendNumber(iter->line());
     235            builder.appendNumber(lineNumber);
    228236        }
    229 
    230         if (!callee)
     237        if (!function)
    231238            break;
    232239    }
  • branches/dfgFourthTier/Source/JavaScriptCore/CMakeLists.txt

    r151420 r151500  
    164164    interpreter/Interpreter.cpp
    165165    interpreter/JSStack.cpp
    166     interpreter/StackIterator.cpp
    167166    interpreter/VMInspector.cpp
    168167
  • branches/dfgFourthTier/Source/JavaScriptCore/ChangeLog

    r151481 r151500  
     12013-06-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Unreviewed, rolled out r151456, r151420:
     4            <http://trac.webkit.org/changeset/151420>
     5
     6        It causes layout test failures.
     7
    182013-06-11  Geoffrey Garen  <ggaren@apple.com>
    29
  • branches/dfgFourthTier/Source/JavaScriptCore/GNUmakefile.list.am

    r151481 r151500  
    434434        Source/JavaScriptCore/interpreter/JSStackInlines.h \
    435435        Source/JavaScriptCore/interpreter/Register.h \
    436         Source/JavaScriptCore/interpreter/StackIterator.cpp \
    437         Source/JavaScriptCore/interpreter/StackIterator.h \
    438         Source/JavaScriptCore/interpreter/StackIteratorPrivate.h \
    439436        Source/JavaScriptCore/interpreter/VMInspector.cpp \
    440437        Source/JavaScriptCore/interpreter/VMInspector.h \
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r151481 r151500  
    24232423                        </File>
    24242424                        <File
    2425                                 RelativePath="..\..\interpreter\StackIterator.cpp"
    2426                                 >
    2427                         </File>
    2428                         <File
    2429                                 RelativePath="..\..\interpreter\StackIterator.h"
    2430                                 >
    2431                         </File>
    2432                         <File
    2433                                 RelativePath="..\..\interpreter\StackIteratorPrivate.h"
    2434                                 >
    2435                         </File>
    2436                         <File
    24372425                                RelativePath="..\..\interpreter\VMInspector.cpp"
    24382426                                >
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r151481 r151500  
    223223    <ClCompile Include="..\interpreter\Interpreter.cpp" />
    224224    <ClCompile Include="..\interpreter\JSStack.cpp" />
    225     <ClCompile Include="..\interpreter\StackIterator.cpp" />
    226225    <ClCompile Include="..\interpreter\VMInspector.cpp" />
    227226    <ClCompile Include="..\jit\ClosureCallStubRoutine.cpp" />
     
    556555    <ClInclude Include="..\interpreter\JSStackInlines.h" />
    557556    <ClInclude Include="..\interpreter\Register.h" />
    558     <ClInclude Include="..\interpreter\StackIterator.h" />
    559     <ClInclude Include="..\interpreter\StackIteratorPrivate.h" />
    560557    <ClInclude Include="..\interpreter\VMInspector.h" />
    561558    <ClInclude Include="..\jit\ClosureCallStubRoutine.h" />
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r151481 r151500  
    286286      <Filter>interpreter</Filter>
    287287    </ClCompile>
    288     <ClCompile Include="..\interpreter\StackIterator.cpp">
    289       <Filter>interpreter</Filter>
    290     </ClCompile>
    291288    <ClCompile Include="..\interpreter\VMInspector.cpp">
    292289      <Filter>interpreter</Filter>
     
    12131210    </ClInclude>
    12141211    <ClInclude Include="..\interpreter\Register.h">
    1215       <Filter>interpreter</Filter>
    1216     </ClInclude>
    1217     <ClInclude Include="..\interpreter\StackIterator.h">
    1218       <Filter>interpreter</Filter>
    1219     </ClInclude>
    1220     <ClInclude Include="..\interpreter\StackIteratorPrivate.h">
    12211212      <Filter>interpreter</Filter>
    12221213    </ClInclude>
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r151481 r151500  
    953953                FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */; };
    954954                FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4A331E15BD2E07006F54F3 /* VMInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
    955                 FE526BD517663A8400B120DC /* StackIteratorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = FE526BD417663A8400B120DC /* StackIteratorPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    956                 FE67DB9317519B4A006A814F /* JSStackInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FE67DB9017519B4A006A814F /* JSStackInlines.h */; };
    957                 FE67DB9417519B4A006A814F /* StackIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE67DB9117519B4A006A814F /* StackIterator.cpp */; };
    958                 FE67DB9517519B4A006A814F /* StackIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE67DB9217519B4A006A814F /* StackIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    959955                FE940322174442590047CF6E /* JITStubsX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = FE940321174442590047CF6E /* JITStubsX86Common.h */; settings = {ATTRIBUTES = (Private, ); }; };
    960956                FECE74571745456500FF9300 /* MacroAssemblerX86Common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FECE74561745456500FF9300 /* MacroAssemblerX86Common.cpp */; };
     
    19911987                FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMInspector.cpp; sourceTree = "<group>"; };
    19921988                FE4A331E15BD2E07006F54F3 /* VMInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInspector.h; sourceTree = "<group>"; };
    1993                 FE526BD417663A8400B120DC /* StackIteratorPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackIteratorPrivate.h; sourceTree = "<group>"; };
    1994                 FE67DB9017519B4A006A814F /* JSStackInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStackInlines.h; sourceTree = "<group>"; };
    1995                 FE67DB9117519B4A006A814F /* StackIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackIterator.cpp; sourceTree = "<group>"; };
    1996                 FE67DB9217519B4A006A814F /* StackIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackIterator.h; sourceTree = "<group>"; };
    19971989                FE940321174442590047CF6E /* JITStubsX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubsX86Common.h; sourceTree = "<group>"; };
    19981990                FECE74561745456500FF9300 /* MacroAssemblerX86Common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerX86Common.cpp; sourceTree = "<group>"; };
     
    22852277                                1429D85B0ED218E900B89619 /* JSStack.cpp */,
    22862278                                14D792640DAA03FB001A9F05 /* JSStack.h */,
    2287                                 FE67DB9017519B4A006A814F /* JSStackInlines.h */,
    22882279                                149B24FF0D8AF6D1009CB8C7 /* Register.h */,
    2289                                 FE67DB9117519B4A006A814F /* StackIterator.cpp */,
    2290                                 FE67DB9217519B4A006A814F /* StackIterator.h */,
    2291                                 FE526BD417663A8400B120DC /* StackIteratorPrivate.h */,
    22922280                                FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */,
    22932281                                FE4A331E15BD2E07006F54F3 /* VMInspector.h */,
     
    32683256                                0F63945515D07057006A597C /* ArrayProfile.h in Headers */,
    32693257                                BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */,
    3270                                 FE67DB9517519B4A006A814F /* StackIterator.h in Headers */,
    3271                                 FE526BD517663A8400B120DC /* StackIteratorPrivate.h in Headers */,
    32723258                                FEF6835F174343CC00A32E25 /* JITStubsARMv7.h in Headers */,
    32733259                                FE24596217601D580074FCE0 /* CallFrameInlines.h in Headers */,
     
    37033689                                14DF04DA16B3996D0016A513 /* StaticPropertyAnalysis.h in Headers */,
    37043690                                14CA958B16AB50DE00938A06 /* StaticPropertyAnalyzer.h in Headers */,
    3705                                 FE67DB9317519B4A006A814F /* JSStackInlines.h in Headers */,
    37063691                                A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */,
    37073692                                BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */,
     
    42364221                                86DB64640F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp in Sources */,
    42374222                                0F56A1D515001CF4002992B1 /* ExecutionCounter.cpp in Sources */,
    4238                                 FE67DB9417519B4A006A814F /* StackIterator.cpp in Sources */,
    42394223                                0FB105851675480F00F8AB6E /* ExitKind.cpp in Sources */,
    42404224                                0FDB2CCF1742D7D8007B3C1B /* FTLJITFinalizer.cpp in Sources */,
  • branches/dfgFourthTier/Source/JavaScriptCore/Target.pri

    r151481 r151500  
    171171    interpreter/Interpreter.cpp \
    172172    interpreter/JSStack.cpp \
    173     interpreter/StackIterator.cpp \
    174173    jit/ClosureCallStubRoutine.cpp \
    175174    jit/ExecutableAllocatorFixedVMPool.cpp \
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r151420 r151500  
    6868   
    6969#if ENABLE(DFG_JIT)
     70CallFrame* CallFrame::trueCallFrame()
     71{
     72    // Am I an inline call frame? If so, we're done.
     73    if (isInlinedFrame())
     74        return this;
     75   
     76    // If I don't have a code block, then I'm not DFG code, so I'm the true call frame.
     77    CodeBlock* machineCodeBlock = codeBlock();
     78    if (!machineCodeBlock)
     79        return this;
     80   
     81    // If the code block does not have any code origins, then there was no inlining, so
     82    // I'm done.
     83    if (!machineCodeBlock->hasCodeOrigins())
     84        return this;
     85   
     86    // Try to determine the CodeOrigin. If we don't have a pc set then the only way
     87    // that this makes sense is if the CodeOrigin index was set in the call frame.
     88    CodeOrigin codeOrigin;
     89    unsigned index = locationAsCodeOriginIndex();
     90    ASSERT(machineCodeBlock->canGetCodeOrigin(index));
     91    if (!machineCodeBlock->canGetCodeOrigin(index)) {
     92        // See above. In release builds, we try to protect ourselves from crashing even
     93        // though stack walking will be goofed up.
     94        return 0;
     95    }
     96    codeOrigin = machineCodeBlock->codeOrigin(index);
     97
     98    if (!codeOrigin.inlineCallFrame)
     99        return this; // Not currently in inlined code.
     100
     101    CodeOrigin innerMostCodeOrigin = codeOrigin;
     102
     103    for (InlineCallFrame* inlineCallFrame = codeOrigin.inlineCallFrame; inlineCallFrame;) {
     104        InlineCallFrame* nextInlineCallFrame = inlineCallFrame->caller.inlineCallFrame;
     105       
     106        CallFrame* inlinedCaller = this + inlineCallFrame->stackOffset;
     107       
     108        JSFunction* calleeAsFunction = inlineCallFrame->callee.get();
     109       
     110        // Fill in the inlinedCaller
     111        inlinedCaller->setCodeBlock(inlineCallFrame->baselineCodeBlock());
     112        if (calleeAsFunction)
     113            inlinedCaller->setScope(calleeAsFunction->scope());
     114        if (nextInlineCallFrame)
     115            inlinedCaller->setCallerFrame(this + nextInlineCallFrame->stackOffset);
     116        else
     117            inlinedCaller->setCallerFrame(this);
     118       
     119        inlinedCaller->setInlineCallFrame(inlineCallFrame);
     120        inlinedCaller->setArgumentCountIncludingThis(inlineCallFrame->arguments.size());
     121        inlinedCaller->setLocationAsBytecodeOffset(codeOrigin.bytecodeIndex);
     122        inlinedCaller->setIsInlinedFrame();
     123        if (calleeAsFunction)
     124            inlinedCaller->setCallee(calleeAsFunction);
     125       
     126        codeOrigin = inlineCallFrame->caller;
     127        inlineCallFrame = nextInlineCallFrame;
     128    }
     129   
     130    return this + innerMostCodeOrigin.inlineCallFrame->stackOffset;
     131}
     132       
     133CallFrame* CallFrame::trueCallerFrame()
     134{
     135    CallFrame* callerFrame = this->callerFrame()->removeHostCallFrameFlag();
     136    if (!codeBlock())
     137        return callerFrame;
     138
     139    // this -> The callee; this is either an inlined callee in which case it already has
     140    //    a pointer to the true caller. Otherwise it contains current PC in the machine
     141    //    caller.
     142    //
     143    // machineCaller -> The caller according to the machine, which may be zero or
     144    //    more frames above the true caller due to inlining.
     145
     146    // Am I an inline call frame? If so, we're done.
     147    if (isInlinedFrame())
     148        return callerFrame;
     149   
     150    // I am a machine call frame, so the question is: is my caller a machine call frame
     151    // that has inlines or a machine call frame that doesn't?
     152    if (!callerFrame)
     153        return 0;
     154
     155    if (!callerFrame->codeBlock())
     156        return callerFrame;
     157    ASSERT(!callerFrame->isInlinedFrame());
     158   
     159    return callerFrame->trueCallFrame()->removeHostCallFrameFlag();
     160}
     161
    70162unsigned CallFrame::bytecodeOffsetFromCodeOriginIndex()
    71163{
     
    98190}
    99191
    100 StackIterator CallFrame::begin(StackIterator::FrameFilter filter)
    101 {
    102     if (!this)
    103         return StackIterator::empty();
    104 
    105     StackIterator iter(&vm());
    106     iter.beginAt(this, filter);
    107     return iter;
    108192}
    109 
    110 StackIterator CallFrame::beginAt(JSFunction* calleeFunctionObj, StackIterator::FrameFilter filter)
    111 {
    112     if (!this)
    113         return StackIterator::empty();
    114 
    115     StackIterator iter(&vm());
    116     iter.beginAt(calleeFunctionObj, filter);
    117     return iter;   
    118 }
    119 
    120 }
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/CallFrame.h

    r151420 r151500  
    2929#include "MacroAssemblerCodeRef.h"
    3030#include "Register.h"
    31 #include "StackIteratorPrivate.h"
    3231
    3332namespace JSC  {
     
    276275#if ENABLE(DFG_JIT)
    277276        void setInlineCallFrame(InlineCallFrame* inlineCallFrame) { static_cast<Register*>(this)[JSStack::ReturnPC] = inlineCallFrame; }
     277
     278        // Call this to get the semantically correct JS CallFrame* for the
     279        // currently executing function.
     280        CallFrame* trueCallFrame();
     281
     282        // Call this to get the semantically correct JS CallFrame* corresponding
     283        // to the caller. This resolves issues surrounding inlining and the
     284        // HostCallFrameFlag stuff.
     285        CallFrame* trueCallerFrame();
     286#else
     287        CallFrame* trueCallFrame() { return this; }
     288        CallFrame* trueCallerFrame() { return callerFrame()->removeHostCallFrameFlag(); }
    278289#endif
    279290        CallFrame* callerFrameNoFlags() { return callerFrame()->removeHostCallFrameFlag(); }
    280 
    281         JS_EXPORT_PRIVATE StackIterator begin(StackIterator::FrameFilter = nullptr);
    282         JS_EXPORT_PRIVATE StackIterator beginAt(JSFunction* calleeFunctionObj, StackIterator::FrameFilter = nullptr);
    283         JS_EXPORT_PRIVATE StackIterator::Frame* end() { return StackIterator::end(); }
    284291
    285292    private:
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r151481 r151500  
    6464#include "Register.h"
    6565#include "SamplingTool.h"
    66 #include "StackIterator.h"
    6766#include "StrictEvalActivation.h"
    6867#include "StrongInlines.h"
     
    202201
    203202
     203static CallFrame* getCallerInfo(VM*, CallFrame*, unsigned& bytecodeOffset, CodeBlock*& callerOut);
     204
    204205JSValue eval(CallFrame* callFrame)
    205206{
     
    410411        dataLogF("[ReturnJITPC]              | %10p | %p \n", it, pc.jitReturnAddress().value());
    411412#endif
    412     StackIterator iter = callFrame->begin();
    413     dataLogF("[ReturnVPC]                | %10p | %d (line %d)\n", it, iter->bytecodeOffset(), iter->line());
     413    unsigned bytecodeOffset = 0;
     414    int line = 0;
     415    CodeBlock* callerCodeBlock = 0;
     416    getCallerInfo(&callFrame->vm(), callFrame, bytecodeOffset, callerCodeBlock);
     417    line = callerCodeBlock->lineNumberForBytecodeOffset(bytecodeOffset);
     418    dataLogF("[ReturnVPC]                | %10p | %d (line %d)\n", it, bytecodeOffset, line);
    414419    ++it;
    415420    dataLogF("[CodeBlock]                | %10p | %p \n", it, callFrame->codeBlock());
     
    461466}
    462467
    463 NEVER_INLINE bool Interpreter::unwindCallFrame(StackIterator& iter, JSValue exceptionValue)
    464 {
    465     CallFrame* callFrame = iter->callFrame();
    466     CodeBlock* codeBlock = iter->codeBlock();
     468NEVER_INLINE bool Interpreter::unwindCallFrame(CallFrame*& callFrame, JSValue exceptionValue, unsigned& bytecodeOffset, CodeBlock*& codeBlock)
     469{
    467470    CodeBlock* oldCodeBlock = codeBlock;
    468471    JSScope* scope = callFrame->scope();
     
    494497    CallFrame* callerFrame = callFrame->callerFrame();
    495498    callFrame->vm().topCallFrame = callerFrame;
    496     return !callerFrame->hasHostCallFrameFlag();
     499    if (callerFrame->hasHostCallFrameFlag())
     500        return false;
     501    callFrame = getCallerInfo(&callFrame->vm(), callFrame, bytecodeOffset, codeBlock);
     502    return true;
    497503}
    498504
     
    549555}
    550556
     557static unsigned getBytecodeOffsetForCallFrame(CallFrame* callFrame)
     558{
     559    callFrame = callFrame->removeHostCallFrameFlag();
     560    CodeBlock* codeBlock = callFrame->codeBlock();
     561    if (!codeBlock)
     562        return 0;
     563#if ENABLE(JIT)
     564#if ENABLE(DFG_JIT)
     565    if (JITCode::isOptimizingJIT(codeBlock->jitType()))
     566        return codeBlock->codeOrigin(callFrame->locationAsCodeOriginIndex()).bytecodeIndex;
     567#endif
     568    return callFrame->locationAsBytecodeOffset();
     569#endif
     570}
     571
     572static CallFrame* getCallerInfo(VM* vm, CallFrame* callFrame, unsigned& bytecodeOffset, CodeBlock*& caller)
     573{
     574    UNUSED_PARAM(vm);
     575    bytecodeOffset = 0;
     576    ASSERT(!callFrame->hasHostCallFrameFlag());
     577    CallFrame* trueCallerFrame = callFrame->trueCallerFrame();
     578    ASSERT(!trueCallerFrame->hasHostCallFrameFlag());
     579
     580    if (trueCallerFrame == CallFrame::noCaller() || !trueCallerFrame || !trueCallerFrame->codeBlock()) {
     581        caller = 0;
     582        return trueCallerFrame;
     583    }
     584   
     585    CodeBlock* callerCodeBlock = trueCallerFrame->codeBlock();
     586#if ENABLE(DFG_JIT)
     587    if (trueCallerFrame->hasLocationAsCodeOriginIndex())
     588        bytecodeOffset = trueCallerFrame->bytecodeOffsetFromCodeOriginIndex();
     589    else
     590#endif // ENABLE(DFG_JIT)
     591        bytecodeOffset = trueCallerFrame->locationAsBytecodeOffset();
     592
     593    caller = callerCodeBlock;
     594    return trueCallerFrame;
     595}
     596
     597static ALWAYS_INLINE const String getSourceURLFromCallFrame(CallFrame* callFrame)
     598{
     599    ASSERT(!callFrame->hasHostCallFrameFlag());
     600    return callFrame->codeBlock()->ownerExecutable()->sourceURL();
     601}
     602
     603static StackFrameCodeType getStackFrameCodeType(CallFrame* callFrame)
     604{
     605    ASSERT(!callFrame->hasHostCallFrameFlag());
     606
     607    switch (callFrame->codeBlock()->codeType()) {
     608    case EvalCode:
     609        return StackFrameEvalCode;
     610    case FunctionCode:
     611        return StackFrameFunctionCode;
     612    case GlobalCode:
     613        return StackFrameGlobalCode;
     614    }
     615    RELEASE_ASSERT_NOT_REACHED();
     616    return StackFrameGlobalCode;
     617}
     618
    551619unsigned StackFrame::line()
    552620{
     
    594662{
    595663    VM& vm = m_vm;
    596     CallFrame* callFrame = vm.topCallFrame;
    597     StackIterator iter = callFrame->begin();
    598     for (; iter != callFrame->end() && maxStackSize--; ++iter) {
    599         CodeBlock* codeBlock = iter->codeBlock();
    600         if (codeBlock) {
    601             StackFrame s(Strong<JSObject>(vm, iter->callee()),
    602                 StackFrameCodeType(iter->codeType()),
    603                 Strong<ExecutableBase>(vm, codeBlock->ownerExecutable()),
    604                 Strong<UnlinkedCodeBlock>(vm, codeBlock->unlinkedCodeBlock()),
    605                 codeBlock->source(),
    606                 codeBlock->ownerExecutable()->lineNo(),
    607                 codeBlock->sourceOffset(),
    608                 iter->bytecodeOffset(),
    609                 iter->sourceURL());
     664    CallFrame* callFrame = vm.topCallFrame->removeHostCallFrameFlag();
     665    if (!callFrame || callFrame == CallFrame::noCaller())
     666        return;
     667    unsigned bytecodeOffset = getBytecodeOffsetForCallFrame(callFrame);
     668    callFrame = callFrame->trueCallFrame();
     669    if (!callFrame)
     670        return;
     671    CodeBlock* callerCodeBlock = callFrame->codeBlock();
     672
     673    while (callFrame && callFrame != CallFrame::noCaller() && maxStackSize--) {
     674        String sourceURL;
     675        if (callerCodeBlock) {
     676            sourceURL = getSourceURLFromCallFrame(callFrame);
     677            StackFrame s(Strong<JSObject>(vm, callFrame->callee()),
     678                getStackFrameCodeType(callFrame),
     679                Strong<ExecutableBase>(vm, callerCodeBlock->ownerExecutable()),
     680                Strong<UnlinkedCodeBlock>(vm, callerCodeBlock->unlinkedCodeBlock()),
     681                callerCodeBlock->source(),
     682                callerCodeBlock->ownerExecutable()->lineNo(),
     683                callerCodeBlock->sourceOffset(),
     684                bytecodeOffset,
     685                sourceURL);
    610686            results.append(s);
    611687        } else {
    612             StackFrame s(Strong<JSObject>(vm, iter->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, String());
     688            StackFrame s(Strong<JSObject>(vm, callFrame->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, String());
    613689            results.append(s);
    614690        }
     691        callFrame = getCallerInfo(&vm, callFrame, bytecodeOffset, callerCodeBlock);
    615692    }
    616693}
     
    688765    // Calculate an exception handler vPC, unwinding call frames as necessary.
    689766    HandlerInfo* handler = 0;
    690     VM& vm = callFrame->vm();
    691     for (StackIterator iter = callFrame->begin(); iter != callFrame->end(); ++iter) {
    692         callFrame = iter->callFrame();
    693         codeBlock = iter->codeBlock();
    694         bytecodeOffset = iter->bytecodeOffset();
    695 
    696         if (isTermination || !(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) {
    697             if (!unwindCallFrame(iter, exceptionValue)) {
    698                 if (LegacyProfiler* profiler = vm.enabledProfiler())
    699                     profiler->exceptionUnwind(callFrame);
    700                 return 0;
    701             }
    702         } else
    703             break;
     767    while (isTermination || !(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) {
     768        if (!unwindCallFrame(callFrame, exceptionValue, bytecodeOffset, codeBlock)) {
     769            if (LegacyProfiler* profiler = callFrame->vm().enabledProfiler())
     770                profiler->exceptionUnwind(callFrame);
     771            return 0;
     772        }
    704773    }
    705774
     
    13001369            return;
    13011370    }
    1302 }   
     1371}
     1372   
     1373JSValue Interpreter::retrieveArgumentsFromVMCode(CallFrame* callFrame, JSFunction* function) const
     1374{
     1375    CallFrame* functionCallFrame = findFunctionCallFrameFromVMCode(callFrame, function);
     1376    if (!functionCallFrame)
     1377        return jsNull();
     1378
     1379    Arguments* arguments = Arguments::create(functionCallFrame->vm(), functionCallFrame);
     1380    arguments->tearOff(functionCallFrame);
     1381    return JSValue(arguments);
     1382}
     1383
     1384JSValue Interpreter::retrieveCallerFromVMCode(CallFrame* callFrame, JSFunction* function) const
     1385{
     1386    CallFrame* functionCallFrame = findFunctionCallFrameFromVMCode(callFrame, function);
     1387
     1388    if (!functionCallFrame)
     1389        return jsNull();
     1390   
     1391    unsigned bytecodeOffset;
     1392    CodeBlock* unusedCallerCodeBlock = 0;
     1393    CallFrame* callerFrame = getCallerInfo(&callFrame->vm(), functionCallFrame, bytecodeOffset, unusedCallerCodeBlock);
     1394    if (!callerFrame)
     1395        return jsNull();
     1396    JSValue caller = callerFrame->callee();
     1397    if (!caller)
     1398        return jsNull();
     1399
     1400    // Skip over function bindings.
     1401    ASSERT(caller.isObject());
     1402    while (asObject(caller)->inherits(&JSBoundFunction::s_info)) {
     1403        callerFrame = getCallerInfo(&callFrame->vm(), callerFrame, bytecodeOffset, unusedCallerCodeBlock);
     1404        if (!callerFrame)
     1405            return jsNull();
     1406        caller = callerFrame->callee();
     1407        if (!caller)
     1408            return jsNull();
     1409    }
     1410
     1411    return caller;
     1412}
     1413
     1414CallFrame* Interpreter::findFunctionCallFrameFromVMCode(CallFrame* callFrame, JSFunction* function)
     1415{
     1416    for (CallFrame* candidate = callFrame->trueCallFrame(); candidate; candidate = candidate->trueCallerFrame()) {
     1417        if (candidate->callee() == function)
     1418            return candidate;
     1419    }
     1420    return 0;
     1421}
    13031422
    13041423void Interpreter::enableSampler()
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/Interpreter.h

    r151420 r151500  
    5757    class JSScope;
    5858    class SamplingTool;
    59     class StackIterator;
    6059    struct CallFrameClosure;
    6160    struct HandlerInfo;
     
    237236        JSValue execute(EvalExecutable*, CallFrame*, JSValue thisValue, JSScope*);
    238237
     238        JSValue retrieveArgumentsFromVMCode(CallFrame*, JSFunction*) const;
     239        JSValue retrieveCallerFromVMCode(CallFrame*, JSFunction*) const;
     240       
    239241        void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
    240242       
     
    243245        NEVER_INLINE HandlerInfo* throwException(CallFrame*&, JSValue&, unsigned bytecodeOffset);
    244246        NEVER_INLINE void debug(CallFrame*, DebugHookID, int firstLine, int lastLine, int column);
     247        static const String getTraceLine(CallFrame*, StackFrameCodeType, const String&, int);
     248        JS_EXPORT_PRIVATE void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max());
    245249        static void addStackTraceIfNecessary(CallFrame*, JSValue error);
    246250
     
    268272        JSValue execute(CallFrameClosure&);
    269273
    270         void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max());
    271         NEVER_INLINE bool unwindCallFrame(StackIterator&, JSValue);
     274        NEVER_INLINE bool unwindCallFrame(CallFrame*&, JSValue, unsigned& bytecodeOffset, CodeBlock*&);
     275
     276        static CallFrame* findFunctionCallFrameFromVMCode(CallFrame*, JSFunction*);
    272277
    273278        void dumpRegisters(CallFrame*);
  • branches/dfgFourthTier/Source/JavaScriptCore/jsc.cpp

    r151420 r151500  
    11/*
    22 *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012, 2013 Apple Inc. All rights reserved.
     3 *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserved.
    44 *  Copyright (C) 2006 Bjoern Graf (bjoern.graf@gmail.com)
    55 *
     
    3939#include "Operations.h"
    4040#include "SamplingTool.h"
    41 #include "StackIterator.h"
    4241#include "StructureRareDataInlines.h"
    4342#include <math.h>
     
    328327    trace.appendLiteral("--> Stack trace:\n");
    329328
     329    Vector<StackFrame> stackTrace;
     330    exec->interpreter()->getStackTrace(stackTrace);
    330331    int i = 0;
    331     for (StackIterator iter = exec->begin(); iter != exec->end(); ++iter, ++i)
    332         trace.append(String::format("    %i   %s\n", i, iter->toString().utf8().data()));
     332
     333    for (Vector<StackFrame>::iterator iter = stackTrace.begin(); iter < stackTrace.end(); iter++) {
     334        StackFrame level = *iter;
     335        trace.append(String::format("    %i   %s\n", i, level.toString(exec).utf8().data()));
     336        i++;
     337    }
    333338    fprintf(stderr, "%s", trace.toString().utf8().data());
    334339    return JSValue::encode(jsUndefined());
  • branches/dfgFourthTier/Source/JavaScriptCore/profiler/ProfileGenerator.cpp

    r151420 r151500  
    3232#include "JSStringRef.h"
    3333#include "JSFunction.h"
     34#include "Interpreter.h"
    3435#include "LegacyProfiler.h"
    3536#include "Operations.h"
    3637#include "Profile.h"
    37 #include "StackIterator.h"
    3838#include "Tracing.h"
    3939
     
    5959void ProfileGenerator::addParentForConsoleStart(ExecState* exec)
    6060{
    61     StackIterator iter = exec->begin();
    62     ++iter;
    63     CallIdentifier identifier = LegacyProfiler::createCallIdentifier(exec, iter->callee(), iter->sourceURL(), iter->line());
    64     m_currentNode = ProfileNode::create(exec, identifier, m_head.get(), m_head.get());
    65    
     61    Vector<StackFrame> stackTrace;
     62    exec->interpreter()->getStackTrace(stackTrace, 2);
     63
     64    m_currentNode = ProfileNode::create(exec, LegacyProfiler::createCallIdentifier(exec, stackTrace[1].callee.get(), stackTrace[1].sourceURL, stackTrace[1].line()), m_head.get(), m_head.get());
    6665    m_head->insertNode(m_currentNode.get());
    6766}
  • branches/dfgFourthTier/Source/JavaScriptCore/profiler/ProfileNode.h

    r151420 r151500  
    4141    class ProfileNode;
    4242
     43    typedef Vector<RefPtr<ProfileNode> >::const_iterator StackIterator;
    4344    typedef HashCountedSet<StringImpl*> FunctionCallHashCount;
    4445
     
    131132
    132133    private:
    133         typedef Vector<RefPtr<ProfileNode> >::const_iterator StackIterator;
    134 
    135134        ProfileNode(ExecState* callerCallFrame, const CallIdentifier&, ProfileNode* headNode, ProfileNode* parentNode);
    136135        ProfileNode(ExecState* callerCallFrame, ProfileNode* headNode, ProfileNode* nodeToCopy);
  • branches/dfgFourthTier/Source/JavaScriptCore/runtime/JSFunction.cpp

    r151420 r151500  
    2626#include "JSFunction.h"
    2727
    28 #include "Arguments.h"
    2928#include "CodeBlock.h"
    3029#include "CommonIdentifiers.h"
     
    3433#include "GetterSetter.h"
    3534#include "JSArray.h"
    36 #include "JSBoundFunction.h"
    3735#include "JSGlobalObject.h"
    3836#include "JSNotAnObject.h"
     
    4341#include "Parser.h"
    4442#include "PropertyNameArray.h"
    45 #include "StackIterator.h"
    4643
    4744using namespace WTF;
     
    182179}
    183180
    184 static JSValue retrieveArguments(ExecState* exec, JSFunction* functionObj)
    185 {
    186     StackIterator iter = exec->beginAt(functionObj);
    187     return iter != exec->end() ? JSValue(iter->arguments()) : jsNull();
    188 }
    189 
    190181JSValue JSFunction::argumentsGetter(ExecState* exec, JSValue slotBase, PropertyName)
    191182{
    192183    JSFunction* thisObj = jsCast<JSFunction*>(slotBase);
    193184    ASSERT(!thisObj->isHostFunction());
    194 
    195     return retrieveArguments(exec, thisObj);
    196 }
    197 
    198 static bool skipOverBoundFunctions(StackIterator::Frame* frame)
    199 {
    200     JSObject* callee = frame->callee();
    201     bool shouldSkip = callee ? callee->inherits(&JSBoundFunction::s_info) : false;
    202     return shouldSkip;
    203 }
    204 
    205 static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj)
    206 {
    207     StackIterator iter = exec->beginAt(functionObj, skipOverBoundFunctions);
    208     ++iter;
    209     return iter != exec->end() && iter->callee() ? iter->callee() : jsNull();
     185    return exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObj);
    210186}
    211187
     
    214190    JSFunction* thisObj = jsCast<JSFunction*>(slotBase);
    215191    ASSERT(!thisObj->isHostFunction());
    216     JSValue caller = retrieveCallerFunction(exec, thisObj);
     192    JSValue caller = exec->interpreter()->retrieveCallerFromVMCode(exec, thisObj);
    217193
    218194    // See ES5.1 15.3.5.4 - Function.caller may not be used to retrieve a strict caller.
     
    322298            return result;
    323299        }
    324         descriptor.setDescriptor(retrieveArguments(exec, thisObject), ReadOnly | DontEnum | DontDelete);
     300        descriptor.setDescriptor(exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete);
    325301        return true;
    326302    }
     
    346322            return result;
    347323        }
    348         descriptor.setDescriptor(retrieveCallerFunction(exec, thisObject), ReadOnly | DontEnum | DontDelete);
     324        descriptor.setDescriptor(exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete);
    349325        return true;
    350326    }
     
    440416            return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
    441417        }
    442         valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveArguments(exec, thisObject));
     418        valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject));
    443419    } else if (propertyName == exec->propertyNames().caller) {
    444420        if (thisObject->jsExecutable()->isStrictMode()) {
     
    447423            return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
    448424        }
    449         valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveCallerFunction(exec, thisObject));
     425        valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject));
    450426    } else if (propertyName == exec->propertyNames().length)
    451427        valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), jsNumber(thisObject->jsExecutable()->parameterCount()));
  • branches/dfgFourthTier/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r151481 r151500  
    3737#include "Operations.h"
    3838#include "Parser.h"
    39 #include "StackIterator.h"
    4039#include <wtf/dtoa.h>
    4140#include <stdio.h>
     
    713712        return JSValue::encode(exec->thisValue().synthesizePrototype(exec));
    714713
    715     StackIterator iter = exec->begin();
    716     ++iter;
    717     if (!thisObject->allowsAccessFrom(iter->callFrame()))
     714    if (!thisObject->allowsAccessFrom(exec->trueCallerFrame()))
    718715        return JSValue::encode(jsUndefined());
    719716
     
    731728        return JSValue::encode(jsUndefined());
    732729
    733     StackIterator iter = exec->begin();
    734     ++iter;
    735     if (!thisObject->allowsAccessFrom(iter->callFrame()))
     730    if (!thisObject->allowsAccessFrom(exec->trueCallerFrame()))
    736731        return JSValue::encode(jsUndefined());
    737732
  • branches/dfgFourthTier/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r151420 r151500  
    3434#include "PropertyDescriptor.h"
    3535#include "PropertyNameArray.h"
    36 #include "StackIterator.h"
    3736
    3837namespace JSC {
     
    141140        return throwVMError(exec, createTypeError(exec, ASCIILiteral("Requested prototype of a value that is not an object.")));
    142141    JSObject* object = asObject(exec->argument(0));
    143     StackIterator iter = exec->begin();
    144     ++iter;
    145     if (!object->allowsAccessFrom(iter->callFrame()))
     142    if (!object->allowsAccessFrom(exec->trueCallerFrame()))
    146143        return JSValue::encode(jsUndefined());
    147144    return JSValue::encode(object->prototype());
  • branches/dfgFourthTier/Source/JavaScriptCore/runtime/Operations.h

    r151420 r151500  
    2323#define Operations_h
    2424
    25 #include "CallFrameInlines.h"
    2625#include "ExceptionHelpers.h"
    2726#include "Interpreter.h"
  • branches/dfgFourthTier/Source/WebCore/ChangeLog

    r151420 r151500  
     12013-06-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Unreviewed, rolled out r151456, r151420:
     4            <http://trac.webkit.org/changeset/151420>
     5
     6        It causes layout test failures.
     7
    182013-06-10  Mark Lam  <mark.lam@apple.com>
    29
  • branches/dfgFourthTier/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp

    r151420 r151500  
    4848#include "JSEventListener.h"
    4949#include "XMLHttpRequest.h"
    50 #include <interpreter/StackIterator.h>
    5150#include <runtime/Error.h>
     51#include <interpreter/Interpreter.h>
    5252#include <wtf/ArrayBuffer.h>
    5353
     
    134134    }
    135135
    136     StackIterator iter = exec->begin();
    137     ++iter;
    138     ASSERT(iter != exec->end());
    139     impl()->setLastSendLineNumber(iter->line());
    140     impl()->setLastSendURL(iter->sourceURL());   
     136    Vector<StackFrame> stackTrace(2);
     137    exec->interpreter()->getStackTrace(stackTrace, 2);
     138    impl()->setLastSendLineNumber(stackTrace[1].line());
     139    impl()->setLastSendURL(stackTrace[1].sourceURL);
    141140
    142141    setDOMException(exec, ec);
  • branches/dfgFourthTier/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp

    r151420 r151500  
    4141#include "ScriptValue.h"
    4242#include <interpreter/CallFrame.h>
    43 #include <interpreter/StackIterator.h>
     43#include <interpreter/Interpreter.h>
    4444#include <runtime/ArgList.h>
    4545#include <runtime/JSCJSValue.h>
     
    5858    Vector<ScriptCallFrame> frames;
    5959    if (JSC::ExecState* exec = JSMainThreadExecState::currentState()) {
    60         for (StackIterator iter = exec->begin(); iter != exec->end() && maxStackSize--; ++iter)
    61             frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), iter->line(), iter->column()));
     60        Vector<StackFrame> stackTrace;
     61        exec->interpreter()->getStackTrace(stackTrace, maxStackSize);
     62        for (size_t i = 0; i < stackTrace.size(); i++)
     63            frames.append(ScriptCallFrame(stackTrace[i].friendlyFunctionName(exec), stackTrace[i].friendlySourceURL(), stackTrace[i].line(), stackTrace[i].column()));
    6264    }
    6365    if (frames.isEmpty() && !emptyIsAllowed) {
     
    7375{
    7476    Vector<ScriptCallFrame> frames;
    75     StackIterator iter = exec->begin();
    76     for (++iter; iter != exec->end() && maxStackSize--; ++iter) {
     77    Vector<StackFrame> stackTrace;
     78    exec->interpreter()->getStackTrace(stackTrace, maxStackSize + 1);
     79    for (size_t i = stackTrace.size() == 1 ? 0 : 1; i < stackTrace.size(); i++) {
    7780        // This early exit is necessary to maintain our old behaviour
    7881        // but the stack trace we produce now is complete and handles all
    7982        // ways in which code may be running
    80         if (!iter->callee() && frames.size())
     83        if (!stackTrace[i].callee && frames.size())
    8184            break;
    82         frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), iter->line(), iter->column()));
     85
     86        String functionName = stackTrace[i].friendlyFunctionName(exec);
     87        frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, stackTrace[i].line(), stackTrace[i].column()));
    8388    }
     89
    8490    return ScriptCallStack::create(frames);
    8591}
Note: See TracChangeset for help on using the changeset viewer.