Fix some RELEASE_ASSERT failures caused by OutOfMemoryErrors.
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Apr 2017 04:15:00 +0000 (04:15 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Apr 2017 04:15:00 +0000 (04:15 +0000)
commitb269fb991cd07e8d605d0887f1db3be8709cbebd
treedaf86f8b04a3c83b52adcac59d179295af484cd0
parent347bb776dd3365106e81495bbed7b247e8f339a6
Fix some RELEASE_ASSERT failures caused by OutOfMemoryErrors.
https://bugs.webkit.org/show_bug.cgi?id=171404
<rdar://problem/31876178>

Reviewed by Saam Barati.

JSTests:

* stress/js-fixed-array-out-of-memory.js: Added.

Source/JavaScriptCore:

1. Added some tryAllocate() functions in JSCellInlines.h.
2. Consolidated the implementations of allocateCell() template functions into a
   single tryAllocateCellHelper() to reduce redundancy and eliminate needing to
   copy-paste for variations of allocateCell and tryAllocateCell.
3. Changed JSFixedArray::createFromArray() and constructEmptyArray() to check for
   allocation failure and throw an OutOfMemoryError.  It was already possible to
   throw errors from these functions for other reasons.  So, their clients are
   already ready to handle OOMEs.

* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* runtime/JSCInlines.h:
* runtime/JSCell.h:
* runtime/JSCellInlines.h:
(JSC::tryAllocateCellHelper):
(JSC::allocateCell):
(JSC::tryAllocateCell):
* runtime/JSFixedArray.h:
(JSC::JSFixedArray::createFromArray):
(JSC::JSFixedArray::tryCreate):
(JSC::JSFixedArray::create): Deleted.
* runtime/JSGlobalObject.h:
(JSC::constructEmptyArray):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@215919 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/stress/js-fixed-array-out-of-memory.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/ftl/FTLOperations.cpp
Source/JavaScriptCore/runtime/JSCInlines.h
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSCellInlines.h
Source/JavaScriptCore/runtime/JSFixedArray.h
Source/JavaScriptCore/runtime/JSGlobalObject.h