Changeset 151651 in webkit


Ignore:
Timestamp:
Jun 17, 2013 11:54:34 AM (11 years ago)
Author:
mark.lam@apple.com
Message:

Rolling r151456, r151420 back in with some fixes.
https://bugs.webkit.org/show_bug.cgi?id=117390.

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

New changes on top of the old patch:

  • Renamed CallFrame::beginAt() to CallFrame::find(), and also provide a version that takes a CallFrame* to search for.

There are 3 types of users of the StackIterator. We need to cater
to each of these as follows:

  1. Users who want a stack trace
    • Here we need to start iterating from vm.topCallFrame.
    • To do this, create the StackIterator as follows:

StackIterator iter = vm.topCallFrame->begin();

  1. Users who want their caller frame
    • Here we need to start iterating from the specified CallFrame*.
    • To do this, create the StackIterator as follows:

StackIterator iter = callFrame->begin();

  1. Users who want the frame of a specific JSFunction object
    • Here we need to start iterating from vm.topCallFrame and find the frame that has a callee matching the specified JSFunction*.
    • To do this, create the StackIterator as follows:

StackIterator iter = exec->find(functionObj);

The previous layout test failures were due to conflation of case 1
and 2. They are now handled appropriately.

  • Fixed a pre-existing layout test crash in inspector/profiler/cpu-profiler-agent-crash-on-start.html.
  • API/JSContextRef.cpp:

(JSContextCreateBacktrace):

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
  • JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • interpreter/CallFrame.cpp:
  • interpreter/CallFrame.h:

(JSC::ExecState::setInlineCallFrame):
(ExecState):

  • interpreter/CallFrameInlines.h:

(JSC::CallFrame::begin):
(JSC::CallFrame::find):
(JSC::CallFrame::end):

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::dumpRegisters):
(JSC::Interpreter::unwindCallFrame):
(JSC::Interpreter::getStackTrace):
(JSC::Interpreter::throwException):
(JSC::Interpreter::debug):

  • interpreter/Interpreter.h:

(Interpreter):

  • interpreter/StackIterator.cpp: Added.

(JSC::StackIterator::StackIterator):
(JSC::StackIterator::gotoNextFrame):
(JSC::StackIterator::find):
(JSC::StackIterator::Frame::codeType):
(JSC::StackIterator::Frame::functionName):
(JSC::StackIterator::Frame::sourceURL):
(JSC::StackIterator::Frame::toString):
(JSC::StackIterator::Frame::bytecodeOffset):
(JSC::StackIterator::Frame::line):
(JSC::StackIterator::Frame::column):
(JSC::StackIterator::Frame::arguments):
(JSC::StackIterator::Frame::retrieveExpressionInfo):
(JSC::StackIterator::Frame::logicalFrame):
(JSC::StackIterator::Frame::logicalCallerFrame):
(JSC::jitTypeName):
(JSC::printIndents):
(JSC::printif):
(JSC::StackIterator::Frame::print):
(debugPrintCallFrame):

  • interpreter/StackIterator.h: Added.

(StackIterator::Frame):
(JSC::StackIterator::Frame::create):
(JSC::StackIterator::Frame::isJSFrame):
(JSC::StackIterator::Frame::callFrame):

  • interpreter/StackIteratorPrivate.h: Added.

(StackIterator):
(JSC::StackIterator::operator*):
(JSC::StackIterator::operator->):
(JSC::StackIterator::operator==):
(JSC::StackIterator::operator!=):
(JSC::StackIterator::operator++):
(JSC::StackIterator::end):

  • jsc.cpp:

(functionJSCStack):

  • profiler/ProfileGenerator.cpp:

(JSC::ProfileGenerator::addParentForConsoleStart):

  • profiler/ProfileNode.h:

(ProfileNode):

  • runtime/JSFunction.cpp:

(JSC::retrieveArguments):
(JSC::JSFunction::argumentsGetter):
(JSC::skipOverBoundFunctions):
(JSC::retrieveCallerFunction):
(JSC::JSFunction::callerGetter):
(JSC::JSFunction::getOwnPropertyDescriptor):
(JSC::JSFunction::defineOwnProperty):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::globalFuncProtoGetter):
(JSC::globalFuncProtoSetter):

  • runtime/ObjectConstructor.cpp:

(JSC::objectConstructorGetPrototypeOf):

  • runtime/Operations.h:

Source/WebCore:

No new tests.

  • ForwardingHeaders/interpreter/StackIterator.h: Copied from Source/WebCore/ForwardingHeaders/interpreter/StackIterator.h.
  • bindings/js/JSXMLHttpRequestCustom.cpp:

(WebCore::JSXMLHttpRequest::send):

  • bindings/js/ScriptCallStackFactory.cpp:

(WebCore::createScriptCallStack):

Location:
branches/dfgFourthTier/Source
Files:
4 added
24 edited

Legend:

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

    r151500 r151651  
    3131#include "InitializeThreading.h"
    3232#include <interpreter/CallFrame.h>
    33 #include <interpreter/Interpreter.h>
    3433#include "JSCallbackObject.h"
    3534#include "JSClassRef.h"
     
    3837#include "Operations.h"
    3938#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     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();
     208    CallFrame* frame = exec->vm().topCallFrame;
     209    size_t i = 0;
     210    ASSERT(maxStackSize);
     211    for (StackIterator iter = frame->begin(); iter != frame->end() && maxStackSize--; ++iter, ++i) {
     212        JSObject* callee = iter->callee();
     213        // If callee is unknown, but we've not added any frame yet, we should
     214        // still add the frame, because something called us, and gave us arguments.
     215        if (!callee && i)
     216            break;
     217
    225218        if (!builder.isEmpty())
    226219            builder.append('\n');
     
    228221        builder.appendNumber(i);
    229222        builder.append(' ');
    230         builder.append(stackTrace[i].friendlyFunctionName(exec));
     223        builder.append(iter->functionName());
    231224        builder.appendLiteral("() at ");
    232         builder.append(stackTrace[i].friendlySourceURL());
    233         if (frame.codeType != StackFrameNativeCode) {
     225        builder.append(iter->sourceURL());
     226        if (iter->isJSFrame()) {
    234227            builder.append(':');
    235             builder.appendNumber(lineNumber);
     228            builder.appendNumber(iter->line());
    236229        }
    237         if (!function)
     230
     231        if (!callee)
    238232            break;
    239233    }
  • branches/dfgFourthTier/Source/JavaScriptCore/CMakeLists.txt

    r151500 r151651  
    164164    interpreter/Interpreter.cpp
    165165    interpreter/JSStack.cpp
     166    interpreter/StackIterator.cpp
    166167    interpreter/VMInspector.cpp
    167168
  • branches/dfgFourthTier/Source/JavaScriptCore/ChangeLog

    r151649 r151651  
     12013-06-17  Mark Lam  <mark.lam@apple.com>
     2
     3        Rolling r151456, r151420 back in with some fixes.
     4        https://bugs.webkit.org/show_bug.cgi?id=117390.
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        New changes on top of the old patch:
     9        - Renamed CallFrame::beginAt() to CallFrame::find(), and also provide
     10          a version that takes a CallFrame* to search for.
     11
     12          There are 3 types of users of the StackIterator. We need to cater
     13          to each of these as follows:
     14
     15          1. Users who want a stack trace
     16             - Here we need to start iterating from vm.topCallFrame.
     17             - To do this, create the StackIterator as follows:
     18                  StackIterator iter = vm.topCallFrame->begin();
     19
     20          2. Users who want their caller frame
     21             - Here we need to start iterating from the specified CallFrame*.
     22             - To do this, create the StackIterator as follows:
     23                  StackIterator iter = callFrame->begin();
     24
     25          3. Users who want the frame of a specific JSFunction object
     26             - Here we need to start iterating from vm.topCallFrame and find
     27               the frame that has a callee matching the specified JSFunction*.
     28             - To do this, create the StackIterator as follows:
     29                  StackIterator iter = exec->find(functionObj);
     30
     31          The previous layout test failures were due to conflation of case 1
     32          and 2. They are now handled appropriately.
     33
     34        - Fixed a pre-existing layout test crash in
     35          inspector/profiler/cpu-profiler-agent-crash-on-start.html.
     36
     37        * API/JSContextRef.cpp:
     38        (JSContextCreateBacktrace):
     39        * CMakeLists.txt:
     40        * GNUmakefile.list.am:
     41        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
     42        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
     43        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
     44        * JavaScriptCore.xcodeproj/project.pbxproj:
     45        * Target.pri:
     46        * interpreter/CallFrame.cpp:
     47        * interpreter/CallFrame.h:
     48        (JSC::ExecState::setInlineCallFrame):
     49        (ExecState):
     50        * interpreter/CallFrameInlines.h:
     51        (JSC::CallFrame::begin):
     52        (JSC::CallFrame::find):
     53        (JSC::CallFrame::end):
     54        * interpreter/Interpreter.cpp:
     55        (JSC::Interpreter::dumpRegisters):
     56        (JSC::Interpreter::unwindCallFrame):
     57        (JSC::Interpreter::getStackTrace):
     58        (JSC::Interpreter::throwException):
     59        (JSC::Interpreter::debug):
     60        * interpreter/Interpreter.h:
     61        (Interpreter):
     62        * interpreter/StackIterator.cpp: Added.
     63        (JSC::StackIterator::StackIterator):
     64        (JSC::StackIterator::gotoNextFrame):
     65        (JSC::StackIterator::find):
     66        (JSC::StackIterator::Frame::codeType):
     67        (JSC::StackIterator::Frame::functionName):
     68        (JSC::StackIterator::Frame::sourceURL):
     69        (JSC::StackIterator::Frame::toString):
     70        (JSC::StackIterator::Frame::bytecodeOffset):
     71        (JSC::StackIterator::Frame::line):
     72        (JSC::StackIterator::Frame::column):
     73        (JSC::StackIterator::Frame::arguments):
     74        (JSC::StackIterator::Frame::retrieveExpressionInfo):
     75        (JSC::StackIterator::Frame::logicalFrame):
     76        (JSC::StackIterator::Frame::logicalCallerFrame):
     77        (JSC::jitTypeName):
     78        (JSC::printIndents):
     79        (JSC::printif):
     80        (JSC::StackIterator::Frame::print):
     81        (debugPrintCallFrame):
     82        * interpreter/StackIterator.h: Added.
     83        (StackIterator::Frame):
     84        (JSC::StackIterator::Frame::create):
     85        (JSC::StackIterator::Frame::isJSFrame):
     86        (JSC::StackIterator::Frame::callFrame):
     87        * interpreter/StackIteratorPrivate.h: Added.
     88        (StackIterator):
     89        (JSC::StackIterator::operator*):
     90        (JSC::StackIterator::operator->):
     91        (JSC::StackIterator::operator==):
     92        (JSC::StackIterator::operator!=):
     93        (JSC::StackIterator::operator++):
     94        (JSC::StackIterator::end):
     95        * jsc.cpp:
     96        (functionJSCStack):
     97        * profiler/ProfileGenerator.cpp:
     98        (JSC::ProfileGenerator::addParentForConsoleStart):
     99        * profiler/ProfileNode.h:
     100        (ProfileNode):
     101        * runtime/JSFunction.cpp:
     102        (JSC::retrieveArguments):
     103        (JSC::JSFunction::argumentsGetter):
     104        (JSC::skipOverBoundFunctions):
     105        (JSC::retrieveCallerFunction):
     106        (JSC::JSFunction::callerGetter):
     107        (JSC::JSFunction::getOwnPropertyDescriptor):
     108        (JSC::JSFunction::defineOwnProperty):
     109        * runtime/JSGlobalObjectFunctions.cpp:
     110        (JSC::globalFuncProtoGetter):
     111        (JSC::globalFuncProtoSetter):
     112        * runtime/ObjectConstructor.cpp:
     113        (JSC::objectConstructorGetPrototypeOf):
     114        * runtime/Operations.h:
     115
    11162013-06-17  Filip Pizlo  <fpizlo@apple.com>
    2117
  • branches/dfgFourthTier/Source/JavaScriptCore/GNUmakefile.list.am

    r151500 r151651  
    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 \
    436439        Source/JavaScriptCore/interpreter/VMInspector.cpp \
    437440        Source/JavaScriptCore/interpreter/VMInspector.h \
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r151500 r151651  
    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
    24252437                                RelativePath="..\..\interpreter\VMInspector.cpp"
    24262438                                >
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj

    r151500 r151651  
    223223    <ClCompile Include="..\interpreter\Interpreter.cpp" />
    224224    <ClCompile Include="..\interpreter\JSStack.cpp" />
     225    <ClCompile Include="..\interpreter\StackIterator.cpp" />
    225226    <ClCompile Include="..\interpreter\VMInspector.cpp" />
    226227    <ClCompile Include="..\jit\ClosureCallStubRoutine.cpp" />
     
    555556    <ClInclude Include="..\interpreter\JSStackInlines.h" />
    556557    <ClInclude Include="..\interpreter\Register.h" />
     558    <ClInclude Include="..\interpreter\StackIterator.h" />
     559    <ClInclude Include="..\interpreter\StackIteratorPrivate.h" />
    557560    <ClInclude Include="..\interpreter\VMInspector.h" />
    558561    <ClInclude Include="..\jit\ClosureCallStubRoutine.h" />
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters

    r151500 r151651  
    286286      <Filter>interpreter</Filter>
    287287    </ClCompile>
     288    <ClCompile Include="..\interpreter\StackIterator.cpp">
     289      <Filter>interpreter</Filter>
     290    </ClCompile>
    288291    <ClCompile Include="..\interpreter\VMInspector.cpp">
    289292      <Filter>interpreter</Filter>
     
    12101213    </ClInclude>
    12111214    <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">
    12121221      <Filter>interpreter</Filter>
    12131222    </ClInclude>
  • branches/dfgFourthTier/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r151649 r151651  
    955955                FE4A331F15BD2E07006F54F3 /* VMInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */; };
    956956                FE4A332015BD2E07006F54F3 /* VMInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = FE4A331E15BD2E07006F54F3 /* VMInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
     957                FE526BD517663A8400B120DC /* StackIteratorPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = FE526BD417663A8400B120DC /* StackIteratorPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
     958                FE67DB9317519B4A006A814F /* JSStackInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FE67DB9017519B4A006A814F /* JSStackInlines.h */; };
     959                FE67DB9417519B4A006A814F /* StackIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE67DB9117519B4A006A814F /* StackIterator.cpp */; };
     960                FE67DB9517519B4A006A814F /* StackIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = FE67DB9217519B4A006A814F /* StackIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    957961                FE940322174442590047CF6E /* JITStubsX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = FE940321174442590047CF6E /* JITStubsX86Common.h */; settings = {ATTRIBUTES = (Private, ); }; };
    958962                FECE74571745456500FF9300 /* MacroAssemblerX86Common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FECE74561745456500FF9300 /* MacroAssemblerX86Common.cpp */; };
     
    19921996                FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VMInspector.cpp; sourceTree = "<group>"; };
    19931997                FE4A331E15BD2E07006F54F3 /* VMInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VMInspector.h; sourceTree = "<group>"; };
     1998                FE526BD417663A8400B120DC /* StackIteratorPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackIteratorPrivate.h; sourceTree = "<group>"; };
     1999                FE67DB9017519B4A006A814F /* JSStackInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStackInlines.h; sourceTree = "<group>"; };
     2000                FE67DB9117519B4A006A814F /* StackIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StackIterator.cpp; sourceTree = "<group>"; };
     2001                FE67DB9217519B4A006A814F /* StackIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StackIterator.h; sourceTree = "<group>"; };
    19942002                FE940321174442590047CF6E /* JITStubsX86Common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubsX86Common.h; sourceTree = "<group>"; };
    19952003                FECE74561745456500FF9300 /* MacroAssemblerX86Common.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerX86Common.cpp; sourceTree = "<group>"; };
     
    22832291                                1429D85B0ED218E900B89619 /* JSStack.cpp */,
    22842292                                14D792640DAA03FB001A9F05 /* JSStack.h */,
     2293                                FE67DB9017519B4A006A814F /* JSStackInlines.h */,
    22852294                                149B24FF0D8AF6D1009CB8C7 /* Register.h */,
     2295                                FE67DB9117519B4A006A814F /* StackIterator.cpp */,
     2296                                FE67DB9217519B4A006A814F /* StackIterator.h */,
     2297                                FE526BD417663A8400B120DC /* StackIteratorPrivate.h */,
    22862298                                FE4A331D15BD2E07006F54F3 /* VMInspector.cpp */,
    22872299                                FE4A331E15BD2E07006F54F3 /* VMInspector.h */,
     
    32643276                                0F63945515D07057006A597C /* ArrayProfile.h in Headers */,
    32653277                                BC18C3E70E16F5CD00B34460 /* ArrayPrototype.h in Headers */,
     3278                                FE67DB9517519B4A006A814F /* StackIterator.h in Headers */,
     3279                                FE526BD517663A8400B120DC /* StackIteratorPrivate.h in Headers */,
    32663280                                FEF6835F174343CC00A32E25 /* JITStubsARMv7.h in Headers */,
    32673281                                FE24596217601D580074FCE0 /* CallFrameInlines.h in Headers */,
     
    36973711                                14DF04DA16B3996D0016A513 /* StaticPropertyAnalysis.h in Headers */,
    36983712                                14CA958B16AB50DE00938A06 /* StaticPropertyAnalyzer.h in Headers */,
     3713                                FE67DB9317519B4A006A814F /* JSStackInlines.h in Headers */,
    36993714                                A730B6121250068F009D25B1 /* StrictEvalActivation.h in Headers */,
    37003715                                BC18C4660E16F5CD00B34460 /* StringConstructor.h in Headers */,
     
    42304245                                86DB64640F95C6FC00D7D921 /* ExecutableAllocatorFixedVMPool.cpp in Sources */,
    42314246                                0F56A1D515001CF4002992B1 /* ExecutionCounter.cpp in Sources */,
     4247                                FE67DB9417519B4A006A814F /* StackIterator.cpp in Sources */,
    42324248                                0FB105851675480F00F8AB6E /* ExitKind.cpp in Sources */,
    42334249                                0FDB2CCF1742D7D8007B3C1B /* FTLJITFinalizer.cpp in Sources */,
  • branches/dfgFourthTier/Source/JavaScriptCore/Target.pri

    r151500 r151651  
    171171    interpreter/Interpreter.cpp \
    172172    interpreter/JSStack.cpp \
     173    interpreter/StackIterator.cpp \
    173174    jit/ClosureCallStubRoutine.cpp \
    174175    jit/ExecutableAllocatorFixedVMPool.cpp \
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r151500 r151651  
    6868   
    6969#if ENABLE(DFG_JIT)
    70 CallFrame* 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        
    133 CallFrame* 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 
    16270unsigned CallFrame::bytecodeOffsetFromCodeOriginIndex()
    16371{
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/CallFrame.h

    r151548 r151651  
    2929#include "MacroAssemblerCodeRef.h"
    3030#include "Register.h"
     31#include "StackIteratorPrivate.h"
    3132
    3233namespace JSC  {
     
    274275#if ENABLE(DFG_JIT)
    275276        void setInlineCallFrame(InlineCallFrame* inlineCallFrame) { static_cast<Register*>(this)[JSStack::ReturnPC] = inlineCallFrame; }
    276 
    277         // Call this to get the semantically correct JS CallFrame* for the
    278         // currently executing function.
    279         CallFrame* trueCallFrame();
    280 
    281         // Call this to get the semantically correct JS CallFrame* corresponding
    282         // to the caller. This resolves issues surrounding inlining and the
    283         // HostCallFrameFlag stuff.
    284         CallFrame* trueCallerFrame();
    285 #else
    286         CallFrame* trueCallFrame() { return this; }
    287         CallFrame* trueCallerFrame() { return callerFrame()->removeHostCallFrameFlag(); }
    288277#endif
    289278        CallFrame* callerFrameNoFlags() { return callerFrame()->removeHostCallFrameFlag(); }
     279
     280        inline StackIterator begin(StackIterator::FrameFilter = nullptr);
     281        inline StackIterator find(JSFunction* calleeFunctionObj, StackIterator::FrameFilter = nullptr);
     282        inline StackIterator::Frame* end();
    290283
    291284    private:
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/CallFrameInlines.h

    r151329 r151651  
    169169}
    170170
     171inline StackIterator CallFrame::begin(StackIterator::FrameFilter filter)
     172{
     173    ASSERT(this);
     174    return StackIterator(this, filter);
     175}
     176
     177inline StackIterator CallFrame::find(JSFunction* calleeFunctionObj, StackIterator::FrameFilter filter)
     178{
     179    ASSERT(this);
     180    StackIterator iter = StackIterator(this, filter);
     181    iter.find(calleeFunctionObj);
     182    return iter;
     183}
     184
     185inline StackIterator::Frame* CallFrame::end()
     186{
     187    return StackIterator::end();
     188}
     189
    171190} // namespace JSC
    172191
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r151500 r151651  
    6464#include "Register.h"
    6565#include "SamplingTool.h"
     66#include "StackIterator.h"
    6667#include "StrictEvalActivation.h"
    6768#include "StrongInlines.h"
     
    201202
    202203
    203 static CallFrame* getCallerInfo(VM*, CallFrame*, unsigned& bytecodeOffset, CodeBlock*& callerOut);
    204 
    205204JSValue eval(CallFrame* callFrame)
    206205{
     
    411410        dataLogF("[ReturnJITPC]              | %10p | %p \n", it, pc.jitReturnAddress().value());
    412411#endif
    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);
    419     ++it;
     412    StackIterator iter = callFrame->begin();
     413    ++iter;
     414    if (iter != callFrame->end()) {
     415        dataLogF("[ReturnVPC]                | %10p | %d (line %d)\n", it, iter->bytecodeOffset(), iter->line());
     416        ++it;
     417    }
    420418    dataLogF("[CodeBlock]                | %10p | %p \n", it, callFrame->codeBlock());
    421419    ++it;
     
    466464}
    467465
    468 NEVER_INLINE bool Interpreter::unwindCallFrame(CallFrame*& callFrame, JSValue exceptionValue, unsigned& bytecodeOffset, CodeBlock*& codeBlock)
    469 {
     466NEVER_INLINE bool Interpreter::unwindCallFrame(StackIterator& iter, JSValue exceptionValue)
     467{
     468    CallFrame* callFrame = iter->callFrame();
     469    CodeBlock* codeBlock = iter->codeBlock();
    470470    CodeBlock* oldCodeBlock = codeBlock;
    471471    JSScope* scope = callFrame->scope();
     
    497497    CallFrame* callerFrame = callFrame->callerFrame();
    498498    callFrame->vm().topCallFrame = callerFrame;
    499     if (callerFrame->hasHostCallFrameFlag())
    500         return false;
    501     callFrame = getCallerInfo(&callFrame->vm(), callFrame, bytecodeOffset, codeBlock);
    502     return true;
     499    return !callerFrame->hasHostCallFrameFlag();
    503500}
    504501
     
    555552}
    556553
    557 static 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 
    572 static 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 
    597 static ALWAYS_INLINE const String getSourceURLFromCallFrame(CallFrame* callFrame)
    598 {
    599     ASSERT(!callFrame->hasHostCallFrameFlag());
    600     return callFrame->codeBlock()->ownerExecutable()->sourceURL();
    601 }
    602 
    603 static 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 
    619554unsigned StackFrame::line()
    620555{
     
    663598    VM& vm = m_vm;
    664599    CallFrame* callFrame = vm.topCallFrame->removeHostCallFrameFlag();
    665     if (!callFrame || callFrame == CallFrame::noCaller())
    666         return;
    667     unsigned bytecodeOffset = getBytecodeOffsetForCallFrame(callFrame);
    668     callFrame = callFrame->trueCallFrame();
    669600    if (!callFrame)
    670601        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);
     602
     603    StackIterator iter = callFrame->begin();
     604    for (; iter != callFrame->end() && maxStackSize--; ++iter) {
     605        CodeBlock* codeBlock = iter->codeBlock();
     606        if (codeBlock) {
     607            StackFrame s(Strong<JSObject>(vm, iter->callee()),
     608                StackFrameCodeType(iter->codeType()),
     609                Strong<ExecutableBase>(vm, codeBlock->ownerExecutable()),
     610                Strong<UnlinkedCodeBlock>(vm, codeBlock->unlinkedCodeBlock()),
     611                codeBlock->source(),
     612                codeBlock->ownerExecutable()->lineNo(),
     613                codeBlock->sourceOffset(),
     614                iter->bytecodeOffset(),
     615                iter->sourceURL());
    686616            results.append(s);
    687617        } else {
    688             StackFrame s(Strong<JSObject>(vm, callFrame->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, String());
     618            StackFrame s(Strong<JSObject>(vm, iter->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, String());
    689619            results.append(s);
    690620        }
    691         callFrame = getCallerInfo(&vm, callFrame, bytecodeOffset, callerCodeBlock);
    692621    }
    693622}
     
    765694    // Calculate an exception handler vPC, unwinding call frames as necessary.
    766695    HandlerInfo* handler = 0;
    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         }
     696    VM& vm = callFrame->vm();
     697    ASSERT(callFrame == vm.topCallFrame);
     698    for (StackIterator iter = callFrame->begin(); iter != callFrame->end(); ++iter) {
     699        callFrame = iter->callFrame();
     700        codeBlock = iter->codeBlock();
     701        bytecodeOffset = iter->bytecodeOffset();
     702
     703        if (isTermination || !(handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset))) {
     704            if (!unwindCallFrame(iter, exceptionValue)) {
     705                if (LegacyProfiler* profiler = vm.enabledProfiler())
     706                    profiler->exceptionUnwind(callFrame);
     707                return 0;
     708            }
     709        } else
     710            break;
    773711    }
    774712
     
    13691307            return;
    13701308    }
    1371 }
    1372    
    1373 JSValue 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 
    1384 JSValue 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 
    1414 CallFrame* 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 }
     1309}   
    14221310
    14231311void Interpreter::enableSampler()
  • branches/dfgFourthTier/Source/JavaScriptCore/interpreter/Interpreter.h

    r151500 r151651  
    5757    class JSScope;
    5858    class SamplingTool;
     59    class StackIterator;
    5960    struct CallFrameClosure;
    6061    struct HandlerInfo;
     
    236237        JSValue execute(EvalExecutable*, CallFrame*, JSValue thisValue, JSScope*);
    237238
    238         JSValue retrieveArgumentsFromVMCode(CallFrame*, JSFunction*) const;
    239         JSValue retrieveCallerFromVMCode(CallFrame*, JSFunction*) const;
    240        
    241239        void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
    242240       
     
    245243        NEVER_INLINE HandlerInfo* throwException(CallFrame*&, JSValue&, unsigned bytecodeOffset);
    246244        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());
    249245        static void addStackTraceIfNecessary(CallFrame*, JSValue error);
    250246
     
    272268        JSValue execute(CallFrameClosure&);
    273269
    274         NEVER_INLINE bool unwindCallFrame(CallFrame*&, JSValue, unsigned& bytecodeOffset, CodeBlock*&);
    275 
    276         static CallFrame* findFunctionCallFrameFromVMCode(CallFrame*, JSFunction*);
     270        void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max());
     271        NEVER_INLINE bool unwindCallFrame(StackIterator&, JSValue);
    277272
    278273        void dumpRegisters(CallFrame*);
  • branches/dfgFourthTier/Source/JavaScriptCore/jsc.cpp

    r151500 r151651  
    11/*
    22 *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012 Apple Inc. All rights reserved.
     3 *  Copyright (C) 2004, 2005, 2006, 2007, 2008, 2012, 2013 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"
    4142#include "StructureRareDataInlines.h"
    4243#include <math.h>
     
    327328    trace.appendLiteral("--> Stack trace:\n");
    328329
    329     Vector<StackFrame> stackTrace;
    330     exec->interpreter()->getStackTrace(stackTrace);
     330    CallFrame* frame = exec->vm().topCallFrame;
    331331    int i = 0;
    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     }
     332    for (StackIterator iter = frame->begin(); iter != frame->end(); ++iter, ++i)
     333        trace.append(String::format("    %i   %s\n", i, iter->toString().utf8().data()));
    338334    fprintf(stderr, "%s", trace.toString().utf8().data());
    339335    return JSValue::encode(jsUndefined());
  • branches/dfgFourthTier/Source/JavaScriptCore/profiler/ProfileGenerator.cpp

    r151500 r151651  
    3232#include "JSStringRef.h"
    3333#include "JSFunction.h"
    34 #include "Interpreter.h"
    3534#include "LegacyProfiler.h"
    3635#include "Operations.h"
    3736#include "Profile.h"
     37#include "StackIterator.h"
    3838#include "Tracing.h"
    3939
     
    5959void ProfileGenerator::addParentForConsoleStart(ExecState* exec)
    6060{
    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());
     61    StackIterator iter = exec->begin();
     62    ++iter;
     63    CallIdentifier identifier = (iter == exec->end())
     64        ? LegacyProfiler::createCallIdentifier(exec, JSValue(), String(), 0)
     65        : LegacyProfiler::createCallIdentifier(exec, iter->callee(), iter->sourceURL(), iter->line());
     66    m_currentNode = ProfileNode::create(exec, identifier, m_head.get(), m_head.get());
     67   
    6568    m_head->insertNode(m_currentNode.get());
    6669}
  • branches/dfgFourthTier/Source/JavaScriptCore/profiler/ProfileNode.h

    r151500 r151651  
    4141    class ProfileNode;
    4242
    43     typedef Vector<RefPtr<ProfileNode> >::const_iterator StackIterator;
    4443    typedef HashCountedSet<StringImpl*> FunctionCallHashCount;
    4544
     
    132131
    133132    private:
     133        typedef Vector<RefPtr<ProfileNode> >::const_iterator StackIterator;
     134
    134135        ProfileNode(ExecState* callerCallFrame, const CallIdentifier&, ProfileNode* headNode, ProfileNode* parentNode);
    135136        ProfileNode(ExecState* callerCallFrame, ProfileNode* headNode, ProfileNode* nodeToCopy);
  • branches/dfgFourthTier/Source/JavaScriptCore/runtime/JSFunction.cpp

    r151500 r151651  
    2626#include "JSFunction.h"
    2727
     28#include "Arguments.h"
    2829#include "CodeBlock.h"
    2930#include "CommonIdentifiers.h"
     
    3334#include "GetterSetter.h"
    3435#include "JSArray.h"
     36#include "JSBoundFunction.h"
    3537#include "JSGlobalObject.h"
    3638#include "JSNotAnObject.h"
     
    4143#include "Parser.h"
    4244#include "PropertyNameArray.h"
     45#include "StackIterator.h"
    4346
    4447using namespace WTF;
     
    179182}
    180183
     184static JSValue retrieveArguments(ExecState* exec, JSFunction* functionObj)
     185{
     186    StackIterator iter = exec->find(functionObj);
     187    return iter != exec->end() ? JSValue(iter->arguments()) : jsNull();
     188}
     189
    181190JSValue JSFunction::argumentsGetter(ExecState* exec, JSValue slotBase, PropertyName)
    182191{
    183192    JSFunction* thisObj = jsCast<JSFunction*>(slotBase);
    184193    ASSERT(!thisObj->isHostFunction());
    185     return exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObj);
     194
     195    return retrieveArguments(exec, thisObj);
     196}
     197
     198static 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
     205static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj)
     206{
     207    StackIterator iter = exec->find(functionObj, skipOverBoundFunctions);
     208    if (iter != exec->end())
     209        ++iter;
     210    return iter != exec->end() && iter->callee() ? iter->callee() : jsNull();
    186211}
    187212
     
    190215    JSFunction* thisObj = jsCast<JSFunction*>(slotBase);
    191216    ASSERT(!thisObj->isHostFunction());
    192     JSValue caller = exec->interpreter()->retrieveCallerFromVMCode(exec, thisObj);
     217    JSValue caller = retrieveCallerFunction(exec, thisObj);
    193218
    194219    // See ES5.1 15.3.5.4 - Function.caller may not be used to retrieve a strict caller.
     
    298323            return result;
    299324        }
    300         descriptor.setDescriptor(exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete);
     325        descriptor.setDescriptor(retrieveArguments(exec, thisObject), ReadOnly | DontEnum | DontDelete);
    301326        return true;
    302327    }
     
    322347            return result;
    323348        }
    324         descriptor.setDescriptor(exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject), ReadOnly | DontEnum | DontDelete);
     349        descriptor.setDescriptor(retrieveCallerFunction(exec, thisObject), ReadOnly | DontEnum | DontDelete);
    325350        return true;
    326351    }
     
    416441            return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
    417442        }
    418         valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveArgumentsFromVMCode(exec, thisObject));
     443        valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveArguments(exec, thisObject));
    419444    } else if (propertyName == exec->propertyNames().caller) {
    420445        if (thisObject->jsExecutable()->isStrictMode()) {
     
    423448            return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
    424449        }
    425         valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), exec->interpreter()->retrieveCallerFromVMCode(exec, thisObject));
     450        valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveCallerFunction(exec, thisObject));
    426451    } else if (propertyName == exec->propertyNames().length)
    427452        valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), jsNumber(thisObject->jsExecutable()->parameterCount()));
  • branches/dfgFourthTier/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r151500 r151651  
    3737#include "Operations.h"
    3838#include "Parser.h"
     39#include "StackIterator.h"
    3940#include <wtf/dtoa.h>
    4041#include <stdio.h>
     
    712713        return JSValue::encode(exec->thisValue().synthesizePrototype(exec));
    713714
    714     if (!thisObject->allowsAccessFrom(exec->trueCallerFrame()))
     715    StackIterator iter = exec->begin();
     716    ++iter;
     717    if ((iter == exec->end()) || !thisObject->allowsAccessFrom(iter->callFrame()))
    715718        return JSValue::encode(jsUndefined());
    716719
     
    728731        return JSValue::encode(jsUndefined());
    729732
    730     if (!thisObject->allowsAccessFrom(exec->trueCallerFrame()))
     733    StackIterator iter = exec->begin();
     734    ++iter;
     735    if ((iter == exec->end()) || !thisObject->allowsAccessFrom(iter->callFrame()))
    731736        return JSValue::encode(jsUndefined());
    732737
  • branches/dfgFourthTier/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

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

    r151569 r151651  
    2323#define Operations_h
    2424
     25#include "CallFrameInlines.h"
    2526#include "ExceptionHelpers.h"
    2627#include "Interpreter.h"
  • branches/dfgFourthTier/Source/WebCore/ChangeLog

    r151618 r151651  
     12013-06-14  Mark Lam  <mark.lam@apple.com>
     2
     3        Rolling r151456, r151420 back in with some fixes.
     4        https://bugs.webkit.org/show_bug.cgi?id=117390.
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        No new tests.
     9
     10        * ForwardingHeaders/interpreter/StackIterator.h: Copied from Source/WebCore/ForwardingHeaders/interpreter/StackIterator.h.
     11        * bindings/js/JSXMLHttpRequestCustom.cpp:
     12        (WebCore::JSXMLHttpRequest::send):
     13        * bindings/js/ScriptCallStackFactory.cpp:
     14        (WebCore::createScriptCallStack):
     15
    1162013-06-15  Filip Pizlo  <fpizlo@apple.com>
    217
  • branches/dfgFourthTier/Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp

    r151500 r151651  
    4848#include "JSEventListener.h"
    4949#include "XMLHttpRequest.h"
     50#include <interpreter/StackIterator.h>
    5051#include <runtime/Error.h>
    51 #include <interpreter/Interpreter.h>
    5252#include <wtf/ArrayBuffer.h>
    5353
     
    134134    }
    135135
    136     Vector<StackFrame> stackTrace(2);
    137     exec->interpreter()->getStackTrace(stackTrace, 2);
    138     impl()->setLastSendLineNumber(stackTrace[1].line());
    139     impl()->setLastSendURL(stackTrace[1].sourceURL);
     136    StackIterator iter = exec->begin();
     137    ++iter;
     138    if (iter != exec->end()) {
     139        impl()->setLastSendLineNumber(iter->line());
     140        impl()->setLastSendURL(iter->sourceURL());
     141    } else {
     142        impl()->setLastSendLineNumber(0);
     143        impl()->setLastSendURL(String());
     144    }
    140145
    141146    setDOMException(exec, ec);
  • branches/dfgFourthTier/Source/WebCore/bindings/js/ScriptCallStackFactory.cpp

    r151500 r151651  
    4141#include "ScriptValue.h"
    4242#include <interpreter/CallFrame.h>
    43 #include <interpreter/Interpreter.h>
     43#include <interpreter/StackIterator.h>
    4444#include <runtime/ArgList.h>
    4545#include <runtime/JSCJSValue.h>
     
    5858    Vector<ScriptCallFrame> frames;
    5959    if (JSC::ExecState* exec = JSMainThreadExecState::currentState()) {
    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()));
     60        ASSERT(exec);
     61        CallFrame* frame = exec->vm().topCallFrame;
     62        for (StackIterator iter = frame->begin(); iter != frame->end() && maxStackSize--; ++iter)
     63            frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), iter->line(), iter->column()));
    6464    }
    6565    if (frames.isEmpty() && !emptyIsAllowed) {
     
    7575{
    7676    Vector<ScriptCallFrame> frames;
    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++) {
     77    ASSERT(exec);
     78    CallFrame* frame = exec->vm().topCallFrame;
     79    StackIterator iter = frame->begin();
     80    for (++iter; iter != frame->end() && maxStackSize--; ++iter) {
    8081        // This early exit is necessary to maintain our old behaviour
    8182        // but the stack trace we produce now is complete and handles all
    8283        // ways in which code may be running
    83         if (!stackTrace[i].callee && frames.size())
     84        if (!iter->callee() && frames.size())
    8485            break;
    85 
    86         String functionName = stackTrace[i].friendlyFunctionName(exec);
    87         frames.append(ScriptCallFrame(functionName, stackTrace[i].sourceURL, stackTrace[i].line(), stackTrace[i].column()));
     86        frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), iter->line(), iter->column()));
    8887    }
    89 
    9088    return ScriptCallStack::create(frames);
    9189}
Note: See TracChangeset for help on using the changeset viewer.