WebKit Bugzilla
Attachment 360196 Details for
Bug 193713
: [JSC] NativeErrorConstructor should not have own IsoSubspace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193713-20190125171011.patch (text/plain), 48.61 KB, created by
Yusuke Suzuki
on 2019-01-25 17:10:12 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2019-01-25 17:10:12 PST
Size:
48.61 KB
patch
obsolete
>Subversion Revision: 240499 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index fee924841fd1e866945470d51083438bc6c4e5c7..a8524698e5730971748464c02aae36346402c7b5 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,67 @@ >+2019-01-25 Yusuke Suzuki <ysuzuki@apple.com> >+ >+ [JSC] NativeErrorConstructor should not have own IsoSubspace >+ https://bugs.webkit.org/show_bug.cgi?id=193713 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This removes an additional member in NativeErrorConstructor, and make sizeof(NativeErrorConstructor) == sizeof(InternalFunction). >+ We also make error constructors lazily allocated by using LazyClassStructure. Since error structures are not accessed from DFG / FTL >+ threads, this is OK. While TypeError constructor is eagerly allocated because it is touched from our builtin JS as @TypeError, we should >+ offer some function instead of exposing TypeError constructor in the future, and remove this @TypeError reference. This change removes >+ IsoSubspace for NativeErrorConstructor in VM. >+ >+ * JavaScriptCore.xcodeproj/project.pbxproj: >+ * Sources.txt: >+ * interpreter/Interpreter.h: >+ * runtime/Error.cpp: >+ (JSC::createEvalError): >+ (JSC::createRangeError): >+ (JSC::createReferenceError): >+ (JSC::createSyntaxError): >+ (JSC::createTypeError): >+ (JSC::createURIError): >+ (WTF::printInternal): Deleted. >+ * runtime/Error.h: >+ * runtime/ErrorType.cpp: Added. >+ (JSC::errorTypeName): >+ (WTF::printInternal): >+ * runtime/ErrorType.h: Added. >+ * runtime/JSGlobalObject.cpp: >+ (JSC::JSGlobalObject::initializeErrorConstructor): >+ (JSC::JSGlobalObject::init): >+ (JSC::JSGlobalObject::visitChildren): >+ * runtime/JSGlobalObject.h: >+ (JSC::JSGlobalObject::internalPromiseConstructor const): >+ (JSC::JSGlobalObject::errorStructure const): >+ (JSC::JSGlobalObject::evalErrorConstructor const): Deleted. >+ (JSC::JSGlobalObject::rangeErrorConstructor const): Deleted. >+ (JSC::JSGlobalObject::referenceErrorConstructor const): Deleted. >+ (JSC::JSGlobalObject::syntaxErrorConstructor const): Deleted. >+ (JSC::JSGlobalObject::typeErrorConstructor const): Deleted. >+ (JSC::JSGlobalObject::URIErrorConstructor const): Deleted. >+ * runtime/NativeErrorConstructor.cpp: >+ (JSC::NativeErrorConstructor<errorType>::NativeErrorConstructor): >+ (JSC::NativeErrorConstructorBase::finishCreation): >+ (JSC::NativeErrorConstructor<errorType>::constructNativeErrorConstructor): >+ (JSC::NativeErrorConstructor<errorType>::callNativeErrorConstructor): >+ (JSC::NativeErrorConstructor::NativeErrorConstructor): Deleted. >+ (JSC::NativeErrorConstructor::finishCreation): Deleted. >+ (JSC::NativeErrorConstructor::visitChildren): Deleted. >+ (JSC::Interpreter::constructWithNativeErrorConstructor): Deleted. >+ (JSC::Interpreter::callNativeErrorConstructor): Deleted. >+ * runtime/NativeErrorConstructor.h: >+ (JSC::NativeErrorConstructorBase::createStructure): >+ (JSC::NativeErrorConstructorBase::NativeErrorConstructorBase): >+ * runtime/NativeErrorPrototype.cpp: >+ (JSC::NativeErrorPrototype::finishCreation): >+ * runtime/NativeErrorPrototype.h: >+ * runtime/VM.cpp: >+ (JSC::VM::VM): >+ * runtime/VM.h: >+ * wasm/js/WasmToJS.cpp: >+ (JSC::Wasm::handleBadI64Use): >+ > 2019-01-25 Jon Davis <jond@apple.com> > > Update JavaScriptCore feature status entries. >diff --git a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >index 47a7c73c0b1aa85554bced34339d58f93979f5ab..686e996a2ed9241f6e9fe316effddc7d6c73554f 100644 >--- a/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >+++ b/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj >@@ -1761,6 +1761,7 @@ > E3C79CAB1DB9A4DC00D1ECA4 /* DOMJITEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C79CAA1DB9A4D600D1ECA4 /* DOMJITEffect.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E3D239C91B829C1C00BBEF67 /* JSModuleEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D239C71B829C1C00BBEF67 /* JSModuleEnvironment.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E3D877741E65C0A000BE945A /* BytecodeDumper.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D877721E65C08900BE945A /* BytecodeDumper.h */; }; >+ E3EE137621FBD43500D83C4B /* ErrorType.h in Headers */ = {isa = PBXBuildFile; fileRef = E3EE137421FBD43400D83C4B /* ErrorType.h */; }; > E3F23A7F1ECF13EE00978D99 /* SnippetSlowPathCalls.h in Headers */ = {isa = PBXBuildFile; fileRef = E3F23A7E1ECF13E500978D99 /* SnippetSlowPathCalls.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E3F23A801ECF13F500978D99 /* SnippetReg.h in Headers */ = {isa = PBXBuildFile; fileRef = E3F23A7D1ECF13E500978D99 /* SnippetReg.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E3F23A811ECF13FA00978D99 /* SnippetParams.h in Headers */ = {isa = PBXBuildFile; fileRef = E3F23A7C1ECF13E500978D99 /* SnippetParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -4708,6 +4709,8 @@ > E3D2642A1D38C042000BE174 /* BytecodeRewriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeRewriter.h; sourceTree = "<group>"; }; > E3D877711E65C08900BE945A /* BytecodeDumper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BytecodeDumper.cpp; sourceTree = "<group>"; }; > E3D877721E65C08900BE945A /* BytecodeDumper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeDumper.h; sourceTree = "<group>"; }; >+ E3EE137421FBD43400D83C4B /* ErrorType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorType.h; sourceTree = "<group>"; }; >+ E3EE137521FBD43400D83C4B /* ErrorType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorType.cpp; sourceTree = "<group>"; }; > E3F23A7B1ECF13E500978D99 /* Snippet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Snippet.h; sourceTree = "<group>"; }; > E3F23A7C1ECF13E500978D99 /* SnippetParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnippetParams.h; sourceTree = "<group>"; }; > E3F23A7D1ECF13E500978D99 /* SnippetReg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnippetReg.h; sourceTree = "<group>"; }; >@@ -6682,6 +6685,8 @@ > BC02E98B0E183E38000F9297 /* ErrorInstance.h */, > BC02E9060E1839DB000F9297 /* ErrorPrototype.cpp */, > BC02E9070E1839DB000F9297 /* ErrorPrototype.h */, >+ E3EE137521FBD43400D83C4B /* ErrorType.cpp */, >+ E3EE137421FBD43400D83C4B /* ErrorType.h */, > 147341DB1DC2CE9600AA29BA /* EvalExecutable.cpp */, > 147341D11DC02E2E00AA29BA /* EvalExecutable.h */, > FE1C0FFE1B194FD100B53FCA /* Exception.cpp */, >@@ -8895,6 +8900,7 @@ > BC02E98D0E183E38000F9297 /* ErrorInstance.h in Headers */, > BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */, > 996B731B1BDA08D100331B84 /* ErrorPrototype.lut.h in Headers */, >+ E3EE137621FBD43500D83C4B /* ErrorType.h in Headers */, > 14AD910C1DCA92940014F9FE /* EvalCodeBlock.h in Headers */, > 147341D21DC02E2E00AA29BA /* EvalExecutable.h in Headers */, > A54982041891D0B00081E5B8 /* EventLoop.h in Headers */, >diff --git a/Source/JavaScriptCore/Sources.txt b/Source/JavaScriptCore/Sources.txt >index 258d49ced1e2d59ddbdf147f4acb1894938dba14..7a74608c4333b0a68f707fcacde3cf1e86b465f3 100644 >--- a/Source/JavaScriptCore/Sources.txt >+++ b/Source/JavaScriptCore/Sources.txt >@@ -748,6 +748,7 @@ runtime/ErrorConstructor.cpp > runtime/ErrorHandlingScope.cpp > runtime/ErrorInstance.cpp > runtime/ErrorPrototype.cpp >+runtime/ErrorType.cpp > runtime/EvalExecutable.cpp > runtime/Exception.cpp > runtime/ExceptionEventLocation.cpp >diff --git a/Source/JavaScriptCore/builtins/BuiltinNames.h b/Source/JavaScriptCore/builtins/BuiltinNames.h >index 8531db260bd0701b371901b674bff5df0bfbd875..4a701448e2a910bbf37c76220810f3532b6996b6 100644 >--- a/Source/JavaScriptCore/builtins/BuiltinNames.h >+++ b/Source/JavaScriptCore/builtins/BuiltinNames.h >@@ -74,8 +74,6 @@ namespace JSC { > macro(getOwnPropertyDescriptor) \ > macro(getOwnPropertyNames) \ > macro(ownKeys) \ >- macro(Error) \ >- macro(RangeError) \ > macro(Set) \ > macro(TypeError) \ > macro(typedArrayLength) \ >diff --git a/Source/JavaScriptCore/interpreter/Interpreter.h b/Source/JavaScriptCore/interpreter/Interpreter.h >index be5d5e99905f9ac1b680f39aa39140c0fad7b57c..394e5353753825cf10fd70666c0b491037d31f68 100644 >--- a/Source/JavaScriptCore/interpreter/Interpreter.h >+++ b/Source/JavaScriptCore/interpreter/Interpreter.h >@@ -117,9 +117,6 @@ namespace JSC { > NEVER_INLINE void debug(CallFrame*, DebugHookType); > static String stackTraceAsString(VM&, const Vector<StackFrame>&); > >- static EncodedJSValue JSC_HOST_CALL constructWithNativeErrorConstructor(ExecState*); >- static EncodedJSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState*); >- > void getStackTrace(JSCell* owner, Vector<StackFrame>& results, size_t framesToSkip = 0, size_t maxStackSize = std::numeric_limits<size_t>::max()); > > private: >diff --git a/Source/JavaScriptCore/runtime/Error.cpp b/Source/JavaScriptCore/runtime/Error.cpp >index 1b8e4c281de269710c7a3752a21d143acdd42c10..9d78664491fe5511a65b82f4a153dc3ce8bf153d 100644 >--- a/Source/JavaScriptCore/runtime/Error.cpp >+++ b/Source/JavaScriptCore/runtime/Error.cpp >@@ -53,7 +53,7 @@ JSObject* createEvalError(ExecState* exec, const String& message, ErrorInstance: > { > ASSERT(!message.isEmpty()); > JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >- return ErrorInstance::create(exec, globalObject->vm(), globalObject->evalErrorConstructor()->errorStructure(), message, appender, TypeNothing, true); >+ return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::EvalError), message, appender, TypeNothing, true); > } > > JSObject* createRangeError(ExecState* exec, const String& message, ErrorInstance::SourceAppender appender) >@@ -65,28 +65,28 @@ JSObject* createRangeError(ExecState* exec, const String& message, ErrorInstance > JSObject* createRangeError(ExecState* exec, JSGlobalObject* globalObject, const String& message, ErrorInstance::SourceAppender appender) > { > ASSERT(!message.isEmpty()); >- return ErrorInstance::create(exec, globalObject->vm(), globalObject->rangeErrorConstructor()->errorStructure(), message, appender, TypeNothing, true); >+ return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::RangeError), message, appender, TypeNothing, true); > } > > JSObject* createReferenceError(ExecState* exec, const String& message, ErrorInstance::SourceAppender appender) > { > ASSERT(!message.isEmpty()); > JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >- return ErrorInstance::create(exec, globalObject->vm(), globalObject->referenceErrorConstructor()->errorStructure(), message, appender, TypeNothing, true); >+ return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::ReferenceError), message, appender, TypeNothing, true); > } > > JSObject* createSyntaxError(ExecState* exec, const String& message, ErrorInstance::SourceAppender appender) > { > ASSERT(!message.isEmpty()); > JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >- return ErrorInstance::create(exec, globalObject->vm(), globalObject->syntaxErrorConstructor()->errorStructure(), message, appender, TypeNothing, true); >+ return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::SyntaxError), message, appender, TypeNothing, true); > } > > JSObject* createTypeError(ExecState* exec, const String& message, ErrorInstance::SourceAppender appender, RuntimeType type) > { > ASSERT(!message.isEmpty()); > JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >- return ErrorInstance::create(exec, globalObject->vm(), globalObject->typeErrorConstructor()->errorStructure(), message, appender, type, true); >+ return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::TypeError), message, appender, type, true); > } > > JSObject* createNotEnoughArgumentsError(ExecState* exec, ErrorInstance::SourceAppender appender) >@@ -98,7 +98,7 @@ JSObject* createURIError(ExecState* exec, const String& message, ErrorInstance:: > { > ASSERT(!message.isEmpty()); > JSGlobalObject* globalObject = exec->lexicalGlobalObject(); >- return ErrorInstance::create(exec, globalObject->vm(), globalObject->URIErrorConstructor()->errorStructure(), message, appender, TypeNothing, true); >+ return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::URIError), message, appender, TypeNothing, true); > } > > JSObject* createError(ExecState* exec, ErrorType errorType, const String& message) >@@ -361,36 +361,3 @@ JSObject* createOutOfMemoryError(ExecState* exec, const String& message) > } > > } // namespace JSC >- >-namespace WTF { >- >-using namespace JSC; >- >-void printInternal(PrintStream& out, JSC::ErrorType errorType) >-{ >- switch (errorType) { >- case JSC::ErrorType::Error: >- out.print("Error"); >- break; >- case JSC::ErrorType::EvalError: >- out.print("EvalError"); >- break; >- case JSC::ErrorType::RangeError: >- out.print("RangeError"); >- break; >- case JSC::ErrorType::ReferenceError: >- out.print("ReferenceError"); >- break; >- case JSC::ErrorType::SyntaxError: >- out.print("SyntaxError"); >- break; >- case JSC::ErrorType::TypeError: >- out.print("TypeError"); >- break; >- case JSC::ErrorType::URIError: >- out.print("URIError"); >- break; >- } >-} >- >-} // namespace WTF >diff --git a/Source/JavaScriptCore/runtime/Error.h b/Source/JavaScriptCore/runtime/Error.h >index f94b005b8304ba4ba50a7d32601b227a7c9d809f..ed022779b1f9e6623caabe349e95ef527286c356 100644 >--- a/Source/JavaScriptCore/runtime/Error.h >+++ b/Source/JavaScriptCore/runtime/Error.h >@@ -23,6 +23,7 @@ > #pragma once > > #include "ErrorInstance.h" >+#include "ErrorType.h" > #include "InternalFunction.h" > #include "JSObject.h" > #include "ThrowScope.h" >@@ -38,16 +39,6 @@ class JSObject; > class SourceCode; > class Structure; > >-enum class ErrorType : uint8_t { >- Error, >- EvalError, >- RangeError, >- ReferenceError, >- SyntaxError, >- TypeError, >- URIError, >-}; >- > // ExecState wrappers. > JSObject* createError(ExecState*, const String&, ErrorInstance::SourceAppender); > JSObject* createEvalError(ExecState*, const String&, ErrorInstance::SourceAppender); >@@ -105,11 +96,3 @@ inline EncodedJSValue throwVMRangeError(ExecState* state, ThrowScope& scope, con > inline EncodedJSValue throwVMDOMAttributeGetterTypeError(ExecState* state, ThrowScope& scope, const ClassInfo* classInfo, PropertyName propertyName) { return JSValue::encode(throwDOMAttributeGetterTypeError(state, scope, classInfo, propertyName)); } > > } // namespace JSC >- >-namespace WTF { >- >-class PrintStream; >- >-void printInternal(PrintStream&, JSC::ErrorType); >- >-} // namespace WTF >diff --git a/Source/JavaScriptCore/runtime/ErrorType.cpp b/Source/JavaScriptCore/runtime/ErrorType.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..2991e98f7f06b4725f2f004554be1e8ea58538fc >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/ErrorType.cpp >@@ -0,0 +1,55 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All Rights Reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ErrorType.h" >+ >+namespace JSC { >+ >+static ASCIILiteral errorTypeNames[] = { >+ "Error"_s, >+ "EvalError"_s, >+ "RangeError"_s, >+ "ReferenceError"_s, >+ "SyntaxError"_s, >+ "TypeError"_s, >+ "URIError"_s, >+}; >+ >+ASCIILiteral errorTypeName(ErrorType errorType) >+{ >+ return errorTypeNames[static_cast<unsigned>(errorType)]; >+} >+ >+} // namespace JSC >+ >+namespace WTF { >+ >+void printInternal(PrintStream& out, JSC::ErrorType errorType) >+{ >+ out.print(JSC::errorTypeName(errorType)); >+} >+ >+} // namespace WTF >diff --git a/Source/JavaScriptCore/runtime/ErrorType.h b/Source/JavaScriptCore/runtime/ErrorType.h >new file mode 100644 >index 0000000000000000000000000000000000000000..52b49af1b35b4a6729066c3eae73e3215901fbb9 >--- /dev/null >+++ b/Source/JavaScriptCore/runtime/ErrorType.h >@@ -0,0 +1,52 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All Rights Reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/text/ASCIILiteral.h> >+ >+namespace JSC { >+ >+enum class ErrorType : uint8_t { >+ Error = 0, >+ EvalError, >+ RangeError, >+ ReferenceError, >+ SyntaxError, >+ TypeError, >+ URIError, >+}; >+static constexpr unsigned NumberOfErrorType { static_cast<unsigned>(ErrorType::URIError) + 1 }; >+ASCIILiteral errorTypeName(ErrorType); >+ >+} // namespace JSC >+ >+namespace WTF { >+ >+class PrintStream; >+ >+void printInternal(PrintStream&, JSC::ErrorType); >+ >+} // namespace WTF >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >index 0a0fbf1b3d0fbe21642bf2df36d914c558f154d9..461d94e253638b26141139bbfd42beffb6c99ec9 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.cpp >@@ -303,11 +303,13 @@ const GlobalObjectMethodTable JSGlobalObject::s_globalObjectMethodTable = { > decodeURIComponent globalFuncDecodeURIComponent DontEnum|Function 1 > encodeURI globalFuncEncodeURI DontEnum|Function 1 > encodeURIComponent globalFuncEncodeURIComponent DontEnum|Function 1 >- EvalError JSGlobalObject::m_evalErrorConstructor DontEnum|CellProperty > globalThis JSGlobalObject::m_globalThis DontEnum|CellProperty >- ReferenceError JSGlobalObject::m_referenceErrorConstructor DontEnum|CellProperty >- SyntaxError JSGlobalObject::m_syntaxErrorConstructor DontEnum|CellProperty >- URIError JSGlobalObject::m_URIErrorConstructor DontEnum|CellProperty >+ EvalError JSGlobalObject::m_evalErrorStructure DontEnum|ClassStructure >+ RangeError JSGlobalObject::m_rangeErrorStructure DontEnum|ClassStructure >+ ReferenceError JSGlobalObject::m_referenceErrorStructure DontEnum|ClassStructure >+ SyntaxError JSGlobalObject::m_syntaxErrorStructure DontEnum|ClassStructure >+ TypeError JSGlobalObject::m_typeErrorStructure DontEnum|ClassStructure >+ URIError JSGlobalObject::m_URIErrorStructure DontEnum|ClassStructure > Proxy createProxyProperty DontEnum|PropertyCallback > JSON createJSONProperty DontEnum|PropertyCallback > Math createMathProperty DontEnum|PropertyCallback >@@ -393,6 +395,17 @@ static JSObject* getGetterById(ExecState* exec, JSObject* base, const Identifier > return slot.getPureResult().toObject(exec); > } > >+template<ErrorType errorType> >+void JSGlobalObject::initializeErrorConstructor(LazyClassStructure::Initializer& init) >+{ >+ NativeErrorPrototype* prototype = NativeErrorPrototype::create(init.vm, m_nativeErrorPrototypeStructure.get(), errorTypeName(errorType)); >+ init.setPrototype(prototype); >+ Structure* structure = ErrorInstance::createStructure(init.vm, this, prototype); >+ init.setStructure(structure); >+ init.setConstructor(NativeErrorConstructor<errorType>::create(init.vm, NativeErrorConstructor<errorType>::createStructure(init.vm, this, prototype), prototype)); >+ prototype->putDirect(init.vm, init.vm.propertyNames->constructor, init.constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); >+} >+ > void JSGlobalObject::init(VM& vm) > { > ASSERT(vm.currentThreadIsHoldingAPILock()); >@@ -705,24 +718,30 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c > m_internalPromiseConstructor.set(vm, this, internalPromiseConstructor); > > m_nativeErrorPrototypeStructure.set(vm, this, NativeErrorPrototype::createStructure(vm, this, m_errorPrototype.get())); >- m_nativeErrorStructure.set(vm, this, NativeErrorConstructor::createStructure(vm, this, errorConstructor)); >- m_evalErrorConstructor.initLater( >- [] (const Initializer<NativeErrorConstructor>& init) { >- init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "EvalError"_s)); >+ >+ m_evalErrorStructure.initLater( >+ [] (LazyClassStructure::Initializer& init) { >+ init.global->initializeErrorConstructor<ErrorType::EvalError>(init); >+ }); >+ m_rangeErrorStructure.initLater( >+ [] (LazyClassStructure::Initializer& init) { >+ init.global->initializeErrorConstructor<ErrorType::RangeError>(init); >+ }); >+ m_referenceErrorStructure.initLater( >+ [] (LazyClassStructure::Initializer& init) { >+ init.global->initializeErrorConstructor<ErrorType::ReferenceError>(init); > }); >- m_rangeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), "RangeError"_s)); >- m_referenceErrorConstructor.initLater( >- [] (const Initializer<NativeErrorConstructor>& init) { >- init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "ReferenceError"_s)); >+ m_syntaxErrorStructure.initLater( >+ [] (LazyClassStructure::Initializer& init) { >+ init.global->initializeErrorConstructor<ErrorType::SyntaxError>(init); > }); >- m_syntaxErrorConstructor.initLater( >- [] (const Initializer<NativeErrorConstructor>& init) { >- init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "SyntaxError"_s)); >+ m_typeErrorStructure.initLater( >+ [] (LazyClassStructure::Initializer& init) { >+ init.global->initializeErrorConstructor<ErrorType::TypeError>(init); > }); >- m_typeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), "TypeError"_s)); >- m_URIErrorConstructor.initLater( >- [] (const Initializer<NativeErrorConstructor>& init) { >- init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "URIError"_s)); >+ m_URIErrorStructure.initLater( >+ [] (LazyClassStructure::Initializer& init) { >+ init.global->initializeErrorConstructor<ErrorType::URIError>(init); > }); > > m_generatorFunctionPrototype.set(vm, this, GeneratorFunctionPrototype::create(vm, GeneratorFunctionPrototype::createStructure(vm, this, m_functionPrototype.get()))); >@@ -756,8 +775,6 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c > putDirectWithoutTransition(vm, vm.propertyNames->Function, functionConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); > putDirectWithoutTransition(vm, vm.propertyNames->Array, arrayConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); > putDirectWithoutTransition(vm, vm.propertyNames->RegExp, m_regExpConstructor.get(), static_cast<unsigned>(PropertyAttribute::DontEnum)); >- putDirectWithoutTransition(vm, vm.propertyNames->RangeError, m_rangeErrorConstructor.get(), static_cast<unsigned>(PropertyAttribute::DontEnum)); >- putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), static_cast<unsigned>(PropertyAttribute::DontEnum)); > > putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ObjectPrivateName(), objectConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); > putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ArrayPrivateName(), arrayConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); >@@ -878,9 +895,7 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct > GlobalPropertyInfo(vm.propertyNames->builtinNames().propertyIsEnumerablePrivateName(), privateFuncPropertyIsEnumerable, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().importModulePrivateName(), privateFuncImportModule, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), >- GlobalPropertyInfo(vm.propertyNames->builtinNames().ErrorPrivateName(), errorConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), >- GlobalPropertyInfo(vm.propertyNames->builtinNames().RangeErrorPrivateName(), m_rangeErrorConstructor.get(), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), >- GlobalPropertyInfo(vm.propertyNames->builtinNames().TypeErrorPrivateName(), m_typeErrorConstructor.get(), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), >+ GlobalPropertyInfo(vm.propertyNames->builtinNames().TypeErrorPrivateName(), m_typeErrorStructure.constructor(this), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayLengthPrivateName(), privateFuncTypedArrayLength, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayGetOriginalConstructorPrivateName(), privateFuncTypedArrayGetOriginalConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), > GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArraySortPrivateName(), privateFuncTypedArraySort, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), >@@ -1549,13 +1564,12 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor) > visitor.append(thisObject->m_stackOverflowFrameCallee); > visitor.append(thisObject->m_regExpConstructor); > visitor.append(thisObject->m_nativeErrorPrototypeStructure); >- visitor.append(thisObject->m_nativeErrorStructure); >- thisObject->m_evalErrorConstructor.visit(visitor); >- visitor.append(thisObject->m_rangeErrorConstructor); >- thisObject->m_referenceErrorConstructor.visit(visitor); >- thisObject->m_syntaxErrorConstructor.visit(visitor); >- visitor.append(thisObject->m_typeErrorConstructor); >- thisObject->m_URIErrorConstructor.visit(visitor); >+ thisObject->m_evalErrorStructure.visit(visitor); >+ thisObject->m_rangeErrorStructure.visit(visitor); >+ thisObject->m_referenceErrorStructure.visit(visitor); >+ thisObject->m_syntaxErrorStructure.visit(visitor); >+ thisObject->m_typeErrorStructure.visit(visitor); >+ thisObject->m_URIErrorStructure.visit(visitor); > visitor.append(thisObject->m_objectConstructor); > visitor.append(thisObject->m_promiseConstructor); > >diff --git a/Source/JavaScriptCore/runtime/JSGlobalObject.h b/Source/JavaScriptCore/runtime/JSGlobalObject.h >index 4462ab1861d42caa91a7f1ca3501dc36477d0ec9..e83c0440ca703344b2ee8c3293fc3c436c5ce011 100644 >--- a/Source/JavaScriptCore/runtime/JSGlobalObject.h >+++ b/Source/JavaScriptCore/runtime/JSGlobalObject.h >@@ -25,6 +25,7 @@ > #include "ArrayBufferSharingMode.h" > #include "BigIntPrototype.h" > #include "BooleanPrototype.h" >+#include "ErrorType.h" > #include "ExceptionHelpers.h" > #include "InternalFunction.h" > #include "JSArray.h" >@@ -101,7 +102,7 @@ class MapPrototype; > class Microtask; > class ModuleLoader; > class ModuleProgramExecutable; >-class NativeErrorConstructor; >+class NativeErrorConstructorBase; > class NullGetterFunction; > class NullSetterFunction; > class ObjectConstructor; >@@ -260,13 +261,14 @@ class JSGlobalObject : public JSSegmentedVariableObject { > WriteBarrier<JSCallee> m_stackOverflowFrameCallee; > WriteBarrier<RegExpConstructor> m_regExpConstructor; > WriteBarrier<Structure> m_nativeErrorPrototypeStructure; >- WriteBarrier<Structure> m_nativeErrorStructure; >- LazyProperty<JSGlobalObject, NativeErrorConstructor> m_evalErrorConstructor; >- WriteBarrier<NativeErrorConstructor> m_rangeErrorConstructor; >- LazyProperty<JSGlobalObject, NativeErrorConstructor> m_referenceErrorConstructor; >- LazyProperty<JSGlobalObject, NativeErrorConstructor> m_syntaxErrorConstructor; >- WriteBarrier<NativeErrorConstructor> m_typeErrorConstructor; >- LazyProperty<JSGlobalObject, NativeErrorConstructor> m_URIErrorConstructor; >+ >+ LazyClassStructure m_evalErrorStructure; >+ LazyClassStructure m_rangeErrorStructure; >+ LazyClassStructure m_referenceErrorStructure; >+ LazyClassStructure m_syntaxErrorStructure; >+ LazyClassStructure m_typeErrorStructure; >+ LazyClassStructure m_URIErrorStructure; >+ > WriteBarrier<ObjectConstructor> m_objectConstructor; > WriteBarrier<ArrayConstructor> m_arrayConstructor; > WriteBarrier<JSPromiseConstructor> m_promiseConstructor; >@@ -580,12 +582,6 @@ class JSGlobalObject : public JSSegmentedVariableObject { > ObjectConstructor* objectConstructor() const { return m_objectConstructor.get(); } > JSPromiseConstructor* promiseConstructor() const { return m_promiseConstructor.get(); } > JSInternalPromiseConstructor* internalPromiseConstructor() const { return m_internalPromiseConstructor.get(); } >- NativeErrorConstructor* evalErrorConstructor() const { return m_evalErrorConstructor.get(this); } >- NativeErrorConstructor* rangeErrorConstructor() const { return m_rangeErrorConstructor.get(); } >- NativeErrorConstructor* referenceErrorConstructor() const { return m_referenceErrorConstructor.get(this); } >- NativeErrorConstructor* syntaxErrorConstructor() const { return m_syntaxErrorConstructor.get(this); } >- NativeErrorConstructor* typeErrorConstructor() const { return m_typeErrorConstructor.get(); } >- NativeErrorConstructor* URIErrorConstructor() const { return m_URIErrorConstructor.get(this); } > > #if ENABLE(INTL) > IntlObject* intlObject() const { return m_intlObject.get(); } >@@ -693,6 +689,27 @@ class JSGlobalObject : public JSSegmentedVariableObject { > Structure* dateStructure() const { return m_dateStructure.get(this); } > Structure* nullPrototypeObjectStructure() const { return m_nullPrototypeObjectStructure.get(); } > Structure* errorStructure() const { return m_errorStructure.get(); } >+ Structure* errorStructure(ErrorType errorType) const >+ { >+ switch (errorType) { >+ case ErrorType::Error: >+ return errorStructure(); >+ case ErrorType::EvalError: >+ return m_evalErrorStructure.get(this); >+ case ErrorType::RangeError: >+ return m_rangeErrorStructure.get(this); >+ case ErrorType::ReferenceError: >+ return m_referenceErrorStructure.get(this); >+ case ErrorType::SyntaxError: >+ return m_syntaxErrorStructure.get(this); >+ case ErrorType::TypeError: >+ return m_typeErrorStructure.get(this); >+ case ErrorType::URIError: >+ return m_URIErrorStructure.get(this); >+ } >+ ASSERT_NOT_REACHED(); >+ return nullptr; >+ } > Structure* calleeStructure() const { return m_calleeStructure.get(); } > Structure* hostFunctionStructure() const { return m_hostFunctionStructure.get(); } > >@@ -1000,6 +1017,9 @@ class JSGlobalObject : public JSSegmentedVariableObject { > void fireWatchpointAndMakeAllArrayStructuresSlowPut(VM&); > void setGlobalThis(VM&, JSObject* globalThis); > >+ template<ErrorType errorType> >+ void initializeErrorConstructor(LazyClassStructure::Initializer&); >+ > JS_EXPORT_PRIVATE void init(VM&); > > JS_EXPORT_PRIVATE static void clearRareData(JSCell*); >diff --git a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp b/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp >index 8f3dd70eaa498c614a17c66317be59aeacfd5a34..c14928655c19bab9dd8fcc2a32b228bacd2b87fd 100644 >--- a/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp >+++ b/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp >@@ -30,53 +30,52 @@ > > namespace JSC { > >-STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(NativeErrorConstructor); >+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(NativeErrorConstructorBase); > >-const ClassInfo NativeErrorConstructor::s_info = { "Function", &InternalFunction::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(NativeErrorConstructor) }; >+const ClassInfo NativeErrorConstructorBase::s_info = { "Function", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(NativeErrorConstructorBase) }; > >-NativeErrorConstructor::NativeErrorConstructor(VM& vm, Structure* structure) >- : InternalFunction(vm, structure, Interpreter::callNativeErrorConstructor, Interpreter::constructWithNativeErrorConstructor) >+template<ErrorType errorType> >+NativeErrorConstructor<errorType>::NativeErrorConstructor(VM& vm, Structure* structure) >+ : NativeErrorConstructorBase(vm, structure, NativeErrorConstructor<errorType>::callNativeErrorConstructor, NativeErrorConstructor<errorType>::constructNativeErrorConstructor) > { > } > >-void NativeErrorConstructor::finishCreation(VM& vm, JSGlobalObject* globalObject, Structure* prototypeStructure, const String& name) >+void NativeErrorConstructorBase::finishCreation(VM& vm, NativeErrorPrototype* prototype, ErrorType errorType) > { >- Base::finishCreation(vm, name); >+ Base::finishCreation(vm, errorTypeName(errorType)); > ASSERT(inherits(vm, info())); > >- NativeErrorPrototype* prototype = NativeErrorPrototype::create(vm, prototypeStructure, name, this); >- >- putDirect(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); >- putDirect(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum); >- m_errorStructure.set(vm, this, ErrorInstance::createStructure(vm, globalObject, prototype)); >- ASSERT(m_errorStructure); >- ASSERT(m_errorStructure->isObject()); >-} >- >-void NativeErrorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor) >-{ >- NativeErrorConstructor* thisObject = jsCast<NativeErrorConstructor*>(cell); >- ASSERT_GC_OBJECT_INHERITS(thisObject, info()); >- Base::visitChildren(thisObject, visitor); >- visitor.append(thisObject->m_errorStructure); >+ putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); >+ putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum); > } > >-EncodedJSValue JSC_HOST_CALL Interpreter::constructWithNativeErrorConstructor(ExecState* exec) >+template<ErrorType errorType> >+EncodedJSValue JSC_HOST_CALL NativeErrorConstructor<errorType>::constructNativeErrorConstructor(ExecState* exec) > { > VM& vm = exec->vm(); > auto scope = DECLARE_THROW_SCOPE(vm); > JSValue message = exec->argument(0); >- Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), jsCast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure()); >+ Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), jsCast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure(vm)); > RETURN_IF_EXCEPTION(scope, encodedJSValue()); > ASSERT(errorStructure); > RELEASE_AND_RETURN(scope, JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false))); > } > >-EncodedJSValue JSC_HOST_CALL Interpreter::callNativeErrorConstructor(ExecState* exec) >+template<ErrorType errorType> >+EncodedJSValue JSC_HOST_CALL NativeErrorConstructor<errorType>::callNativeErrorConstructor(ExecState* exec) > { >+ VM& vm = exec->vm(); > JSValue message = exec->argument(0); >- Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure(); >+ Structure* errorStructure = jsCast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure(vm); > return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false)); > } > >+// Instantiate JSGenericArrayBufferConstructors. >+template class NativeErrorConstructor<ErrorType::EvalError>; >+template class NativeErrorConstructor<ErrorType::RangeError>; >+template class NativeErrorConstructor<ErrorType::ReferenceError>; >+template class NativeErrorConstructor<ErrorType::SyntaxError>; >+template class NativeErrorConstructor<ErrorType::TypeError>; >+template class NativeErrorConstructor<ErrorType::URIError>; >+ > } // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/NativeErrorConstructor.h b/Source/JavaScriptCore/runtime/NativeErrorConstructor.h >index 827a096f860fa1cb5f3147ed6e25d3beb9ad4362..7307d010c9344696c64aac9a8c295f7ab33e4a30 100644 >--- a/Source/JavaScriptCore/runtime/NativeErrorConstructor.h >+++ b/Source/JavaScriptCore/runtime/NativeErrorConstructor.h >@@ -20,6 +20,7 @@ > > #pragma once > >+#include "Error.h" > #include "InternalFunction.h" > #include "NativeErrorPrototype.h" > >@@ -29,40 +30,56 @@ class ErrorInstance; > class FunctionPrototype; > class NativeErrorPrototype; > >-class NativeErrorConstructor final : public InternalFunction { >+class NativeErrorConstructorBase : public InternalFunction { > public: >- typedef InternalFunction Base; >+ using Base = InternalFunction; > >- template<typename CellType> >- static IsoSubspace* subspaceFor(VM& vm) >+ DECLARE_INFO; >+ >+ static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) > { >- return &vm.nativeErrorConstructorSpace; >+ return Structure::create(vm, globalObject, prototype, TypeInfo(InternalFunctionType, StructureFlags), info()); > } > >- static NativeErrorConstructor* create(VM& vm, JSGlobalObject* globalObject, Structure* structure, Structure* prototypeStructure, const String& name) >+protected: >+ NativeErrorConstructorBase(VM& vm, Structure* structure, NativeFunction functionForCall, NativeFunction functionForConstruct) >+ : InternalFunction(vm, structure, functionForCall, functionForConstruct) > { >- NativeErrorConstructor* constructor = new (NotNull, allocateCell<NativeErrorConstructor>(vm.heap)) NativeErrorConstructor(vm, structure); >- constructor->finishCreation(vm, globalObject, prototypeStructure, name); >- return constructor; > } > >- DECLARE_INFO; >+ void finishCreation(VM&, NativeErrorPrototype*, ErrorType); >+}; > >- static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype) >+template<ErrorType errorType> >+class NativeErrorConstructor final : public NativeErrorConstructorBase { >+public: >+ static NativeErrorConstructor* create(VM& vm, Structure* structure, NativeErrorPrototype* prototype) > { >- return Structure::create(vm, globalObject, prototype, TypeInfo(InternalFunctionType, StructureFlags), info()); >+ NativeErrorConstructor* constructor = new (NotNull, allocateCell<NativeErrorConstructor>(vm.heap)) NativeErrorConstructor(vm, structure); >+ constructor->finishCreation(vm, prototype, errorType); >+ return constructor; > } > >- Structure* errorStructure() { return m_errorStructure.get(); } >- >-protected: >- void finishCreation(VM&, JSGlobalObject*, Structure* prototypeStructure, const String& name); >- >+ Structure* errorStructure(VM& vm) { return globalObject(vm)->errorStructure(errorType); } > private: >- NativeErrorConstructor(VM&, Structure*); >- static void visitChildren(JSCell*, SlotVisitor&); >+ static EncodedJSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState*); >+ static EncodedJSValue JSC_HOST_CALL constructNativeErrorConstructor(ExecState*); > >- WriteBarrier<Structure> m_errorStructure; >+ NativeErrorConstructor(VM&, Structure*); > }; > >+using EvalErrorConstructor = NativeErrorConstructor<ErrorType::EvalError>; >+using RangeErrorConstructor = NativeErrorConstructor<ErrorType::RangeError>; >+using ReferenceErrorConstructor = NativeErrorConstructor<ErrorType::ReferenceError>; >+using SyntaxErrorConstructor = NativeErrorConstructor<ErrorType::SyntaxError>; >+using TypeErrorConstructor = NativeErrorConstructor<ErrorType::TypeError>; >+using URIErrorConstructor = NativeErrorConstructor<ErrorType::URIError>; >+ >+static_assert(sizeof(EvalErrorConstructor) == sizeof(InternalFunction), ""); >+static_assert(sizeof(RangeErrorConstructor) == sizeof(InternalFunction), ""); >+static_assert(sizeof(ReferenceErrorConstructor) == sizeof(InternalFunction), ""); >+static_assert(sizeof(SyntaxErrorConstructor) == sizeof(InternalFunction), ""); >+static_assert(sizeof(TypeErrorConstructor) == sizeof(InternalFunction), ""); >+static_assert(sizeof(URIErrorConstructor) == sizeof(InternalFunction), ""); >+ > } // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp b/Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp >index 24867930655c9f45ec49c6c86055b9f39d9791a2..0004430ddc82ae2655bd274ad5d1e3ada525b2c6 100644 >--- a/Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp >+++ b/Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp >@@ -33,12 +33,11 @@ NativeErrorPrototype::NativeErrorPrototype(VM& vm, Structure* structure) > { > } > >-void NativeErrorPrototype::finishCreation(VM& vm, const WTF::String& nameAndMessage, NativeErrorConstructor* constructor) >+void NativeErrorPrototype::finishCreation(VM& vm, const WTF::String& nameAndMessage) > { > Base::finishCreation(vm); > putDirect(vm, vm.propertyNames->name, jsString(&vm, nameAndMessage), static_cast<unsigned>(PropertyAttribute::DontEnum)); > putDirect(vm, vm.propertyNames->message, jsEmptyString(&vm), static_cast<unsigned>(PropertyAttribute::DontEnum)); >- putDirect(vm, vm.propertyNames->constructor, constructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); > } > > } // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/NativeErrorPrototype.h b/Source/JavaScriptCore/runtime/NativeErrorPrototype.h >index e6c2b5a57c0eaa8821a7bc9240ceb21b2b31e79a..b668f4a22afa62e3eca134cceecfc4042134495c 100644 >--- a/Source/JavaScriptCore/runtime/NativeErrorPrototype.h >+++ b/Source/JavaScriptCore/runtime/NativeErrorPrototype.h >@@ -24,8 +24,6 @@ > > namespace JSC { > >-class NativeErrorConstructor; >- > class NativeErrorPrototype final : public ErrorPrototype { > private: > NativeErrorPrototype(VM&, Structure*); >@@ -33,15 +31,15 @@ class NativeErrorPrototype final : public ErrorPrototype { > public: > typedef ErrorPrototype Base; > >- static NativeErrorPrototype* create(VM& vm, Structure* structure, const String& name, NativeErrorConstructor* constructor) >+ static NativeErrorPrototype* create(VM& vm, Structure* structure, const String& name) > { > NativeErrorPrototype* prototype = new (NotNull, allocateCell<NativeErrorPrototype>(vm.heap)) NativeErrorPrototype(vm, structure); >- prototype->finishCreation(vm, name, constructor); >+ prototype->finishCreation(vm, name); > return prototype; > } > > protected: >- void finishCreation(VM&, const String& nameAndMessage, NativeErrorConstructor*); >+ void finishCreation(VM&, const String& nameAndMessage); > }; > > } // namespace JSC >diff --git a/Source/JavaScriptCore/runtime/VM.cpp b/Source/JavaScriptCore/runtime/VM.cpp >index cb2dc47cddd6429ecfd01e932ef8d9885ff10779..15c66a7949d766cb0ac6f00b5f12197bd1f5d7f0 100644 >--- a/Source/JavaScriptCore/runtime/VM.cpp >+++ b/Source/JavaScriptCore/runtime/VM.cpp >@@ -302,7 +302,6 @@ VM::VM(VMType vmType, HeapType heapType) > , generatorFunctionSpace ISO_SUBSPACE_INIT(heap, cellJSValueOOBHeapCellType.get(), JSGeneratorFunction) > , inferredValueSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), InferredValue) > , internalFunctionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), InternalFunction) >- , nativeErrorConstructorSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), NativeErrorConstructor) > , nativeExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), NativeExecutable) > , nativeStdFunctionSpace ISO_SUBSPACE_INIT(heap, cellJSValueOOBHeapCellType.get(), JSNativeStdFunction) > #if JSC_OBJC_API_ENABLED >diff --git a/Source/JavaScriptCore/runtime/VM.h b/Source/JavaScriptCore/runtime/VM.h >index 3f4accf358bf8cae99aaecdf6d9da105c1c4cd33..925b8a6e7f93d5daeef201c4e63401d902feaf06 100644 >--- a/Source/JavaScriptCore/runtime/VM.h >+++ b/Source/JavaScriptCore/runtime/VM.h >@@ -377,7 +377,6 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> { > IsoSubspace generatorFunctionSpace; > IsoSubspace inferredValueSpace; > IsoSubspace internalFunctionSpace; >- IsoSubspace nativeErrorConstructorSpace; > IsoSubspace nativeExecutableSpace; > IsoSubspace nativeStdFunctionSpace; > #if JSC_OBJC_API_ENABLED >diff --git a/Source/JavaScriptCore/wasm/js/WasmToJS.cpp b/Source/JavaScriptCore/wasm/js/WasmToJS.cpp >index ee00fc88e0caf2544d9d79ecc93f4e1232538b32..7b32c7cc97473f6b36c0680c27d31276c9840b2b 100644 >--- a/Source/JavaScriptCore/wasm/js/WasmToJS.cpp >+++ b/Source/JavaScriptCore/wasm/js/WasmToJS.cpp >@@ -104,7 +104,7 @@ static Expected<MacroAssemblerCodeRef<WasmEntryPtrTag>, BindingFailure> handleBa > { > auto throwScope = DECLARE_THROW_SCOPE(*vm); > JSGlobalObject* globalObject = instance->globalObject(*vm); >- auto* error = ErrorInstance::create(exec, *vm, globalObject->typeErrorConstructor()->errorStructure(), "i64 not allowed as return type or argument to an imported function"_s); >+ auto* error = ErrorInstance::create(exec, *vm, globalObject->errorStructure(ErrorType::TypeError), "i64 not allowed as return type or argument to an imported function"_s); > throwException(exec, throwScope, error); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193713
:
360196
|
360198
|
360199
|
360206
|
360212
|
360213
|
360216
|
360219
|
360220
|
360221
|
360222
|
360224
|
360230