Bug 191050

Summary: Convert StringBuilder to be templatized on an OverflowHandler.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal    
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 184883    
Bug Blocks:    

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.