Changeset 292895 in webkit
- Timestamp:
- Apr 14, 2022 4:39:06 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 8 edited
-
JSTests/ChangeLog (modified) (1 diff)
-
JSTests/stress/shadow-realm-globalThis-mutable-prototype.js (added)
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/js/ShadowRealm-globalThis-expected.txt (added)
-
LayoutTests/js/ShadowRealm-globalThis.html (added)
-
Source/JavaScriptCore/ChangeLog (modified) (1 diff)
-
Source/JavaScriptCore/runtime/JSGlobalObject.h (modified) (2 diffs)
-
Source/JavaScriptCore/runtime/JSObject.cpp (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (modified) (1 diff)
-
Source/WebCore/bindings/scripts/test/JS/JSShadowRealmGlobalScope.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r292883 r292895 1 2022-04-14 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] ShadowRealm global object has a mutable prototype 4 https://bugs.webkit.org/show_bug.cgi?id=239332 5 6 Reviewed by Yusuke Suzuki. 7 8 * stress/shadow-realm-globalThis-mutable-prototype.js: Added. 9 1 10 2022-04-14 Alexey Shvayka <ashvayka@apple.com> 2 11 -
trunk/LayoutTests/ChangeLog
r292893 r292895 1 2022-04-14 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] ShadowRealm global object has a mutable prototype 4 https://bugs.webkit.org/show_bug.cgi?id=239332 5 6 Reviewed by Yusuke Suzuki. 7 8 Add a new layout test to verify changes to verify that ShadowRealmGlobalObject has a properly 9 mutable prototype. 10 11 * js/ShadowRealm-globalThis-expected.txt: Added. 12 * js/ShadowRealm-globalThis.html: Added. 13 1 14 2022-04-14 Nikolaos Mouchtaris <nmouchtaris@apple.com> 2 15 -
trunk/Source/JavaScriptCore/ChangeLog
r292891 r292895 1 2022-04-14 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] ShadowRealm global object has a mutable prototype 4 https://bugs.webkit.org/show_bug.cgi?id=239332 5 6 Reviewed by Yusuke Suzuki. 7 8 This patch circumvents the `ASSERT(toThis() == this)` in JSObject::setPrototypeWithCycleCheck() 9 when `this` is a GlobalObject. Ordinarily, GlobalObjects have the IsImmutablePrototypeExoticObject 10 bit set and miss this pathway, however this is not the case for ShadowRealm Global Objects. 11 12 In addition, the JSC internal version is also modified to have a mutable prototype in the same way 13 as in WebCore. 14 15 * runtime/JSGlobalObject.h: 16 (JSC::JSGlobalObject::deriveShadowRealmGlobalObject): 17 (JSC::JSGlobalObject::createStructureForShadowRealm): 18 * runtime/JSObject.cpp: 19 (JSC::JSObject::setPrototypeWithCycleCheck): 20 1 21 2022-04-14 Yusuke Suzuki <ysuzuki@apple.com> 2 22 -
trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h
r292830 r292895 1100 1100 { 1101 1101 auto& vm = globalObject->vm(); 1102 return JSGlobalObject::createWithCustomMethodTable(vm, JSGlobalObject::createStructure(vm, jsNull()), globalObject->globalObjectMethodTable()); 1102 JSGlobalObject* result = JSGlobalObject::createWithCustomMethodTable(vm, JSGlobalObject::createStructureForShadowRealm(vm, jsNull()), globalObject->globalObjectMethodTable()); 1103 return result; 1103 1104 } 1104 1105 … … 1141 1142 { 1142 1143 Structure* result = Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags), info()); 1144 result->setTransitionWatchpointIsLikelyToBeFired(true); 1145 return result; 1146 } 1147 static Structure* createStructureForShadowRealm(VM& vm, JSValue prototype) 1148 { 1149 Structure* result = Structure::create(vm, nullptr, prototype, TypeInfo(GlobalObjectType, StructureFlags & ~IsImmutablePrototypeExoticObject), info()); 1143 1150 result->setTransitionWatchpointIsLikelyToBeFired(true); 1144 1151 return result; -
trunk/Source/JavaScriptCore/runtime/JSObject.cpp
r292810 r292895 1916 1916 } 1917 1917 1918 ASSERT(methodTable(vm)->toThis(this, globalObject, ECMAMode::sloppy()) == this); 1918 // Default realm global objects should have mutable prototypes despite having 1919 // a Proxy globalThis. 1920 ASSERT(this->isGlobalObject() || methodTable(vm)->toThis(this, globalObject, ECMAMode::sloppy()) == this); 1919 1921 1920 1922 if (this->getPrototypeDirect(vm) == prototype) -
trunk/Source/WebCore/ChangeLog
r292893 r292895 1 2022-04-14 Caitlin Potter <caitp@igalia.com> 2 3 [JSC] ShadowRealm global object has a mutable prototype 4 https://bugs.webkit.org/show_bug.cgi?id=239332 5 6 Reviewed by Yusuke Suzuki. 7 8 Hack: The IDL code generator now special cases ShadowRealmGlobalObject to remove the 9 ImmutablePrototypeExoticObject bit from the inherited JSGlobalObject structure flags. 10 11 As a result, this enables the assignment of a ShadowRealm's globalThis.__proto__, or 12 overwriting the prototype with [Object / Reflect].setPrototypeOf(). 13 14 Test: js/ShadowRealm-globalThis.html 15 16 * bindings/scripts/CodeGeneratorJS.pm: 17 (GenerateHeader): 18 * bindings/scripts/test/JS/JSShadowRealmGlobalScope.h: 19 1 20 2022-04-14 Nikolaos Mouchtaris <nmouchtaris@apple.com> 2 21 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r292641 r292895 3206 3206 if (%structureFlags) { 3207 3207 push(@headerContent, "public:\n"); 3208 push(@headerContent, " static constexpr unsigned StructureFlags = Base::StructureFlags"); 3208 if ($interfaceName eq "ShadowRealmGlobalScope") { 3209 # Hack to make ShadowRealmGlobalScope a default realm global object (not an ImmutablePrototypeExoticObject) 3210 push(@headerContent, " static constexpr unsigned StructureFlags = (Base::StructureFlags & ~JSC::IsImmutablePrototypeExoticObject)"); 3211 } else { 3212 push(@headerContent, " static constexpr unsigned StructureFlags = Base::StructureFlags"); 3213 } 3209 3214 foreach my $structureFlag (sort (keys %structureFlags)) { 3210 3215 push(@headerContent, " | " . $structureFlag); -
trunk/Source/WebCore/bindings/scripts/test/JS/JSShadowRealmGlobalScope.h
r290129 r292895 58 58 static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); 59 59 public: 60 static constexpr unsigned StructureFlags = Base::StructureFlags| JSC::HasStaticPropertyTable;60 static constexpr unsigned StructureFlags = (Base::StructureFlags & ~JSC::IsImmutablePrototypeExoticObject) | JSC::HasStaticPropertyTable; 61 61 protected: 62 62 JSShadowRealmGlobalScope(JSC::VM&, JSC::Structure*, Ref<ShadowRealmGlobalScope>&&);
Note: See TracChangeset
for help on using the changeset viewer.