Placement new does an unnecessary NULL check
https://bugs.webkit.org/show_bug.cgi?id=74676
Reviewed by Sam Weinig.
Source/JavaScriptCore:
We can define our own version, which skips the NULL check.
Not a measurable speedup, but code inspection shows better code generated,
and I believe this is a step toward turning off -fomit-frame-pointer.
- API/JSCallbackConstructor.h:
(JSC::JSCallbackConstructor::create):
- API/JSCallbackFunction.h:
(JSC::JSCallbackFunction::create): Use the NotNull version of placement
new to skip the NULL check.
- API/JSCallbackObject.h: Removed a conflicting, unnecessaray placement new.
(JSC::JSCallbackObject::create):
- debugger/DebuggerActivation.h:
(JSC::DebuggerActivation::create):
(JSC::HandleHeap::grow):
(JSC::HandleHeap::allocate):
(JSC::MarkedBlock::create):
(JSC::MarkedBlock::recycle):
(JSC::JITCode::clear):
(GlobalObject::create):
- profiler/CallIdentifier.h:
- runtime/Arguments.h:
(JSC::Arguments::create):
- runtime/ArrayConstructor.h:
(JSC::ArrayConstructor::create):
- runtime/ArrayPrototype.h:
(JSC::ArrayPrototype::create):
- runtime/BooleanConstructor.h:
(JSC::BooleanConstructor::create):
(JSC::BooleanObject::create):
- runtime/BooleanPrototype.h:
(JSC::BooleanPrototype::create):
- runtime/DateConstructor.h:
(JSC::DateConstructor::create):
(JSC::DateInstance::create):
(JSC::DatePrototype::create):
(JSC::StrictModeTypeErrorFunction::create):
- runtime/ErrorConstructor.h:
(JSC::ErrorConstructor::create):
(JSC::ErrorInstance::create):
- runtime/ErrorPrototype.h:
(JSC::ErrorPrototype::create):
- runtime/ExceptionHelpers.h:
(JSC::InterruptedExecutionError::create):
(JSC::TerminatedExecutionError::create):
(JSC::NativeExecutable::create):
(JSC::EvalExecutable::create):
(JSC::ProgramExecutable::create):
(JSC::FunctionExecutable::create):
- runtime/FunctionConstructor.h:
(JSC::FunctionConstructor::create):
- runtime/FunctionPrototype.h:
(JSC::FunctionPrototype::create):
(JSC::GetterSetter::create):
- runtime/JSAPIValueWrapper.h:
(JSC::JSAPIValueWrapper::create):
(JSC::JSActivation::create):
(JSC::JSArray::create):
- runtime/JSBoundFunction.cpp:
(JSC::JSBoundFunction::create):
(JSC::JSByteArray::create): Use the NotNull version of placement
new to skip the NULL check.
- runtime/JSCell.h: Removed a conflicting, unnecessaray placement new.
(JSC::JSFunction::create):
(JSC::JSFunction::create):
- runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::create):
(JSC::JSGlobalThis::create):
(JSC::JSNotAnObject::create):
(JSC::JSONObject::create):
(JSC::JSFinalObject::create):
- runtime/JSPropertyNameIterator.cpp:
(JSC::JSPropertyNameIterator::create):
- runtime/JSPropertyNameIterator.h:
(JSC::JSPropertyNameIterator::create):
- runtime/JSStaticScopeObject.h:
(JSC::JSStaticScopeObject::create):
(JSC::StringObject::create):
(JSC::RopeBuilder::createNull):
(JSC::RopeBuilder::create):
(JSC::RopeBuilder::createHasOtherOwner):
(JSC::MathObject::create):
- runtime/NativeErrorConstructor.h:
(JSC::NativeErrorConstructor::create):
- runtime/NativeErrorPrototype.h:
(JSC::NativeErrorPrototype::create):
- runtime/NumberConstructor.h:
(JSC::NumberConstructor::create):
(JSC::NumberObject::create):
- runtime/NumberPrototype.h:
(JSC::NumberPrototype::create):
- runtime/ObjectConstructor.h:
(JSC::ObjectConstructor::create):
- runtime/ObjectPrototype.h:
(JSC::ObjectPrototype::create):
(JSC::RegExp::createWithoutCaching):
- runtime/RegExpConstructor.h:
(JSC::RegExpConstructor::create):
- runtime/RegExpMatchesArray.h:
(JSC::RegExpMatchesArray::create):
(JSC::RegExpObject::create):
- runtime/RegExpPrototype.h:
(JSC::RegExpPrototype::create):
(JSC::ScopeChainNode::create):
- runtime/StrictEvalActivation.h:
(JSC::StrictEvalActivation::create):
- runtime/StringConstructor.h:
(JSC::StringConstructor::create):
(JSC::StringObject::create):
- runtime/StringPrototype.h:
(JSC::StringPrototype::create):
(JSC::Structure::create):
(JSC::Structure::createStructure):
- runtime/StructureChain.h:
(JSC::StructureChain::create):
(GlobalObject::create):
(WTF::BitVector::OutOfLineBits::create): Use the NotNull version of placement
new to skip the NULL check.
- wtf/BumpPointerAllocator.h:
(WTF::BumpPointerPool::create): Standardized spacing to make grep easier.
(WTF::ByteArray::create):
(WTF::::append):
(WTF::::prepend): Use NotNull, as above.
- wtf/FastAllocBase.h: Added a placement new, since this class would otherwise
hide the name of the global placement new.
(WTF::fastNew): Standardized spacing. Most of these functions don't need
NotNull, since they check for NULL, and the optimizer can see that.
- wtf/HashTable.h:
- wtf/HashTraits.h:
(WTF::SimpleClassHashTraits::constructDeletedValue):
(WTF::MetaAllocator::allocFreeSpaceNode): NotNull, as above.
(throw): This is our NotNull placement new. Declaring that we throw is
the C++ way to say that operator new will not return NULL.
(WTF::T):
(WTF::::append):
(WTF::::tryAppend):
(WTF::::uncheckedAppend):
(WTF::::insert):
- wtf/text/AtomicStringHash.h:
- wtf/text/StringImpl.cpp:
(WTF::StringImpl::createUninitialized):
(WTF::StringImpl::reallocate):
(WTF::StringImpl::tryCreateUninitialized):
- wtf/text/StringStatics.cpp:
(WTF::AtomicString::init): Use NotNull, as above.
- yarr/YarrInterpreter.cpp:
(JSC::Yarr::Interpreter::allocDisjunctionContext):
(JSC::Yarr::Interpreter::ParenthesesDisjunctionContext::ParenthesesDisjunctionContext):
(JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext): Standardized
spacing for easy grep.
Source/WebCore:
- bindings/js/JSImageConstructor.h:
(WebCore::JSImageConstructor::create):
- bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateConstructorDeclaration):
- bridge/c/CRuntimeObject.h:
(JSC::Bindings::CRuntimeObject::create):
(JSC::Bindings::CRuntimeMethod::create):
- bridge/jni/jsc/JavaInstanceJSC.cpp:
(JavaRuntimeMethod::create):
- bridge/jni/jsc/JavaRuntimeObject.h:
(JSC::Bindings::JavaRuntimeObject::create):
- bridge/objc/ObjCRuntimeObject.h:
(JSC::Bindings::ObjCRuntimeObject::create):
- bridge/objc/objc_instance.mm:
(ObjCRuntimeMethod::create):
- bridge/objc/objc_runtime.h:
(JSC::Bindings::ObjcFallbackObjectImp::create):
(JSC::RuntimeArray::create):
(JSC::RuntimeMethod::create):
(JSC::Bindings::RuntimeObject::create):
(WebCore::FormElementKeyHashTraits::constructDeletedValue): Use NotNull
placement new, as in JavaScriptCore.
(WebCore::PODArena::allocateObject): No need to check for NULL explicitly,
since that's the built-in behavior of placement new.
- platform/graphics/FontCache.cpp:
(WebCore::FontDataCacheKeyTraits::constructDeletedValue):
- platform/graphics/IntRectHash.h:
- platform/graphics/IntSizeHash.h: More NotNull.
- rendering/RenderObject.h: Declaring that we throw is the C++ way to say
that operator new will not return NULL.