Skip to content
Permalink
Browse files
Force PAS_ASSERT to generate different crash sites for each assertion.
https://bugs.webkit.org/show_bug.cgi?id=240209

Reviewed by Yusuke Suzuki.

Clang currently optimizes all crash sites into one in each function.  Hence, if we
get a crash address at the 1 crash site, we don't know which failed assertion got
us there.  This patch uses an asm statement to force Clang to emit a different
crash site for each assertion.

Benchmarks show that performance is neutral on both Jetstream2 and Speedometer2.

Size-wise, there is some increase.  The following is the "size" output on
JavaScriptCore on M1:

          __TEXT.   __DATA  __OBJC  others    dec       hex
    old   19628032  180224  0       18792448  38600704  24d0000
    new   19644416  180224  0       19251200  39075840  2544000

    diff  16384     0       0       458752    475136

The increase in the "others" categories are mostly in the String Table, Symbol
Table, and Function Start Addresses.  These take up disk space but should not
impact RAM usage unless they are accessed by a a debugger.

* libpas/src/libpas/pas_utils.h:
(pas_assertion_failed):

Canonical link: https://commits.webkit.org/250398@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293952 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Mark Lam committed May 8, 2022
1 parent 2804ea0 commit faada14a2ef2d98d29d06c55fcf45678b40e7f7d
Showing 2 changed files with 35 additions and 5 deletions.
@@ -1,3 +1,33 @@
2022-05-07 Mark Lam <mark.lam@apple.com>

Force PAS_ASSERT to generate different crash sites for each assertion.
https://bugs.webkit.org/show_bug.cgi?id=240209

Reviewed by Yusuke Suzuki.

Clang currently optimizes all crash sites into one in each function. Hence, if we
get a crash address at the 1 crash site, we don't know which failed assertion got
us there. This patch uses an asm statement to force Clang to emit a different
crash site for each assertion.

Benchmarks show that performance is neutral on both Jetstream2 and Speedometer2.

Size-wise, there is some increase. The following is the "size" output on
JavaScriptCore on M1:

__TEXT. __DATA __OBJC others dec hex
old 19628032 180224 0 18792448 38600704 24d0000
new 19644416 180224 0 19251200 39075840 2544000

diff 16384 0 0 458752 475136

The increase in the "others" categories are mostly in the String Table, Symbol
Table, and Function Start Addresses. These take up disk space but should not
impact RAM usage unless they are accessed by a a debugger.

* libpas/src/libpas/pas_utils.h:
(pas_assertion_failed):

2022-04-27 Ross Kirsling <rkirsling@gmail.com>

Unreviewed libpas build fix for PlayStation.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021 Apple Inc. All rights reserved.
* Copyright (c) 2018-2022 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -193,10 +193,10 @@ PAS_API PAS_NO_RETURN void pas_assertion_failed(
static PAS_ALWAYS_INLINE PAS_NO_RETURN void pas_assertion_failed(
const char* filename, int line, const char* function, const char* expression)
{
PAS_UNUSED_PARAM(filename);
PAS_UNUSED_PARAM(line);
PAS_UNUSED_PARAM(function);
PAS_UNUSED_PARAM(expression);
#if PAS_COMPILER(GCC) || PAS_COMPILER(CLANG)
// Force each assertion crash site to be unique.
asm volatile("" : "=r"(filename), "=r"(line), "=r"(function), "=r"(expression));
#endif
__builtin_trap();
}
#endif /* PAS_ENABLE_TESTING -> so end of !PAS_ENABLE_TESTING */

0 comments on commit faada14

Please sign in to comment.