source: webkit/trunk/Source/JavaScriptCore/testRegExp.cpp@ 291779

Last change on this file since 291779 was 291779, checked in by Chris Dumez, 3 years ago

Prepare JSC for making the String(const char*) constructor explicit
https://bugs.webkit.org/show_bug.cgi?id=238264

Reviewed by Geoff Garen.

Source/JavaScriptCore:

Prepare JSC for making the String(const char*) constructor explicit. Making this constructor
explicit helps catch many instances where we're constructing a String from a literal but we
are missing the ""_s suffix.

  • API/JSAPIGlobalObject.cpp:
  • API/JSAPIGlobalObject.mm:

(JSC::computeValidImportSpecifier):
(JSC::JSAPIGlobalObject::moduleLoaderFetch):

  • API/JSAPIValueWrapper.cpp:
  • API/JSAPIWrapperObject.mm:
  • API/JSCallbackConstructor.cpp:
  • API/JSCallbackFunction.cpp:
  • API/JSCallbackObject.cpp:
  • API/JSCallbackObjectFunctions.h:

(JSC::JSCallbackObject<Parent>::getOwnPropertySlot):

  • API/JSScript.mm:

(-[JSScript readCache]):

  • API/JSTypedArray.cpp:

(JSObjectMakeTypedArrayWithArrayBuffer):
(JSObjectMakeTypedArrayWithArrayBufferAndOffset):

  • API/JSValue.mm:

(createStructHandlerMap):
(handerForStructTag):

  • API/JSWrapperMap.mm:

(allocateConstructorForCustomClass):

  • API/ObjCCallbackFunction.mm:

(JSC::ObjCCallbackFunctionImpl::name):

  • API/glib/JSAPIWrapperGlobalObject.cpp:
  • API/glib/JSAPIWrapperObjectGLib.cpp:
  • API/glib/JSCCallbackFunction.cpp:
  • API/tests/JSONParseTest.cpp:

(testJSONParse):

  • bindings/ScriptFunctionCall.cpp:

(Deprecated::ScriptCallArgumentHandler::appendArgument):

  • bytecode/CodeBlock.cpp:
  • bytecode/EvalCodeBlock.cpp:
  • bytecode/ExecutableToCodeBlockEdge.cpp:
  • bytecode/ExitKind.cpp:

(JSC::exitKindToString):

  • bytecode/ExitKind.h:
  • bytecode/FunctionCodeBlock.cpp:
  • bytecode/ModuleProgramCodeBlock.cpp:
  • bytecode/ProgramCodeBlock.cpp:
  • bytecode/UnlinkedCodeBlock.cpp:
  • bytecode/UnlinkedEvalCodeBlock.cpp:
  • bytecode/UnlinkedFunctionCodeBlock.cpp:
  • bytecode/UnlinkedFunctionExecutable.cpp:
  • bytecode/UnlinkedModuleProgramCodeBlock.cpp:
  • bytecode/UnlinkedProgramCodeBlock.cpp:
  • bytecompiler/BytecodeGenerator.cpp:

(JSC::BytecodeGenerator::BytecodeGenerator):
(JSC::BytecodeGenerator::emitHasPrivateBrand):
(JSC::BytecodeGenerator::emitCheckPrivateBrand):
(JSC::BytecodeGenerator::emitReturn):

  • bytecompiler/NodesCodegen.cpp:

(JSC::PropertyListNode::emitSaveComputedFieldName):
(JSC::BaseDotNode::emitGetPropertyValue):
(JSC::BaseDotNode::emitPutProperty):
(JSC::PostfixNode::emitDot):
(JSC::DeleteBracketNode::emitBytecode):
(JSC::DeleteDotNode::emitBytecode):
(JSC::PrefixNode::emitDot):
(JSC::InstanceOfNode::emitBytecode):

  • debugger/DebuggerCallFrame.cpp:

(JSC::DebuggerCallFrame::functionName const):

  • debugger/DebuggerScope.cpp:
  • heap/HeapSnapshotBuilder.cpp:

(JSC::HeapSnapshotBuilder::json):

  • heap/RootMarkReason.cpp:

(JSC::rootMarkReasonDescription):

  • heap/RootMarkReason.h:
  • inspector/JSGlobalObjectInspectorController.cpp:

(Inspector::JSGlobalObjectInspectorController::appendAPIBacktrace):

  • inspector/JSInjectedScriptHost.cpp:

(Inspector::JSInjectedScriptHost::getInternalProperties):

  • inspector/JSInjectedScriptHostPrototype.cpp:
  • inspector/JSJavaScriptCallFrame.cpp:
  • inspector/JSJavaScriptCallFramePrototype.cpp:
  • inspector/agents/InspectorAuditAgent.cpp:

(Inspector::InspectorAuditAgent::run):

  • inspector/agents/InspectorDebuggerAgent.cpp:

(Inspector::InspectorDebuggerAgent::getScriptSource):

  • inspector/agents/InspectorDebuggerAgent.h:
  • inspector/agents/InspectorHeapAgent.cpp:

(Inspector::InspectorHeapAgent::getRemoteObject):

  • jit/ExecutableAllocator.cpp:

(JSC::dumpJITMemory):

  • jit/JITCode.cpp:

(JSC::JITCode::typeName):

  • jit/JITCode.h:
  • jit/JITOperations.cpp:

(JSC::getWrappedValue):

  • jsc.cpp:

(toCString):
(JSC_DEFINE_HOST_FUNCTION):
(runWithOptions):
(CommandLine::parseArguments):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::handleVarargsCheckpoint):

  • parser/Lexer.cpp:

(JSC::Lexer<T>::scanRegExp):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parsePrimaryExpression):

  • runtime/AbstractModuleRecord.cpp:
  • runtime/AggregateErrorConstructor.cpp:
  • runtime/ArrayConstructor.cpp:
  • runtime/ArrayIteratorPrototype.cpp:
  • runtime/ArrayPrototype.cpp:
  • runtime/AsyncFromSyncIteratorPrototype.cpp:
  • runtime/AsyncFunctionConstructor.cpp:
  • runtime/AsyncFunctionPrototype.cpp:
  • runtime/AsyncGeneratorFunctionConstructor.cpp:
  • runtime/AsyncGeneratorFunctionPrototype.cpp:
  • runtime/AsyncGeneratorPrototype.cpp:
  • runtime/AsyncIteratorPrototype.cpp:
  • runtime/AtomicsObject.cpp:
  • runtime/BigIntConstructor.cpp:
  • runtime/BigIntObject.cpp:
  • runtime/BigIntPrototype.cpp:
  • runtime/BooleanConstructor.cpp:
  • runtime/BooleanObject.cpp:
  • runtime/BooleanPrototype.cpp:
  • runtime/BytecodeCacheError.cpp:

(JSC::BytecodeCacheError::StandardError::message const):

  • runtime/CallData.cpp:

(JSC::call):

  • runtime/CallData.h:
  • runtime/ClassInfo.h:
  • runtime/ClonedArguments.cpp:
  • runtime/CodeCache.cpp:

(JSC::CodeCache::getUnlinkedGlobalFunctionExecutable):

  • runtime/Completion.cpp:

(JSC::checkModuleSyntax):
(JSC::createSymbolForEntryPointModule):

  • runtime/ConsoleObject.cpp:
  • runtime/ConstructData.cpp:

(JSC::construct):

  • runtime/ConstructData.h:
  • runtime/CustomGetterSetter.cpp:
  • runtime/DOMAttributeGetterSetter.cpp:
  • runtime/DateConstructor.cpp:
  • runtime/DateInstance.cpp:
  • runtime/DatePrototype.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/DirectArguments.cpp:
  • runtime/Error.h:

(JSC::throwVMError):

  • runtime/ErrorConstructor.cpp:
  • runtime/ErrorInstance.cpp:
  • runtime/ErrorPrototype.cpp:
  • runtime/EvalExecutable.cpp:
  • runtime/Exception.cpp:
  • runtime/ExceptionHelpers.cpp:

(JSC::notAFunctionSourceAppender):
(JSC::invalidParameterInSourceAppender):
(JSC::invalidParameterInstanceofSourceAppender):
(JSC::invalidPrototypeSourceAppender):
(JSC::createTDZError):
(JSC::createInvalidPrivateNameError):
(JSC::createRedefinedPrivateNameError):
(JSC::createPrivateMethodAccessError):
(JSC::createReinstallPrivateMethodError):

  • runtime/ExecutableBase.cpp:
  • runtime/FinalizationRegistryConstructor.cpp:
  • runtime/FinalizationRegistryPrototype.cpp:
  • runtime/FunctionConstructor.cpp:
  • runtime/FunctionExecutable.cpp:

(JSC::FunctionExecutable::toStringSlow):

  • runtime/FunctionPrototype.cpp:
  • runtime/FunctionRareData.cpp:
  • runtime/GeneratorFunctionConstructor.cpp:
  • runtime/GeneratorFunctionPrototype.cpp:
  • runtime/GeneratorPrototype.cpp:
  • runtime/GetterSetter.cpp:
  • runtime/GlobalExecutable.cpp:
  • runtime/HashMapImpl.cpp:
  • runtime/InternalFunction.cpp:
  • runtime/IntlCollator.cpp:

(JSC::IntlCollator::initializeCollator):

  • runtime/IntlCollatorConstructor.cpp:
  • runtime/IntlCollatorPrototype.cpp:
  • runtime/IntlDateTimeFormat.cpp:

(JSC::IntlDateTimeFormat::initializeDateTimeFormat):

  • runtime/IntlDateTimeFormatConstructor.cpp:
  • runtime/IntlDateTimeFormatPrototype.cpp:
  • runtime/IntlDisplayNames.cpp:
  • runtime/IntlDisplayNamesConstructor.cpp:
  • runtime/IntlDisplayNamesPrototype.cpp:
  • runtime/IntlListFormat.cpp:
  • runtime/IntlListFormatConstructor.cpp:
  • runtime/IntlListFormatPrototype.cpp:
  • runtime/IntlLocale.cpp:

(JSC::IntlLocale::initializeLocale):

  • runtime/IntlLocaleConstructor.cpp:
  • runtime/IntlLocalePrototype.cpp:
  • runtime/IntlNumberFormat.cpp:

(JSC::IntlNumberFormat::initializeNumberFormat):

  • runtime/IntlNumberFormatConstructor.cpp:
  • runtime/IntlNumberFormatPrototype.cpp:
  • runtime/IntlObject.cpp:

(JSC::intlStringOption):

  • runtime/IntlObject.h:
  • runtime/IntlPluralRules.cpp:
  • runtime/IntlPluralRulesConstructor.cpp:
  • runtime/IntlPluralRulesPrototype.cpp:
  • runtime/IntlRelativeTimeFormat.cpp:

(JSC::IntlRelativeTimeFormat::initializeRelativeTimeFormat):

  • runtime/IntlRelativeTimeFormatConstructor.cpp:
  • runtime/IntlRelativeTimeFormatPrototype.cpp:
  • runtime/IntlSegmentIterator.cpp:
  • runtime/IntlSegmentIteratorPrototype.cpp:
  • runtime/IntlSegmenter.cpp:
  • runtime/IntlSegmenterConstructor.cpp:
  • runtime/IntlSegmenterPrototype.cpp:
  • runtime/IntlSegments.cpp:
  • runtime/IntlSegmentsPrototype.cpp:
  • runtime/IteratorPrototype.cpp:
  • runtime/JSArray.cpp:

(JSC::JSArray::tryCreateUninitializedRestricted):

  • runtime/JSArrayBuffer.cpp:
  • runtime/JSArrayBufferConstructor.cpp:
  • runtime/JSArrayBufferPrototype.cpp:
  • runtime/JSArrayBufferView.cpp:
  • runtime/JSArrayIterator.cpp:
  • runtime/JSAsyncFunction.cpp:
  • runtime/JSAsyncGenerator.cpp:
  • runtime/JSAsyncGeneratorFunction.cpp:
  • runtime/JSBigInt.cpp:

(JSC::JSBigInt::parseInt):

  • runtime/JSBoundFunction.cpp:
  • runtime/JSCallee.cpp:
  • runtime/JSCell.cpp:

(JSC::JSCell::dumpToStream):
(JSC::JSCell::className const):

  • runtime/JSCell.h:
  • runtime/JSCustomGetterFunction.cpp:
  • runtime/JSCustomSetterFunction.cpp:
  • runtime/JSDataView.cpp:
  • runtime/JSDataViewPrototype.cpp:

(JSC::JSC_DEFINE_CUSTOM_GETTER):

  • runtime/JSFinalizationRegistry.cpp:

(JSC::JSFinalizationRegistry::runFinalizationCleanup):

  • runtime/JSFunction.cpp:
  • runtime/JSGenerator.cpp:
  • runtime/JSGeneratorFunction.cpp:
  • runtime/JSGenericTypedArrayViewInlines.h:

(JSC::JSGenericTypedArrayView<Adaptor>::create):
(JSC::JSGenericTypedArrayView<Adaptor>::validateRange):

  • runtime/JSGenericTypedArrayViewPrototypeFunctions.h:

(JSC::speciesConstruct):
(JSC::genericTypedArrayViewProtoFuncSet):
(JSC::genericTypedArrayViewPrivateFuncSubarrayCreate):

  • runtime/JSGlobalLexicalEnvironment.cpp:
  • runtime/JSGlobalObject.cpp:
  • runtime/JSImmutableButterfly.cpp:
  • runtime/JSInternalPromise.cpp:
  • runtime/JSInternalPromiseConstructor.cpp:
  • runtime/JSInternalPromisePrototype.cpp:
  • runtime/JSLexicalEnvironment.cpp:
  • runtime/JSMap.cpp:
  • runtime/JSMapIterator.cpp:
  • runtime/JSModuleEnvironment.cpp:
  • runtime/JSModuleLoader.cpp:
  • runtime/JSModuleNamespaceObject.cpp:
  • runtime/JSModuleRecord.cpp:
  • runtime/JSNativeStdFunction.cpp:
  • runtime/JSONObject.cpp:
  • runtime/JSObject.cpp:

(JSC::JSObject::markAuxiliaryAndVisitOutOfLineProperties):

  • runtime/JSPromise.cpp:
  • runtime/JSPromiseConstructor.cpp:
  • runtime/JSPromisePrototype.cpp:
  • runtime/JSPropertyNameEnumerator.cpp:
  • runtime/JSProxy.cpp:
  • runtime/JSRemoteFunction.cpp:

(JSC::wrapArgument):
(JSC::wrapReturnValue):
(JSC::JSRemoteFunction::finishCreation):

  • runtime/JSScope.cpp:
  • runtime/JSScriptFetchParameters.cpp:
  • runtime/JSScriptFetcher.cpp:
  • runtime/JSSegmentedVariableObject.cpp:
  • runtime/JSSet.cpp:
  • runtime/JSSetIterator.cpp:
  • runtime/JSSourceCode.cpp:
  • runtime/JSString.cpp:

(JSC::JSString::dumpToStream):

  • runtime/JSStringIterator.cpp:
  • runtime/JSSymbolTableObject.cpp:
  • runtime/JSTemplateObjectDescriptor.cpp:
  • runtime/JSTypedArrayConstructors.cpp:
  • runtime/JSTypedArrayPrototypes.cpp:
  • runtime/JSTypedArrayViewConstructor.cpp:
  • runtime/JSTypedArrayViewPrototype.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/JSTypedArrays.cpp:
  • runtime/JSWeakMap.cpp:
  • runtime/JSWeakObjectRef.cpp:
  • runtime/JSWeakSet.cpp:
  • runtime/JSWithScope.cpp:
  • runtime/LiteralParser.cpp:

(JSC::LiteralParser<CharType>::parsePrimitiveValue):

  • runtime/MapConstructor.cpp:
  • runtime/MapIteratorPrototype.cpp:
  • runtime/MapPrototype.cpp:
  • runtime/MathObject.cpp:
  • runtime/ModuleProgramExecutable.cpp:
  • runtime/NativeErrorConstructor.cpp:
  • runtime/NativeExecutable.cpp:
  • runtime/NullGetterFunction.cpp:
  • runtime/NullSetterFunction.cpp:
  • runtime/NumberConstructor.cpp:
  • runtime/NumberObject.cpp:
  • runtime/NumberPrototype.cpp:

(JSC::toStringWithRadix):
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::numberToStringInternal):
(JSC::int52ToString):

  • runtime/ObjectConstructor.cpp:
  • runtime/ObjectPrototype.cpp:
  • runtime/Operations.h:

(JSC::arithmeticBinaryOp):
(JSC::shift):
(JSC::bitwiseBinaryOp):

  • runtime/ProgramExecutable.cpp:
  • runtime/PropertyTable.cpp:
  • runtime/ProxyConstructor.cpp:

(JSC::ProxyConstructor::finishCreation):

  • runtime/ProxyObject.cpp:
  • runtime/ProxyRevoke.cpp:
  • runtime/ReflectObject.cpp:
  • runtime/RegExp.cpp:
  • runtime/RegExpCache.cpp:

(JSC::RegExpCache::ensureEmptyRegExpSlow):

  • runtime/RegExpConstructor.cpp:
  • runtime/RegExpObject.cpp:
  • runtime/RegExpPrototype.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/RegExpStringIteratorPrototype.cpp:
  • runtime/ScopedArguments.cpp:
  • runtime/ScopedArgumentsTable.cpp:
  • runtime/ScriptExecutable.cpp:
  • runtime/SetConstructor.cpp:
  • runtime/SetIteratorPrototype.cpp:
  • runtime/SetPrototype.cpp:
  • runtime/ShadowRealmConstructor.cpp:
  • runtime/ShadowRealmObject.cpp:
  • runtime/ShadowRealmPrototype.cpp:
  • runtime/SparseArrayValueMap.cpp:
  • runtime/StrictEvalActivation.cpp:
  • runtime/StringConstructor.cpp:
  • runtime/StringIteratorPrototype.cpp:
  • runtime/StringObject.cpp:
  • runtime/StringPrototype.cpp:

(JSC::toLocaleCase):
(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/Structure.cpp:
  • runtime/StructureChain.cpp:
  • runtime/StructureRareData.cpp:
  • runtime/Symbol.cpp:
  • runtime/SymbolConstructor.cpp:
  • runtime/SymbolObject.cpp:
  • runtime/SymbolPrototype.cpp:
  • runtime/SymbolTable.cpp:
  • runtime/TemporalCalendar.cpp:
  • runtime/TemporalCalendarConstructor.cpp:
  • runtime/TemporalCalendarPrototype.cpp:
  • runtime/TemporalDuration.cpp:

(JSC::TemporalDuration::total const):

  • runtime/TemporalDurationConstructor.cpp:
  • runtime/TemporalDurationPrototype.cpp:
  • runtime/TemporalInstant.cpp:
  • runtime/TemporalInstantConstructor.cpp:
  • runtime/TemporalInstantPrototype.cpp:
  • runtime/TemporalNow.cpp:
  • runtime/TemporalObject.cpp:

(JSC::temporalLargestUnit):
(JSC::temporalSmallestUnit):

  • runtime/TemporalPlainDate.cpp:
  • runtime/TemporalPlainDateConstructor.cpp:
  • runtime/TemporalPlainDatePrototype.cpp:
  • runtime/TemporalPlainTime.cpp:
  • runtime/TemporalPlainTimeConstructor.cpp:
  • runtime/TemporalPlainTimePrototype.cpp:
  • runtime/TemporalTimeZone.cpp:
  • runtime/TemporalTimeZoneConstructor.cpp:
  • runtime/TemporalTimeZonePrototype.cpp:
  • runtime/TypeProfiler.cpp:

(JSC::TypeProfiler::logTypesForTypeLocation):

  • runtime/TypeSet.cpp:

(JSC::StructureShape::propertyHash):

  • runtime/WeakMapConstructor.cpp:
  • runtime/WeakMapPrototype.cpp:

(JSC::WeakMapPrototype::finishCreation):

  • runtime/WeakObjectRefConstructor.cpp:
  • runtime/WeakObjectRefPrototype.cpp:
  • runtime/WeakSetConstructor.cpp:
  • runtime/WeakSetPrototype.cpp:

(JSC::WeakSetPrototype::finishCreation):

  • testRegExp.cpp:
  • tools/FunctionAllowlist.cpp:

(JSC::FunctionAllowlist::FunctionAllowlist):

  • tools/FunctionOverrides.cpp:

(JSC::initializeOverrideInfo):

  • tools/JSDollarVM.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES):

  • tools/SigillCrashAnalyzer.cpp:

(JSC::SigillCrashAnalyzer::analyze):

  • tools/VMInspector.cpp:

(JSC::VMInspector::dumpRegisters):
(JSC::VMInspector::dumpCellMemoryToStream):

  • wasm/WasmExceptionType.h:

(JSC::Wasm::errorMessageForExceptionType):

  • wasm/WasmFormat.h:

(JSC::Wasm::typeToString):

  • wasm/WasmGlobal.cpp:

(JSC::Wasm::Global::set):

  • wasm/WasmLLIntPlan.cpp:

(JSC::Wasm::LLIntPlan::didCompleteCompilation):

  • wasm/WasmOperations.cpp:

(JSC::Wasm::JSC_DEFINE_JIT_OPERATION):

  • wasm/js/JSToWasmICCallee.cpp:
  • wasm/js/JSWebAssembly.cpp:
  • wasm/js/JSWebAssemblyException.cpp:
  • wasm/js/JSWebAssemblyGlobal.cpp:

(JSC::JSWebAssemblyGlobal::type):

  • wasm/js/JSWebAssemblyHelpers.h:

(JSC::fromJSValue):

  • wasm/js/JSWebAssemblyInstance.cpp:

(JSC::JSWebAssemblyInstance::createPrivateModuleKey):
(JSC::JSWebAssemblyInstance::tryCreate):

  • wasm/js/JSWebAssemblyMemory.cpp:
  • wasm/js/JSWebAssemblyModule.cpp:
  • wasm/js/JSWebAssemblyTable.cpp:

(JSC::JSWebAssemblyTable::type):

  • wasm/js/JSWebAssemblyTag.cpp:
  • wasm/js/WebAssemblyCompileErrorConstructor.cpp:
  • wasm/js/WebAssemblyCompileErrorPrototype.cpp:
  • wasm/js/WebAssemblyExceptionConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyExceptionPrototype.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyFunction.cpp:
  • wasm/js/WebAssemblyFunctionBase.cpp:
  • wasm/js/WebAssemblyGlobalConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyGlobalPrototype.cpp:
  • wasm/js/WebAssemblyInstanceConstructor.cpp:
  • wasm/js/WebAssemblyInstancePrototype.cpp:
  • wasm/js/WebAssemblyLinkErrorConstructor.cpp:
  • wasm/js/WebAssemblyLinkErrorPrototype.cpp:
  • wasm/js/WebAssemblyMemoryConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyMemoryPrototype.cpp:
  • wasm/js/WebAssemblyModuleConstructor.cpp:
  • wasm/js/WebAssemblyModulePrototype.cpp:
  • wasm/js/WebAssemblyModuleRecord.cpp:

(JSC::WebAssemblyModuleRecord::initializeExports):

  • wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
  • wasm/js/WebAssemblyRuntimeErrorPrototype.cpp:
  • wasm/js/WebAssemblyTableConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyTablePrototype.cpp:
  • wasm/js/WebAssemblyTagConstructor.cpp:
  • wasm/js/WebAssemblyTagPrototype.cpp:
  • wasm/js/WebAssemblyWrapperFunction.cpp:

(JSC::WebAssemblyWrapperFunction::create):

  • yarr/RegularExpression.cpp:

(JSC::Yarr::RegularExpression::Private::compile):

  • yarr/YarrErrorCode.cpp:

(JSC::Yarr::errorMessage):

  • yarr/YarrErrorCode.h:

Source/WebCore:

  • bindings/js/JSDOMGlobalObject.cpp:
  • bindings/js/JSDOMWindowBase.cpp:
  • bindings/js/JSDOMWindowProperties.cpp:
  • bindings/js/JSFileSystemDirectoryHandleIterator.cpp:
  • bindings/js/JSIDBSerializationGlobalObject.cpp:
  • bindings/js/JSRemoteDOMWindowBase.cpp:
  • bindings/js/JSShadowRealmGlobalScopeBase.cpp:
  • bindings/js/JSWindowProxy.cpp:
  • bindings/js/JSWorkerGlobalScopeBase.cpp:
  • bindings/js/JSWorkletGlobalScopeBase.cpp:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation):

  • bridge/objc/ObjCRuntimeObject.mm:
  • bridge/objc/objc_instance.mm:

(JSC::Bindings::ObjcInstance::getMethod):

  • bridge/objc/objc_runtime.mm:
  • bridge/runtime_array.cpp:
  • bridge/runtime_method.cpp:
  • bridge/runtime_object.cpp:

Source/WTF:

  • wtf/ResourceUsage.h:
  • wtf/cocoa/ResourceUsageCocoa.cpp:

(WTF::displayNameForVMTag):

  • wtf/text/WTFString.cpp:

(WTF::String::numberToStringFixedPrecision):
(WTF::String::number):
(WTF::String::numberToStringFixedWidth):

  • wtf/text/WTFString.h:
  • Property svn:eol-style set to native
File size: 15.4 KB
Line 
1/*
2 * Copyright (C) 2011-2022 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include "config.h"
22#include "RegExp.h"
23
24#include "InitializeThreading.h"
25#include "JSCInlines.h"
26#include "YarrFlags.h"
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30#include <wtf/Vector.h>
31#include <wtf/text/StringBuilder.h>
32
33#if COMPILER(MSVC)
34#include <crtdbg.h>
35#include <mmsystem.h>
36#include <windows.h>
37#endif
38
39const int MaxLineLength = 100 * 1024;
40
41using namespace JSC;
42
43struct CommandLine {
44 CommandLine()
45 : interactive(false)
46 , verbose(false)
47 {
48 }
49
50 bool interactive;
51 bool verbose;
52 Vector<String> arguments;
53 Vector<String> files;
54};
55
56class StopWatch {
57public:
58 void start();
59 void stop();
60 long getElapsedMS(); // call stop() first
61
62private:
63 MonotonicTime m_startTime;
64 MonotonicTime m_stopTime;
65};
66
67void StopWatch::start()
68{
69 m_startTime = MonotonicTime::now();
70}
71
72void StopWatch::stop()
73{
74 m_stopTime = MonotonicTime::now();
75}
76
77long StopWatch::getElapsedMS()
78{
79 return (m_stopTime - m_startTime).millisecondsAs<long>();
80}
81
82struct RegExpTest {
83 RegExpTest()
84 : offset(0)
85 , result(0)
86 {
87 }
88
89 String subject;
90 int offset;
91 int result;
92 Vector<int, 32> expectVector;
93};
94
95class GlobalObject final : public JSGlobalObject {
96public:
97 using Base = JSGlobalObject;
98
99 static GlobalObject* create(VM& vm, Structure* structure, const Vector<String>& arguments)
100 {
101 GlobalObject* globalObject = new (NotNull, allocateCell<GlobalObject>(vm)) GlobalObject(vm, structure, arguments);
102 return globalObject;
103 }
104
105 DECLARE_INFO;
106
107 static constexpr bool needsDestructor = true;
108
109 static Structure* createStructure(VM& vm, JSValue prototype)
110 {
111 return Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info());
112 }
113
114private:
115 GlobalObject(VM&, Structure*, const Vector<String>& arguments);
116
117 void finishCreation(VM& vm, const Vector<String>& arguments)
118 {
119 Base::finishCreation(vm);
120 UNUSED_PARAM(arguments);
121 }
122};
123STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(GlobalObject, JSGlobalObject);
124
125const ClassInfo GlobalObject::s_info = { "global"_s, &JSGlobalObject::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(GlobalObject) };
126
127GlobalObject::GlobalObject(VM& vm, Structure* structure, const Vector<String>& arguments)
128 : JSGlobalObject(vm, structure)
129{
130 finishCreation(vm, arguments);
131}
132
133// Use SEH for Release builds only to get rid of the crash report dialog
134// (luckily the same tests fail in Release and Debug builds so far). Need to
135// be in a separate main function because the realMain function requires object
136// unwinding.
137
138#if COMPILER(MSVC) && !defined(_DEBUG)
139#define TRY __try {
140#define EXCEPT(x) } __except (EXCEPTION_EXECUTE_HANDLER) { x; }
141#else
142#define TRY
143#define EXCEPT(x)
144#endif
145
146int realMain(int argc, char** argv);
147
148int main(int argc, char** argv)
149{
150#if OS(WINDOWS)
151 // Cygwin calls ::SetErrorMode(SEM_FAILCRITICALERRORS), which we will inherit. This is bad for
152 // testing/debugging, as it causes the post-mortem debugger not to be invoked. We reset the
153 // error mode here to work around Cygwin's behavior. See <http://webkit.org/b/55222>.
154 ::SetErrorMode(0);
155
156#if defined(_DEBUG)
157 _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
158 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
159 _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
160 _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
161 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
162 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
163#endif
164
165 timeBeginPeriod(1);
166#endif
167
168 JSC::initialize();
169
170 // We can't use destructors in the following code because it uses Windows
171 // Structured Exception Handling
172 int res = 0;
173 TRY
174 res = realMain(argc, argv);
175 EXCEPT(res = 3)
176 return res;
177}
178
179static bool testOneRegExp(JSGlobalObject* globalObject, RegExp* regexp, RegExpTest* regExpTest, bool verbose, unsigned lineNumber)
180{
181 bool result = true;
182 Vector<int> outVector;
183 outVector.resize(regExpTest->expectVector.size());
184 int matchResult = regexp->match(globalObject, regExpTest->subject, regExpTest->offset, outVector);
185
186 if (matchResult != regExpTest->result) {
187 result = false;
188 if (verbose)
189 printf("Line %d: results mismatch - expected %d got %d\n", lineNumber, regExpTest->result, matchResult);
190 } else if (matchResult != -1) {
191 if (outVector.size() != regExpTest->expectVector.size()) {
192 result = false;
193 if (verbose) {
194#if OS(WINDOWS)
195 printf("Line %d: output vector size mismatch - expected %Iu got %Iu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
196#else
197 printf("Line %d: output vector size mismatch - expected %zu got %zu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
198#endif
199 }
200 } else if (outVector.size() % 2) {
201 result = false;
202 if (verbose) {
203#if OS(WINDOWS)
204 printf("Line %d: output vector size is odd (%Iu), should be even\n", lineNumber, outVector.size());
205#else
206 printf("Line %d: output vector size is odd (%zu), should be even\n", lineNumber, outVector.size());
207#endif
208 }
209 } else {
210 // Check in pairs since the first value of the pair could be -1 in which case the second doesn't matter.
211 size_t pairCount = outVector.size() / 2;
212 for (size_t i = 0; i < pairCount; ++i) {
213 size_t startIndex = i*2;
214 if (outVector[startIndex] != regExpTest->expectVector[startIndex]) {
215 result = false;
216 if (verbose) {
217#if OS(WINDOWS)
218 printf("Line %d: output vector mismatch at index %Iu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
219#else
220 printf("Line %d: output vector mismatch at index %zu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
221#endif
222 }
223 }
224 if ((i > 0) && (regExpTest->expectVector[startIndex] != -1) && (outVector[startIndex+1] != regExpTest->expectVector[startIndex+1])) {
225 result = false;
226 if (verbose) {
227#if OS(WINDOWS)
228 printf("Line %d: output vector mismatch at index %Iu - expected %d got %d\n", lineNumber, startIndex + 1, regExpTest->expectVector[startIndex + 1], outVector[startIndex + 1]);
229#else
230 printf("Line %d: output vector mismatch at index %zu - expected %d got %d\n", lineNumber, startIndex + 1, regExpTest->expectVector[startIndex + 1], outVector[startIndex + 1]);
231#endif
232 }
233 }
234 }
235 }
236 }
237
238 return result;
239}
240
241static int scanString(char* buffer, int bufferLength, StringBuilder& builder, char termChar)
242{
243 bool escape = false;
244
245 for (int i = 0; i < bufferLength; ++i) {
246 UChar c = buffer[i];
247
248 if (escape) {
249 switch (c) {
250 case '0':
251 c = '\0';
252 break;
253 case 'a':
254 c = '\a';
255 break;
256 case 'b':
257 c = '\b';
258 break;
259 case 'f':
260 c = '\f';
261 break;
262 case 'n':
263 c = '\n';
264 break;
265 case 'r':
266 c = '\r';
267 break;
268 case 't':
269 c = '\t';
270 break;
271 case 'v':
272 c = '\v';
273 break;
274 case '\\':
275 c = '\\';
276 break;
277 case '?':
278 c = '\?';
279 break;
280 case 'u':
281 if ((i + 4) >= bufferLength)
282 return -1;
283 unsigned int charValue;
284 if (sscanf(buffer+i+1, "%04x", &charValue) != 1)
285 return -1;
286 c = static_cast<UChar>(charValue);
287 i += 4;
288 break;
289 }
290
291 builder.append(c);
292 escape = false;
293 } else {
294 if (c == termChar)
295 return i;
296
297 if (c == '\\')
298 escape = true;
299 else
300 builder.append(c);
301 }
302 }
303
304 return -1;
305}
306
307static RegExp* parseRegExpLine(VM& vm, char* line, int lineLength, const char** regexpError)
308{
309 StringBuilder pattern;
310
311 if (line[0] != '/')
312 return nullptr;
313
314 int i = scanString(line + 1, lineLength - 1, pattern, '/') + 1;
315
316 if ((i >= lineLength) || (line[i] != '/'))
317 return nullptr;
318
319 ++i;
320
321 auto flags = Yarr::parseFlags(line + i);
322 if (!flags) {
323 *regexpError = Yarr::errorMessage(Yarr::ErrorCode::InvalidRegularExpressionFlags);
324 return nullptr;
325 }
326
327 RegExp* r = RegExp::create(vm, pattern.toString(), flags.value());
328 if (!r->isValid()) {
329 *regexpError = r->errorMessage();
330 return nullptr;
331 }
332
333 return r;
334}
335
336static RegExpTest* parseTestLine(char* line, int lineLength)
337{
338 StringBuilder subjectString;
339
340 if ((line[0] != ' ') || (line[1] != '"'))
341 return nullptr;
342
343 int i = scanString(line + 2, lineLength - 2, subjectString, '"') + 2;
344
345 if ((i >= (lineLength - 2)) || (line[i] != '"') || (line[i+1] != ',') || (line[i+2] != ' '))
346 return nullptr;
347
348 i += 3;
349
350 int offset;
351
352 if (sscanf(line + i, "%d, ", &offset) != 1)
353 return nullptr;
354
355 while (line[i] && line[i] != ' ')
356 ++i;
357
358 ++i;
359
360 int matchResult;
361
362 if (sscanf(line + i, "%d, ", &matchResult) != 1)
363 return nullptr;
364
365 while (line[i] && line[i] != ' ')
366 ++i;
367
368 ++i;
369
370 if (line[i++] != '(')
371 return nullptr;
372
373 int start, end;
374
375 RegExpTest* result = new RegExpTest();
376
377 result->subject = subjectString.toString();
378 result->offset = offset;
379 result->result = matchResult;
380
381 while (line[i] && line[i] != ')') {
382 if (sscanf(line + i, "%d, %d", &start, &end) != 2) {
383 delete result;
384 return nullptr;
385 }
386
387 result->expectVector.append(start);
388 result->expectVector.append(end);
389
390 while (line[i] && (line[i] != ',') && (line[i] != ')'))
391 i++;
392 i++;
393 while (line[i] && (line[i] != ',') && (line[i] != ')'))
394 i++;
395
396 if (line[i] == ')')
397 break;
398 if (!line[i] || (line[i] != ',')) {
399 delete result;
400 return nullptr;
401 }
402 i++;
403 }
404
405 return result;
406}
407
408static bool runFromFiles(GlobalObject* globalObject, const Vector<String>& files, bool verbose)
409{
410 String script;
411 String fileName;
412 Vector<char> scriptBuffer;
413 unsigned tests = 0;
414 unsigned failures = 0;
415 Vector<char> lineBuffer(MaxLineLength + 1);
416
417 VM& vm = globalObject->vm();
418
419 bool success = true;
420 for (size_t i = 0; i < files.size(); i++) {
421 FILE* testCasesFile = fopen(files[i].utf8().data(), "rb");
422
423 if (!testCasesFile) {
424 printf("Unable to open test data file \"%s\"\n", files[i].utf8().data());
425 continue;
426 }
427
428 RegExp* regexp = nullptr;
429 size_t lineLength = 0;
430 char* linePtr = nullptr;
431 unsigned int lineNumber = 0;
432 const char* regexpError = nullptr;
433
434 while ((linePtr = fgets(lineBuffer.data(), MaxLineLength, testCasesFile))) {
435 lineLength = strlen(linePtr);
436 if (linePtr[lineLength - 1] == '\n') {
437 linePtr[lineLength - 1] = '\0';
438 --lineLength;
439 }
440 ++lineNumber;
441
442 if (linePtr[0] == '#')
443 continue;
444
445 if (linePtr[0] == '/') {
446 regexp = parseRegExpLine(vm, linePtr, lineLength, &regexpError);
447 if (!regexp) {
448 failures++;
449 fprintf(stderr, "Failure on line %u. '%s' %s\n", lineNumber, linePtr, regexpError);
450 }
451 } else if (linePtr[0] == ' ') {
452 RegExpTest* regExpTest = parseTestLine(linePtr, lineLength);
453
454 if (regexp && regExpTest) {
455 ++tests;
456 if (!testOneRegExp(globalObject, regexp, regExpTest, verbose, lineNumber)) {
457 failures++;
458 printf("Failure on line %u\n", lineNumber);
459 }
460 }
461
462 if (regExpTest)
463 delete regExpTest;
464 } else if (linePtr[0] == '-') {
465 tests++;
466 regexp = nullptr; // Reset the live regexp to avoid confusing other subsequent tests
467 bool successfullyParsed = parseRegExpLine(vm, linePtr + 1, lineLength - 1, &regexpError);
468 if (successfullyParsed) {
469 failures++;
470 fprintf(stderr, "Failure on line %u. '%s' %s\n", lineNumber, linePtr + 1, regexpError);
471 }
472 }
473 }
474
475 fclose(testCasesFile);
476 }
477
478 if (failures)
479 printf("%u tests run, %u failures\n", tests, failures);
480 else
481 printf("%u tests passed\n", tests);
482
483#if ENABLE(REGEXP_TRACING)
484 vm.dumpRegExpTrace();
485#endif
486 return success;
487}
488
489#define RUNNING_FROM_XCODE 0
490
491static NO_RETURN void printUsageStatement(bool help = false)
492{
493 fprintf(stderr, "Usage: regexp_test [options] file\n");
494 fprintf(stderr, " -h|--help Prints this help message\n");
495 fprintf(stderr, " -v|--verbose Verbose output\n");
496
497 exit(help ? EXIT_SUCCESS : EXIT_FAILURE);
498}
499
500static void parseArguments(int argc, char** argv, CommandLine& options)
501{
502 int i = 1;
503 for (; i < argc; ++i) {
504 const char* arg = argv[i];
505 if (!strcmp(arg, "-h") || !strcmp(arg, "--help"))
506 printUsageStatement(true);
507 if (!strcmp(arg, "-v") || !strcmp(arg, "--verbose"))
508 options.verbose = true;
509 else
510 options.files.append(argv[i]);
511 }
512
513 for (; i < argc; ++i)
514 options.arguments.append(argv[i]);
515}
516
517int realMain(int argc, char** argv)
518{
519 VM* vm = &VM::create(HeapType::Large).leakRef();
520 JSLockHolder locker(vm);
521
522 CommandLine options;
523 parseArguments(argc, argv, options);
524
525 GlobalObject* globalObject = GlobalObject::create(*vm, GlobalObject::createStructure(*vm, jsNull()), options.arguments);
526 bool success = runFromFiles(globalObject, options.files, options.verbose);
527
528 return success ? 0 : 3;
529}
530
531#if OS(WINDOWS)
532extern "C" __declspec(dllexport) int WINAPI dllLauncherEntryPoint(int argc, const char* argv[])
533{
534 return main(argc, const_cast<char**>(argv));
535}
536#endif
Note: See TracBrowser for help on using the repository browser.