Bug 191050 - Convert StringBuilder to be templatized on an OverflowHandler.
Summary: Convert StringBuilder to be templatized on an OverflowHandler.
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on: 184883
  Show dependency treegraph
Reported: 2018-10-29 17:55 PDT by Mark Lam
Modified: 2018-10-29 18:38 PDT (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Mark Lam 2018-10-29 17:55:11 PDT
https://bugs.webkit.org/show_bug.cgi?id=184883 introduced the ConditionalCrashOnOverflow handler which is used in StringBuilder so that it can do a runtime determination whether to crash on overflows or not.  Technically, StringBuilder can be templatized with an OverflowHandler template parameter instead (just like CheckedArithmetic) and produce more efficient code.  However, when I attempted this (to templatize StringBuilder), I ran into an issue of clang not exporting explicitly instantiated some StringBuilder methods (instantiated for CrashOnOverflow and for RecordOverflow handlers).  As a result, clients of JavaScriptCore were not able to link to those methods.

To work around this issue, I introduced the ConditionalCrashOnOverflow handler, thereby allowing StringBuilder to remain a plain class.  If we can find a way to make clang export explicitly instantiated template methods, we should convert StringBuilder into a template and do away with the runtime shouldCrashOnOverflow checks in ConditionalCrashOnOverflow.