Changeset 240543 in webkit
- Timestamp:
- Jan 26, 2019 1:07:25 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r240449 r240543 1 2019-01-25 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] NativeErrorConstructor should not have own IsoSubspace 4 https://bugs.webkit.org/show_bug.cgi?id=193713 5 6 Reviewed by Saam Barati. 7 8 Remove @Error use. 9 10 * stress/try-get-by-id-should-spill-registers-dfg.js: 11 (let.f.createBuiltin): 12 1 13 2019-01-24 Yusuke Suzuki <ysuzuki@apple.com> 2 14 -
trunk/JSTests/stress/try-get-by-id-should-spill-registers-dfg.js
r225129 r240543 3 3 let f = createBuiltin(`(function (arg) { 4 4 let r = @tryGetById(arg, "prototype"); 5 if (arg !== true) throw new @Error("Bad clobber of arg");5 if (arg !== true) throw new Error("Bad clobber of arg"); 6 6 return r; 7 7 })`); -
trunk/Source/JavaScriptCore/CMakeLists.txt
r240457 r240543 773 773 runtime/ErrorInstance.h 774 774 runtime/ErrorPrototype.h 775 runtime/ErrorType.h 775 776 runtime/EvalExecutable.h 776 777 runtime/Exception.h -
trunk/Source/JavaScriptCore/ChangeLog
r240540 r240543 1 2019-01-25 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] NativeErrorConstructor should not have own IsoSubspace 4 https://bugs.webkit.org/show_bug.cgi?id=193713 5 6 Reviewed by Saam Barati. 7 8 This removes an additional member in NativeErrorConstructor, and make sizeof(NativeErrorConstructor) == sizeof(InternalFunction). 9 We also make error constructors lazily allocated by using LazyClassStructure. Since error structures are not accessed from DFG / FTL 10 threads, this is OK. While TypeError constructor is eagerly allocated because it is touched from our builtin JS as @TypeError, we should 11 offer some function instead of exposing TypeError constructor in the future, and remove this @TypeError reference. This change removes 12 IsoSubspace for NativeErrorConstructor in VM. We also remove @Error and @RangeError references for builtins since they are no longer 13 referenced. 14 15 * CMakeLists.txt: 16 * JavaScriptCore.xcodeproj/project.pbxproj: 17 * Sources.txt: 18 * builtins/BuiltinNames.h: 19 * interpreter/Interpreter.h: 20 * runtime/Error.cpp: 21 (JSC::createEvalError): 22 (JSC::createRangeError): 23 (JSC::createReferenceError): 24 (JSC::createSyntaxError): 25 (JSC::createTypeError): 26 (JSC::createURIError): 27 (WTF::printInternal): Deleted. 28 * runtime/Error.h: 29 * runtime/ErrorPrototype.cpp: 30 (JSC::ErrorPrototype::create): 31 (JSC::ErrorPrototype::finishCreation): 32 * runtime/ErrorPrototype.h: 33 (JSC::ErrorPrototype::create): Deleted. 34 * runtime/ErrorType.cpp: Added. 35 (JSC::errorTypeName): 36 (WTF::printInternal): 37 * runtime/ErrorType.h: Added. 38 * runtime/JSGlobalObject.cpp: 39 (JSC::JSGlobalObject::initializeErrorConstructor): 40 (JSC::JSGlobalObject::init): 41 (JSC::JSGlobalObject::visitChildren): 42 * runtime/JSGlobalObject.h: 43 (JSC::JSGlobalObject::internalPromiseConstructor const): 44 (JSC::JSGlobalObject::errorStructure const): 45 (JSC::JSGlobalObject::evalErrorConstructor const): Deleted. 46 (JSC::JSGlobalObject::rangeErrorConstructor const): Deleted. 47 (JSC::JSGlobalObject::referenceErrorConstructor const): Deleted. 48 (JSC::JSGlobalObject::syntaxErrorConstructor const): Deleted. 49 (JSC::JSGlobalObject::typeErrorConstructor const): Deleted. 50 (JSC::JSGlobalObject::URIErrorConstructor const): Deleted. 51 * runtime/NativeErrorConstructor.cpp: 52 (JSC::NativeErrorConstructor<errorType>::NativeErrorConstructor): 53 (JSC::NativeErrorConstructorBase::finishCreation): 54 (JSC::NativeErrorConstructor<errorType>::constructNativeErrorConstructor): 55 (JSC::NativeErrorConstructor<errorType>::callNativeErrorConstructor): 56 (JSC::NativeErrorConstructor::NativeErrorConstructor): Deleted. 57 (JSC::NativeErrorConstructor::finishCreation): Deleted. 58 (JSC::NativeErrorConstructor::visitChildren): Deleted. 59 (JSC::Interpreter::constructWithNativeErrorConstructor): Deleted. 60 (JSC::Interpreter::callNativeErrorConstructor): Deleted. 61 * runtime/NativeErrorConstructor.h: 62 (JSC::NativeErrorConstructorBase::createStructure): 63 (JSC::NativeErrorConstructorBase::NativeErrorConstructorBase): 64 * runtime/NativeErrorPrototype.cpp: 65 (JSC::NativeErrorPrototype::finishCreation): Deleted. 66 * runtime/NativeErrorPrototype.h: 67 * runtime/VM.cpp: 68 (JSC::VM::VM): 69 * runtime/VM.h: 70 * wasm/js/WasmToJS.cpp: 71 (JSC::Wasm::handleBadI64Use): 72 1 73 2019-01-25 Devin Rousso <drousso@apple.com> 2 74 -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r240525 r240543 1774 1774 E3D239C91B829C1C00BBEF67 /* JSModuleEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D239C71B829C1C00BBEF67 /* JSModuleEnvironment.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1775 1775 E3D877741E65C0A000BE945A /* BytecodeDumper.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D877721E65C08900BE945A /* BytecodeDumper.h */; }; 1776 E3EE137621FBD43500D83C4B /* ErrorType.h in Headers */ = {isa = PBXBuildFile; fileRef = E3EE137421FBD43400D83C4B /* ErrorType.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1776 1777 E3F23A7F1ECF13EE00978D99 /* SnippetSlowPathCalls.h in Headers */ = {isa = PBXBuildFile; fileRef = E3F23A7E1ECF13E500978D99 /* SnippetSlowPathCalls.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1777 1778 E3F23A801ECF13F500978D99 /* SnippetReg.h in Headers */ = {isa = PBXBuildFile; fileRef = E3F23A7D1ECF13E500978D99 /* SnippetReg.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 4723 4724 E3D877711E65C08900BE945A /* BytecodeDumper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BytecodeDumper.cpp; sourceTree = "<group>"; }; 4724 4725 E3D877721E65C08900BE945A /* BytecodeDumper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytecodeDumper.h; sourceTree = "<group>"; }; 4726 E3EE137421FBD43400D83C4B /* ErrorType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorType.h; sourceTree = "<group>"; }; 4727 E3EE137521FBD43400D83C4B /* ErrorType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorType.cpp; sourceTree = "<group>"; }; 4725 4728 E3F23A7B1ECF13E500978D99 /* Snippet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Snippet.h; sourceTree = "<group>"; }; 4726 4729 E3F23A7C1ECF13E500978D99 /* SnippetParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnippetParams.h; sourceTree = "<group>"; }; … … 6699 6702 BC02E9060E1839DB000F9297 /* ErrorPrototype.cpp */, 6700 6703 BC02E9070E1839DB000F9297 /* ErrorPrototype.h */, 6704 E3EE137521FBD43400D83C4B /* ErrorType.cpp */, 6705 E3EE137421FBD43400D83C4B /* ErrorType.h */, 6701 6706 147341DB1DC2CE9600AA29BA /* EvalExecutable.cpp */, 6702 6707 147341D11DC02E2E00AA29BA /* EvalExecutable.h */, … … 8912 8917 BC02E90F0E1839DB000F9297 /* ErrorPrototype.h in Headers */, 8913 8918 996B731B1BDA08D100331B84 /* ErrorPrototype.lut.h in Headers */, 8919 E3EE137621FBD43500D83C4B /* ErrorType.h in Headers */, 8914 8920 14AD910C1DCA92940014F9FE /* EvalCodeBlock.h in Headers */, 8915 8921 147341D21DC02E2E00AA29BA /* EvalExecutable.h in Headers */, … … 9322 9328 53EE01B8218F7EFF00AD1F8D /* JSScriptInternal.h in Headers */, 9323 9329 A7C0C4AC168103020017011D /* JSScriptRefPrivate.h in Headers */, 9330 14D01A7721FB351F00BC54E9 /* JSScriptSourceProvider.h in Headers */, 9324 9331 0F919D11157F332C004A4E7D /* JSSegmentedVariableObject.h in Headers */, 9325 9332 0F4F82881E2FFDE00075184C /* JSSegmentedVariableObjectHeapCellType.h in Headers */, … … 9792 9799 14E84FA214EE1ACC00D6D5D4 /* WeakImpl.h in Headers */, 9793 9800 14BE7D3317135CF400D1807A /* WeakInlines.h in Headers */, 9794 14D01A7721FB351F00BC54E9 /* JSScriptSourceProvider.h in Headers */,9795 9801 A7CA3AE417DA41AE006538AF /* WeakMapConstructor.h in Headers */, 9796 9802 E3A32BC71FC83147007D7E76 /* WeakMapImpl.h in Headers */, -
trunk/Source/JavaScriptCore/Sources.txt
r240255 r240543 749 749 runtime/ErrorInstance.cpp 750 750 runtime/ErrorPrototype.cpp 751 runtime/ErrorType.cpp 751 752 runtime/EvalExecutable.cpp 752 753 runtime/Exception.cpp -
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r240255 r240543 75 75 macro(getOwnPropertyNames) \ 76 76 macro(ownKeys) \ 77 macro(Error) \78 macro(RangeError) \79 77 macro(Set) \ 80 78 macro(TypeError) \ -
trunk/Source/JavaScriptCore/interpreter/Interpreter.h
r240465 r240543 118 118 static String stackTraceAsString(VM&, const Vector<StackFrame>&); 119 119 120 static EncodedJSValue JSC_HOST_CALL constructWithNativeErrorConstructor(ExecState*);121 static EncodedJSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState*);122 123 120 void getStackTrace(JSCell* owner, Vector<StackFrame>& results, size_t framesToSkip = 0, size_t maxStackSize = std::numeric_limits<size_t>::max()); 124 121 -
trunk/Source/JavaScriptCore/runtime/Error.cpp
r240465 r240543 54 54 ASSERT(!message.isEmpty()); 55 55 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 56 return ErrorInstance::create(exec, globalObject->vm(), globalObject->e valErrorConstructor()->errorStructure(), message, appender, TypeNothing, true);56 return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::EvalError), message, appender, TypeNothing, true); 57 57 } 58 58 … … 66 66 { 67 67 ASSERT(!message.isEmpty()); 68 return ErrorInstance::create(exec, globalObject->vm(), globalObject-> rangeErrorConstructor()->errorStructure(), message, appender, TypeNothing, true);68 return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::RangeError), message, appender, TypeNothing, true); 69 69 } 70 70 … … 73 73 ASSERT(!message.isEmpty()); 74 74 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 75 return ErrorInstance::create(exec, globalObject->vm(), globalObject-> referenceErrorConstructor()->errorStructure(), message, appender, TypeNothing, true);75 return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::ReferenceError), message, appender, TypeNothing, true); 76 76 } 77 77 … … 80 80 ASSERT(!message.isEmpty()); 81 81 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 82 return ErrorInstance::create(exec, globalObject->vm(), globalObject-> syntaxErrorConstructor()->errorStructure(), message, appender, TypeNothing, true);82 return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::SyntaxError), message, appender, TypeNothing, true); 83 83 } 84 84 … … 87 87 ASSERT(!message.isEmpty()); 88 88 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 89 return ErrorInstance::create(exec, globalObject->vm(), globalObject-> typeErrorConstructor()->errorStructure(), message, appender, type, true);89 return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::TypeError), message, appender, type, true); 90 90 } 91 91 … … 99 99 ASSERT(!message.isEmpty()); 100 100 JSGlobalObject* globalObject = exec->lexicalGlobalObject(); 101 return ErrorInstance::create(exec, globalObject->vm(), globalObject-> URIErrorConstructor()->errorStructure(), message, appender, TypeNothing, true);101 return ErrorInstance::create(exec, globalObject->vm(), globalObject->errorStructure(ErrorType::URIError), message, appender, TypeNothing, true); 102 102 } 103 103 … … 362 362 363 363 } // namespace JSC 364 365 namespace WTF {366 367 using namespace JSC;368 369 void printInternal(PrintStream& out, JSC::ErrorType errorType)370 {371 switch (errorType) {372 case JSC::ErrorType::Error:373 out.print("Error");374 break;375 case JSC::ErrorType::EvalError:376 out.print("EvalError");377 break;378 case JSC::ErrorType::RangeError:379 out.print("RangeError");380 break;381 case JSC::ErrorType::ReferenceError:382 out.print("ReferenceError");383 break;384 case JSC::ErrorType::SyntaxError:385 out.print("SyntaxError");386 break;387 case JSC::ErrorType::TypeError:388 out.print("TypeError");389 break;390 case JSC::ErrorType::URIError:391 out.print("URIError");392 break;393 }394 }395 396 } // namespace WTF -
trunk/Source/JavaScriptCore/runtime/Error.h
r240246 r240543 24 24 25 25 #include "ErrorInstance.h" 26 #include "ErrorType.h" 26 27 #include "InternalFunction.h" 27 28 #include "JSObject.h" … … 38 39 class SourceCode; 39 40 class Structure; 40 41 enum class ErrorType : uint8_t {42 Error,43 EvalError,44 RangeError,45 ReferenceError,46 SyntaxError,47 TypeError,48 URIError,49 };50 41 51 42 // ExecState wrappers. … … 106 97 107 98 } // namespace JSC 108 109 namespace WTF {110 111 class PrintStream;112 113 void printInternal(PrintStream&, JSC::ErrorType);114 115 } // namespace WTF -
trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
r236697 r240543 54 54 } 55 55 56 void ErrorPrototype::finishCreation(VM& vm) 56 ErrorPrototype* ErrorPrototype::create(VM& vm, JSGlobalObject*, Structure* structure) 57 { 58 ErrorPrototype* prototype = new (NotNull, allocateCell<ErrorPrototype>(vm.heap)) ErrorPrototype(vm, structure); 59 prototype->finishCreation(vm, "Error"_s); 60 return prototype; 61 } 62 63 void ErrorPrototype::finishCreation(VM& vm, const String& name) 57 64 { 58 65 Base::finishCreation(vm); 59 66 ASSERT(inherits(vm, info())); 60 putDirect (vm, vm.propertyNames->name, jsNontrivialString(&vm, String("Error"_s)), static_cast<unsigned>(PropertyAttribute::DontEnum));61 putDirect (vm, vm.propertyNames->message, jsEmptyString(&vm), static_cast<unsigned>(PropertyAttribute::DontEnum));67 putDirectWithoutTransition(vm, vm.propertyNames->name, jsString(&vm, name), static_cast<unsigned>(PropertyAttribute::DontEnum)); 68 putDirectWithoutTransition(vm, vm.propertyNames->message, jsEmptyString(&vm), static_cast<unsigned>(PropertyAttribute::DontEnum)); 62 69 } 63 70 -
trunk/Source/JavaScriptCore/runtime/ErrorPrototype.h
r206525 r240543 32 32 static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable; 33 33 34 static ErrorPrototype* create(VM& vm, JSGlobalObject*, Structure* structure) 35 { 36 ErrorPrototype* prototype = new (NotNull, allocateCell<ErrorPrototype>(vm.heap)) ErrorPrototype(vm, structure); 37 prototype->finishCreation(vm); 38 return prototype; 39 } 34 static ErrorPrototype* create(VM&, JSGlobalObject*, Structure*); 40 35 41 36 DECLARE_INFO; … … 48 43 protected: 49 44 ErrorPrototype(VM&, Structure*); 50 void finishCreation(VM& );45 void finishCreation(VM&, const String&); 51 46 }; 52 47 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp
r240465 r240543 304 304 encodeURI globalFuncEncodeURI DontEnum|Function 1 305 305 encodeURIComponent globalFuncEncodeURIComponent DontEnum|Function 1 306 EvalError JSGlobalObject::m_evalErrorConstructor DontEnum|CellProperty307 306 globalThis JSGlobalObject::m_globalThis DontEnum|CellProperty 308 ReferenceError JSGlobalObject::m_referenceErrorConstructor DontEnum|CellProperty 309 SyntaxError JSGlobalObject::m_syntaxErrorConstructor DontEnum|CellProperty 310 URIError JSGlobalObject::m_URIErrorConstructor DontEnum|CellProperty 307 EvalError JSGlobalObject::m_evalErrorStructure DontEnum|ClassStructure 308 RangeError JSGlobalObject::m_rangeErrorStructure DontEnum|ClassStructure 309 ReferenceError JSGlobalObject::m_referenceErrorStructure DontEnum|ClassStructure 310 SyntaxError JSGlobalObject::m_syntaxErrorStructure DontEnum|ClassStructure 311 TypeError JSGlobalObject::m_typeErrorStructure DontEnum|ClassStructure 312 URIError JSGlobalObject::m_URIErrorStructure DontEnum|ClassStructure 311 313 Proxy createProxyProperty DontEnum|PropertyCallback 312 314 JSON createJSONProperty DontEnum|PropertyCallback … … 394 396 } 395 397 398 template<ErrorType errorType> 399 void JSGlobalObject::initializeErrorConstructor(LazyClassStructure::Initializer& init) 400 { 401 init.setPrototype(NativeErrorPrototype::create(init.vm, NativeErrorPrototype::createStructure(init.vm, this, m_errorPrototype.get()), errorTypeName(errorType))); 402 init.setStructure(ErrorInstance::createStructure(init.vm, this, init.prototype)); 403 init.setConstructor(NativeErrorConstructor<errorType>::create(init.vm, NativeErrorConstructor<errorType>::createStructure(init.vm, this, m_errorConstructor.get()), jsCast<NativeErrorPrototype*>(init.prototype))); 404 } 405 396 406 void JSGlobalObject::init(VM& vm) 397 407 { … … 705 715 m_internalPromiseConstructor.set(vm, this, internalPromiseConstructor); 706 716 707 m_nativeErrorPrototypeStructure.set(vm, this, NativeErrorPrototype::createStructure(vm, this, m_errorPrototype.get())); 708 m_nativeErrorStructure.set(vm, this, NativeErrorConstructor::createStructure(vm, this, errorConstructor)); 709 m_evalErrorConstructor.initLater( 710 [] (const Initializer<NativeErrorConstructor>& init) { 711 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "EvalError"_s)); 712 }); 713 m_rangeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), "RangeError"_s)); 714 m_referenceErrorConstructor.initLater( 715 [] (const Initializer<NativeErrorConstructor>& init) { 716 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "ReferenceError"_s)); 717 }); 718 m_syntaxErrorConstructor.initLater( 719 [] (const Initializer<NativeErrorConstructor>& init) { 720 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "SyntaxError"_s)); 721 }); 722 m_typeErrorConstructor.set(vm, this, NativeErrorConstructor::create(vm, this, m_nativeErrorStructure.get(), m_nativeErrorPrototypeStructure.get(), "TypeError"_s)); 723 m_URIErrorConstructor.initLater( 724 [] (const Initializer<NativeErrorConstructor>& init) { 725 init.set(NativeErrorConstructor::create(init.vm, init.owner, init.owner->m_nativeErrorStructure.get(), init.owner->m_nativeErrorPrototypeStructure.get(), "URIError"_s)); 717 m_errorConstructor.set(vm, this, errorConstructor); 718 m_evalErrorStructure.initLater( 719 [] (LazyClassStructure::Initializer& init) { 720 init.global->initializeErrorConstructor<ErrorType::EvalError>(init); 721 }); 722 m_rangeErrorStructure.initLater( 723 [] (LazyClassStructure::Initializer& init) { 724 init.global->initializeErrorConstructor<ErrorType::RangeError>(init); 725 }); 726 m_referenceErrorStructure.initLater( 727 [] (LazyClassStructure::Initializer& init) { 728 init.global->initializeErrorConstructor<ErrorType::ReferenceError>(init); 729 }); 730 m_syntaxErrorStructure.initLater( 731 [] (LazyClassStructure::Initializer& init) { 732 init.global->initializeErrorConstructor<ErrorType::SyntaxError>(init); 733 }); 734 m_typeErrorStructure.initLater( 735 [] (LazyClassStructure::Initializer& init) { 736 init.global->initializeErrorConstructor<ErrorType::TypeError>(init); 737 }); 738 m_URIErrorStructure.initLater( 739 [] (LazyClassStructure::Initializer& init) { 740 init.global->initializeErrorConstructor<ErrorType::URIError>(init); 726 741 }); 727 742 … … 757 772 putDirectWithoutTransition(vm, vm.propertyNames->Array, arrayConstructor, static_cast<unsigned>(PropertyAttribute::DontEnum)); 758 773 putDirectWithoutTransition(vm, vm.propertyNames->RegExp, m_regExpConstructor.get(), static_cast<unsigned>(PropertyAttribute::DontEnum)); 759 putDirectWithoutTransition(vm, vm.propertyNames->RangeError, m_rangeErrorConstructor.get(), static_cast<unsigned>(PropertyAttribute::DontEnum));760 putDirectWithoutTransition(vm, vm.propertyNames->TypeError, m_typeErrorConstructor.get(), static_cast<unsigned>(PropertyAttribute::DontEnum));761 774 762 775 putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ObjectPrivateName(), objectConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly); … … 879 892 GlobalPropertyInfo(vm.propertyNames->builtinNames().importModulePrivateName(), privateFuncImportModule, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), 880 893 GlobalPropertyInfo(vm.propertyNames->builtinNames().enqueueJobPrivateName(), JSFunction::create(vm, this, 0, String(), enqueueJob), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), 881 GlobalPropertyInfo(vm.propertyNames->builtinNames().ErrorPrivateName(), errorConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),882 GlobalPropertyInfo(vm.propertyNames->builtinNames().RangeErrorPrivateName(), m_rangeErrorConstructor.get(), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),883 GlobalPropertyInfo(vm.propertyNames->builtinNames().TypeErrorPrivateName(), m_typeError Constructor.get(), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),894 // FIXME: Offer @makeTypeError function instead of exposing @TypeError here. 895 // https://bugs.webkit.org/show_bug.cgi?id=193858 896 GlobalPropertyInfo(vm.propertyNames->builtinNames().TypeErrorPrivateName(), m_typeErrorStructure.constructor(this), PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), 884 897 GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayLengthPrivateName(), privateFuncTypedArrayLength, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), 885 898 GlobalPropertyInfo(vm.propertyNames->builtinNames().typedArrayGetOriginalConstructorPrivateName(), privateFuncTypedArrayGetOriginalConstructor, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly), … … 1549 1562 visitor.append(thisObject->m_stackOverflowFrameCallee); 1550 1563 visitor.append(thisObject->m_regExpConstructor); 1551 visitor.append(thisObject->m_nativeErrorPrototypeStructure); 1552 visitor.append(thisObject->m_nativeErrorStructure); 1553 thisObject->m_evalErrorConstructor.visit(visitor); 1554 visitor.append(thisObject->m_rangeErrorConstructor); 1555 thisObject->m_referenceErrorConstructor.visit(visitor); 1556 thisObject->m_syntaxErrorConstructor.visit(visitor); 1557 visitor.append(thisObject->m_typeErrorConstructor); 1558 thisObject->m_URIErrorConstructor.visit(visitor); 1564 visitor.append(thisObject->m_errorConstructor); 1565 thisObject->m_evalErrorStructure.visit(visitor); 1566 thisObject->m_rangeErrorStructure.visit(visitor); 1567 thisObject->m_referenceErrorStructure.visit(visitor); 1568 thisObject->m_syntaxErrorStructure.visit(visitor); 1569 thisObject->m_typeErrorStructure.visit(visitor); 1570 thisObject->m_URIErrorStructure.visit(visitor); 1559 1571 visitor.append(thisObject->m_objectConstructor); 1560 1572 visitor.append(thisObject->m_promiseConstructor); -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r240465 r240543 26 26 #include "BigIntPrototype.h" 27 27 #include "BooleanPrototype.h" 28 #include "ErrorType.h" 28 29 #include "ExceptionHelpers.h" 29 30 #include "InternalFunction.h" … … 102 103 class ModuleLoader; 103 104 class ModuleProgramExecutable; 104 class NativeErrorConstructor ;105 class NativeErrorConstructorBase; 105 106 class NullGetterFunction; 106 107 class NullSetterFunction; … … 260 261 WriteBarrier<JSCallee> m_stackOverflowFrameCallee; 261 262 WriteBarrier<RegExpConstructor> m_regExpConstructor; 262 WriteBarrier<Structure> m_nativeErrorPrototypeStructure; 263 WriteBarrier<Structure> m_nativeErrorStructure; 264 LazyProperty<JSGlobalObject, NativeErrorConstructor> m_evalErrorConstructor; 265 WriteBarrier<NativeErrorConstructor> m_rangeErrorConstructor; 266 LazyProperty<JSGlobalObject, NativeErrorConstructor> m_referenceErrorConstructor; 267 LazyProperty<JSGlobalObject, NativeErrorConstructor> m_syntaxErrorConstructor; 268 WriteBarrier<NativeErrorConstructor> m_typeErrorConstructor; 269 LazyProperty<JSGlobalObject, NativeErrorConstructor> m_URIErrorConstructor; 263 264 WriteBarrier<ErrorConstructor> m_errorConstructor; 265 LazyClassStructure m_evalErrorStructure; 266 LazyClassStructure m_rangeErrorStructure; 267 LazyClassStructure m_referenceErrorStructure; 268 LazyClassStructure m_syntaxErrorStructure; 269 LazyClassStructure m_typeErrorStructure; 270 LazyClassStructure m_URIErrorStructure; 271 270 272 WriteBarrier<ObjectConstructor> m_objectConstructor; 271 273 WriteBarrier<ArrayConstructor> m_arrayConstructor; … … 581 583 JSPromiseConstructor* promiseConstructor() const { return m_promiseConstructor.get(); } 582 584 JSInternalPromiseConstructor* internalPromiseConstructor() const { return m_internalPromiseConstructor.get(); } 583 NativeErrorConstructor* evalErrorConstructor() const { return m_evalErrorConstructor.get(this); }584 NativeErrorConstructor* rangeErrorConstructor() const { return m_rangeErrorConstructor.get(); }585 NativeErrorConstructor* referenceErrorConstructor() const { return m_referenceErrorConstructor.get(this); }586 NativeErrorConstructor* syntaxErrorConstructor() const { return m_syntaxErrorConstructor.get(this); }587 NativeErrorConstructor* typeErrorConstructor() const { return m_typeErrorConstructor.get(); }588 NativeErrorConstructor* URIErrorConstructor() const { return m_URIErrorConstructor.get(this); }589 585 590 586 #if ENABLE(INTL) … … 694 690 Structure* nullPrototypeObjectStructure() const { return m_nullPrototypeObjectStructure.get(); } 695 691 Structure* errorStructure() const { return m_errorStructure.get(); } 692 Structure* errorStructure(ErrorType errorType) const 693 { 694 switch (errorType) { 695 case ErrorType::Error: 696 return errorStructure(); 697 case ErrorType::EvalError: 698 return m_evalErrorStructure.get(this); 699 case ErrorType::RangeError: 700 return m_rangeErrorStructure.get(this); 701 case ErrorType::ReferenceError: 702 return m_referenceErrorStructure.get(this); 703 case ErrorType::SyntaxError: 704 return m_syntaxErrorStructure.get(this); 705 case ErrorType::TypeError: 706 return m_typeErrorStructure.get(this); 707 case ErrorType::URIError: 708 return m_URIErrorStructure.get(this); 709 } 710 ASSERT_NOT_REACHED(); 711 return nullptr; 712 } 696 713 Structure* calleeStructure() const { return m_calleeStructure.get(); } 697 714 Structure* hostFunctionStructure() const { return m_hostFunctionStructure.get(); } … … 1001 1018 void setGlobalThis(VM&, JSObject* globalThis); 1002 1019 1020 template<ErrorType errorType> 1021 void initializeErrorConstructor(LazyClassStructure::Initializer&); 1022 1003 1023 JS_EXPORT_PRIVATE void init(VM&); 1004 1024 -
trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.cpp
r236697 r240543 31 31 namespace JSC { 32 32 33 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(NativeErrorConstructor );33 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(NativeErrorConstructorBase); 34 34 35 const ClassInfo NativeErrorConstructor ::s_info = { "Function", &InternalFunction::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(NativeErrorConstructor) };35 const ClassInfo NativeErrorConstructorBase::s_info = { "Function", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(NativeErrorConstructorBase) }; 36 36 37 NativeErrorConstructor::NativeErrorConstructor(VM& vm, Structure* structure) 38 : InternalFunction(vm, structure, Interpreter::callNativeErrorConstructor, Interpreter::constructWithNativeErrorConstructor) 37 template<ErrorType errorType> 38 NativeErrorConstructor<errorType>::NativeErrorConstructor(VM& vm, Structure* structure) 39 : NativeErrorConstructorBase(vm, structure, NativeErrorConstructor<errorType>::callNativeErrorConstructor, NativeErrorConstructor<errorType>::constructNativeErrorConstructor) 39 40 { 40 41 } 41 42 42 void NativeErrorConstructor ::finishCreation(VM& vm, JSGlobalObject* globalObject, Structure* prototypeStructure, const String& name)43 void NativeErrorConstructorBase::finishCreation(VM& vm, NativeErrorPrototype* prototype, ErrorType errorType) 43 44 { 44 Base::finishCreation(vm, name);45 Base::finishCreation(vm, errorTypeName(errorType)); 45 46 ASSERT(inherits(vm, info())); 46 47 47 NativeErrorPrototype* prototype = NativeErrorPrototype::create(vm, prototypeStructure, name, this); 48 49 putDirect(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); 50 putDirect(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum); 51 m_errorStructure.set(vm, this, ErrorInstance::createStructure(vm, globalObject, prototype)); 52 ASSERT(m_errorStructure); 53 ASSERT(m_errorStructure->isObject()); 48 putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::DontEnum | PropertyAttribute::ReadOnly); 49 putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum); 54 50 } 55 51 56 void NativeErrorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor) 57 { 58 NativeErrorConstructor* thisObject = jsCast<NativeErrorConstructor*>(cell); 59 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 60 Base::visitChildren(thisObject, visitor); 61 visitor.append(thisObject->m_errorStructure); 62 } 63 64 EncodedJSValue JSC_HOST_CALL Interpreter::constructWithNativeErrorConstructor(ExecState* exec) 52 template<ErrorType errorType> 53 EncodedJSValue JSC_HOST_CALL NativeErrorConstructor<errorType>::constructNativeErrorConstructor(ExecState* exec) 65 54 { 66 55 VM& vm = exec->vm(); 67 56 auto scope = DECLARE_THROW_SCOPE(vm); 68 57 JSValue message = exec->argument(0); 69 Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), jsCast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure( ));58 Structure* errorStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), jsCast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure(vm)); 70 59 RETURN_IF_EXCEPTION(scope, encodedJSValue()); 71 60 ASSERT(errorStructure); … … 73 62 } 74 63 75 EncodedJSValue JSC_HOST_CALL Interpreter::callNativeErrorConstructor(ExecState* exec) 64 template<ErrorType errorType> 65 EncodedJSValue JSC_HOST_CALL NativeErrorConstructor<errorType>::callNativeErrorConstructor(ExecState* exec) 76 66 { 67 VM& vm = exec->vm(); 77 68 JSValue message = exec->argument(0); 78 Structure* errorStructure = static_cast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure();69 Structure* errorStructure = jsCast<NativeErrorConstructor*>(exec->jsCallee())->errorStructure(vm); 79 70 return JSValue::encode(ErrorInstance::create(exec, errorStructure, message, nullptr, TypeNothing, false)); 80 71 } 81 72 73 template class NativeErrorConstructor<ErrorType::EvalError>; 74 template class NativeErrorConstructor<ErrorType::RangeError>; 75 template class NativeErrorConstructor<ErrorType::ReferenceError>; 76 template class NativeErrorConstructor<ErrorType::SyntaxError>; 77 template class NativeErrorConstructor<ErrorType::TypeError>; 78 template class NativeErrorConstructor<ErrorType::URIError>; 79 82 80 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/NativeErrorConstructor.h
r230813 r240543 21 21 #pragma once 22 22 23 #include "Error.h" 23 24 #include "InternalFunction.h" 24 25 #include "NativeErrorPrototype.h" … … 30 31 class NativeErrorPrototype; 31 32 32 class NativeErrorConstructor final: public InternalFunction {33 class NativeErrorConstructorBase : public InternalFunction { 33 34 public: 34 typedef InternalFunction Base; 35 36 template<typename CellType> 37 static IsoSubspace* subspaceFor(VM& vm) 38 { 39 return &vm.nativeErrorConstructorSpace; 40 } 41 42 static NativeErrorConstructor* create(VM& vm, JSGlobalObject* globalObject, Structure* structure, Structure* prototypeStructure, const String& name) 43 { 44 NativeErrorConstructor* constructor = new (NotNull, allocateCell<NativeErrorConstructor>(vm.heap)) NativeErrorConstructor(vm, structure); 45 constructor->finishCreation(vm, globalObject, prototypeStructure, name); 46 return constructor; 47 } 35 using Base = InternalFunction; 48 36 49 37 DECLARE_INFO; … … 54 42 } 55 43 56 Structure* errorStructure() { return m_errorStructure.get(); } 44 protected: 45 NativeErrorConstructorBase(VM& vm, Structure* structure, NativeFunction functionForCall, NativeFunction functionForConstruct) 46 : InternalFunction(vm, structure, functionForCall, functionForConstruct) 47 { 48 } 57 49 58 protected: 59 void finishCreation(VM&, JSGlobalObject*, Structure* prototypeStructure, const String& name); 60 61 private: 62 NativeErrorConstructor(VM&, Structure*); 63 static void visitChildren(JSCell*, SlotVisitor&); 64 65 WriteBarrier<Structure> m_errorStructure; 50 void finishCreation(VM&, NativeErrorPrototype*, ErrorType); 66 51 }; 67 52 53 template<ErrorType errorType> 54 class NativeErrorConstructor final : public NativeErrorConstructorBase { 55 public: 56 static NativeErrorConstructor* create(VM& vm, Structure* structure, NativeErrorPrototype* prototype) 57 { 58 NativeErrorConstructor* constructor = new (NotNull, allocateCell<NativeErrorConstructor>(vm.heap)) NativeErrorConstructor(vm, structure); 59 constructor->finishCreation(vm, prototype, errorType); 60 return constructor; 61 } 62 63 Structure* errorStructure(VM& vm) { return globalObject(vm)->errorStructure(errorType); } 64 private: 65 static EncodedJSValue JSC_HOST_CALL callNativeErrorConstructor(ExecState*); 66 static EncodedJSValue JSC_HOST_CALL constructNativeErrorConstructor(ExecState*); 67 68 NativeErrorConstructor(VM&, Structure*); 69 }; 70 71 using EvalErrorConstructor = NativeErrorConstructor<ErrorType::EvalError>; 72 using RangeErrorConstructor = NativeErrorConstructor<ErrorType::RangeError>; 73 using ReferenceErrorConstructor = NativeErrorConstructor<ErrorType::ReferenceError>; 74 using SyntaxErrorConstructor = NativeErrorConstructor<ErrorType::SyntaxError>; 75 using TypeErrorConstructor = NativeErrorConstructor<ErrorType::TypeError>; 76 using URIErrorConstructor = NativeErrorConstructor<ErrorType::URIError>; 77 78 static_assert(sizeof(EvalErrorConstructor) == sizeof(InternalFunction), ""); 79 static_assert(sizeof(RangeErrorConstructor) == sizeof(InternalFunction), ""); 80 static_assert(sizeof(ReferenceErrorConstructor) == sizeof(InternalFunction), ""); 81 static_assert(sizeof(SyntaxErrorConstructor) == sizeof(InternalFunction), ""); 82 static_assert(sizeof(TypeErrorConstructor) == sizeof(InternalFunction), ""); 83 static_assert(sizeof(URIErrorConstructor) == sizeof(InternalFunction), ""); 84 68 85 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp
r222473 r240543 34 34 } 35 35 36 void NativeErrorPrototype::finishCreation(VM& vm, const WTF::String& nameAndMessage, NativeErrorConstructor* constructor)37 {38 Base::finishCreation(vm);39 putDirect(vm, vm.propertyNames->name, jsString(&vm, nameAndMessage), static_cast<unsigned>(PropertyAttribute::DontEnum));40 putDirect(vm, vm.propertyNames->message, jsEmptyString(&vm), static_cast<unsigned>(PropertyAttribute::DontEnum));41 putDirect(vm, vm.propertyNames->constructor, constructor, static_cast<unsigned>(PropertyAttribute::DontEnum));42 }43 44 36 } // namespace JSC -
trunk/Source/JavaScriptCore/runtime/NativeErrorPrototype.h
r229413 r240543 25 25 namespace JSC { 26 26 27 class NativeErrorConstructor;28 29 27 class NativeErrorPrototype final : public ErrorPrototype { 30 28 private: … … 34 32 typedef ErrorPrototype Base; 35 33 36 static NativeErrorPrototype* create(VM& vm, Structure* structure, const String& name , NativeErrorConstructor* constructor)34 static NativeErrorPrototype* create(VM& vm, Structure* structure, const String& name) 37 35 { 38 36 NativeErrorPrototype* prototype = new (NotNull, allocateCell<NativeErrorPrototype>(vm.heap)) NativeErrorPrototype(vm, structure); 39 prototype->finishCreation(vm, name , constructor);37 prototype->finishCreation(vm, name); 40 38 return prototype; 41 39 } 42 43 protected:44 void finishCreation(VM&, const String& nameAndMessage, NativeErrorConstructor*);45 40 }; 46 41 -
trunk/Source/JavaScriptCore/runtime/VM.cpp
r240465 r240543 303 303 , inferredValueSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), InferredValue) 304 304 , internalFunctionSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), InternalFunction) 305 , nativeErrorConstructorSpace ISO_SUBSPACE_INIT(heap, destructibleObjectHeapCellType.get(), NativeErrorConstructor)306 305 , nativeExecutableSpace ISO_SUBSPACE_INIT(heap, destructibleCellHeapCellType.get(), NativeExecutable) 307 306 , nativeStdFunctionSpace ISO_SUBSPACE_INIT(heap, cellJSValueOOBHeapCellType.get(), JSNativeStdFunction) -
trunk/Source/JavaScriptCore/runtime/VM.h
r240465 r240543 378 378 IsoSubspace inferredValueSpace; 379 379 IsoSubspace internalFunctionSpace; 380 IsoSubspace nativeErrorConstructorSpace;381 380 IsoSubspace nativeExecutableSpace; 382 381 IsoSubspace nativeStdFunctionSpace; -
trunk/Source/JavaScriptCore/wasm/js/WasmToJS.cpp
r235786 r240543 105 105 auto throwScope = DECLARE_THROW_SCOPE(*vm); 106 106 JSGlobalObject* globalObject = instance->globalObject(*vm); 107 auto* error = ErrorInstance::create(exec, *vm, globalObject-> typeErrorConstructor()->errorStructure(), "i64 not allowed as return type or argument to an imported function"_s);107 auto* error = ErrorInstance::create(exec, *vm, globalObject->errorStructure(ErrorType::TypeError), "i64 not allowed as return type or argument to an imported function"_s); 108 108 throwException(exec, throwScope, error); 109 109 }
Note: See TracChangeset
for help on using the changeset viewer.