Changeset 219046 in webkit


Ignore:
Timestamp:
Jun 30, 2017 11:24:44 PM (7 years ago)
Author:
keith_miller@apple.com
Message:

Force crashWithInfo to be out of line.
https://bugs.webkit.org/show_bug.cgi?id=174028

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

Update DFG_ASSERT macro to call CRASH_WITH_SECURITY_IMPLICATION_AND_INFO.

  • dfg/DFGGraph.cpp:

(JSC::DFG::logDFGAssertionFailure):
(JSC::DFG::Graph::logAssertionFailure):
(JSC::DFG::crash): Deleted.
(JSC::DFG::Graph::handleAssertionFailure): Deleted.

  • dfg/DFGGraph.h:

Source/WTF:

The first pass at making crashes hold information about why they
were crashing had the problem that it would inline the assertion.
This meant that clang could coalesce DFG_ASSERTS with other
assertion failures in the same function. This patch moves it out
of line to help fix that issue.

  • wtf/Assertions.cpp:

(WTFCrashWithInfo):

  • wtf/Assertions.h:

(WTF::isIntegralType):

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r219043 r219046  
     12017-06-30  Keith Miller  <keith_miller@apple.com>
     2
     3        Force crashWithInfo to be out of line.
     4        https://bugs.webkit.org/show_bug.cgi?id=174028
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Update DFG_ASSERT macro to call CRASH_WITH_SECURITY_IMPLICATION_AND_INFO.
     9
     10        * dfg/DFGGraph.cpp:
     11        (JSC::DFG::logDFGAssertionFailure):
     12        (JSC::DFG::Graph::logAssertionFailure):
     13        (JSC::DFG::crash): Deleted.
     14        (JSC::DFG::Graph::handleAssertionFailure): Deleted.
     15        * dfg/DFGGraph.h:
     16
    1172017-06-30  Yusuke Suzuki  <utatane.tea@gmail.com>
    218
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp

    r219006 r219046  
    14391439}
    14401440
    1441 NO_RETURN_DUE_TO_CRASH static void crash(
     1441static void logDFGAssertionFailure(
    14421442    Graph& graph, const CString& whileText, const char* file, int line, const char* function,
    14431443    const char* assertion)
     
    14531453    dataLog("DFG ASSERTION FAILED: ", assertion, "\n");
    14541454    dataLog(file, "(", line, ") : ", function, "\n");
    1455     CRASH_WITH_SECURITY_IMPLICATION();
    1456 }
    1457 
    1458 void Graph::handleAssertionFailure(
     1455    WTFReportBacktrace();
     1456}
     1457
     1458void Graph::logAssertionFailure(
    14591459    std::nullptr_t, const char* file, int line, const char* function, const char* assertion)
    14601460{
    1461     crash(*this, "", file, line, function, assertion);
    1462 }
    1463 
    1464 void Graph::handleAssertionFailure(
     1461    logDFGAssertionFailure(*this, "", file, line, function, assertion);
     1462}
     1463
     1464void Graph::logAssertionFailure(
    14651465    Node* node, const char* file, int line, const char* function, const char* assertion)
    14661466{
    1467     crash(*this, toCString("While handling node ", node, "\n\n"), file, line, function, assertion);
    1468 }
    1469 
    1470 void Graph::handleAssertionFailure(
     1467    logDFGAssertionFailure(*this, toCString("While handling node ", node, "\n\n"), file, line, function, assertion);
     1468}
     1469
     1470void Graph::logAssertionFailure(
    14711471    BasicBlock* block, const char* file, int line, const char* function, const char* assertion)
    14721472{
    1473     crash(*this, toCString("While handling block ", pointerDump(block), "\n\n"), file, line, function, assertion);
     1473    logDFGAssertionFailure(*this, toCString("While handling block ", pointerDump(block), "\n\n"), file, line, function, assertion);
    14741474}
    14751475
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.h

    r219006 r219046  
    9494    } while (false)
    9595
    96 #define DFG_ASSERT(graph, node, assertion) do {                         \
     96#define DFG_ASSERT(graph, node, assertion, ...) do {                    \
    9797        if (!!(assertion))                                              \
    9898            break;                                                      \
    99         (graph).handleAssertionFailure(                                 \
     99        (graph).logAssertionFailure(                                    \
    100100            (node), __FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion); \
     101        CRASH_WITH_SECURITY_IMPLICATION_AND_INFO(__VA_ARGS__);          \
    101102    } while (false)
    102103
    103 #define DFG_CRASH(graph, node, reason) do {                             \
    104         (graph).handleAssertionFailure(                                 \
     104#define DFG_CRASH(graph, node, reason, ...) do {                        \
     105        (graph).logAssertionFailure(                                    \
    105106            (node), __FILE__, __LINE__, WTF_PRETTY_FUNCTION, (reason)); \
     107        CRASH_WITH_SECURITY_IMPLICATION_AND_INFO(__VA_ARGS__);          \
    106108    } while (false)
    107109
     
    888890    void visitChildren(SlotVisitor&) override;
    889891   
    890     NO_RETURN_DUE_TO_CRASH void handleAssertionFailure(
     892    void logAssertionFailure(
    891893        std::nullptr_t, const char* file, int line, const char* function,
    892894        const char* assertion);
    893     NO_RETURN_DUE_TO_CRASH void handleAssertionFailure(
     895    void logAssertionFailure(
    894896        Node*, const char* file, int line, const char* function,
    895897        const char* assertion);
    896     NO_RETURN_DUE_TO_CRASH void handleAssertionFailure(
     898    void logAssertionFailure(
    897899        BasicBlock*, const char* file, int line, const char* function,
    898900        const char* assertion);
  • trunk/Source/WTF/ChangeLog

    r219042 r219046  
     12017-06-30  Keith Miller  <keith_miller@apple.com>
     2
     3        Force crashWithInfo to be out of line.
     4        https://bugs.webkit.org/show_bug.cgi?id=174028
     5
     6        Reviewed by Filip Pizlo.
     7
     8        The first pass at making crashes hold information about why they
     9        were crashing had the problem that it would inline the assertion.
     10        This meant that clang could coalesce DFG_ASSERTS with other
     11        assertion failures in the same function. This patch moves it out
     12        of line to help fix that issue.
     13
     14        * wtf/Assertions.cpp:
     15        (WTFCrashWithInfo):
     16        * wtf/Assertions.h:
     17        (WTF::isIntegralType):
     18
    1192017-06-30  Yusuke Suzuki  <utatane.tea@gmail.com>
    220
  • trunk/Source/WTF/wtf/Assertions.cpp

    r218069 r219046  
    560560} // extern "C"
    561561
     562#if OS(DARWIN) && (CPU(X64_64) || CPU(ARM64))
     563#if CPU(X86_64)
     564#define STUFF_REGISTER_FOR_CRASH(reg, info) __asm__ volatile ("movq %0, %%" reg : : "r" (static_cast<uint64_t>(info)) : reg)
     565
     566// This ordering was chosen to be consistent with JSC's JIT asserts. We probably shouldn't change this ordering
     567// since it would make tooling crash reports much harder. If, for whatever reason, we decide to change the ordering
     568// here we should update the abortWithuint64_t functions.
     569#define STUFF_FOR_CRASH_REGISTER1 "r11"
     570#define STUFF_FOR_CRASH_REGISTER2 "r10"
     571#define STUFF_FOR_CRASH_REGISTER3 "r9"
     572#define STUFF_FOR_CRASH_REGISTER4 "r8"
     573#define STUFF_FOR_CRASH_REGISTER5 "r15"
     574
     575#elif CPU(ARM64) // CPU(X86_64)
     576#define STUFF_REGISTER_FOR_CRASH(reg, info) __asm__ volatile ("mov " reg ", %0" : : "r" (static_cast<uint64_t>(info)) : reg)
     577
     578// See comment above on the ordering.
     579#define STUFF_FOR_CRASH_REGISTER1 "x16"
     580#define STUFF_FOR_CRASH_REGISTER2 "x17"
     581#define STUFF_FOR_CRASH_REGISTER3 "x18"
     582#define STUFF_FOR_CRASH_REGISTER4 "x19"
     583#define STUFF_FOR_CRASH_REGISTER5 "x20"
     584
     585#endif // CPU(ARM64)
     586
     587void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4)
     588{
     589    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER1, reason);
     590    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER2, misc1);
     591    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER3, misc2);
     592    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER4, misc3);
     593    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER5, misc4);
     594    CRASH();
     595}
     596
     597void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3)
     598{
     599    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER1, reason);
     600    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER2, misc1);
     601    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER3, misc2);
     602    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER4, misc3);
     603    CRASH();
     604}
     605
     606void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t reason, uint64_t misc1, uint64_t misc2)
     607{
     608    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER1, reason);
     609    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER2, misc1);
     610    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER3, misc2);
     611    CRASH();
     612}
     613
     614void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t reason, uint64_t misc1)
     615{
     616    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER1, reason);
     617    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER2, misc1);
     618    CRASH();
     619}
     620
     621void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t reason)
     622{
     623    STUFF_REGISTER_FOR_CRASH(STUFF_FOR_CRASH_REGISTER1, reason);
     624    CRASH();
     625}
     626
     627void WTFCrashWithInfo(int, const char*, const char*, int)
     628{
     629    CRASH();
     630}
     631
     632#else
     633
     634void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t) { CRASH(); }
     635void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t, uint64_t, uint64_t, uint64_t) { CRASH(); }
     636void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t, uint64_t, uint64_t) { CRASH(); }
     637void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t, uint64_t) { CRASH(); }
     638void WTFCrashWithInfo(int, const char*, const char*, int, uint64_t) { CRASH(); }
     639void WTFCrashWithInfo(int, const char*, const char*, int) { CRASH(); }
     640
     641#endif // OS(DARWIN) && (CPU(X64_64) || CPU(ARM64))
     642
    562643namespace WTF {
    563644
  • trunk/Source/WTF/wtf/Assertions.h

    r219006 r219046  
    5252#endif
    5353
     54#ifdef __cplusplus
     55#include <type_traits>
     56#endif
     57
    5458#ifdef NDEBUG
    5559/* Disable ASSERT* macros in release mode. */
     
    466470#endif
    467471
     472#ifdef __cplusplus
     473
     474// The combination of line, file, function, and counter should be a unique number per call to this crash. This forces the compiler to not coalesce calls to WTFCrashWithInfo.
     475// The easiest way to fill these values per translation unit is to pass __LINE__, __FILE__, WTF_PRETTY_FUNCTION, and __COUNTER__.
     476WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3, uint64_t misc4);
     477WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2, uint64_t misc3);
     478WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1, uint64_t misc2);
     479WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason, uint64_t misc1);
     480WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, uint64_t reason);
     481WTF_EXPORT_PRIVATE NO_RETURN_DUE_TO_CRASH void WTFCrashWithInfo(int line, const char* file, const char* function, int counter);
     482
     483
     484namespace WTF {
     485inline void isIntegralType() { }
     486
     487template<typename T, typename... Types>
     488void isIntegralType(T, Types... types)
     489{
     490    static_assert(std::is_integral<T>::value || std::is_enum<T>::value, "All types need to be integral bitwise_cast to integral type for logging");
     491    isIntegralType(types...);
     492}
     493}
     494
     495#ifndef INLINE_CRASH_WITH_SECURITY_IMPLICATION_AND_INFO
     496// This is useful if you are going to stuff data into registers before crashing. Like the crashWithInfo functions below...
     497// GCC doesn't like the ##__VA_ARGS__ here since this macro is called from another macro so we just CRASH instead there.
     498#if COMPILER(CLANG) || COMPILER(MSVC)
     499#define CRASH_WITH_SECURITY_IMPLICATION_AND_INFO(...) do { \
     500        WTF::isIntegralType(__VA_ARGS__); \
     501        WTFCrashWithInfo(__LINE__, __FILE__, WTF_PRETTY_FUNCTION, __COUNTER__, ##__VA_ARGS__); \
     502    } while (false)
     503#else
     504#define CRASH_WITH_SECURITY_IMPLICATION_AND_INFO(...) CRASH()
     505#endif
     506#endif // INLINE_CRASH_WITH_SECURITY_IMPLICATION_AND_INFO
     507
     508#endif // __cplusplus
    468509
    469510#endif /* WTF_Assertions_h */
Note: See TracChangeset for help on using the changeset viewer.