<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196535] trunk/Source/bmalloc</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196535">196535</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2016-02-12 17:05:43 -0800 (Fri, 12 Feb 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make BCRASH() use breakpoint traps too for non-debug OS(DARWIN).
https://bugs.webkit.org/show_bug.cgi?id=154184

Reviewed by Saam Barati.

This makes it behave consistently with WTFCrash().

* bmalloc/BAssert.h:
* bmalloc/BPlatform.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourcebmallocChangeLog">trunk/Source/bmalloc/ChangeLog</a></li>
<li><a href="#trunkSourcebmallocbmallocBAsserth">trunk/Source/bmalloc/bmalloc/BAssert.h</a></li>
<li><a href="#trunkSourcebmallocbmallocBPlatformh">trunk/Source/bmalloc/bmalloc/BPlatform.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourcebmallocChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/ChangeLog (196534 => 196535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/ChangeLog        2016-02-13 00:42:03 UTC (rev 196534)
+++ trunk/Source/bmalloc/ChangeLog        2016-02-13 01:05:43 UTC (rev 196535)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-02-12  Mark Lam  &lt;mark.lam@apple.com&gt;
+
+        Make BCRASH() use breakpoint traps too for non-debug OS(DARWIN).
+        https://bugs.webkit.org/show_bug.cgi?id=154184
+
+        Reviewed by Saam Barati.
+
+        This makes it behave consistently with WTFCrash().
+
+        * bmalloc/BAssert.h:
+        * bmalloc/BPlatform.h:
+
</ins><span class="cx"> 2016-02-11  Michael Saboff  &lt;msaboff@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed build fix after r196421.
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocBAsserth"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/BAssert.h (196534 => 196535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/BAssert.h        2016-02-13 00:42:03 UTC (rev 196534)
+++ trunk/Source/bmalloc/bmalloc/BAssert.h        2016-02-13 01:05:43 UTC (rev 196535)
</span><span class="lines">@@ -26,10 +26,36 @@
</span><span class="cx"> #ifndef BAssert_h
</span><span class="cx"> #define BAssert_h
</span><span class="cx"> 
</span><ins>+#include &quot;BPlatform.h&quot;
+
+#if defined(NDEBUG) &amp;&amp; BOS(DARWIN)
+
+#if BCPU(X86_64) || BCPU(X86)
+#define BBreakpointTrap()  asm volatile (&quot;int3&quot;)
+#elif BCPU(ARM_THUMB2)
+#define BBreakpointTrap()  asm volatile (&quot;bkpt #0&quot;)
+#elif BCPU(ARM64)
+#define BBreakpointTrap()  asm volatile (&quot;brk #0&quot;)
+#else
+#error &quot;Unsupported CPU&quot;.
+#endif
+
+// Crash with a SIGTRAP i.e EXC_BREAKPOINT.
+// We are not using __builtin_trap because it is only guaranteed to abort, but not necessarily
+// trigger a SIGTRAP. Instead, we use inline asm to ensure that we trigger the SIGTRAP.
</ins><span class="cx"> #define BCRASH() do { \
</span><ins>+        BBreakpointTrap(); \
+        __builtin_unreachable(); \
+    } while (false)
+
+#else // not defined(NDEBUG) &amp;&amp; BOS(DARWIN)
+
+#define BCRASH() do { \
</ins><span class="cx">     *(int*)0xbbadbeef = 0; \
</span><span class="cx"> } while (0);
</span><span class="cx"> 
</span><ins>+#endif // defined(NDEBUG) &amp;&amp; BOS(DARWIN)
+
</ins><span class="cx"> #define BASSERT_IMPL(x) do { \
</span><span class="cx">     if (!(x)) \
</span><span class="cx">         BCRASH(); \
</span></span></pre></div>
<a id="trunkSourcebmallocbmallocBPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/bmalloc/bmalloc/BPlatform.h (196534 => 196535)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/bmalloc/bmalloc/BPlatform.h        2016-02-13 00:42:03 UTC (rev 196534)
+++ trunk/Source/bmalloc/bmalloc/BPlatform.h        2016-02-13 01:05:43 UTC (rev 196535)
</span><span class="lines">@@ -47,4 +47,138 @@
</span><span class="cx"> #define BOS_UNIX 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/* ==== Platform adaptation macros: these describe properties of the target environment. ==== */
+
+/* BCPU() - the target CPU architecture */
+#define BCPU(_FEATURE) (defined BCPU_##_FEATURE  &amp;&amp; BCPU_##_FEATURE)
+
+/* BCPU(X86) - i386 / x86 32-bit */
+#if defined(__i386__) \
+|| defined(i386)     \
+|| defined(_M_IX86)  \
+|| defined(_X86_)    \
+|| defined(__THW_INTEL)
+#define BCPU_X86 1
+#endif
+
+/* BCPU(X86_64) - AMD64 / Intel64 / x86_64 64-bit */
+#if defined(__x86_64__) \
+|| defined(_M_X64)
+#define BCPU_X86_64 1
+#endif
+
+/* BCPU(ARM64) - Apple */
+#if (defined(__arm64__) &amp;&amp; defined(__APPLE__)) || defined(__aarch64__)
+#define BCPU_ARM64 1
+#endif
+
+/* BCPU(ARM) - ARM, any version*/
+#define BARM_ARCH_AT_LEAST(N) (BCPU(ARM) &amp;&amp; BARM_ARCH_VERSION &gt;= N)
+
+#if   defined(arm) \
+|| defined(__arm__) \
+|| defined(ARM) \
+|| defined(_ARM_)
+#define BCPU_ARM 1
+
+/* Set BARM_ARCH_VERSION */
+#if   defined(__ARM_ARCH_4__) \
+|| defined(__ARM_ARCH_4T__) \
+|| defined(__MARM_ARMV4__)
+#define BARM_ARCH_VERSION 4
+
+#elif defined(__ARM_ARCH_5__) \
+|| defined(__ARM_ARCH_5T__) \
+|| defined(__MARM_ARMV5__)
+#define BARM_ARCH_VERSION 5
+
+#elif defined(__ARM_ARCH_5E__) \
+|| defined(__ARM_ARCH_5TE__) \
+|| defined(__ARM_ARCH_5TEJ__)
+#define BARM_ARCH_VERSION 5
+
+#elif defined(__ARM_ARCH_6__) \
+|| defined(__ARM_ARCH_6J__) \
+|| defined(__ARM_ARCH_6K__) \
+|| defined(__ARM_ARCH_6Z__) \
+|| defined(__ARM_ARCH_6ZK__) \
+|| defined(__ARM_ARCH_6T2__) \
+|| defined(__ARMV6__)
+#define BARM_ARCH_VERSION 6
+
+#elif defined(__ARM_ARCH_7A__) \
+|| defined(__ARM_ARCH_7K__) \
+|| defined(__ARM_ARCH_7R__) \
+|| defined(__ARM_ARCH_7S__)
+#define BARM_ARCH_VERSION 7
+
+#elif defined(__ARM_ARCH_8__)
+#define BARM_ARCH_VERSION 8
+
+/* MSVC sets _M_ARM */
+#elif defined(_M_ARM)
+#define BARM_ARCH_VERSION _M_ARM
+
+/* RVCT sets _TARGET_ARCH_ARM */
+#elif defined(__TARGET_ARCH_ARM)
+#define BARM_ARCH_VERSION __TARGET_ARCH_ARM
+
+#else
+#define WTF_ARM_ARCH_VERSION 0
+
+#endif
+
+/* Set BTHUMB_ARCH_VERSION */
+#if   defined(__ARM_ARCH_4T__)
+#define BTHUMB_ARCH_VERSION 1
+
+#elif defined(__ARM_ARCH_5T__) \
+|| defined(__ARM_ARCH_5TE__) \
+|| defined(__ARM_ARCH_5TEJ__)
+#define BTHUMB_ARCH_VERSION 2
+
+#elif defined(__ARM_ARCH_6J__) \
+|| defined(__ARM_ARCH_6K__) \
+|| defined(__ARM_ARCH_6Z__) \
+|| defined(__ARM_ARCH_6ZK__) \
+|| defined(__ARM_ARCH_6M__)
+#define BTHUMB_ARCH_VERSION 3
+
+#elif defined(__ARM_ARCH_6T2__) \
+|| defined(__ARM_ARCH_7__) \
+|| defined(__ARM_ARCH_7A__) \
+|| defined(__ARM_ARCH_7K__) \
+|| defined(__ARM_ARCH_7M__) \
+|| defined(__ARM_ARCH_7R__) \
+|| defined(__ARM_ARCH_7S__)
+#define BTHUMB_ARCH_VERSION 4
+
+/* RVCT sets __TARGET_ARCH_THUMB */
+#elif defined(__TARGET_ARCH_THUMB)
+#define BTHUMB_ARCH_VERSION __TARGET_ARCH_THUMB
+
+#else
+#define BTHUMB_ARCH_VERSION 0
+#endif
+
+/* BCPU(ARM_TRADITIONAL) - Thumb2 is not available, only traditional ARM (v4 or greater) */
+/* BCPU(ARM_THUMB2) - Thumb2 instruction set is available */
+/* Only one of these will be defined. */
+#if !defined(BCPU_ARM_TRADITIONAL) &amp;&amp; !defined(BCPU_ARM_THUMB2)
+#  if defined(thumb2) || defined(__thumb2__) \
+|| ((defined(__thumb) || defined(__thumb__)) &amp;&amp; BTHUMB_ARCH_VERSION == 4)
+#    define BCPU_ARM_TRADITIONAL 0
+#    define BCPU_ARM_THUMB2 1
+#  elif BARM_ARCH_AT_LEAST(4)
+#    define BCPU_ARM_TRADITIONAL 1
+#    define BCPU_ARM_THUMB2 0
+#  else
+#    error &quot;Not supported ARM architecture&quot;
+#  endif
+#elif BCPU(ARM_TRADITIONAL) &amp;&amp; BCPU(ARM_THUMB2) /* Sanity Check */
+#  error &quot;Cannot use both of BCPU_ARM_TRADITIONAL and BCPU_ARM_THUMB2 platforms&quot;
+#endif /* !defined(BCPU_ARM_TRADITIONAL) &amp;&amp; !defined(BCPU_ARM_THUMB2) */
+
+#endif /* ARM */
+
</ins><span class="cx"> #endif // BPlatform_h
</span></span></pre>
</div>
</div>

</body>
</html>