Changeset 235419 in webkit


Ignore:
Timestamp:
Aug 27, 2018, 10:01:05 PM (7 years ago)
Author:
mark.lam@apple.com
Message:

Fix exception throwing code so that topCallFrame and topEntryFrame stay true to their names.
https://bugs.webkit.org/show_bug.cgi?id=188577
<rdar://problem/42985684>

Reviewed by Saam Barati.

JSTests:

  • stress/regress-188577.js: Added.

Source/JavaScriptCore:

  1. Introduced CallFrame::convertToStackOverflowFrame() which converts the current (top) CallFrame (which may not have a valid callee) into a StackOverflowFrame.

The StackOverflowFrame is a sentinel frame that the low level code (exception
throwing code, stack visitor, and stack unwinding code) will know to skip
over. The StackOverflowFrame will also have a valid JSCallee so that client
code can compute the globalObject or VM from this frame.

As a result, client code that throws StackOverflowErrors no longer need to
compute the caller frame to throw from: it just converts the top frame into
a StackOverflowFrame and everything should *Just Work*.

  1. NativeCallFrameTracerWithRestore is now obsolete.

Instead, client code should always call convertToStackOverflowFrame() on the
frame before instantiating a NativeCallFrameTracer with it.

This means that topCallFrame will always point to the top CallFrame (which
may be a StackOverflowFrame), and topEntryFrame will always point to the top
EntryFrame. We'll never temporarily point them to the previous EntryFrame
(which we used to do with NativeCallFrameTracerWithRestore).

  1. genericUnwind() and Interpreter::unwind() will now always unwind from the top CallFrame, and will know how to handle a StackOverflowFrame if they see one.

This obsoletes the UnwindStart flag.

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • debugger/Debugger.cpp:

(JSC::Debugger::pauseIfNeeded):

  • interpreter/CallFrame.cpp:

(JSC::CallFrame::callerFrame const):
(JSC::CallFrame::unsafeCallerFrame const):
(JSC::CallFrame::convertToStackOverflowFrame):
(JSC::CallFrame::callerFrame): Deleted.
(JSC::CallFrame::unsafeCallerFrame): Deleted.

  • interpreter/CallFrame.h:

(JSC::ExecState::iterate):

  • interpreter/CallFrameInlines.h: Added.

(JSC::CallFrame::isStackOverflowFrame const):
(JSC::CallFrame::isWasmFrame const):

  • interpreter/EntryFrame.h: Added.

(JSC::EntryFrame::vmEntryRecordOffset):
(JSC::EntryFrame::calleeSaveRegistersBufferOffset):

  • interpreter/FrameTracers.h:

(JSC::NativeCallFrameTracerWithRestore::NativeCallFrameTracerWithRestore): Deleted.
(JSC::NativeCallFrameTracerWithRestore::~NativeCallFrameTracerWithRestore): Deleted.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::unwind):

  • interpreter/Interpreter.h:
  • interpreter/StackVisitor.cpp:

(JSC::StackVisitor::StackVisitor):

  • interpreter/StackVisitor.h:

(JSC::StackVisitor::visit):
(JSC::StackVisitor::topEntryFrameIsEmpty const):

  • interpreter/VMEntryRecord.h:

(JSC::VMEntryRecord::callee const):
(JSC::EntryFrame::vmEntryRecordOffset): Deleted.
(JSC::EntryFrame::calleeSaveRegistersBufferOffset): Deleted.

  • jit/AssemblyHelpers.h:
  • jit/JITExceptions.cpp:

(JSC::genericUnwind):

  • jit/JITExceptions.h:
  • jit/JITOperations.cpp:
  • llint/LLIntOffsetsExtractor.cpp:
  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • runtime/CallData.cpp:
  • runtime/CommonSlowPaths.cpp:

(JSC::throwArityCheckStackOverflowError):
(JSC::SLOW_PATH_DECL):

  • runtime/CommonSlowPathsExceptions.cpp: Removed.
  • runtime/CommonSlowPathsExceptions.h: Removed.
  • runtime/Completion.cpp:

(JSC::evaluateWithScopeExtension):

  • runtime/JSGeneratorFunction.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::stackOverflowFrameCallee const):

  • runtime/VM.cpp:

(JSC::VM::throwException):

  • runtime/VM.h:
  • runtime/VMInlines.h:

(JSC::VM::topJSCallFrame const):

LayoutTests:

  • http/tests/misc/large-js-program-expected.txt:
Location:
trunk
Files:
3 added
2 deleted
34 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r235356 r235419  
     12018-08-27  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix exception throwing code so that topCallFrame and topEntryFrame stay true to their names.
     4        https://bugs.webkit.org/show_bug.cgi?id=188577
     5        <rdar://problem/42985684>
     6
     7        Reviewed by Saam Barati.
     8
     9        * stress/regress-188577.js: Added.
     10
    1112018-08-24  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
    212
  • trunk/LayoutTests/ChangeLog

    r235417 r235419  
     12018-08-27  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix exception throwing code so that topCallFrame and topEntryFrame stay true to their names.
     4        https://bugs.webkit.org/show_bug.cgi?id=188577
     5        <rdar://problem/42985684>
     6
     7        Reviewed by Saam Barati.
     8
     9        * http/tests/misc/large-js-program-expected.txt:
     10
    1112018-08-27  Justin Fan  <justin_fan@apple.com>
    212
  • trunk/LayoutTests/http/tests/misc/large-js-program-expected.txt

    r231717 r235419  
    1 CONSOLE MESSAGE: line 27: RangeError: Maximum call stack size exceeded.
     1CONSOLE MESSAGE: RangeError: Maximum call stack size exceeded.
    22This tests verifies that a large program doesn't crash JavaScript.
    33
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r235271 r235419  
    613613    interpreter/AbstractPC.h
    614614    interpreter/CallFrame.h
     615    interpreter/CallFrameInlines.h
    615616    interpreter/CalleeBits.h
     617    interpreter/EntryFrame.h
    616618    interpreter/FrameTracers.h
    617619    interpreter/Register.h
  • trunk/Source/JavaScriptCore/ChangeLog

    r235412 r235419  
     12018-08-27  Mark Lam  <mark.lam@apple.com>
     2
     3        Fix exception throwing code so that topCallFrame and topEntryFrame stay true to their names.
     4        https://bugs.webkit.org/show_bug.cgi?id=188577
     5        <rdar://problem/42985684>
     6
     7        Reviewed by Saam Barati.
     8
     9        1. Introduced CallFrame::convertToStackOverflowFrame() which converts the current
     10           (top) CallFrame (which may not have a valid callee) into a StackOverflowFrame.
     11
     12           The StackOverflowFrame is a sentinel frame that the low level code (exception
     13           throwing code, stack visitor, and stack unwinding code) will know to skip
     14           over.  The StackOverflowFrame will also have a valid JSCallee so that client
     15           code can compute the globalObject or VM from this frame.
     16
     17           As a result, client code that throws StackOverflowErrors no longer need to
     18           compute the caller frame to throw from: it just converts the top frame into
     19           a StackOverflowFrame and everything should *Just Work*.
     20
     21        2. NativeCallFrameTracerWithRestore is now obsolete.
     22
     23           Instead, client code should always call convertToStackOverflowFrame() on the
     24           frame before instantiating a NativeCallFrameTracer with it.
     25
     26           This means that topCallFrame will always point to the top CallFrame (which
     27           may be a StackOverflowFrame), and topEntryFrame will always point to the top
     28           EntryFrame.  We'll never temporarily point them to the previous EntryFrame
     29           (which we used to do with NativeCallFrameTracerWithRestore).
     30
     31        3. genericUnwind() and Interpreter::unwind() will now always unwind from the top
     32           CallFrame, and will know how to handle a StackOverflowFrame if they see one.
     33
     34           This obsoletes the UnwindStart flag.
     35
     36        * CMakeLists.txt:
     37        * JavaScriptCore.xcodeproj/project.pbxproj:
     38        * Sources.txt:
     39        * debugger/Debugger.cpp:
     40        (JSC::Debugger::pauseIfNeeded):
     41        * interpreter/CallFrame.cpp:
     42        (JSC::CallFrame::callerFrame const):
     43        (JSC::CallFrame::unsafeCallerFrame const):
     44        (JSC::CallFrame::convertToStackOverflowFrame):
     45        (JSC::CallFrame::callerFrame): Deleted.
     46        (JSC::CallFrame::unsafeCallerFrame): Deleted.
     47        * interpreter/CallFrame.h:
     48        (JSC::ExecState::iterate):
     49        * interpreter/CallFrameInlines.h: Added.
     50        (JSC::CallFrame::isStackOverflowFrame const):
     51        (JSC::CallFrame::isWasmFrame const):
     52        * interpreter/EntryFrame.h: Added.
     53        (JSC::EntryFrame::vmEntryRecordOffset):
     54        (JSC::EntryFrame::calleeSaveRegistersBufferOffset):
     55        * interpreter/FrameTracers.h:
     56        (JSC::NativeCallFrameTracerWithRestore::NativeCallFrameTracerWithRestore): Deleted.
     57        (JSC::NativeCallFrameTracerWithRestore::~NativeCallFrameTracerWithRestore): Deleted.
     58        * interpreter/Interpreter.cpp:
     59        (JSC::Interpreter::unwind):
     60        * interpreter/Interpreter.h:
     61        * interpreter/StackVisitor.cpp:
     62        (JSC::StackVisitor::StackVisitor):
     63        * interpreter/StackVisitor.h:
     64        (JSC::StackVisitor::visit):
     65        (JSC::StackVisitor::topEntryFrameIsEmpty const):
     66        * interpreter/VMEntryRecord.h:
     67        (JSC::VMEntryRecord::callee const):
     68        (JSC::EntryFrame::vmEntryRecordOffset): Deleted.
     69        (JSC::EntryFrame::calleeSaveRegistersBufferOffset): Deleted.
     70        * jit/AssemblyHelpers.h:
     71        * jit/JITExceptions.cpp:
     72        (JSC::genericUnwind):
     73        * jit/JITExceptions.h:
     74        * jit/JITOperations.cpp:
     75        * llint/LLIntOffsetsExtractor.cpp:
     76        * llint/LLIntSlowPaths.cpp:
     77        (JSC::LLInt::LLINT_SLOW_PATH_DECL):
     78        * llint/LowLevelInterpreter.asm:
     79        * llint/LowLevelInterpreter32_64.asm:
     80        * llint/LowLevelInterpreter64.asm:
     81        * runtime/CallData.cpp:
     82        * runtime/CommonSlowPaths.cpp:
     83        (JSC::throwArityCheckStackOverflowError):
     84        (JSC::SLOW_PATH_DECL):
     85        * runtime/CommonSlowPathsExceptions.cpp: Removed.
     86        * runtime/CommonSlowPathsExceptions.h: Removed.
     87        * runtime/Completion.cpp:
     88        (JSC::evaluateWithScopeExtension):
     89        * runtime/JSGeneratorFunction.h:
     90        * runtime/JSGlobalObject.cpp:
     91        (JSC::JSGlobalObject::init):
     92        (JSC::JSGlobalObject::visitChildren):
     93        * runtime/JSGlobalObject.h:
     94        (JSC::JSGlobalObject::stackOverflowFrameCallee const):
     95        * runtime/VM.cpp:
     96        (JSC::VM::throwException):
     97        * runtime/VM.h:
     98        * runtime/VMInlines.h:
     99        (JSC::VM::topJSCallFrame const):
     100
    11012018-08-27  Keith Rollin  <krollin@apple.com>
    2102
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r235177 r235419  
    10771077                6514F21918B3E1670098FF8B /* Bytecodes.h in Headers */ = {isa = PBXBuildFile; fileRef = 6514F21718B3E1670098FF8B /* Bytecodes.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10781078                65303D641447B9E100D3F904 /* ParserTokens.h in Headers */ = {isa = PBXBuildFile; fileRef = 65303D631447B9E100D3F904 /* ParserTokens.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1079                 6553A33217A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 6553A33017A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h */; };
    10801079                65570F5A1AA4C3EA009B3C23 /* Regress141275.mm in Sources */ = {isa = PBXBuildFile; fileRef = 65570F591AA4C00A009B3C23 /* Regress141275.mm */; };
    10811080                657CF45919BF6662004ACBF2 /* JSCallee.h in Headers */ = {isa = PBXBuildFile; fileRef = 657CF45719BF6662004ACBF2 /* JSCallee.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    17501749                E49DC16D12EF295300184A1F /* SourceProviderCacheItem.h in Headers */ = {isa = PBXBuildFile; fileRef = E49DC14912EF261A00184A1F /* SourceProviderCacheItem.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17511750                FE05FAFD1FE4CEDA00093230 /* DeprecatedInspectorValues.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 992D6A111FBD491D000245F4 /* DeprecatedInspectorValues.cpp */; };
     1751                FE086BCA2123DEFB003F2929 /* EntryFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = FE086BC92123DEFA003F2929 /* EntryFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17521752                FE0D4A061AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE0D4A041AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp */; };
    17531753                FE0D4A091ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FE0D4A071ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp */; };
     
    18011801                FEA08621182B7A0400F6D851 /* DebuggerPrimitives.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0861F182B7A0400F6D851 /* DebuggerPrimitives.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18021802                FEA0C4031CDD7D1D00481991 /* FunctionWhitelist.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */; };
     1803                FEA3BBA8212B655900E93AD1 /* CallFrameInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA3BBA7212B655800E93AD1 /* CallFrameInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18031804                FEA3BBAC212C97CB00E93AD1 /* DFGCFG.h in Headers */ = {isa = PBXBuildFile; fileRef = FEA3BBAB212C97CB00E93AD1 /* DFGCFG.h */; };
    18041805                FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; };
     
    35653566                65525FC31A6DD3B3007B5495 /* NullSetterFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NullSetterFunction.cpp; sourceTree = "<group>"; };
    35663567                65525FC41A6DD3B3007B5495 /* NullSetterFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullSetterFunction.h; sourceTree = "<group>"; };
    3567                 6553A32F17A1F1EE008CF6F3 /* CommonSlowPathsExceptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonSlowPathsExceptions.cpp; sourceTree = "<group>"; };
    3568                 6553A33017A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonSlowPathsExceptions.h; sourceTree = "<group>"; };
    35693568                65570F581AA4C00A009B3C23 /* Regress141275.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Regress141275.h; path = API/tests/Regress141275.h; sourceTree = "<group>"; };
    35703569                65570F591AA4C00A009B3C23 /* Regress141275.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Regress141275.mm; path = API/tests/Regress141275.mm; sourceTree = "<group>"; };
     
    46794678                F692A8870255597D01FF60F7 /* JSCJSValue.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCJSValue.cpp; sourceTree = "<group>"; tabWidth = 8; };
    46804679                F73926918DC64330AFCDF0D7 /* JSSourceCode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSourceCode.cpp; sourceTree = "<group>"; };
     4680                FE086BC92123DEFA003F2929 /* EntryFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EntryFrame.h; sourceTree = "<group>"; };
    46814681                FE0D4A041AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ExecutionTimeLimitTest.cpp; path = API/tests/ExecutionTimeLimitTest.cpp; sourceTree = "<group>"; };
    46824682                FE0D4A051AB8DD0A002F54BF /* ExecutionTimeLimitTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ExecutionTimeLimitTest.h; path = API/tests/ExecutionTimeLimitTest.h; sourceTree = "<group>"; };
     
    47674767                FEA0C4001CDD7D0E00481991 /* FunctionWhitelist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FunctionWhitelist.cpp; sourceTree = "<group>"; };
    47684768                FEA0C4011CDD7D0E00481991 /* FunctionWhitelist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FunctionWhitelist.h; sourceTree = "<group>"; };
    4769                 FEA3BBAB212C97CB00E93AD1 /* DFGCFG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGCFG.h; path = dfg/DFGCFG.h; sourceTree = "<group>"; };
     4769                FEA3BBA7212B655800E93AD1 /* CallFrameInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallFrameInlines.h; sourceTree = "<group>"; };
     4770                FEA3BBAB212C97CB00E93AD1 /* DFGCFG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFGCFG.h; sourceTree = "<group>"; };
    47704771                FEB137561BB11EEE00CD5100 /* MacroAssemblerARM64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MacroAssemblerARM64.cpp; sourceTree = "<group>"; };
    47714772                FEB41CCB1F73284200C5481E /* ProbeFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProbeFrame.h; sourceTree = "<group>"; };
     
    55025503                                1429D8DB0ED2205B00B89619 /* CallFrame.cpp */,
    55035504                                1429D8DC0ED2205B00B89619 /* CallFrame.h */,
     5505                                FEA3BBA7212B655800E93AD1 /* CallFrameInlines.h */,
    55045506                                A7F869EC0F95C2EC00558697 /* CallFrameClosure.h */,
    55055507                                1429D85B0ED218E900B89619 /* CLoopStack.cpp */,
    55065508                                14D792640DAA03FB001A9F05 /* CLoopStack.h */,
    55075509                                A7C1EAEB17987AB600299DB2 /* CLoopStackInlines.h */,
     5510                                FE086BC92123DEFA003F2929 /* EntryFrame.h */,
    55085511                                E34EDBF61DB5FFC100DC87A5 /* FrameTracers.h */,
    55095512                                1429D7D30ED2128200B89619 /* Interpreter.cpp */,
     
    65006503                                A709F2F117A0AC2A00512E98 /* CommonSlowPaths.cpp */,
    65016504                                0F15F15D14B7A73A005DE37D /* CommonSlowPaths.h */,
    6502                                 6553A32F17A1F1EE008CF6F3 /* CommonSlowPathsExceptions.cpp */,
    6503                                 6553A33017A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h */,
    65046505                                A7E5A3A51797432D00E893C0 /* CompilationResult.cpp */,
    65056506                                A7E5A3A61797432D00E893C0 /* CompilationResult.h */,
     
    84348435                                99DA00A41BD5993100F4575C /* builtins_model.py in Headers */,
    84358436                                99DA00A51BD5993100F4575C /* builtins_templates.py in Headers */,
     8437                                FEA3BBA8212B655900E93AD1 /* CallFrameInlines.h in Headers */,
    84368438                                41DEA1321B9F3163006D65DD /* BuiltinUtils.h in Headers */,
    84378439                                9E72940B190F0514001A91B5 /* BundlePath.h in Headers */,
     
    84958497                                BC18C3F30E16F5CD00B34460 /* CommonIdentifiers.h in Headers */,
    84968498                                0F15F15F14B7A73E005DE37D /* CommonSlowPaths.h in Headers */,
    8497                                 6553A33217A1F1EE008CF6F3 /* CommonSlowPathsExceptions.h in Headers */,
    84988499                                A7E5A3A81797432D00E893C0 /* CompilationResult.h in Headers */,
    84998500                                0F4F11E8209BCDAB00709654 /* CompilerTimingScope.h in Headers */,
     
    90859086                                C2A7F688160432D400F76B98 /* JSDestructibleObject.h in Headers */,
    90869087                                0F7DF13C1E2971130095951B /* JSDestructibleObjectHeapCellType.h in Headers */,
     9088                                FE086BCA2123DEFB003F2929 /* EntryFrame.h in Headers */,
    90879089                                FE384EE61ADDB7AD0055DE2C /* JSDollarVM.h in Headers */,
    90889090                                86E3C614167BABD7006D760A /* JSExport.h in Headers */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r234713 r235419  
    716716runtime/CommonIdentifiers.cpp
    717717runtime/CommonSlowPaths.cpp
    718 runtime/CommonSlowPathsExceptions.cpp
    719718runtime/CompilationResult.cpp
    720719tools/CompilerTimingScope.cpp
  • trunk/Source/JavaScriptCore/debugger/Debugger.cpp

    r235254 r235419  
    11/*
    2  *  Copyright (C) 2008-2017 Apple Inc. All rights reserved.
     2 *  Copyright (C) 2008-2018 Apple Inc. All rights reserved.
    33 *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
    44 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
     
    687687    VM& vm = m_vm;
    688688    auto scope = DECLARE_THROW_SCOPE(vm);
     689    ASSERT(callFrame);
    689690
    690691    if (m_isPaused)
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.cpp

    r235254 r235419  
    11/*
    2  * Copyright (C) 2008-2017 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008-2018 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    214214}
    215215
    216 CallFrame* CallFrame::callerFrame(EntryFrame*& currEntryFrame)
     216CallFrame* CallFrame::callerFrame(EntryFrame*& currEntryFrame) const
    217217{
    218218    if (callerFrameOrEntryFrame() == currEntryFrame) {
     
    224224}
    225225
    226 SUPPRESS_ASAN CallFrame* CallFrame::unsafeCallerFrame(EntryFrame*& currEntryFrame)
     226SUPPRESS_ASAN CallFrame* CallFrame::unsafeCallerFrame(EntryFrame*& currEntryFrame) const
    227227{
    228228    if (unsafeCallerFrameOrEntryFrame() == currEntryFrame) {
     
    338338}
    339339
     340void CallFrame::convertToStackOverflowFrame(VM& vm)
     341{
     342    ASSERT(!isGlobalExec());
     343
     344    EntryFrame* entryFrame = vm.topEntryFrame;
     345    CallFrame* throwOriginFrame = this;
     346    do {
     347        throwOriginFrame = throwOriginFrame->callerFrame(entryFrame);
     348    } while (throwOriginFrame && throwOriginFrame->callee().isWasm());
     349
     350    JSObject* originCallee = throwOriginFrame ? throwOriginFrame->jsCallee() : vmEntryRecord(vm.topEntryFrame)->callee();
     351    JSObject* stackOverflowCallee = originCallee->globalObject()->stackOverflowFrameCallee();
     352
     353    setCodeBlock(nullptr);
     354    setCallee(stackOverflowCallee);
     355    setArgumentCountIncludingThis(0);
     356}
     357
    340358} // namespace JSC
  • trunk/Source/JavaScriptCore/interpreter/CallFrame.h

    r235254 r235419  
    141141        SUPPRESS_ASAN void* unsafeCallerFrameOrEntryFrame() const { return unsafeCallerFrameAndPC().callerFrame; }
    142142
    143         CallFrame* unsafeCallerFrame(EntryFrame*&);
    144         JS_EXPORT_PRIVATE CallFrame* callerFrame(EntryFrame*&);
     143        CallFrame* unsafeCallerFrame(EntryFrame*&) const;
     144        JS_EXPORT_PRIVATE CallFrame* callerFrame(EntryFrame*&) const;
    145145
    146146        JS_EXPORT_PRIVATE SourceOrigin callerSourceOrigin();
     
    257257        }
    258258
     259        void convertToStackOverflowFrame(VM&);
     260        inline bool isStackOverflowFrame() const;
     261        inline bool isWasmFrame() const;
     262
    259263        void setArgumentCountIncludingThis(int count) { static_cast<Register*>(this)[CallFrameSlot::argumentCount].payload() = count; }
    260264        void setCallee(JSObject* callee) { static_cast<Register*>(this)[CallFrameSlot::callee] = callee; }
     
    269273        // receiver. We should always be using StackVisitor directly.
    270274        // It's only valid to call this from a non-wasm top frame.
    271         template <typename Functor> void iterate(const Functor& functor)
     275        template <StackVisitor::EmptyEntryFrameAction action = StackVisitor::ContinueIfTopEntryFrameIsEmpty, typename Functor> void iterate(const Functor& functor)
    272276        {
    273277            VM* vm;
     
    278282            } else
    279283                vm = nullptr;
    280             StackVisitor::visit<Functor>(this, vm, functor);
     284            StackVisitor::visit<action, Functor>(this, vm, functor);
    281285        }
    282286
  • trunk/Source/JavaScriptCore/interpreter/FrameTracers.h

    r227165 r235419  
    11/*
    2  * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    9494};
    9595
    96 class NativeCallFrameTracerWithRestore {
    97 public:
    98     ALWAYS_INLINE NativeCallFrameTracerWithRestore(VM* vm, EntryFrame* EntryFrame, CallFrame* callFrame)
    99         : m_vm(vm)
    100     {
    101         ASSERT(vm);
    102         ASSERT(callFrame);
    103         assertStackPointerIsAligned();
    104         m_savedTopEntryFrame = vm->topEntryFrame;
    105         m_savedTopCallFrame = vm->topCallFrame;
    106         vm->topEntryFrame = EntryFrame;
    107         vm->topCallFrame = callFrame;
    108     }
    109 
    110     ALWAYS_INLINE ~NativeCallFrameTracerWithRestore()
    111     {
    112         m_vm->topEntryFrame = m_savedTopEntryFrame;
    113         m_vm->topCallFrame = m_savedTopCallFrame;
    114     }
    115 
    116 private:
    117     VM* m_vm;
    118     EntryFrame* m_savedTopEntryFrame;
    119     CallFrame* m_savedTopCallFrame;
    120 };
    121 
    122 }
     96} // namespace JSC
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp

    r235254 r235419  
    719719};
    720720
    721 NEVER_INLINE HandlerInfo* Interpreter::unwind(VM& vm, CallFrame*& callFrame, Exception* exception, UnwindStart unwindStart)
     721NEVER_INLINE HandlerInfo* Interpreter::unwind(VM& vm, CallFrame*& callFrame, Exception* exception)
    722722{
    723723    auto scope = DECLARE_CATCH_SCOPE(vm);
    724724
    725     if (unwindStart == UnwindFromCallerFrame) {
    726         if (callFrame->callerFrameOrEntryFrame() == vm.topEntryFrame)
    727             return nullptr;
    728 
    729         callFrame = callFrame->callerFrame();
    730         vm.topCallFrame = callFrame;
    731     }
    732 
     725    ASSERT(reinterpret_cast<void*>(callFrame) != vm.topEntryFrame);
    733726    CodeBlock* codeBlock = callFrame->codeBlock();
    734727
     
    741734        exceptionValue = jsNull();
    742735
    743     EXCEPTION_ASSERT_UNUSED(scope, scope.exception() && (!Options::exceptionStackTraceLimit() || scope.exception()->stack().size()));
     736    EXCEPTION_ASSERT_UNUSED(scope, scope.exception());
    744737
    745738    // Calculate an exception handler vPC, unwinding call frames as necessary.
    746739    HandlerInfo* handler = nullptr;
    747740    UnwindFunctor functor(vm, callFrame, isTerminatedExecutionException(vm, exception), codeBlock, handler);
    748     StackVisitor::visit(callFrame, &vm, functor);
     741    StackVisitor::visit<StackVisitor::TerminateIfTopEntryFrameIsEmpty>(callFrame, &vm, functor);
    749742    if (!handler)
    750743        return nullptr;
  • trunk/Source/JavaScriptCore/interpreter/Interpreter.h

    r232314 r235419  
    6565    struct UnlinkedInstruction;
    6666
    67     enum UnwindStart : uint8_t { UnwindFromCurrentFrame, UnwindFromCallerFrame };
    68 
    6967    enum DebugHookType {
    7068        WillExecuteProgram,
     
    117115
    118116        void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc);
    119        
    120         NEVER_INLINE HandlerInfo* unwind(VM&, CallFrame*&, Exception*, UnwindStart);
     117
     118        NEVER_INLINE HandlerInfo* unwind(VM&, CallFrame*&, Exception*);
    121119        void notifyDebuggerOfExceptionToBeThrown(VM&, CallFrame*, Exception*);
    122120        NEVER_INLINE void debug(CallFrame*, DebugHookType);
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.cpp

    r234082 r235419  
    11/*
    2  * Copyright (C) 2013, 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545    if (startFrame) {
    4646        ASSERT(vm);
     47        ASSERT(!vm->topCallFrame || reinterpret_cast<void*>(vm->topCallFrame) != vm->topEntryFrame);
     48
    4749        m_frame.m_entryFrame = vm->topEntryFrame;
    4850        topFrame = vm->topCallFrame;
    49        
    50         if (topFrame && static_cast<void*>(m_frame.m_entryFrame) == static_cast<void*>(topFrame)) {
    51             topFrame = vmEntryRecord(m_frame.m_entryFrame)->m_prevTopCallFrame;
    52             m_frame.m_entryFrame = vmEntryRecord(m_frame.m_entryFrame)->m_prevTopEntryFrame;
     51
     52        if (topFrame && topFrame->isStackOverflowFrame()) {
     53            topFrame = topFrame->callerFrame(m_frame.m_entryFrame);
     54            m_topEntryFrameIsEmpty = (m_frame.m_entryFrame != vm->topEntryFrame);
     55            if (startFrame == vm->topCallFrame)
     56                startFrame = topFrame;
    5357        }
     58
    5459    } else {
    5560        m_frame.m_entryFrame = 0;
  • trunk/Source/JavaScriptCore/interpreter/StackVisitor.h

    r234082 r235419  
    11/*
    2  * Copyright (C) 2013-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727
    2828#include "CalleeBits.h"
    29 #include "VMEntryRecord.h"
    3029#include "WasmIndexOrName.h"
    3130#include <wtf/Function.h>
     
    3635
    3736struct CodeOrigin;
     37struct EntryFrame;
    3838struct InlineCallFrame;
    3939
     
    137137    //     Status operator()(StackVisitor&) const;
    138138
    139     template <typename Functor>
     139    enum EmptyEntryFrameAction {
     140        ContinueIfTopEntryFrameIsEmpty,
     141        TerminateIfTopEntryFrameIsEmpty,
     142    };
     143
     144    template <EmptyEntryFrameAction action = ContinueIfTopEntryFrameIsEmpty, typename Functor>
    140145    static void visit(CallFrame* startFrame, VM* vm, const Functor& functor)
    141146    {
    142147        StackVisitor visitor(startFrame, vm);
     148        if (action == TerminateIfTopEntryFrameIsEmpty && visitor.topEntryFrameIsEmpty())
     149            return;
    143150        while (visitor->callFrame()) {
    144151            Status status = functor(visitor);
     
    153160    void unwindToMachineCodeBlockFrame();
    154161
     162    bool topEntryFrameIsEmpty() const { return m_topEntryFrameIsEmpty; }
     163
    155164private:
    156165    JS_EXPORT_PRIVATE StackVisitor(CallFrame* startFrame, VM*);
     
    165174
    166175    Frame m_frame;
     176    bool m_topEntryFrameIsEmpty { false };
    167177};
    168178
  • trunk/Source/JavaScriptCore/interpreter/VMEntryRecord.h

    r223738 r235419  
    11/*
    2  * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3232struct EntryFrame;
    3333class ExecState;
     34class JSObject;
    3435class VM;
    3536
     
    4243    ExecState* m_prevTopCallFrame;
    4344    EntryFrame* m_prevTopEntryFrame;
     45    JSObject* m_callee;
     46
     47    JSObject* callee() const { return m_callee; }
    4448
    4549#if ENABLE(JIT) && NUMBER_OF_CALLEE_SAVES_REGISTERS > 0
     
    5660extern "C" VMEntryRecord* vmEntryRecord(EntryFrame*);
    5761
    58 struct EntryFrame {
    59 #if ENABLE(JIT) && NUMBER_OF_CALLEE_SAVES_REGISTERS > 0
    60     static ptrdiff_t vmEntryRecordOffset()
    61     {
    62         EntryFrame* fakeEntryFrame = reinterpret_cast<EntryFrame*>(0x1000);
    63         VMEntryRecord* record = vmEntryRecord(fakeEntryFrame);
    64         return static_cast<ptrdiff_t>(
    65             reinterpret_cast<char*>(record) - reinterpret_cast<char*>(fakeEntryFrame));
    66     }
    67 
    68     static ptrdiff_t calleeSaveRegistersBufferOffset()
    69     {
    70         return vmEntryRecordOffset() + OBJECT_OFFSETOF(VMEntryRecord, calleeSaveRegistersBuffer);
    71     }
    72 #endif
    73 };
    74 
    7562} // namespace JSC
  • trunk/Source/JavaScriptCore/jit/AssemblyHelpers.h

    r232444 r235419  
    2929
    3030#include "CodeBlock.h"
     31#include "EntryFrame.h"
    3132#include "FPRInfo.h"
    3233#include "GPRInfo.h"
  • trunk/Source/JavaScriptCore/jit/JITExceptions.cpp

    r230865 r235419  
    3131#include "CodeBlock.h"
    3232#include "Disassembler.h"
     33#include "EntryFrame.h"
    3334#include "Interpreter.h"
    3435#include "JSCInlines.h"
     
    3940#include "Opcode.h"
    4041#include "ShadowChicken.h"
    41 #include "VM.h"
     42#include "VMInlines.h"
    4243
    4344namespace JSC {
    4445
    45 void genericUnwind(VM* vm, ExecState* callFrame, UnwindStart unwindStart)
     46void genericUnwind(VM* vm, ExecState* callFrame)
    4647{
    4748    auto scope = DECLARE_CATCH_SCOPE(*vm);
     49    CallFrame* topJSCallFrame = vm->topJSCallFrame();
    4850    if (Options::breakOnThrow()) {
    49         CodeBlock* codeBlock = callFrame->codeBlock();
    50         if (codeBlock)
    51             dataLog("In call frame ", RawPointer(callFrame), " for code block ", *codeBlock, "\n");
    52         else
    53             dataLog("In call frame ", RawPointer(callFrame), " with null CodeBlock\n");
     51        CodeBlock* codeBlock = topJSCallFrame->codeBlock();
     52        dataLog("In call frame ", RawPointer(topJSCallFrame), " for code block ", codeBlock, "\n");
    5453        CRASH();
    5554    }
    5655   
    57     ExecState* shadowChickenTopFrame = callFrame;
    58     if (unwindStart == UnwindFromCallerFrame) {
    59         EntryFrame* topEntryFrame = vm->topEntryFrame;
    60         shadowChickenTopFrame = callFrame->callerFrame(topEntryFrame);
    61     }
    62     vm->shadowChicken().log(*vm, shadowChickenTopFrame, ShadowChicken::Packet::throwPacket());
    63    
     56    vm->shadowChicken().log(*vm, topJSCallFrame, ShadowChicken::Packet::throwPacket());
     57
    6458    Exception* exception = scope.exception();
    6559    RELEASE_ASSERT(exception);
    66     HandlerInfo* handler = vm->interpreter->unwind(*vm, callFrame, exception, unwindStart); // This may update callFrame.
     60    HandlerInfo* handler = vm->interpreter->unwind(*vm, callFrame, exception); // This may update callFrame.
    6761
    6862    void* catchRoutine;
     
    8478    } else
    8579        catchRoutine = LLInt::getCodePtr<ExceptionHandlerPtrTag>(handleUncaughtException).executableAddress();
    86    
     80
    8781    ASSERT(bitwise_cast<uintptr_t>(callFrame) < bitwise_cast<uintptr_t>(vm->topEntryFrame));
    8882
     
    9589}
    9690
    97 void genericUnwind(VM* vm, ExecState* callFrame)
    98 {
    99     genericUnwind(vm, callFrame, UnwindFromCurrentFrame);
    100 }
    101 
    10291} // namespace JSC
  • trunk/Source/JavaScriptCore/jit/JITExceptions.h

    r206525 r235419  
    11/*
    2  * Copyright (C) 2012 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828namespace JSC {
    2929
    30 enum UnwindStart : uint8_t;
    31 
    3230class ExecState;
    3331class VM;
    3432
    35 void genericUnwind(VM*, ExecState*, UnwindStart);
    3633void genericUnwind(VM*, ExecState*);
    3734
  • trunk/Source/JavaScriptCore/jit/JITOperations.cpp

    r235198 r235419  
    103103    VM* vm = codeBlock->vm();
    104104    auto scope = DECLARE_THROW_SCOPE(*vm);
    105 
    106     EntryFrame* entryFrame = vm->topEntryFrame;
    107     CallFrame* callerFrame = exec->callerFrame(entryFrame);
    108     if (!callerFrame) {
    109         callerFrame = exec;
    110         entryFrame = vm->topEntryFrame;
    111     }
    112 
    113     NativeCallFrameTracerWithRestore tracer(vm, entryFrame, callerFrame);
    114     throwStackOverflowError(callerFrame, scope);
     105    exec->convertToStackOverflowFrame(*vm);
     106    NativeCallFrameTracer tracer(vm, exec);
     107    throwStackOverflowError(exec, scope);
    115108}
    116109
     
    122115    int32_t missingArgCount = CommonSlowPaths::arityCheckFor(exec, *vm, CodeForCall);
    123116    if (missingArgCount < 0) {
    124         EntryFrame* entryFrame = vm->topEntryFrame;
    125         CallFrame* callerFrame = exec->callerFrame(entryFrame);
    126         NativeCallFrameTracerWithRestore tracer(vm, entryFrame, callerFrame);
    127         throwStackOverflowError(callerFrame, scope);
     117        exec->convertToStackOverflowFrame(*vm);
     118        NativeCallFrameTracer tracer(vm, exec);
     119        throwStackOverflowError(vm->topCallFrame, scope);
    128120    }
    129121
     
    138130    int32_t missingArgCount = CommonSlowPaths::arityCheckFor(exec, *vm, CodeForConstruct);
    139131    if (missingArgCount < 0) {
    140         EntryFrame* entryFrame = vm->topEntryFrame;
    141         CallFrame* callerFrame = exec->callerFrame(entryFrame);
    142         NativeCallFrameTracerWithRestore tracer(vm, entryFrame, callerFrame);
    143         throwStackOverflowError(callerFrame, scope);
     132        exec->convertToStackOverflowFrame(*vm);
     133        NativeCallFrameTracer tracer(vm, exec);
     134        throwStackOverflowError(vm->topCallFrame, scope);
    144135    }
    145136
     
    24502441void JIT_OPERATION lookupExceptionHandlerFromCallerFrame(VM* vm, ExecState* exec)
    24512442{
    2452     vm->topCallFrame = exec->callerFrame();
    2453     genericUnwind(vm, exec, UnwindFromCallerFrame);
    2454     ASSERT(vm->targetMachinePCForThrow);
     2443    exec->convertToStackOverflowFrame(*vm);
     2444    lookupExceptionHandler(vm, exec);
    24552445}
    24562446
  • trunk/Source/JavaScriptCore/llint/LLIntOffsetsExtractor.cpp

    r231027 r235419  
    5959#include "TypeProfilerLog.h"
    6060#include "VM.h"
    61 #include "VMEntryRecord.h"
    6261#include "ValueProfile.h"
    6362#include "Watchdog.h"
  • trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp

    r233658 r235419  
    3030#include "CallFrame.h"
    3131#include "CommonSlowPaths.h"
    32 #include "CommonSlowPathsExceptions.h"
    3332#include "Error.h"
    3433#include "ErrorHandlingScope.h"
     
    526525    auto throwScope = DECLARE_THROW_SCOPE(vm);
    527526
    528     EntryFrame* topEntryFrame = vm.topEntryFrame;
    529     CallFrame* callerFrame = exec->callerFrame(topEntryFrame);
    530     if (!callerFrame) {
    531         callerFrame = exec;
    532         topEntryFrame = vm.topEntryFrame;
    533     }
    534     NativeCallFrameTracerWithRestore tracer(&vm, topEntryFrame, callerFrame);
     527    // It's ok to create the NativeCallFrameTracer here before we
     528    // convertToStackOverflowFrame() because this function is always called
     529    // after the frame has been propulated with a proper CodeBlock and callee.
     530    NativeCallFrameTracer tracer(&vm, exec);
    535531
    536532    LLINT_SET_PC_FOR_STUBS();
     
    564560#endif
    565561
     562    exec->convertToStackOverflowFrame(vm);
    566563    ErrorHandlingScope errorScope(vm);
    567     throwStackOverflowError(callerFrame, throwScope);
    568     pc = returnToThrow(callerFrame);
     564    throwStackOverflowError(exec, throwScope);
     565    pc = returnToThrow(exec);
    569566    LLINT_RETURN_TWO(pc, exec);
    570567}
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r235102 r235419  
    10771077    callSlowPath(_llint_stack_check)
    10781078    bpeq r1, 0, .stackHeightOKGetCodeBlock
     1079
     1080    # We're throwing before the frame is fully set up. This frame will be
     1081    # ignored by the unwinder. So, let's restore the callee saves before we
     1082    # start unwinding. We need to do this before we change the cfr.
     1083    restoreCalleeSavesUsedByLLInt()
     1084
    10791085    move r1, cfr
    1080     dispatch(0) # Go to exception handler in PC
     1086    jmp _llint_throw_from_slow_path_trampoline
    10811087
    10821088.stackHeightOKGetCodeBlock:
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm

    r234184 r235419  
    128128    loadp VM::topEntryFrame[vm], t4
    129129    storep t4, VMEntryRecord::m_prevTopEntryFrame[sp]
     130    loadp ProtoCallFrame::calleeValue[protoCallFrame], t4
     131    storep t4, VMEntryRecord::m_callee[sp]
    130132
    131133    # Align stack pointer
     
    310312    loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
    311313    restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer(t3, t0)
    312     loadp VM::callFrameForCatch[t3], cfr
    313314    storep 0, VM::callFrameForCatch[t3]
    314315
    315     loadp CallerFrame[cfr], cfr
    316 
     316    loadp VM::topEntryFrame[t3], cfr
    317317    if ARMv7
    318318        vmEntryRecord(cfr, t3)
     
    576576    cCall2(slowPath)   # This slowPath has a simple protocol: t0 = 0 => no error, t0 != 0 => error
    577577    btiz r0, .noError
     578
     579    # We're throwing before the frame is fully set up. This frame will be
     580    # ignored by the unwinder. So, let's restore the callee saves before we
     581    # start unwinding. We need to do this before we change the cfr.
     582    restoreCalleeSavesUsedByLLInt()
     583
    578584    move r1, cfr   # r1 contains caller frame
    579585    jmp _llint_throw_from_slow_path_trampoline
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

    r234184 r235419  
    133133    loadp VM::topEntryFrame[vm], t4
    134134    storep t4, VMEntryRecord::m_prevTopEntryFrame[sp]
     135    loadp ProtoCallFrame::calleeValue[protoCallFrame], t4
     136    storep t4, VMEntryRecord::m_callee[sp]
    135137
    136138    loadi ProtoCallFrame::paddedArgCount[protoCallFrame], t4
     
    245247    popCalleeSaves()
    246248    functionEpilogue()
    247 
    248249    ret
    249250end
     
    283284    loadp MarkedBlockFooterOffset + MarkedBlock::Footer::m_vm[t3], t3
    284285    restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer(t3, t0)
    285     loadp VM::callFrameForCatch[t3], cfr
    286286    storep 0, VM::callFrameForCatch[t3]
    287287
    288     loadp CallerFrame[cfr], cfr
     288    loadp VM::topEntryFrame[t3], cfr
    289289    vmEntryRecord(cfr, t2)
    290290
     
    509509    cCall2(slowPath)   # This slowPath has the protocol: r0 = 0 => no error, r0 != 0 => error
    510510    btiz r0, .noError
     511
     512    # We're throwing before the frame is fully set up. This frame will be
     513    # ignored by the unwinder. So, let's restore the callee saves before we
     514    # start unwinding. We need to do this before we change the cfr.
     515    restoreCalleeSavesUsedByLLInt()
     516
    511517    move r1, cfr   # r1 contains caller frame
    512518    jmp _llint_throw_from_slow_path_trampoline
  • trunk/Source/JavaScriptCore/runtime/CallData.cpp

    r235254 r235419  
    11/*
    2  * Copyright (C) 2008, 2016 Apple Inc. All Rights Reserved.
     2 * Copyright (C) 2008-2018 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
  • trunk/Source/JavaScriptCore/runtime/CommonSlowPaths.cpp

    r233122 r235419  
    3434#include "ClonedArguments.h"
    3535#include "CodeProfiling.h"
    36 #include "CommonSlowPathsExceptions.h"
    3736#include "DefinePropertyAttributes.h"
    3837#include "DirectArguments.h"
     
    164163    } while (false)
    165164
     165static void throwArityCheckStackOverflowError(ExecState* exec, ThrowScope& scope)
     166{
     167    JSObject* error = createStackOverflowError(exec);
     168    throwException(exec, scope, error);
     169#if LLINT_TRACING
     170    if (UNLIKELY(Options::traceLLIntSlowPath()))
     171        dataLog("Throwing exception ", JSValue(scope.exception()), ".\n");
     172#endif
     173}
     174
    166175SLOW_PATH_DECL(slow_path_call_arityCheck)
    167176{
     
    169178    int slotsToAdd = CommonSlowPaths::arityCheckFor(exec, vm, CodeForCall);
    170179    if (slotsToAdd < 0) {
    171         exec = exec->callerFrame();
    172         vm.topCallFrame = exec;
     180        exec->convertToStackOverflowFrame(vm);
     181        NativeCallFrameTracer tracer(&vm, exec);
    173182        ErrorHandlingScope errorScope(vm);
    174183        throwScope.release();
    175         CommonSlowPaths::interpreterThrowInCaller(exec, createStackOverflowError(exec));
     184        throwArityCheckStackOverflowError(exec, throwScope);
    176185        RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
    177186    }
     
    184193    int slotsToAdd = CommonSlowPaths::arityCheckFor(exec, vm, CodeForConstruct);
    185194    if (slotsToAdd < 0) {
    186         exec = exec->callerFrame();
    187         vm.topCallFrame = exec;
     195        exec->convertToStackOverflowFrame(vm);
     196        NativeCallFrameTracer tracer(&vm, exec);
    188197        ErrorHandlingScope errorScope(vm);
    189         CommonSlowPaths::interpreterThrowInCaller(exec, createStackOverflowError(exec));
     198        throwArityCheckStackOverflowError(exec, throwScope);
    190199        RETURN_TWO(bitwise_cast<void*>(static_cast<uintptr_t>(1)), exec);
    191200    }
  • trunk/Source/JavaScriptCore/runtime/Completion.cpp

    r235254 r235419  
    22 *  Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
    33 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
    4  *  Copyright (C) 2003-2017 Apple Inc.
     4 *  Copyright (C) 2003-2018 Apple Inc.
    55 *
    66 *  This library is free software; you can redistribute it and/or
     
    127127    if (scopeExtensionObject) {
    128128        JSScope* ignoredPreviousScope = globalObject->globalScope();
    129         globalObject->setGlobalScopeExtension(JSWithScope::create(exec->vm(), globalObject, ignoredPreviousScope, scopeExtensionObject));
     129        globalObject->setGlobalScopeExtension(JSWithScope::create(vm, globalObject, ignoredPreviousScope, scopeExtensionObject));
    130130    }
    131131
  • trunk/Source/JavaScriptCore/runtime/JSGeneratorFunction.h

    r229413 r235419  
    3333class JSGlobalObject;
    3434class LLIntOffsetsExtractor;
    35 class LLIntDesiredOffsets;
    3635
    3736class JSGeneratorFunction final : public JSFunction {
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r234491 r235419  
    417417    ExecState* exec = JSGlobalObject::globalExec();
    418418
     419    JSCallee* stackOverflowFrameCallee = JSCallee::create(vm, this, globalScope());
     420    m_stackOverflowFrameCallee.set(vm, this, stackOverflowFrameCallee);
     421
    419422    m_hostFunctionStructure.set(vm, this, JSFunction::createStructure(vm, this, m_functionPrototype.get()));
    420423
     
    13281331    visitor.append(thisObject->m_globalScopeExtension);
    13291332    visitor.append(thisObject->m_globalCallee);
     1333    visitor.append(thisObject->m_stackOverflowFrameCallee);
    13301334    visitor.append(thisObject->m_regExpConstructor);
    13311335    visitor.append(thisObject->m_errorConstructor);
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r233426 r235419  
    8484class JSArrayBufferConstructor;
    8585class JSArrayBufferPrototype;
     86class JSCallee;
    8687class JSGlobalObjectDebuggable;
    8788class JSInternalPromise;
     
    257258    WriteBarrier<JSGlobalLexicalEnvironment> m_globalLexicalEnvironment;
    258259    WriteBarrier<JSScope> m_globalScopeExtension;
    259     WriteBarrier<JSObject> m_globalCallee;
     260    WriteBarrier<JSCallee> m_globalCallee;
     261    WriteBarrier<JSCallee> m_stackOverflowFrameCallee;
    260262    WriteBarrier<RegExpConstructor> m_regExpConstructor;
    261263    WriteBarrier<ErrorConstructor> m_errorConstructor;
     
    442444
    443445    WeakRandom m_weakRandom;
     446
     447    JSCallee* stackOverflowFrameCallee() const { return m_stackOverflowFrameCallee.get(); }
    444448
    445449    InlineWatchpointSet& arrayIteratorProtocolWatchpoint() { return m_arrayIteratorProtocolWatchpoint; }
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r235261 r235419  
    144144#include "UnlinkedCodeBlock.h"
    145145#include "VMEntryScope.h"
     146#include "VMInlines.h"
    146147#include "VMInspector.h"
    147148#include "VariableEnvironment.h"
     
    831832void VM::throwException(ExecState* exec, Exception* exception)
    832833{
     834    ASSERT(exec == topCallFrame || exec->isGlobalExec());
     835    CallFrame* throwOriginFrame = exec->isGlobalExec() ? exec : topJSCallFrame();
     836
    833837    if (Options::breakOnThrow()) {
    834         CodeBlock* codeBlock = exec->codeBlock();
    835         dataLog("Throwing exception in call frame ", RawPointer(exec), " for code block ", codeBlock, "\n");
     838        CodeBlock* codeBlock = throwOriginFrame ? throwOriginFrame->codeBlock() : nullptr;
     839        dataLog("Throwing exception in call frame ", RawPointer(throwOriginFrame), " for code block ", codeBlock, "\n");
    836840        CRASH();
    837841    }
    838842
    839     ASSERT(exec == topCallFrame || exec->isGlobalExec());
    840 
    841     interpreter->notifyDebuggerOfExceptionToBeThrown(*this, exec, exception);
     843    interpreter->notifyDebuggerOfExceptionToBeThrown(*this, throwOriginFrame, exception);
    842844
    843845    setException(exception);
  • trunk/Source/JavaScriptCore/runtime/VM.h

    r235261 r235419  
    5252#include "Strong.h"
    5353#include "StructureCache.h"
    54 #include "VMEntryRecord.h"
    5554#include "VMTraps.h"
    5655#include "WasmContext.h"
     
    169168}
    170169
     170struct EntryFrame;
    171171struct HashTable;
    172172struct Instruction;
     
    295295    unsigned id() const { return m_id; }
    296296    bool isEntered() const { return !!entryScope; }
     297
     298    inline CallFrame* topJSCallFrame() const;
    297299
    298300    // Global object in which execution began.
  • trunk/Source/JavaScriptCore/runtime/VMInlines.h

    r220186 r235419  
    11/*
    2  * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
     28#include "CallFrameInlines.h"
     29#include "EntryFrame.h"
    2830#include "ProfilerDatabase.h"
    2931#include "VM.h"
     
    6163}
    6264
     65inline CallFrame* VM::topJSCallFrame() const
     66{
     67    CallFrame* frame = topCallFrame;
     68    if (UNLIKELY(!frame))
     69        return frame;
     70    if (LIKELY(!frame->isWasmFrame() && !frame->isStackOverflowFrame()))
     71        return frame;
     72    EntryFrame* entryFrame = topEntryFrame;
     73    do {
     74        frame = frame->callerFrame(entryFrame);
     75        ASSERT(!frame || !frame->isStackOverflowFrame());
     76    } while (frame && frame->isWasmFrame());
     77    return frame;
     78}
     79
    6380} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.